protected void assembleTiles(RenderContext rc) { // TODO // The need to create Tiles with a defined image source couples the need to determine a tile's visibility with // he need to know its image source. Decoupling the two would mean we only need to know the image source when // the texture is actually requested Could the tile-based operations done here be implicit on level/row/column, // or use transient pooled tile objects not tied to an image source? if (this.topLevelTiles.isEmpty()) { this.createTopLevelTiles(); } for (int idx = 0, len = this.topLevelTiles.size(); idx < len; idx++) { this.addTileOrDescendants(rc, (ImageTile) this.topLevelTiles.get(idx)); } }
@Override protected void doRender(RenderContext rc) { if (rc.terrain.getSector().isEmpty()) { return; // no terrain surface to render on } this.determineActiveProgram(rc); this.assembleTiles(rc); this.activeProgram = null; // clear the active program to avoid leaking render resources this.ancestorTile = null; // clear the ancestor tile and texture this.ancestorTexture = null; }
public void setImageOptions(ImageOptions imageOptions) { this.imageOptions = imageOptions; this.invalidateTiles(); }
final TiledSurfaceImage surfaceImage = new TiledSurfaceImage(); surfaceImage.setTileFactory(tileFactory); surfaceImage.setLevelSet(levelSet);
this.setPickEnabled(false); TiledSurfaceImage surfaceImage = new TiledSurfaceImage(); surfaceImage.setLevelSet(new LevelSet(levelsConfig)); surfaceImage.setTileFactory(this); surfaceImage.setImageOptions(new ImageOptions(WorldWind.RGB_565)); // reduce memory usage by using a 16-bit configuration with no alpha this.addRenderable(surfaceImage);
/** * Specifies this Web Map Service (WMS) layer's configuration. The configuration must specify the following values: * service address, WMS protocol version, layer names, coordinate reference system, sector and resolution. All other * WMS configuration values may be unspecified, in which case a default value is used. * * @param sector the geographic region in which to display the WMS layer * @param metersPerPixel the desired resolution in meters on Earth * @param config the WMS layer configuration values */ public void setConfiguration(Sector sector, double metersPerPixel, WmsLayerConfig config) { if (sector == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "WmsLayer", "setConfiguration", "missingSector")); } if (metersPerPixel <= 0) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "WmsLayer", "setConfiguration", "invalidResolution")); } if (config == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "WmsLayer", "setConfiguration", "missingConfig")); } double radiansPerPixel = metersPerPixel / WorldWind.WGS84_SEMI_MAJOR_AXIS; LevelSetConfig levelsConfig = new LevelSetConfig(); levelsConfig.sector.set(sector); levelsConfig.numLevels = levelsConfig.numLevelsForResolution(radiansPerPixel); TiledSurfaceImage surfaceImage = (TiledSurfaceImage) this.getRenderable(0); surfaceImage.setLevelSet(new LevelSet(levelsConfig)); surfaceImage.setTileFactory(new WmsTileFactory(config)); }
/** * Test the three parameter {@code setConfiguration} method when the meters per pixel parameter has been changed. */ @Test public void testSetConfiguration_ThreeParameter_MetersPerPixelUpdate() { // Mocked objects facilitating testing double minLat = 10.0; double deltaLat = 1.0; double minLon = -95.0; double deltaLon = 2.0; Sector initialSector = new Sector(minLat, minLon, deltaLat, deltaLon); String initialNotionalServiceAddress = "notionalServiceAddress"; String initialNotionalLayerList = "notionalLayerList"; WmsLayerConfig initialWmsLayerConfig = new WmsLayerConfig(initialNotionalServiceAddress, initialNotionalLayerList); double metersPerPixel = 0.5; WmsLayer wmsLayer = new WmsLayer(initialSector, metersPerPixel, initialWmsLayerConfig); double alternativeMetersPerPixel = 10.0; int originalNumberOfLevels = ((TiledSurfaceImage) wmsLayer.getRenderable(0)).getLevelSet().numLevels(); wmsLayer.setConfiguration(initialSector, alternativeMetersPerPixel, initialWmsLayerConfig); int numberOfLevels = ((TiledSurfaceImage) wmsLayer.getRenderable(0)).getLevelSet().numLevels(); // assertEquals is not used as the determination of the number of levels is a function of LevelSetConfig assertFalse("levels updated", originalNumberOfLevels == numberOfLevels); }
protected void addTileOrDescendants(RenderContext rc, ImageTile tile) { if (!tile.intersectsSector(this.levelSet.sector) || !tile.intersectsFrustum(rc, rc.frustum)) { return; // ignore the tile and its descendants if it's not needed or not visible } if (tile.level.isLastLevel() || !tile.mustSubdivide(rc, this.detailControl)) { this.addTile(rc, tile); return; // use the tile if it does not need to be subdivided } ImageTile currentAncestorTile = this.ancestorTile; Texture currentAncestorTexture = this.ancestorTexture; ImageSource tileImageSource = tile.getImageSource(); if (tileImageSource != null) { // tile has an image source; its level is not empty Texture tileTexture = rc.getTexture(tileImageSource); if (tileTexture != null) { // tile has a texture; use it as a fallback tile for descendants this.ancestorTile = tile; this.ancestorTexture = tileTexture; } } for (Tile child : tile.subdivideToCache(this.tileFactory, this.tileCache, 4)) { // each tile has a cached size of 1 this.addTileOrDescendants(rc, (ImageTile) child); // recursively process the tile's children } this.ancestorTile = currentAncestorTile; // restore the last fallback tile, even if it was null this.ancestorTexture = currentAncestorTexture; }
protected void init() { this.setDisplayName("WMS Layer"); this.setPickEnabled(false); this.addRenderable(new TiledSurfaceImage()); }
/** * Constructs a Blue Marble image layer with the WMS at a specified address. * * @param serviceAddress a URL string specifying the WMS address * * @throws IllegalArgumentException If the service address is null */ public BlueMarbleLayer(String serviceAddress) { if (serviceAddress == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "BlueMarbleLayer", "constructor", "missingServiceAddress")); } WmsLayerConfig config = new WmsLayerConfig(); config.serviceAddress = serviceAddress; config.wmsVersion = "1.3.0"; config.layerNames = "BlueMarble-200405"; config.coordinateSystem = "EPSG:4326"; config.transparent = false; // the BlueMarble layer is opaque this.setDisplayName("Blue Marble"); this.setConfiguration(new Sector().setFullSphere(), 500, config); // 500m resolution on Earth TiledSurfaceImage surfaceImage = (TiledSurfaceImage) this.getRenderable(0); surfaceImage.setImageOptions(new ImageOptions(WorldWind.RGB_565)); // exploit opaque imagery to reduce memory usage } }
final TiledSurfaceImage surfaceImage = new TiledSurfaceImage(); surfaceImage.setTileFactory(new WmsTileFactory(wmsLayerConfig)); surfaceImage.setLevelSet(new LevelSet(levelSetConfig));
surfaceImage.setLevelSet(new LevelSet(levelsConfig)); surfaceImage.setTileFactory(new WmsTileFactory(config));
assertEquals("detail levels", anticipatedLevels, ((TiledSurfaceImage) wmsLayer.getRenderable(0)).getLevelSet().numLevels());
config.tileHeight = 256; TiledSurfaceImage surfaceImage = new TiledSurfaceImage(); surfaceImage.setLevelSet(new LevelSet(config)); surfaceImage.setTileFactory(new GpkgTileFactory(content)); gpkgRenderables.addRenderable(surfaceImage);
/** * Test the four parameter {@code setConfiguration} method updates when the meters per pixel is changed. */ @Test public void testSetConfiguration_FourParameter_MetersPerPixelUpdate() { // Mocked objects facilitating testing double minLat = 10.0; double deltaLat = 1.0; double minLon = -95.0; double deltaLon = 2.0; double notionalGlobeRadius = 3000000.0; Sector initialSector = new Sector(minLat, minLon, deltaLat, deltaLon); Globe initialGlobe = PowerMockito.mock(Globe.class); PowerMockito.when(initialGlobe.getEquatorialRadius()).thenReturn(notionalGlobeRadius); String initialNotionalServiceAddress = "notionalServiceAddress"; String initialNotionalLayerList = "notionalLayerList"; WmsLayerConfig initialWmsLayerConfig = new WmsLayerConfig(initialNotionalServiceAddress, initialNotionalLayerList); double metersPerPixel = 0.5; WmsLayer wmsLayer = new WmsLayer(initialSector, initialGlobe, metersPerPixel, initialWmsLayerConfig); double alternativeMetersPerPixel = 10.0; int originalNumberOfLevels = ((TiledSurfaceImage) wmsLayer.getRenderable(0)).getLevelSet().numLevels(); wmsLayer.setConfiguration(initialSector, initialGlobe, alternativeMetersPerPixel, initialWmsLayerConfig); int numberOfLevels = ((TiledSurfaceImage) wmsLayer.getRenderable(0)).getLevelSet().numLevels(); assertFalse("levels updated", originalNumberOfLevels == numberOfLevels); } }
public void setTileFactory(TileFactory tileFactory) { this.tileFactory = tileFactory; this.invalidateTiles(); }
/** * Test the four parameter {@code setConfiguration} method updates when the {@link Globe} is changed. */ @Test public void testSetConfiguration_FourParameter_GlobeUpdate() { // Mocked objects facilitating testing double minLat = 10.0; double deltaLat = 1.0; double minLon = -95.0; double deltaLon = 2.0; double notionalGlobeRadius = 3000000.0; Sector initialSector = new Sector(minLat, minLon, deltaLat, deltaLon); Globe initialGlobe = PowerMockito.mock(Globe.class); PowerMockito.when(initialGlobe.getEquatorialRadius()).thenReturn(notionalGlobeRadius); String initialNotionalServiceAddress = "notionalServiceAddress"; String initialNotionalLayerList = "notionalLayerList"; WmsLayerConfig initialWmsLayerConfig = new WmsLayerConfig(initialNotionalServiceAddress, initialNotionalLayerList); double metersPerPixel = 0.5; WmsLayer wmsLayer = new WmsLayer(initialSector, initialGlobe, metersPerPixel, initialWmsLayerConfig); int initialLayers = ((TiledSurfaceImage) wmsLayer.getRenderable(0)).getLevelSet().numLevels(); Globe alternativeGlobe = PowerMockito.mock(Globe.class); PowerMockito.when(alternativeGlobe.getEquatorialRadius()).thenReturn(2 * notionalGlobeRadius); wmsLayer.setConfiguration(initialSector, alternativeGlobe, metersPerPixel, initialWmsLayerConfig); int numberOfLevels = ((TiledSurfaceImage) wmsLayer.getRenderable(0)).getLevelSet().numLevels(); assertFalse("layer levels updated by globe object change", initialLayers == numberOfLevels); }
public void setLevelSet(LevelSet levelSet) { if (levelSet == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "TiledSurfaceImage", "setLevelSet", "missingLevelSet")); } this.levelSet = levelSet; this.invalidateTiles(); }
/** * Test the three parameter {@code setConfiguration} method updates when the {@link Sector} is changed. */ @Test public void testSetConfiguration_ThreeParameter_SectorUpdate() { // Mocked objects facilitating testing double minLat = 10.0; double deltaLat = 1.0; double minLon = -95.0; double deltaLon = 2.0; Sector initialSector = new Sector(minLat, minLon, deltaLat, deltaLon); String initialNotionalServiceAddress = "notionalServiceAddress"; String initialNotionalLayerList = "notionalLayerList"; WmsLayerConfig initialWmsLayerConfig = new WmsLayerConfig(initialNotionalServiceAddress, initialNotionalLayerList); double metersPerPixel = 0.5; WmsLayer wmsLayer = new WmsLayer(initialSector, metersPerPixel, initialWmsLayerConfig); double alternativeLatMin = -45.0; double alternativeLonMin = 50.0; double alternativeDeltaLat = 5.0; double alternativeDeltaLon = 2.0; Sector alternativeSector = new Sector(alternativeLatMin, alternativeLonMin, alternativeDeltaLat, alternativeDeltaLon); wmsLayer.setConfiguration(alternativeSector, metersPerPixel, initialWmsLayerConfig); Sector sector = ((TiledSurfaceImage) wmsLayer.getRenderable(0)).getLevelSet().sector; assertEquals("sector updated", alternativeSector, sector); }
/** * Test the four parameter {@code setConfiguration} method updates when the {@link Sector} is changed. */ @Test public void testSetConfiguration_FourParameter_SectorUpdate() { // Mocked objects facilitating testing double minLat = 10.0; double deltaLat = 1.0; double minLon = -95.0; double deltaLon = 2.0; double notionalGlobeRadius = 3000000.0; Sector initialSector = new Sector(minLat, minLon, deltaLat, deltaLon); Globe initialGlobe = PowerMockito.mock(Globe.class); PowerMockito.when(initialGlobe.getEquatorialRadius()).thenReturn(notionalGlobeRadius); String initialNotionalServiceAddress = "notionalServiceAddress"; String initialNotionalLayerList = "notionalLayerList"; WmsLayerConfig initialWmsLayerConfig = new WmsLayerConfig(initialNotionalServiceAddress, initialNotionalLayerList); double metersPerPixel = 0.5; WmsLayer wmsLayer = new WmsLayer(initialSector, initialGlobe, metersPerPixel, initialWmsLayerConfig); double alternativeLatMin = -45.0; double alternativeLonMin = 50.0; double alternativeDeltaLat = 5.0; double alternativeDeltaLon = 2.0; Sector alternativeSector = new Sector(alternativeLatMin, alternativeLonMin, alternativeDeltaLat, alternativeDeltaLon); wmsLayer.setConfiguration(alternativeSector, initialGlobe, metersPerPixel, initialWmsLayerConfig); Sector sector = ((TiledSurfaceImage) wmsLayer.getRenderable(0)).getLevelSet().sector; assertEquals("sector updated", alternativeSector, sector); }