@Test public void pixelXToLongitudeTest() { for (byte zoomLevel = ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) { double longitude = MercatorProjection.pixelXToLongitude(0, zoomLevel); Assert.assertEquals(CoordinatesUtil.LONGITUDE_MIN, longitude, 0); long mapSize = MercatorProjection.getMapSize(zoomLevel); longitude = MercatorProjection.pixelXToLongitude(mapSize / 2, zoomLevel); Assert.assertEquals(0, longitude, 0); longitude = MercatorProjection.pixelXToLongitude(mapSize, zoomLevel); Assert.assertEquals(CoordinatesUtil.LONGITUDE_MAX, longitude, 0); } }
public static double pixelXToLongitude(double pixelX, byte zoomLevel) { long mapSize = getMapSize(zoomLevel); if (pixelX < 0 || pixelX > mapSize) { throw new IllegalArgumentException("invalid pixelX coordinate at zoom level " + zoomLevel + ": " + pixelX); } return 360 * ((pixelX / mapSize) - 0.5); }
MercatorProjection { public static double pixelXToLongitude(double pixelX, byte zoomLevel) { long mapSize = getMapSize(zoomLevel); if (pixelX < 0 || pixelX > mapSize) { throw new IllegalArgumentException("invalid pixelX coordinate at zoom level " + zoomLevel + ": " + pixelX); } return 360 * ((pixelX / mapSize) - 0.5); } }
MercatorProjection { public static double pixelXToLongitude(double pixelX, byte zoomLevel) { long mapSize = getMapSize(zoomLevel); if (pixelX < 0 || pixelX > mapSize) { throw new IllegalArgumentException("invalid pixelX coordinate at zoom level " + zoomLevel + ": " + pixelX); } return 360 * ((pixelX / mapSize) - 0.5); } private  MercatorProjection(); }
MercatorProjection { public static double pixelXToLongitude(double pixelX, byte zoomLevel) { long mapSize = getMapSize(zoomLevel); if (pixelX < 0 || pixelX > mapSize) { throw new IllegalArgumentException("invalid pixelX coordinate at zoom level " + zoomLevel + ": " + pixelX); } return 360 * ((pixelX / mapSize) - 0.5); } private  MercatorProjection(); static double calculateGroundResolution(double latitude, byte zoomLevel); static double deltaLat(double deltaPixel, double lat, byte zoom); static long getMapSize(byte zoomLevel); static double latitudeToPixelY(double latitude, byte zoomLevel); static long latitudeToTileY(double latitude, byte zoomLevel); 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); }
MercatorProjection { public static double pixelXToLongitude(double pixelX, byte zoomLevel) { long mapSize = getMapSize(zoomLevel); if (pixelX < 0 || pixelX > mapSize) { throw new IllegalArgumentException("invalid pixelX coordinate at zoom level " + zoomLevel + ": " + pixelX); } return 360 * ((pixelX / mapSize) - 0.5); } private  MercatorProjection(); static double calculateGroundResolution(double latitude, byte zoomLevel); static double deltaLat(double deltaPixel, double lat, byte zoom); static long getMapSize(byte zoomLevel); static double latitudeToPixelY(double latitude, byte zoomLevel); static long latitudeToTileY(double latitude, byte zoomLevel); 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; }