Changeset 16978 in osm
- Timestamp:
- 2009-08-10T18:51:56+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmMercator.java
r16974 r16978 70 70 /** 71 71 * Transforms latitude to pixelspace 72 * <p> 73 * Mathematical optimization<br> 74 * <code> 75 * log(u) := log((1.0 + sin(toRadians(aLat))) / (1.0 - sin(toRadians(aLat))<br> 72 76 * 77 * y = -1 * (radius(aZoomlevel) / 2 * log(u)))) - falseNorthing(aZoomlevel))<br> 78 * y = -1 * (getMaxPixel(aZoomlevel) / 2 * PI / 2 * log(u)) - -1 * getMaxPixel(aZoomLevel) / 2<br> 79 * y = getMaxPixel(aZoomlevel) / (-4 * PI) * log(u)) + getMaxPixel(aZoomLevel) / 2<br> 80 * y = getMaxPixel(aZoomlevel) * ((log(u) / (-4 * PI)) + 1/2)<br> 81 * </code> 82 * </p> 73 83 * @param aLat 74 84 * [-90...90] 75 85 * @return [0..2^Zoomlevel*TILE_SIZE[ 86 * @author Jan Peter Stotz 76 87 */ 77 88 public static int LatToY(double aLat, int aZoomlevel) { … … 80 91 else if (aLat > MAX_LAT) 81 92 aLat = MAX_LAT; 82 double latitude = Math.toRadians(aLat); 83 int y = (int) (-1 84 * (radius(aZoomlevel) / 2.0 * Math.log((1.0 + Math.sin(latitude)) / (1.0 - Math.sin(latitude)))) - falseNorthing(aZoomlevel)); 85 y = Math.min(y, getMaxPixels(aZoomlevel) - 1); 93 double sinLat = Math.sin(Math.toRadians(aLat)); 94 double log = Math.log((1.0 + sinLat) / (1.0 - sinLat)); 95 int mp = getMaxPixels(aZoomlevel); 96 int y = (int) (mp * (0.5 - (log / (4.0 * Math.PI)))); 97 y = Math.min(y, mp - 1); 86 98 return y; 87 99 }
Note:
See TracChangeset
for help on using the changeset viewer.