public int countImagesInSector(Sector sector, int levelNumber) { if (sector == null) { String msg = Logging.getMessage("nullValue.SectorIsNull"); Logging.logger().severe(msg); throw new IllegalArgumentException(msg); } Level targetLevel = this.levels.getLastLevel(); if (levelNumber >= 0) { for (int i = levelNumber; i < this.getLevels().getLastLevel().getLevelNumber(); i++) { if (this.levels.isLevelEmpty(i)) continue; targetLevel = this.levels.getLevel(i); break; } } // Collect all the tiles intersecting the input sector. LatLon delta = targetLevel.getTileDelta(); Angle latOrigin = this.levels.getTileOrigin().getLatitude(); Angle lonOrigin = this.levels.getTileOrigin().getLongitude(); final int nwRow = Tile.computeRow(delta.getLatitude(), sector.getMaxLatitude(), latOrigin); final int nwCol = Tile.computeColumn(delta.getLongitude(), sector.getMinLongitude(), lonOrigin); final int seRow = Tile.computeRow(delta.getLatitude(), sector.getMinLatitude(), latOrigin); final int seCol = Tile.computeColumn(delta.getLongitude(), sector.getMaxLongitude(), lonOrigin); int numRows = nwRow - seRow + 1; int numCols = seCol - nwCol + 1; return numRows * numCols; }
private MercatorTextureTile[][] getTilesInSector(Sector sector, int levelNumber) { if (sector == null) { String msg = Logging.getMessage("nullValue.SectorIsNull"); Logging.logger().severe(msg); throw new IllegalArgumentException(msg); } Level targetLevel = this.levels.getLastLevel(); if (levelNumber >= 0) { for (int i = levelNumber; i < this.getLevels().getLastLevel().getLevelNumber(); i++) { if (this.levels.isLevelEmpty(i)) continue; targetLevel = this.levels.getLevel(i); break; } } // Collect all the tiles intersecting the input sector. LatLon delta = targetLevel.getTileDelta(); Angle latOrigin = this.levels.getTileOrigin().getLatitude(); Angle lonOrigin = this.levels.getTileOrigin().getLongitude(); final int nwRow = Tile.computeRow(delta.getLatitude(), sector.getMaxLatitude(), latOrigin); final int nwCol = Tile.computeColumn(delta.getLongitude(), sector.getMinLongitude(), lonOrigin); final int seRow = Tile.computeRow(delta.getLatitude(), sector.getMinLatitude(), latOrigin); final int seCol = Tile.computeColumn(delta.getLongitude(), sector.getMaxLongitude(), lonOrigin); int numRows = nwRow - seRow + 1; int numCols = seCol - nwCol + 1; MercatorTextureTile[][] sectorTiles = new MercatorTextureTile[numRows][numCols]; for (int row = nwRow; row >= seRow; row--) { for (int col = nwCol; col <= seCol; col++) { TileKey key = new TileKey(targetLevel.getLevelNumber(), row, col, targetLevel.getCacheName()); Sector tileSector = this.levels.computeSectorForKey(key); MercatorSector mSector = MercatorSector.fromSector(tileSector); // TODO: check sectorTiles[nwRow - row][col - nwCol] = new MercatorTextureTile(mSector, targetLevel, row, col); } } return sectorTiles; }
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; } }
public URL getURL(Tile tile, String altImageFormat) throws MalformedURLException { StringBuffer sb; if (this.URLTemplate == null) { sb = new StringBuffer(WWXML.fixGetMapString(tile.getLevel().getService())); if (!sb.toString().toLowerCase().contains("service=wms")) sb.append("service=WMS"); sb.append("&request=GetMap"); sb.append("&version=").append(this.wmsVersion); sb.append(this.crs); sb.append("&layers=").append(this.layerNames); sb.append("&styles=").append(this.styleNames != null ? this.styleNames : ""); sb.append("&transparent=TRUE"); if (this.backgroundColor != null) sb.append("&bgcolor=").append(this.backgroundColor); this.URLTemplate = sb.toString(); } else { sb = new StringBuffer(this.URLTemplate); } String format = (altImageFormat != null) ? altImageFormat : this.imageFormat; if (null != format) sb.append("&format=").append(format); sb.append("&width=").append(tile.getWidth()); sb.append("&height=").append(tile.getHeight()); Sector s = tile.getSector(); sb.append("&bbox="); sb.append(s.getMinLongitude().getDegrees()); sb.append(","); sb.append(s.getMinLatitude().getDegrees()); sb.append(","); sb.append(s.getMaxLongitude().getDegrees()); sb.append(","); sb.append(s.getMaxLatitude().getDegrees()); // sb.append("&"); // terminate the query string return new java.net.URL(sb.toString().replace(" ", "%20")); }