protected Tile[] buildTiles(PlaceNameService placeNameService, NavigationTile navTile) { final Angle dLat = placeNameService.getTileDelta().getLatitude(); final Angle dLon = placeNameService.getTileDelta().getLongitude(); // Determine the row and column offset from the global tiling origin for the southwest tile // corner int firstRow = Tile.computeRow(dLat, navTile.navSector.getMinLatitude()); int firstCol = Tile.computeColumn(dLon, navTile.navSector.getMinLongitude()); int lastRow = Tile.computeRow(dLat, navTile.navSector.getMaxLatitude().subtract(dLat)); int lastCol = Tile.computeColumn(dLon, navTile.navSector.getMaxLongitude().subtract(dLon)); int nLatTiles = lastRow - firstRow + 1; int nLonTiles = lastCol - firstCol + 1; Tile[] tiles = new Tile[nLatTiles * nLonTiles]; Angle p1 = Tile.computeRowLatitude(firstRow, dLat); for (int row = 0; row <= lastRow - firstRow; row++) { Angle p2; p2 = p1.add(dLat); Angle t1 = Tile.computeColumnLongitude(firstCol, dLon); for (int col = 0; col <= lastCol - firstCol; col++) { Angle t2; t2 = t1.add(dLon); // Need offset row and column to correspond to total ro/col numbering tiles[col + row * nLonTiles] = new Tile(placeNameService, new Sector(p1, p2, t1, t2), row + firstRow, col + firstCol); t1 = t2; } p1 = p2; } return tiles; }
private static MeshTile[] createTiles(LevelSet levelSet, int levelNumber, MeshCoords coords) { Sector sector = levelSet.getSector(); Level level = levelSet.getLevel(levelNumber); Angle dLat = level.getTileDelta().getLatitude(); Angle dLon = level.getTileDelta().getLongitude(); Angle latOrigin = levelSet.getTileOrigin().getLatitude(); Angle lonOrigin = levelSet.getTileOrigin().getLongitude(); // Determine the row and column offset from the common World Wind global tiling origin. int firstRow = Tile.computeRow(dLat, sector.getMinLatitude(), latOrigin); int firstCol = Tile.computeColumn(dLon, sector.getMinLongitude(), lonOrigin); int lastRow = Tile.computeRow(dLat, sector.getMaxLatitude(), latOrigin); int lastCol = Tile.computeColumn(dLon, sector.getMaxLongitude(), lonOrigin); int numLatTiles = lastRow - firstRow + 1; int numLonTiles = lastCol - firstCol + 1; AffineTransform sectorTransform = createTransform(sector, coords); MeshTile[] tiles = new MeshTile[numLatTiles * numLonTiles]; int index = 0; Angle p1 = Tile.computeRowLatitude(firstRow, dLat, latOrigin); for (int row = firstRow; row <= lastRow; row++) { Angle p2 = p1.add(dLat); Angle t1 = Tile.computeColumnLongitude(firstCol, dLon, lonOrigin); for (int col = firstCol; col <= lastCol; col++) { Angle t2 = t1.add(dLon); Sector tileSector = new Sector(p1, p2, t1, t2); MeshCoords tileCoords = transformSector(sectorTransform, tileSector); tiles[index++] = new MeshTile(tileSector, level, row, col, tileCoords); t1 = t2; } p1 = p2; } return tiles; }