Class WebMercatorProjection
java.lang.Object
net.buildtheearth.terraminusminus.projection.mercator.WebMercatorProjection
- All Implemented Interfaces:
GeographicProjection
Implementation of the web Mercator projection, with projected space normalized between 0 and 2^zoom * 256.
This projection is mainly used by tiled mapping services like GoogleMaps or OpenStreetMap.
In this implementation of the projection, 1 unit on the projected space corresponds to 1 pixel on those services at the same zoom level.
The origin is on the upper left corner of the map.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.buildtheearth.terraminusminus.projection.GeographicProjection
GeographicProjection.Deserializer, GeographicProjection.Serializer -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleprotected final doubleprotected final doubleprotected final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble[]bounds()Indicates the minimum and maximum X and Y coordinates on the projected space.double[]fromGeo(double longitude, double latitude) Converts geographic coordinates to map coordinatesdoubleGives an estimation of the scale of this projection.double[]toGeo(double x, double y) Converts map coordinates to geographic coordinatestoString()booleanupright()Indicates whether or not the north pole is projected to the north of the south pole on the projected space, assuming Minecraft's coordinate system cardinal directions for the projected space (north is negative Z).intzoom()
-
Field Details
-
LIMIT_LATITUDE
public static final double LIMIT_LATITUDE -
zoom
protected final int zoom -
scaleTo
protected final transient double scaleTo -
scaleFrom
protected final transient double scaleFrom
-
-
Constructor Details
-
WebMercatorProjection
-
-
Method Details
-
toGeo
Description copied from interface:GeographicProjectionConverts map coordinates to geographic coordinates- Specified by:
toGeoin interfaceGeographicProjection- Parameters:
x- - x map coordinatey- - y map coordinate- Returns:
- {longitude, latitude} in degrees
- Throws:
OutOfProjectionBoundsException- if the specified point on the projected space cannot be mapped to a point of the geographic space
-
fromGeo
Description copied from interface:GeographicProjectionConverts geographic coordinates to map coordinates- Specified by:
fromGeoin interfaceGeographicProjection- Parameters:
longitude- - longitude, in degreeslatitude- - latitude, in degrees- Returns:
- {x, y} map coordinates
- Throws:
OutOfProjectionBoundsException- if the specified point on the geographic space cannot be mapped to a point of the projected space
-
bounds
public double[] bounds()Description copied from interface:GeographicProjectionIndicates the minimum and maximum X and Y coordinates on the projected space.- Specified by:
boundsin interfaceGeographicProjection- Returns:
- {minimum X, minimum Y, maximum X, maximum Y}
-
upright
public boolean upright()Description copied from interface:GeographicProjectionIndicates whether or not the north pole is projected to the north of the south pole on the projected space, assuming Minecraft's coordinate system cardinal directions for the projected space (north is negative Z).- Specified by:
uprightin interfaceGeographicProjection- Returns:
- north pole Z <= south pole Z
-
metersPerUnit
public double metersPerUnit()Description copied from interface:GeographicProjectionGives an estimation of the scale of this projection. This is just an estimation, as distortion is inevitable when projecting a sphere onto a flat surface, so this value varies from places to places in reality.- Specified by:
metersPerUnitin interfaceGeographicProjection- Returns:
- an estimation of the scale of this projection
-
toString
-
properties
- Specified by:
propertiesin interfaceGeographicProjection- Returns:
- any additional configuration properties used by this projection
-
zoom
public int zoom()
-