Changeset 35190 in osm
- Timestamp:
- 2019-10-13T22:09:23+02:00 (5 years ago)
- Location:
- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java
r34760 r35190 56 56 57 57 /** Maximum zoom level */ 58 public static final int MAX_ZOOM = 2 2;58 public static final int MAX_ZOOM = 24; 59 59 /** Minimum zoom level */ 60 60 public static final int MIN_ZOOM = 0; -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmMercator.java
r32602 r35190 29 29 public static final OsmMercator MERCATOR_256 = new OsmMercator(); 30 30 31 /** tile size of the displayed tiles */32 private inttileSize = DEFAUL_TILE_SIZE;31 /** tile size of the displayed tiles. Use long so all calculations will be in 64bit to properly handle zooms above 22 for 256 tile size */ 32 private long tileSize = DEFAUL_TILE_SIZE; 33 33 34 34 /** … … 57 57 * @return number of pixels 58 58 */ 59 public intgetMaxPixels(int aZoomlevel) {59 public long getMaxPixels(int aZoomlevel) { 60 60 return tileSize * (1 << aZoomlevel); 61 61 } 62 62 63 public intfalseEasting(int aZoomlevel) {63 public long falseEasting(int aZoomlevel) { 64 64 return getMaxPixels(aZoomlevel) / 2; 65 65 } 66 66 67 public intfalseNorthing(int aZoomlevel) {67 public long falseNorthing(int aZoomlevel) { 68 68 return -1 * getMaxPixels(aZoomlevel) / 2; 69 69 } … … 80 80 * @return the distance 81 81 */ 82 public double getDistance( int x1, int y1, int x2, inty2, int zoomLevel) {82 public double getDistance(long x1, long y1, long x2, long y2, int zoomLevel) { 83 83 double la1 = yToLat(y1, zoomLevel); 84 84 double lo1 = xToLon(x1, zoomLevel); … … 130 130 */ 131 131 public double lonToX(double aLongitude, int aZoomlevel) { 132 intmp = getMaxPixels(aZoomlevel);132 long mp = getMaxPixels(aZoomlevel); 133 133 double x = (mp * (aLongitude + 180L)) / 360L; 134 134 return Math.min(x, mp); … … 160 160 double sinLat = Math.sin(Math.toRadians(aLat)); 161 161 double log = Math.log((1.0 + sinLat) / (1.0 - sinLat)); 162 intmp = getMaxPixels(aZoomlevel);162 long mp = getMaxPixels(aZoomlevel); 163 163 double y = mp * (0.5 - (log / (4.0 * Math.PI))); 164 164 return Math.min(y, mp - 1); … … 183 183 * @return ]-180..180[ 184 184 */ 185 public double xToLon( intaX, int aZoomlevel) {185 public double xToLon(long aX, int aZoomlevel) { 186 186 return ((360d * aX) / getMaxPixels(aZoomlevel)) - 180.0; 187 187 } … … 195 195 * @return [MIN_LAT..MAX_LAT] is about [-85..85] 196 196 */ 197 public double yToLat(int aY, int aZoomlevel) { 198 aY += falseNorthing(aZoomlevel); 199 double latitude = (Math.PI / 2) - (2 * Math.atan(Math.exp(-1.0 * aY / radius(aZoomlevel)))); 197 public double yToLat(long aY, int aZoomlevel) { 198 double latitude = (Math.PI / 2) - (2 * Math.atan(Math.exp(-1.0 * (aY + falseNorthing(aZoomlevel)) / radius(aZoomlevel)))); 200 199 return -1 * Math.toDegrees(latitude); 201 200 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java
r33973 r35190 12 12 import java.util.Set; 13 13 14 import org.openstreetmap.gui.jmapviewer.JMapViewer; 14 15 import org.openstreetmap.gui.jmapviewer.OsmMercator; 15 16 import org.openstreetmap.gui.jmapviewer.Tile; … … 73 74 @Override 74 75 public int getMaxZoom() { 75 return 21;76 return JMapViewer.MAX_ZOOM; 76 77 } 77 78 78 79 @Override 79 80 public int getMinZoom() { 80 return 0;81 return JMapViewer.MIN_ZOOM; 81 82 } 82 83
Note:
See TracChangeset
for help on using the changeset viewer.