This commit is contained in:
Hannes Janetzek
2013-02-04 17:38:30 +01:00
parent 76e1dcae7c
commit fb1b0d4087
2 changed files with 18 additions and 2 deletions

View File

@@ -82,6 +82,12 @@ public final class MercatorProjection {
* ((long) Tile.TILE_SIZE << mapPosition.zoomLevel);
}
/**
* Projects a longitude coordinate (in degrees) to the range [0.0,1.0]
* @param latitude
* the latitude coordinate that should be converted.
* @return the position .
*/
public static double latitudeToY(double latitude) {
double sinLatitude = Math.sin(latitude * (Math.PI / 180));
return 0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI);
@@ -147,6 +153,12 @@ public final class MercatorProjection {
* ((long) Tile.TILE_SIZE << mapPosition.zoomLevel);
}
/**
* Projects a longitude coordinate (in degrees) to the range [0.0,1.0]
* @param longitude
* the longitude coordinate that should be converted.
* @return the position .
*/
public static double longitudeToX(double longitude) {
return (longitude + 180) / 360;
}