@Test public void getTilePositionsTest() { for (int tileSize : TILE_SIZES) { BoundingBox boundingBox = new BoundingBox(-1, -1, 1, 1); List<TilePosition> tilePositions = LayerUtil.getTilePositions(boundingBox, (byte) 0, new Point(0, 0), tileSize); Assert.assertEquals(1, tilePositions.size()); TilePosition tilePosition = tilePositions.get(0); Assert.assertEquals(new Tile(0, 0, (byte) 0), tilePosition.tile); Assert.assertEquals(new Point(0, 0), tilePosition.point); } }
public static List<TilePosition> getTilePositions(BoundingBox boundingBox, byte zoomLevel, Point topLeftPoint, int tileSize) { long tileLeft = MercatorProjection.longitudeToTileX(boundingBox.minLongitude, zoomLevel); long tileTop = MercatorProjection.latitudeToTileY(boundingBox.maxLatitude, zoomLevel); long tileRight = MercatorProjection.longitudeToTileX(boundingBox.maxLongitude, zoomLevel); long tileBottom = MercatorProjection.latitudeToTileY(boundingBox.minLatitude, zoomLevel); int initialCapacity = (int) ((tileRight - tileLeft + 1) * (tileBottom - tileTop + 1)); List<TilePosition> tilePositions = new ArrayList<TilePosition>(initialCapacity); for (long tileY = tileTop; tileY <= tileBottom; ++tileY) { for (long tileX = tileLeft; tileX <= tileRight; ++tileX) { double pixelX = MercatorProjection.tileToPixel(tileX, tileSize) - topLeftPoint.x; double pixelY = MercatorProjection.tileToPixel(tileY, tileSize) - topLeftPoint.y; tilePositions.add(new TilePosition(new Tile(tileX, tileY, zoomLevel), new Point(pixelX, pixelY))); } } return tilePositions; }
LayerUtil { public static List<TilePosition> getTilePositions(BoundingBox boundingBox, byte zoomLevel, Point topLeftPoint, int tileSize) { long tileLeft = MercatorProjection.longitudeToTileX(boundingBox.minLongitude, zoomLevel); long tileTop = MercatorProjection.latitudeToTileY(boundingBox.maxLatitude, zoomLevel); long tileRight = MercatorProjection.longitudeToTileX(boundingBox.maxLongitude, zoomLevel); long tileBottom = MercatorProjection.latitudeToTileY(boundingBox.minLatitude, zoomLevel); int initialCapacity = (int) ((tileRight - tileLeft + 1) * (tileBottom - tileTop + 1)); List<TilePosition> tilePositions = new ArrayList<TilePosition>(initialCapacity); for (long tileY = tileTop; tileY <= tileBottom; ++tileY) { for (long tileX = tileLeft; tileX <= tileRight; ++tileX) { double pixelX = MercatorProjection.tileToPixel(tileX, tileSize) - topLeftPoint.x; double pixelY = MercatorProjection.tileToPixel(tileY, tileSize) - topLeftPoint.y; tilePositions.add(new TilePosition(new Tile(tileX, tileY, zoomLevel), new Point(pixelX, pixelY))); } } return tilePositions; } }
LayerUtil { public static List<TilePosition> getTilePositions(BoundingBox boundingBox, byte zoomLevel, Point topLeftPoint, int tileSize) { long tileLeft = MercatorProjection.longitudeToTileX(boundingBox.minLongitude, zoomLevel); long tileTop = MercatorProjection.latitudeToTileY(boundingBox.maxLatitude, zoomLevel); long tileRight = MercatorProjection.longitudeToTileX(boundingBox.maxLongitude, zoomLevel); long tileBottom = MercatorProjection.latitudeToTileY(boundingBox.minLatitude, zoomLevel); int initialCapacity = (int) ((tileRight - tileLeft + 1) * (tileBottom - tileTop + 1)); List<TilePosition> tilePositions = new ArrayList<TilePosition>(initialCapacity); for (long tileY = tileTop; tileY <= tileBottom; ++tileY) { for (long tileX = tileLeft; tileX <= tileRight; ++tileX) { double pixelX = MercatorProjection.tileToPixel(tileX, tileSize) - topLeftPoint.x; double pixelY = MercatorProjection.tileToPixel(tileY, tileSize) - topLeftPoint.y; tilePositions.add(new TilePosition(new Tile(tileX, tileY, zoomLevel), new Point(pixelX, pixelY))); } } return tilePositions; } private  LayerUtil(); }
LayerUtil { public static List<TilePosition> getTilePositions(BoundingBox boundingBox, byte zoomLevel, Point topLeftPoint, int tileSize) { long tileLeft = MercatorProjection.longitudeToTileX(boundingBox.minLongitude, zoomLevel); long tileTop = MercatorProjection.latitudeToTileY(boundingBox.maxLatitude, zoomLevel); long tileRight = MercatorProjection.longitudeToTileX(boundingBox.maxLongitude, zoomLevel); long tileBottom = MercatorProjection.latitudeToTileY(boundingBox.minLatitude, zoomLevel); int initialCapacity = (int) ((tileRight - tileLeft + 1) * (tileBottom - tileTop + 1)); List<TilePosition> tilePositions = new ArrayList<TilePosition>(initialCapacity); for (long tileY = tileTop; tileY <= tileBottom; ++tileY) { for (long tileX = tileLeft; tileX <= tileRight; ++tileX) { double pixelX = MercatorProjection.tileToPixel(tileX, tileSize) - topLeftPoint.x; double pixelY = MercatorProjection.tileToPixel(tileY, tileSize) - topLeftPoint.y; tilePositions.add(new TilePosition(new Tile(tileX, tileY, zoomLevel), new Point(pixelX, pixelY))); } } return tilePositions; } private  LayerUtil(); static List<TilePosition> getTilePositions(BoundingBox boundingBox, byte zoomLevel, Point topLeftPoint,
			int tileSize); }
LayerUtil { public static List<TilePosition> getTilePositions(BoundingBox boundingBox, byte zoomLevel, Point topLeftPoint, int tileSize) { long tileLeft = MercatorProjection.longitudeToTileX(boundingBox.minLongitude, zoomLevel); long tileTop = MercatorProjection.latitudeToTileY(boundingBox.maxLatitude, zoomLevel); long tileRight = MercatorProjection.longitudeToTileX(boundingBox.maxLongitude, zoomLevel); long tileBottom = MercatorProjection.latitudeToTileY(boundingBox.minLatitude, zoomLevel); int initialCapacity = (int) ((tileRight - tileLeft + 1) * (tileBottom - tileTop + 1)); List<TilePosition> tilePositions = new ArrayList<TilePosition>(initialCapacity); for (long tileY = tileTop; tileY <= tileBottom; ++tileY) { for (long tileX = tileLeft; tileX <= tileRight; ++tileX) { double pixelX = MercatorProjection.tileToPixel(tileX, tileSize) - topLeftPoint.x; double pixelY = MercatorProjection.tileToPixel(tileY, tileSize) - topLeftPoint.y; tilePositions.add(new TilePosition(new Tile(tileX, tileY, zoomLevel), new Point(pixelX, pixelY))); } } return tilePositions; } private  LayerUtil(); static List<TilePosition> getTilePositions(BoundingBox boundingBox, byte zoomLevel, Point topLeftPoint,
			int tileSize);  }