public class Mercator
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static double |
MAX_LAT |
static double |
MIN_LAT |
Constructor and Description |
---|
Mercator() |
Modifier and Type | Method and Description |
---|---|
static int |
falseEasting(int aZoomlevel) |
static int |
falseNorthing(int aZoomlevel) |
static int |
getMaxPixels(int aZoomlevel)
Returns the absolute number of pixels in y or x, defined as: 2^Zoomlevel *
TILE_WIDTH where TILE_WIDTH is the width of a tile in pixels
|
static int |
latToY(double aLat,
int aZoomlevel)
Transforms latitude to pixel space
|
static int |
lonToX(double aLongitude,
int aZoomlevel)
Transform longitude to pixel space
|
static double |
radius(int aZoomlevel) |
static double |
xToLon(int aX,
int aZoomlevel)
Transforms pixel coordinate X to longitude
|
static double |
yToLat(int aY,
int aZoomlevel)
Transforms pixel coordinate Y to latitude
|
public static final double MAX_LAT
public static final double MIN_LAT
public static double radius(int aZoomlevel)
public static int getMaxPixels(int aZoomlevel)
aZoomlevel
- public static int falseEasting(int aZoomlevel)
public static int falseNorthing(int aZoomlevel)
public static int lonToX(double aLongitude, int aZoomlevel)
Mathematical optimization
x = radius(aZoomlevel) * toRadians(aLongitude) + falseEasting(aZoomLevel)
x = getMaxPixels(aZoomlevel) / (2 * PI) * (aLongitude * PI) / 180 + getMaxPixels(aZoomlevel) / 2
x = getMaxPixels(aZoomlevel) * aLongitude / 360 + 180 * getMaxPixels(aZoomlevel) / 360
x = getMaxPixels(aZoomlevel) * (aLongitude + 180) / 360
aLongitude
- [-180..180]public static int latToY(double aLat, int aZoomlevel)
Mathematical optimization
log(u) := log((1.0 + sin(toRadians(aLat))) / (1.0 - sin(toRadians(aLat))
y = -1 * (radius(aZoomlevel) / 2 * log(u)))) - falseNorthing(aZoomlevel))
y = -1 * (getMaxPixel(aZoomlevel) / 2 * PI / 2 * log(u)) - -1 * getMaxPixel(aZoomLevel) / 2
y = getMaxPixel(aZoomlevel) / (-4 * PI) * log(u)) + getMaxPixel(aZoomLevel) / 2
y = getMaxPixel(aZoomlevel) * ((log(u) / (-4 * PI)) + 1/2)
aLat
- [-90...90]public static double xToLon(int aX, int aZoomlevel)
Mathematical optimization
lon = toDegree((aX - falseEasting(aZoomlevel)) / radius(aZoomlevel))
lon = 180 / PI * ((aX - getMaxPixels(aZoomlevel) / 2) / getMaxPixels(aZoomlevel) / (2 * PI)
lon = 180 * ((aX - getMaxPixels(aZoomlevel) / 2) / getMaxPixels(aZoomlevel))
lon = 360 / getMaxPixels(aZoomlevel) * (aX - getMaxPixels(aZoomlevel) / 2)
lon = 360 * aX / getMaxPixels(aZoomlevel) - 180
aX
- [0..2^Zoomlevel*TILE_WIDTH[public static double yToLat(int aY, int aZoomlevel)
aY
- [0..2^Zoomlevel*TILE_WIDTH[