Subject: [PATCH] 23113.jmapviewer
---
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
|
b
|
|
| 12 | 12 | import org.openstreetmap.gui.jmapviewer.TileXY; |
| 13 | 13 | |
| 14 | 14 | /** |
| | 15 | * Used for generating tiles |
| 15 | 16 | * |
| 16 | 17 | * @author Jan Peter Stotz |
| 17 | 18 | */ |
| … |
… |
|
| 44 | 45 | |
| 45 | 46 | /** |
| 46 | 47 | * A unique id for this tile source. |
| 47 | | * |
| | 48 | * <p> |
| 48 | 49 | * Unlike the name it has to be unique and has to consist only of characters |
| 49 | 50 | * valid for filenames. |
| 50 | 51 | * |
| … |
… |
|
| 110 | 111 | * @param zoom zoom level |
| 111 | 112 | * @return the pixel coordinates |
| 112 | 113 | */ |
| 113 | | Point latLonToXY(ICoordinate point, int zoom); |
| | 114 | default Point latLonToXY(ICoordinate point, int zoom) { |
| | 115 | return latLonToXY(point.getLat(), point.getLon(), zoom); |
| | 116 | } |
| 114 | 117 | |
| 115 | 118 | /** |
| 116 | 119 | * Transforms a point in pixel space to longitude/latitude (WGS84). |
| … |
… |
|
| 118 | 121 | * @param zoom zoom level |
| 119 | 122 | * @return WGS84 Coordinates of given point |
| 120 | 123 | */ |
| 121 | | ICoordinate xyToLatLon(Point point, int zoom); |
| | 124 | default ICoordinate xyToLatLon(Point point, int zoom) { |
| | 125 | return xyToLatLon(point.x, point.y, zoom); |
| | 126 | } |
| 122 | 127 | |
| 123 | 128 | /** |
| 124 | 129 | * Transforms a point in pixel space to longitude/latitude (WGS84). |
| … |
… |
|
| 144 | 149 | * @param zoom zoom level |
| 145 | 150 | * @return x and y tile indices |
| 146 | 151 | */ |
| 147 | | TileXY latLonToTileXY(ICoordinate point, int zoom); |
| | 152 | default TileXY latLonToTileXY(ICoordinate point, int zoom) { |
| | 153 | return latLonToTileXY(point.getLat(), point.getLon(), zoom); |
| | 154 | } |
| 148 | 155 | |
| 149 | 156 | /** |
| 150 | 157 | * Transforms tile indices to longitude and latitude. |
| … |
… |
|
| 152 | 159 | * @param zoom zoom level |
| 153 | 160 | * @return WGS84 coordinates of given tile |
| 154 | 161 | */ |
| 155 | | ICoordinate tileXYToLatLon(TileXY xy, int zoom); |
| | 162 | default ICoordinate tileXYToLatLon(TileXY xy, int zoom) { |
| | 163 | return tileXYToLatLon(xy.getXIndex(), xy.getYIndex(), zoom); |
| | 164 | } |
| 156 | 165 | |
| 157 | 166 | /** |
| 158 | 167 | * Determines to longitude and latitude of a tile. |
| … |
… |
|
| 160 | 169 | * @param tile Tile |
| 161 | 170 | * @return WGS84 coordinates of given tile |
| 162 | 171 | */ |
| 163 | | ICoordinate tileXYToLatLon(Tile tile); |
| | 172 | default ICoordinate tileXYToLatLon(Tile tile) { |
| | 173 | return tileXYToLatLon(tile.getXtile(), tile.getYtile(), tile.getZoom()); |
| | 174 | } |
| 164 | 175 | |
| 165 | 176 | /** |
| 166 | 177 | * Transforms tile indices to longitude and latitude. |
| … |
… |
|
| 248 | 259 | /** |
| 249 | 260 | * Returns a range of tiles, that cover a given tile, which is |
| 250 | 261 | * usually at a different zoom level. |
| 251 | | * |
| | 262 | * <p> |
| 252 | 263 | * In standard tile layout, 4 tiles cover a tile one zoom lower, 16 tiles |
| 253 | 264 | * cover a tile 2 zoom levels below etc. |
| 254 | 265 | * If the zoom level of the covering tiles is greater or equal, a single |
| … |
… |
|
| 262 | 273 | |
| 263 | 274 | /** |
| 264 | 275 | * Get coordinate reference system for this tile source. |
| 265 | | * |
| | 276 | * <p> |
| 266 | 277 | * E.g. "EPSG:3857" for Google-Mercator. |
| 267 | 278 | * @return code for the coordinate reference system in use |
| 268 | 279 | */ |
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
|
b
|
|
| 1 | 1 | // License: GPL. For details, see Readme.txt file. |
| 2 | 2 | package org.openstreetmap.gui.jmapviewer.tilesources; |
| 3 | 3 | |
| 4 | | import java.awt.Point; |
| 5 | 4 | import java.io.IOException; |
| 6 | 5 | import java.security.MessageDigest; |
| 7 | 6 | import java.security.NoSuchAlgorithmException; |
| … |
… |
|
| 10 | 9 | import java.util.Map; |
| 11 | 10 | import java.util.Map.Entry; |
| 12 | 11 | import java.util.Set; |
| | 12 | import java.util.logging.Level; |
| 13 | 13 | |
| | 14 | import org.openstreetmap.gui.jmapviewer.FeatureAdapter; |
| 14 | 15 | import org.openstreetmap.gui.jmapviewer.JMapViewer; |
| 15 | 16 | import org.openstreetmap.gui.jmapviewer.OsmMercator; |
| 16 | | import org.openstreetmap.gui.jmapviewer.Tile; |
| 17 | | import org.openstreetmap.gui.jmapviewer.TileXY; |
| 18 | | import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate; |
| 19 | 17 | |
| 20 | 18 | /** |
| 21 | 19 | * Class generalizing all tile based tile sources |
| … |
… |
|
| 39 | 37 | * |
| 40 | 38 | * @param info description of the Tile Source |
| 41 | 39 | */ |
| 42 | | public AbstractTMSTileSource(TileSourceInfo info) { |
| | 40 | protected AbstractTMSTileSource(TileSourceInfo info) { |
| 43 | 41 | this.name = info.getName(); |
| 44 | 42 | this.baseUrl = info.getUrl(); |
| 45 | 43 | if (baseUrl != null && baseUrl.endsWith("/")) { |
| … |
… |
|
| 89 | 87 | } |
| 90 | 88 | |
| 91 | 89 | /** |
| | 90 | * Get the tile path after the URL |
| 92 | 91 | * @param zoom level of the tile |
| 93 | 92 | * @param tilex tile number in x axis |
| 94 | 93 | * @param tiley tile number in y axis |
| 95 | | * @return String containg path part of URL of the tile |
| | 94 | * @return String containing path part of URL of the tile |
| 96 | 95 | * @throws IOException when subclass cannot return the tile URL |
| 97 | 96 | */ |
| 98 | 97 | public String getTilePath(int zoom, int tilex, int tiley) throws IOException { |
| … |
… |
|
| 127 | 126 | return tileSize; |
| 128 | 127 | } |
| 129 | 128 | |
| 130 | | @Override |
| 131 | | public Point latLonToXY(ICoordinate point, int zoom) { |
| 132 | | return latLonToXY(point.getLat(), point.getLon(), zoom); |
| 133 | | } |
| 134 | | |
| 135 | | @Override |
| 136 | | public ICoordinate xyToLatLon(Point point, int zoom) { |
| 137 | | return xyToLatLon(point.x, point.y, zoom); |
| 138 | | } |
| 139 | | |
| 140 | | @Override |
| 141 | | public TileXY latLonToTileXY(ICoordinate point, int zoom) { |
| 142 | | return latLonToTileXY(point.getLat(), point.getLon(), zoom); |
| 143 | | } |
| 144 | | |
| 145 | | @Override |
| 146 | | public ICoordinate tileXYToLatLon(TileXY xy, int zoom) { |
| 147 | | return tileXYToLatLon(xy.getXIndex(), xy.getYIndex(), zoom); |
| 148 | | } |
| 149 | | |
| 150 | | @Override |
| 151 | | public ICoordinate tileXYToLatLon(Tile tile) { |
| 152 | | return tileXYToLatLon(tile.getXtile(), tile.getYtile(), tile.getZoom()); |
| 153 | | } |
| 154 | | |
| 155 | 129 | @Override |
| 156 | 130 | public int getTileXMax(int zoom) { |
| 157 | 131 | return getTileMax(zoom); |
| … |
… |
|
| 190 | 164 | } |
| 191 | 165 | if (noTileChecksums != null && content != null) { |
| 192 | 166 | for (Entry<String, Set<String>> searchEntry: noTileChecksums.entrySet()) { |
| 193 | | MessageDigest md = null; |
| | 167 | MessageDigest md; |
| 194 | 168 | try { |
| 195 | 169 | md = MessageDigest.getInstance(searchEntry.getKey()); |
| 196 | 170 | } catch (NoSuchAlgorithmException e) { |
| | 171 | FeatureAdapter.getLogger(this.getClass()).log(Level.FINER, searchEntry.getKey() + " algorithm was not found", e); |
| 197 | 172 | break; |
| 198 | 173 | } |
| 199 | 174 | byte[] byteDigest = md.digest(content); |
| 200 | 175 | final int len = byteDigest.length; |
| 201 | 176 | |
| 202 | 177 | char[] hexChars = new char[len * 2]; |
| 203 | | for (int i = 0, j = 0; i < len; i++) { |
| 204 | | final int v = byteDigest[i]; |
| | 178 | int j = 0; |
| | 179 | for (final int v : byteDigest) { |
| 205 | 180 | int vn = (v & 0xf0) >> 4; |
| 206 | | hexChars[j++] = (char) (vn + (vn >= 10 ? 'a'-10 : '0')); |
| | 181 | hexChars[j++] = (char) (vn + (vn >= 10 ? 'a' - 10 : '0')); |
| 207 | 182 | vn = (v & 0xf); |
| 208 | | hexChars[j++] = (char) (vn + (vn >= 10 ? 'a'-10 : '0')); |
| | 183 | hexChars[j++] = (char) (vn + (vn >= 10 ? 'a' - 10 : '0')); |
| 209 | 184 | } |
| 210 | 185 | for (String val: searchEntry.getValue()) { |
| 211 | 186 | if (new String(hexChars).equalsIgnoreCase(val)) { |