MercatorProjection { public static double limitLatitude(double latitude) { return Math.max(Math.min(latitude, LATITUDE_MAX), LATITUDE_MIN); } private  MercatorProjection(); static double calculateGroundResolution(double latitude, byte zoomLevel); static double latitudeToPixelY(double latitude, byte zoomLevel); static long latitudeToTileY(double latitude, byte zoomLevel); static double limitLatitude(double latitude); static double limitLongitude(double longitude); static double longitudeToPixelX(double longitude, byte zoomLevel); static long longitudeToTileX(double longitude, byte zoomLevel); static double pixelXToLongitude(double pixelX, byte zoomLevel); static long pixelXToTileX(double pixelX, byte zoomLevel); static double pixelYToLatitude(double pixelY, byte zoomLevel); static long pixelYToTileY(double pixelY, byte zoomLevel); static double tileXToLongitude(long tileX, byte zoomLevel); static double tileYToLatitude(long tileY, byte zoomLevel); static final double EARTH_CIRCUMFERENCE; static final double LATITUDE_MAX; static final double LATITUDE_MIN; static final double LONGITUDE_MAX; static final double LONGITUDE_MIN; }
@Test public void limitLatitudeTest() { Assert.assertEquals(MercatorProjection.LATITUDE_MIN, MercatorProjection.limitLatitude(-90), 0); Assert.assertEquals(0, MercatorProjection.limitLatitude(0), 0); Assert.assertEquals(MercatorProjection.LATITUDE_MAX, MercatorProjection.limitLatitude(90), 0); }