Changeset 16959 in osm for applications/viewer
- Timestamp:
- 2009-08-10T12:04:42+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmMercator.java
r14053 r16959 46 46 * Transform longitude to pixelspace 47 47 * 48 * <p> 49 * Mathematical optimization<br> 50 * <code> 51 * x = radius(aZoomlevel) * toRadians(aLongitude) + falseEasting(aZoomLevel)<br> 52 * x = getMaxPixels(aZoomlevel) / (2 * PI) * (aLongitude * PI) / 180 + getMaxPixels(aZoomlevel) / 2<br> 53 * x = getMaxPixels(aZoomlevel) * aLongitude / 360 + 180 * getMaxPixels(aZoomlevel) / 360<br> 54 * x = getMaxPixels(aZoomlevel) * (aLongitude + 180) / 360<br> 55 * </code> 56 * </p> 57 * 48 58 * @param aLongitude 49 59 * [-180..180] 50 60 * @return [0..2^Zoomlevel*TILE_SIZE[ 61 * @author Jan Peter Stotz 51 62 */ 52 63 public static int LonToX(double aLongitude, int aZoomlevel) { 53 double longitude = Math.toRadians(aLongitude);54 int x = (int) (( radius(aZoomlevel) * longitude) + falseEasting(aZoomlevel));55 x = Math.min(x, getMaxPixels(aZoomlevel)- 1);64 int mp = getMaxPixels(aZoomlevel); 65 int x = (int) ((mp * (aLongitude + 180l)) / 360l); 66 x = Math.min(x, mp - 1); 56 67 return x; 57 68 }
Note:
See TracChangeset
for help on using the changeset viewer.