Skip to content

Commit

Permalink
Update Mercator.java
Browse files Browse the repository at this point in the history
  • Loading branch information
clarisma committed Sep 12, 2024
1 parent c6ca572 commit f10e7c7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/com/geodesk/geom/Mercator.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* (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,
* 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").
*
Expand Down Expand Up @@ -122,6 +122,12 @@ public static double lonFromX(double x)
return x * 360 / MAP_WIDTH;
}

public static double lonPrecision7fromX(double x)
{
double lon = lonFromX(x);
return ((double)Math.round(lon * 10000000)) / 10000000;
}

/**
* Converts a projected latitude to WGS84.
*
Expand All @@ -134,6 +140,12 @@ public static double latFromY(double y)
* 360 / Math.PI - 90;
}

public static double latPrecision7fromY(double y)
{
double lat = latFromY(y);
return ((double)Math.round(lat * 10000000)) / 10000000;
}

public static double metersAtY(int y)
{
return EARTH_CIRCUMFERENCE / MAP_WIDTH / scale(y);
Expand Down

0 comments on commit f10e7c7

Please sign in to comment.