Subject: [PATCH] 23113.jmapviewer
---
Index: src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java b/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java
--- a/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java	(revision 36114)
+++ b/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java	(date 1691685403246)
@@ -12,6 +12,7 @@
 import org.openstreetmap.gui.jmapviewer.TileXY;
 
 /**
+ * Used for generating tiles
  *
  * @author Jan Peter Stotz
  */
@@ -44,7 +45,7 @@
 
     /**
      * A unique id for this tile source.
-     *
+     * <p>
      * Unlike the name it has to be unique and has to consist only of characters
      * valid for filenames.
      *
@@ -110,7 +111,9 @@
      * @param zoom zoom level
      * @return the pixel coordinates
      */
-    Point latLonToXY(ICoordinate point, int zoom);
+    default Point latLonToXY(ICoordinate point, int zoom) {
+        return latLonToXY(point.getLat(), point.getLon(), zoom);
+    }
 
     /**
      * Transforms a point in pixel space to longitude/latitude (WGS84).
@@ -118,7 +121,9 @@
      * @param zoom zoom level
      * @return WGS84 Coordinates of given point
      */
-    ICoordinate xyToLatLon(Point point, int zoom);
+    default ICoordinate xyToLatLon(Point point, int zoom) {
+        return xyToLatLon(point.x, point.y, zoom);
+    }
 
     /**
      * Transforms a point in pixel space to longitude/latitude (WGS84).
@@ -144,7 +149,9 @@
      * @param zoom zoom level
      * @return x and y tile indices
      */
-    TileXY latLonToTileXY(ICoordinate point, int zoom);
+    default TileXY latLonToTileXY(ICoordinate point, int zoom) {
+        return latLonToTileXY(point.getLat(), point.getLon(), zoom);
+    }
 
     /**
      * Transforms tile indices to longitude and latitude.
@@ -152,7 +159,9 @@
      * @param zoom zoom level
      * @return WGS84 coordinates of given tile
      */
-    ICoordinate tileXYToLatLon(TileXY xy, int zoom);
+    default ICoordinate tileXYToLatLon(TileXY xy, int zoom) {
+        return tileXYToLatLon(xy.getXIndex(), xy.getYIndex(), zoom);
+    }
 
     /**
      * Determines to longitude and latitude of a tile.
@@ -160,7 +169,9 @@
      * @param tile Tile
      * @return WGS84 coordinates of given tile
      */
-    ICoordinate tileXYToLatLon(Tile tile);
+    default ICoordinate tileXYToLatLon(Tile tile) {
+        return tileXYToLatLon(tile.getXtile(), tile.getYtile(), tile.getZoom());
+    }
 
     /**
      * Transforms tile indices to longitude and latitude.
@@ -248,7 +259,7 @@
     /**
      * Returns a range of tiles, that cover a given tile, which is
      * usually at a different zoom level.
-     *
+     * <p>
      * In standard tile layout, 4 tiles cover a tile one zoom lower, 16 tiles
      * cover a tile 2 zoom levels below etc.
      * If the zoom level of the covering tiles is greater or equal, a single
@@ -262,7 +273,7 @@
 
     /**
      * Get coordinate reference system for this tile source.
-     *
+     * <p>
      * E.g. "EPSG:3857" for Google-Mercator.
      * @return code for the coordinate reference system in use
      */
Index: src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java b/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java
--- a/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java	(revision 36114)
+++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java	(date 1691685242598)
@@ -1,7 +1,6 @@
 // License: GPL. For details, see Readme.txt file.
 package org.openstreetmap.gui.jmapviewer.tilesources;
 
-import java.awt.Point;
 import java.io.IOException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
@@ -10,12 +9,11 @@
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.logging.Level;
 
+import org.openstreetmap.gui.jmapviewer.FeatureAdapter;
 import org.openstreetmap.gui.jmapviewer.JMapViewer;
 import org.openstreetmap.gui.jmapviewer.OsmMercator;
-import org.openstreetmap.gui.jmapviewer.Tile;
-import org.openstreetmap.gui.jmapviewer.TileXY;
-import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate;
 
 /**
  * Class generalizing all tile based tile sources
@@ -39,7 +37,7 @@
      *
      * @param info description of the Tile Source
      */
-    public AbstractTMSTileSource(TileSourceInfo info) {
+    protected AbstractTMSTileSource(TileSourceInfo info) {
         this.name = info.getName();
         this.baseUrl = info.getUrl();
         if (baseUrl != null && baseUrl.endsWith("/")) {
@@ -89,10 +87,11 @@
     }
 
     /**
+     * Get the tile path after the URL
      * @param zoom level of the tile
      * @param tilex tile number in x axis
      * @param tiley tile number in y axis
-     * @return String containg path part of URL of the tile
+     * @return String containing path part of URL of the tile
      * @throws IOException when subclass cannot return the tile URL
      */
     public String getTilePath(int zoom, int tilex, int tiley) throws IOException {
@@ -127,31 +126,6 @@
         return tileSize;
     }
 
-    @Override
-    public Point latLonToXY(ICoordinate point, int zoom) {
-        return latLonToXY(point.getLat(), point.getLon(), zoom);
-    }
-
-    @Override
-    public ICoordinate xyToLatLon(Point point, int zoom) {
-        return xyToLatLon(point.x, point.y, zoom);
-    }
-
-    @Override
-    public TileXY latLonToTileXY(ICoordinate point, int zoom) {
-        return latLonToTileXY(point.getLat(), point.getLon(), zoom);
-    }
-
-    @Override
-    public ICoordinate tileXYToLatLon(TileXY xy, int zoom) {
-        return tileXYToLatLon(xy.getXIndex(), xy.getYIndex(), zoom);
-    }
-
-    @Override
-    public ICoordinate tileXYToLatLon(Tile tile) {
-        return tileXYToLatLon(tile.getXtile(), tile.getYtile(), tile.getZoom());
-    }
-
     @Override
     public int getTileXMax(int zoom) {
         return getTileMax(zoom);
@@ -190,22 +164,23 @@
         }
         if (noTileChecksums != null && content != null) {
             for (Entry<String, Set<String>> searchEntry: noTileChecksums.entrySet()) {
-                MessageDigest md = null;
+                MessageDigest md;
                 try {
                     md = MessageDigest.getInstance(searchEntry.getKey());
                 } catch (NoSuchAlgorithmException e) {
+                    FeatureAdapter.getLogger(this.getClass()).log(Level.FINER, searchEntry.getKey() + " algorithm was not found", e);
                     break;
                 }
                 byte[] byteDigest = md.digest(content);
                 final int len = byteDigest.length;
 
                 char[] hexChars = new char[len * 2];
-                for (int i = 0, j = 0; i < len; i++) {
-                    final int v = byteDigest[i];
+                int j = 0;
+                for (final int v : byteDigest) {
                     int vn = (v & 0xf0) >> 4;
-                    hexChars[j++] = (char) (vn + (vn >= 10 ? 'a'-10 : '0'));
+                    hexChars[j++] = (char) (vn + (vn >= 10 ? 'a' - 10 : '0'));
                     vn = (v & 0xf);
-                    hexChars[j++] = (char) (vn + (vn >= 10 ? 'a'-10 : '0'));
+                    hexChars[j++] = (char) (vn + (vn >= 10 ? 'a' - 10 : '0'));
                 }
                 for (String val: searchEntry.getValue()) {
                     if (new String(hexChars).equalsIgnoreCase(val)) {
