Class Mercator

java.lang.Object
com.geodesk.geom.Mercator

public final class Mercator extends Object
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:3857, except that instead of meters at the Equator, it uses a made-up unit called "imp" ("integer, Mercator-projected"). See Coordinate System
  • 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
    • lonPrecision7fromX

      public static double lonPrecision7fromX(double x)
    • 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
    • latPrecision7fromY

      public static double latPrecision7fromY(double y)
    • 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

      public static double distance(Coordinate c1, Coordinate c2)
    • distance

      public static double distance(Geometry a, Geometry b)
    • 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 meters
      atY - the projected latitude (i.e. in imps, not degrees)
      Returns:
      the distance in imps
    • area

      public static double area(Geometry geom)
      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

      public static Envelope expandEnvelope(Envelope env, double meters)
    • envelope

      public static Envelope envelope(double lon1, double lat1, double lon2, double lat2)
    • project

      public static void project(Geometry geom)
      Converts the WGS84 (longitude/latitude) coordinates of a Geometry into Mercator projection. The Geometry is modified in-place.
      Parameters:
      geom - the `Geometry` whose coordinates to project