Package com.geodesk.core
Class Mercator
java.lang.Object
com.geodesk.core.Mercator
Methods for working with Mercator-projected coordinates.
GeoDesk uses a Pseudo-Mercator projection that projects
coordinates onto a square Cartesian plane 2^32 units wide/tall
(in essence, the value range fully uses a 32-bit signed
int; a pair of coordinates fits into a 64-bit signed long).
This projection is compatible with Web Mercator EPSG:3785,
except that instead of meters at the Equator, it uses a made-up
unit called "imp" ("integer, Mercator-projected").
See Coordinate System
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
Calculates the area of the given geometry (in square meters).static double
deltaFromMeters
(double meters, double atY) Calculates the equivalent number of imps that are equal to the given distance in meters at a planar-projected latitude.static double
distance
(double x1, double y1, double x2, double y2) Calculates the Euclidean distance between two projected points.static double
distance
(Coordinate c1, Coordinate c2) static double
static Envelope
envelope
(double lon1, double lat1, double lon2, double lat2) static Envelope
expandEnvelope
(Envelope env, double meters) static double
latFromY
(double y) Converts a projected latitude to WGS84.static double
lonFromX
(double x) Converts a projected longitude to WGS84.static double
metersAtY
(int y) static void
Converts the WGS84 (longitude/latitude) coordinates of aGeometry
into Mercator projection.static double
scale
(double y) static double
xFromLon
(double lon) Converts a longitude to imps.static int
xFromLon100nd
(int lon) Converts a longitude to imps.static double
yFromLat
(double lat) Converts a latitude to imps.static int
yFromLat100nd
(int lat) Converts a latitude to imps.
-
Constructor Details
-
Mercator
public Mercator()
-
-
Method Details
-
xFromLon
public static double xFromLon(double lon) Converts a longitude to imps.- Parameters:
lon
- longitude (in degrees)- Returns:
- equivalent imps
-
xFromLon100nd
public static int xFromLon100nd(int lon) Converts a longitude to imps.- Parameters:
lon
- longitude (in 100-nanodegree increments)- Returns:
- equivalent imps
-
yFromLat
public static double yFromLat(double lat) Converts a latitude to imps.- Parameters:
lat
- latitude (in degrees)- Returns:
- equivalent imps
-
yFromLat100nd
public static int yFromLat100nd(int lat) Converts a latitude to imps.- Parameters:
lat
- latitude (in 100-nanodegree increments)- Returns:
- equivalent imps
-
scale
public static double scale(double y) -
lonFromX
public static double lonFromX(double x) Converts a projected longitude to WGS84.- Parameters:
x
- projected latitude (in imps)- Returns:
- equivalent WSG-84 longitude in degrees
-
latFromY
public static double latFromY(double y) Converts a projected latitude to WGS84.- Parameters:
y
- projected latitude (in imps)- Returns:
- equivalent WSG-84 latitude in degrees
-
metersAtY
public static double metersAtY(int y) -
distance
public static double distance(double x1, double y1, double x2, double y2) Calculates the Euclidean distance between two projected points. A simple method that is sufficiently accurate only for short distances.- Parameters:
x1
- (in imps)y1
- (in imps)x2
- (in imps)y2
- (in imps)- Returns:
- distance in meters
-
distance
-
distance
-
deltaFromMeters
public static double deltaFromMeters(double meters, double atY) Calculates the equivalent number of imps that are equal to the given distance in meters at a planar-projected latitude.- Parameters:
meters
- distance in metersatY
- the projected latitude (i.e. in imps, not degrees)- Returns:
- the distance in imps
-
area
Calculates the area of the given geometry (in square meters). A simple method that is sufficiently accurate only for small areas.- Parameters:
geom
- the geometry- Returns:
- area in square meters
-
expandEnvelope
-
envelope
-
project
Converts the WGS84 (longitude/latitude) coordinates of aGeometry
into Mercator projection. The Geometry is modified in-place.- Parameters:
geom
- the `Geometry` whose coordinates to project
-