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; }
private void createTopLevelTiles() { MercatorSector sector = (MercatorSector) this.levels.getSector(); Level level = levels.getFirstLevel(); Angle dLat = level.getTileDelta().getLatitude(); Angle dLon = level.getTileDelta().getLongitude(); Angle latOrigin = this.levels.getTileOrigin().getLatitude(); Angle lonOrigin = this.levels.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 nLatTiles = lastRow - firstRow + 1; int nLonTiles = lastCol - firstCol + 1; this.topLevels = new ArrayList<MercatorTextureTile>(nLatTiles * nLonTiles); // Angle p1 = Tile.computeRowLatitude(firstRow, dLat); double deltaLat = dLat.degrees / 90; double d1 = -1.0 + deltaLat * firstRow; for (int row = firstRow; row <= lastRow; row++) { // Angle p2; // p2 = p1.add(dLat); double d2 = d1 + deltaLat; Angle t1 = Tile.computeColumnLongitude(firstCol, dLon, lonOrigin); for (int col = firstCol; col <= lastCol; col++) { Angle t2; t2 = t1.add(dLon); this.topLevels.add( new MercatorTextureTile(new MercatorSector(d1, d2, t1, t2), level, row, col)); t1 = t2; } d1 = d2; } }