@Test public void testLonLatToPixelXY() { int[] pixelXY = BingTileUtil.lonLatToPixelXY(7, 51, 5); Assert.assertArrayEquals(new int[] {4255, 2742}, pixelXY); }
public static int[] lonLatToPixelXY(double longitude, double latitude, int zoomLevel) { double _latitude = clip( latitude, WebMercatorTileService.MIN_LATITUDE, WebMercatorTileService.MAX_LATITUDE); double _longitude = clip( longitude, WebMercatorTileService.MIN_LONGITUDE, WebMercatorTileService.MAX_LONGITUDE); double x = (_longitude + 180) / 360; double sinLatitude = Math.sin(_latitude * Math.PI / 180); double y = 0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI); int mapSize = mapSize(zoomLevel); int pixelX = (int) clip(x * mapSize + 0.5, 0, mapSize - 1); int pixelY = (int) clip(y * mapSize + 0.5, 0, mapSize - 1); return new int[] {pixelX, pixelY}; }
BingTileUtil { public static int[] lonLatToPixelXY(double longitude, double latitude, int zoomLevel) { double _latitude = clip( latitude, WebMercatorTileService.MIN_LATITUDE, WebMercatorTileService.MAX_LATITUDE); double _longitude = clip( longitude, WebMercatorTileService.MIN_LONGITUDE, WebMercatorTileService.MAX_LONGITUDE); double x = (_longitude + 180) / 360; double sinLatitude = Math.sin(_latitude * Math.PI / 180); double y = 0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI); int mapSize = mapSize(zoomLevel); int pixelX = (int) clip(x * mapSize + 0.5, 0, mapSize - 1); int pixelY = (int) clip(y * mapSize + 0.5, 0, mapSize - 1); return new int[] {pixelX, pixelY}; } }
BingTileUtil { public static int[] lonLatToPixelXY(double longitude, double latitude, int zoomLevel) { double _latitude = clip( latitude, WebMercatorTileService.MIN_LATITUDE, WebMercatorTileService.MAX_LATITUDE); double _longitude = clip( longitude, WebMercatorTileService.MIN_LONGITUDE, WebMercatorTileService.MAX_LONGITUDE); double x = (_longitude + 180) / 360; double sinLatitude = Math.sin(_latitude * Math.PI / 180); double y = 0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI); int mapSize = mapSize(zoomLevel); int pixelX = (int) clip(x * mapSize + 0.5, 0, mapSize - 1); int pixelY = (int) clip(y * mapSize + 0.5, 0, mapSize - 1); return new int[] {pixelX, pixelY}; } private  BingTileUtil(); }
BingTileUtil { public static int[] lonLatToPixelXY(double longitude, double latitude, int zoomLevel) { double _latitude = clip( latitude, WebMercatorTileService.MIN_LATITUDE, WebMercatorTileService.MAX_LATITUDE); double _longitude = clip( longitude, WebMercatorTileService.MIN_LONGITUDE, WebMercatorTileService.MAX_LONGITUDE); double x = (_longitude + 180) / 360; double sinLatitude = Math.sin(_latitude * Math.PI / 180); double y = 0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI); int mapSize = mapSize(zoomLevel); int pixelX = (int) clip(x * mapSize + 0.5, 0, mapSize - 1); int pixelY = (int) clip(y * mapSize + 0.5, 0, mapSize - 1); return new int[] {pixelX, pixelY}; } private  BingTileUtil(); static int[] lonLatToPixelXY(double longitude, double latitude, int zoomLevel); static double[] pixelXYToLonLat(int pixelX, int pixelY, int zoomLevel); static int mapSize(int zoomLevel); static int[] pixelXYToTileXY(int pixelX, int pixelY); static String tileXYToQuadKey(int tileX, int tileY, int zoomLevel); static String lonLatToQuadKey(double lon, double lat, int zoomLevel); static ReferencedEnvelope getTileBoundingBox(double lon, double lat, int zoomLevel); }
BingTileUtil { public static int[] lonLatToPixelXY(double longitude, double latitude, int zoomLevel) { double _latitude = clip( latitude, WebMercatorTileService.MIN_LATITUDE, WebMercatorTileService.MAX_LATITUDE); double _longitude = clip( longitude, WebMercatorTileService.MIN_LONGITUDE, WebMercatorTileService.MAX_LONGITUDE); double x = (_longitude + 180) / 360; double sinLatitude = Math.sin(_latitude * Math.PI / 180); double y = 0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI); int mapSize = mapSize(zoomLevel); int pixelX = (int) clip(x * mapSize + 0.5, 0, mapSize - 1); int pixelY = (int) clip(y * mapSize + 0.5, 0, mapSize - 1); return new int[] {pixelX, pixelY}; } private  BingTileUtil(); static int[] lonLatToPixelXY(double longitude, double latitude, int zoomLevel); static double[] pixelXYToLonLat(int pixelX, int pixelY, int zoomLevel); static int mapSize(int zoomLevel); static int[] pixelXYToTileXY(int pixelX, int pixelY); static String tileXYToQuadKey(int tileX, int tileY, int zoomLevel); static String lonLatToQuadKey(double lon, double lat, int zoomLevel); static ReferencedEnvelope getTileBoundingBox(double lon, double lat, int zoomLevel);  }