MercatorPoint { @Nonnull public static MercatorPoint latLonToMercs(@Nonnull final GeoPoint point) { final double lat = MathUtils.limitTo(point.getLat(), MapConst.LATITUDE_MIN, MapConst.LATITUDE_MAX); final double lon = point.getLon(); final double geoX = Math.toRadians(MapConst.WORLD_RADIUS * lon); final double geoY = MapConst.WORLD_RADIUS * Math.log(Math.tan(Math.toRadians(lat + 90.0) / 2.0)); final double mercX = Math.min(1.0, Math.max(0.0, (geoX / MapConst.WORLD_SIZE) + 0.5)); final double mercY = Math.min(1.0, Math.max(0.0, 1.0 - ((geoY / MapConst.WORLD_SIZE) + 0.5))); assert MathUtils.isBetween(mercX, 0.0, 1.0) : mercX + ", " + point; assert MathUtils.isBetween(mercY, 0.0, 1.0) : mercY + ", " + point; return new MercatorPoint(mercX, mercY); } MercatorPoint(
            final double mercX,
            final double mercY); double getMercX(); double getMercY(); @Nonnull static GeoPoint mercsToLatLon(final double mercX, final double mercY); @Nonnull static GeoPoint mercsToLatLon(@Nonnull final MercatorPoint mercs); @Nonnull static MercatorPoint latLonToMercs(@Nonnull final GeoPoint point); @Nonnull static MercatorPoint latLonToMercs(final double lat, final double lon); boolean canEqual(@Nonnull final Object obj); @Override boolean equals(@Nullable final Object obj); @Override int hashCode(); @Override String toString();  }
@Test public void testLatLonToMercs() { LOG.info("testLatLonToMercs"); Assert.assertEquals(new MercatorPoint(0.5, 0.5), MercatorPoint.latLonToMercs(new GeoPoint(0.0, 0.0))); MercatorPoint expected = MercatorPoint.latLonToMercs(new GeoPoint(90.0, -180.0)); Assert.assertTrue(expected.toString(), MathUtils.isBetween(expected.getMercX(), 0.0, 0.0)); Assert.assertTrue(expected.toString(), MathUtils.isBetween(expected.getMercY(), 0.0, 0.01)); expected = MercatorPoint.latLonToMercs(new GeoPoint(-90.0, Geo.LON180)); Assert.assertTrue(expected.toString(), MathUtils.isBetween(expected.getMercX(), 1.0, 1.0)); Assert.assertTrue(expected.toString(), MathUtils.isBetween(expected.getMercY(), 0.99, 1.0)); }