@Test public void testGetTileBoundingBox() { double[] coords = {7, 51}; int levelOfDetail = 8; ReferencedEnvelope env = BingTileUtil.getTileBoundingBox(coords[0], coords[1], levelOfDetail); double delta = 0.000001; Assert.assertEquals(5.625, env.getMinX(), delta); Assert.assertEquals(50.7364551370, env.getMinY(), delta); Assert.assertEquals(7.03125, env.getMaxX(), delta); Assert.assertEquals(51.6180165487, env.getMaxY(), delta); }
public static ReferencedEnvelope getTileBoundingBox(double lon, double lat, int zoomLevel) { int[] imageXY = lonLatToPixelXY(lon, lat, zoomLevel); int numberOfTilesX = imageXY[0] / BingTile.DEFAULT_TILE_SIZE; int numberOfTilesY = imageXY[1] / BingTile.DEFAULT_TILE_SIZE; int tileTopLeftPixelX = numberOfTilesX * BingTile.DEFAULT_TILE_SIZE; int tileTopLeftPixelY = numberOfTilesY * BingTile.DEFAULT_TILE_SIZE; double[] topLeftCoords = pixelXYToLonLat(tileTopLeftPixelX, tileTopLeftPixelY, zoomLevel); double[] bottomRightCoords = pixelXYToLonLat( tileTopLeftPixelX + BingTile.DEFAULT_TILE_SIZE, tileTopLeftPixelY + BingTile.DEFAULT_TILE_SIZE, zoomLevel); Envelope envelope = new Envelope( topLeftCoords[0], bottomRightCoords[0], topLeftCoords[1], bottomRightCoords[1]); return new ReferencedEnvelope(envelope, DefaultGeographicCRS.WGS84); }
BingTileUtil { public static ReferencedEnvelope getTileBoundingBox(double lon, double lat, int zoomLevel) { int[] imageXY = lonLatToPixelXY(lon, lat, zoomLevel); int numberOfTilesX = imageXY[0] / BingTile.DEFAULT_TILE_SIZE; int numberOfTilesY = imageXY[1] / BingTile.DEFAULT_TILE_SIZE; int tileTopLeftPixelX = numberOfTilesX * BingTile.DEFAULT_TILE_SIZE; int tileTopLeftPixelY = numberOfTilesY * BingTile.DEFAULT_TILE_SIZE; double[] topLeftCoords = pixelXYToLonLat(tileTopLeftPixelX, tileTopLeftPixelY, zoomLevel); double[] bottomRightCoords = pixelXYToLonLat( tileTopLeftPixelX + BingTile.DEFAULT_TILE_SIZE, tileTopLeftPixelY + BingTile.DEFAULT_TILE_SIZE, zoomLevel); Envelope envelope = new Envelope( topLeftCoords[0], bottomRightCoords[0], topLeftCoords[1], bottomRightCoords[1]); return new ReferencedEnvelope(envelope, DefaultGeographicCRS.WGS84); } }
BingTileUtil { public static ReferencedEnvelope getTileBoundingBox(double lon, double lat, int zoomLevel) { int[] imageXY = lonLatToPixelXY(lon, lat, zoomLevel); int numberOfTilesX = imageXY[0] / BingTile.DEFAULT_TILE_SIZE; int numberOfTilesY = imageXY[1] / BingTile.DEFAULT_TILE_SIZE; int tileTopLeftPixelX = numberOfTilesX * BingTile.DEFAULT_TILE_SIZE; int tileTopLeftPixelY = numberOfTilesY * BingTile.DEFAULT_TILE_SIZE; double[] topLeftCoords = pixelXYToLonLat(tileTopLeftPixelX, tileTopLeftPixelY, zoomLevel); double[] bottomRightCoords = pixelXYToLonLat( tileTopLeftPixelX + BingTile.DEFAULT_TILE_SIZE, tileTopLeftPixelY + BingTile.DEFAULT_TILE_SIZE, zoomLevel); Envelope envelope = new Envelope( topLeftCoords[0], bottomRightCoords[0], topLeftCoords[1], bottomRightCoords[1]); return new ReferencedEnvelope(envelope, DefaultGeographicCRS.WGS84); } private  BingTileUtil(); }
BingTileUtil { public static ReferencedEnvelope getTileBoundingBox(double lon, double lat, int zoomLevel) { int[] imageXY = lonLatToPixelXY(lon, lat, zoomLevel); int numberOfTilesX = imageXY[0] / BingTile.DEFAULT_TILE_SIZE; int numberOfTilesY = imageXY[1] / BingTile.DEFAULT_TILE_SIZE; int tileTopLeftPixelX = numberOfTilesX * BingTile.DEFAULT_TILE_SIZE; int tileTopLeftPixelY = numberOfTilesY * BingTile.DEFAULT_TILE_SIZE; double[] topLeftCoords = pixelXYToLonLat(tileTopLeftPixelX, tileTopLeftPixelY, zoomLevel); double[] bottomRightCoords = pixelXYToLonLat( tileTopLeftPixelX + BingTile.DEFAULT_TILE_SIZE, tileTopLeftPixelY + BingTile.DEFAULT_TILE_SIZE, zoomLevel); Envelope envelope = new Envelope( topLeftCoords[0], bottomRightCoords[0], topLeftCoords[1], bottomRightCoords[1]); return new ReferencedEnvelope(envelope, DefaultGeographicCRS.WGS84); } 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 ReferencedEnvelope getTileBoundingBox(double lon, double lat, int zoomLevel) { int[] imageXY = lonLatToPixelXY(lon, lat, zoomLevel); int numberOfTilesX = imageXY[0] / BingTile.DEFAULT_TILE_SIZE; int numberOfTilesY = imageXY[1] / BingTile.DEFAULT_TILE_SIZE; int tileTopLeftPixelX = numberOfTilesX * BingTile.DEFAULT_TILE_SIZE; int tileTopLeftPixelY = numberOfTilesY * BingTile.DEFAULT_TILE_SIZE; double[] topLeftCoords = pixelXYToLonLat(tileTopLeftPixelX, tileTopLeftPixelY, zoomLevel); double[] bottomRightCoords = pixelXYToLonLat( tileTopLeftPixelX + BingTile.DEFAULT_TILE_SIZE, tileTopLeftPixelY + BingTile.DEFAULT_TILE_SIZE, zoomLevel); Envelope envelope = new Envelope( topLeftCoords[0], bottomRightCoords[0], topLeftCoords[1], bottomRightCoords[1]); return new ReferencedEnvelope(envelope, DefaultGeographicCRS.WGS84); } 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);  }