gov.nasa.worldwind.WorldWind Java Examples
The following examples show how to use
gov.nasa.worldwind.WorldWind.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WWJPanel.java From openvisualtraceroute with GNU Lesser General Public License v3.0 | 6 votes |
private Path createPath(final Color color) { final ShapeAttributes attrs = new BasicShapeAttributes(); attrs.setEnableLighting(true); attrs.setOutlineMaterial(new Material(color)); attrs.setInteriorMaterial(new Material(new Color(color.getRed(), color.getGreen(), color.getBlue(), 50), 50)); attrs.setInteriorOpacity(0.3); attrs.setOutlineWidth(_mapLineThickness); attrs.setOutlineOpacity(0.7); final Path path = new Path(); path.setExtrude(true); path.setAttributes(attrs); path.setVisible(true); path.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND); path.setPathType(AVKey.GREAT_CIRCLE); path.setFollowTerrain(true); return path; }
Example #2
Source File: WmsHandler.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
private Object createComponent(WMSCapabilities caps, AVList params) { AVList configParams = params.copy(); // Copy to insulate changes from the caller. // Some wms servers are slow, so increase the timeouts and limits used by world wind's retrievers. configParams.setValue(AVKey.URL_CONNECT_TIMEOUT, 30000); configParams.setValue(AVKey.URL_READ_TIMEOUT, 30000); configParams.setValue(AVKey.RETRIEVAL_QUEUE_STALE_REQUEST_LIMIT, 60000); try { String factoryKey = getFactoryKeyForCapabilities(caps); Factory factory = (Factory) WorldWind.createConfigurationComponent(factoryKey); return factory.createFromConfigSource(caps, configParams); } catch (Exception e) { // Ignore the exception, and just return null. } return null; }
Example #3
Source File: FeatureCollectionPointsLayer.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
private void addPoint( SimpleFeature pointFeature ) { Geometry geometry = (Geometry) pointFeature.getDefaultGeometry(); if (geometry == null) { return; } int numGeometries = geometry.getNumGeometries(); for( int i = 0; i < numGeometries; i++ ) { Geometry geometryN = geometry.getGeometryN(i); if (geometryN instanceof Point) { Point point = (Point) geometryN; FeaturePoint marker = new FeaturePoint(Position.fromDegrees(point.getY(), point.getX(), 0), featureStoreInfo); marker.setFeature(pointFeature); marker.setAltitudeMode(WorldWind.CLAMP_TO_GROUND); marker.setAttributes(basicMarkerAttributes); addRenderable(marker); } } }
Example #4
Source File: BasicMercatorTiledImageLayer.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
public BasicMercatorTiledImageLayer( LevelSet levelSet ) { super(levelSet); if (!WorldWind.getMemoryCacheSet().containsCache(MercatorTextureTile.class.getName())) { long size = Configuration.getLongValue(AVKey.TEXTURE_IMAGE_CACHE_SIZE, 3000000L); MemoryCache cache = new BasicMemoryCache((long) (0.85 * size), size); cache.setName("Texture Tiles"); WorldWind.getMemoryCacheSet().addCache(MercatorTextureTile.class.getName(), cache); } }
Example #5
Source File: WorldMap3DPanel.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
public WorldMap3DPanel(boolean flatEarth, boolean removeExtraLayers, PolygonsLayerModel polygonsLayerModel) { super(null, Configuration.getRequiredGLCapabilities(), new BasicGLCapabilitiesChooser()); // create the default model as described in the current world wind properties Model model = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME); setModel(model); if (flatEarth) { setFlatEarth(); } else { setGlobeEarth(); } this.selector = new Rectangle3DSelection(this.wwd) { @Override protected void setCursor(Cursor cursor) { WorldMap3DPanel.this.setCursor((cursor == null) ? WorldMapPanelWrapper.DEFAULT_CURSOR : cursor); } }; this.selector.setInteriorColor(WorldMapPanelWrapper.SELECTION_FILL_COLOR); this.selector.setBorderColor(WorldMapPanelWrapper.SELECTION_BORDER_COLOR); this.selector.setBorderWidth(WorldMapPanelWrapper.SELECTION_LINE_WIDTH); this.selector.getLayer().setEnabled(true); LayerList layerList = this.wwd.getModel().getLayers(); if (removeExtraLayers) { for (Layer layer : layerList) { if (layer instanceof CompassLayer || layer instanceof WorldMapLayer || layer instanceof StarsLayer || layer instanceof LandsatI3WMSLayer || layer instanceof SkyGradientLayer) { layerList.remove(layer); } } } layerList.add(this.selector.getLayer()); layerList.add(new Polygons3DLayer(polygonsLayerModel)); }
Example #6
Source File: AppPanel.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
public AppPanel(final WorldWindowGLCanvas shareWith, final boolean includeStatusBar, final boolean flatWorld, final boolean removeExtraLayers) { super(new BorderLayout()); this.wwd = new WorldWindowGLCanvas(shareWith); // Create the default model as described in the current worldwind properties. final Model m = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME); this.wwd.setModel(m); if (flatWorld) { m.setGlobe(new EarthFlat()); this.wwd.setView(new FlatOrbitView()); } else { m.setGlobe(new Earth()); this.wwd.setView(new BasicOrbitView()); } if (removeExtraLayers) { final LayerList layerList = m.getLayers(); for (Layer layer : layerList) { if (layer instanceof CompassLayer || layer instanceof WorldMapLayer || layer instanceof StarsLayer || layer instanceof LandsatI3WMSLayer || layer instanceof SkyGradientLayer) layerList.remove(layer); } } // Setup a select listener for the worldmap click-and-go feature this.wwd.addSelectListener(new ClickAndGoSelectListener(wwd, WorldMapLayer.class)); this.wwd.getSceneController().setClutterFilter(new PlacemarkClutterFilter()); this.add(this.wwd, BorderLayout.CENTER); if (includeStatusBar) { this.statusBar = new MinimalStatusBar(); this.add(statusBar, BorderLayout.PAGE_END); this.statusBar.setEventSource(wwd); } }
Example #7
Source File: BasicMercatorTiledImageLayer.java From hortonmachine with GNU General Public License v3.0 | 4 votes |
private void addTileToCache( MercatorTextureTile tile ) { WorldWind.getMemoryCache(MercatorTextureTile.class.getName()).add(tile.getTileKey(), tile); }
Example #8
Source File: BasicMercatorTiledImageLayer.java From hortonmachine with GNU General Public License v3.0 | 4 votes |
protected void downloadTexture( final MercatorTextureTile tile ) { if (!WorldWind.getRetrievalService().isAvailable()) return; java.net.URL url; try { url = tile.getResourceURL(); if (url == null) return; if (WorldWind.getNetworkStatus().isHostUnavailable(url)) return; } catch (java.net.MalformedURLException e) { Logging.logger().log(java.util.logging.Level.SEVERE, Logging.getMessage("layers.TextureLayer.ExceptionCreatingTextureUrl", tile), e); return; } Retriever retriever; if (url.getProtocol().toLowerCase().startsWith("http")) { retriever = new HTTPRetriever(url, new DownloadPostProcessor(tile, this)); retriever.setValue(URLRetriever.EXTRACT_ZIP_ENTRY, "true"); // supports legacy layers } else if ("file".equalsIgnoreCase(url.getProtocol())) { retriever = new FileRetriever(url, new DownloadPostProcessor(tile, this)); retriever.setValue(URLRetriever.EXTRACT_ZIP_ENTRY, "true"); // supports legacy layers } else { Logging.logger().severe(Logging.getMessage("layers.TextureLayer.UnknownRetrievalProtocol", url.toString())); return; } // Apply any overridden timeouts. Integer cto = AVListImpl.getIntegerValue(this, AVKey.URL_CONNECT_TIMEOUT); if (cto != null && cto > 0) retriever.setConnectTimeout(cto); Integer cro = AVListImpl.getIntegerValue(this, AVKey.URL_READ_TIMEOUT); if (cro != null && cro > 0) retriever.setReadTimeout(cro); Integer srl = AVListImpl.getIntegerValue(this, AVKey.RETRIEVAL_QUEUE_STALE_REQUEST_LIMIT); if (srl != null && srl > 0) retriever.setStaleRequestLimit(srl); WorldWind.getRetrievalService().runRetriever(retriever, tile.getPriority()); }
Example #9
Source File: NwwPanel.java From hortonmachine with GNU General Public License v3.0 | 4 votes |
protected NwwPanel( boolean useWwGlCanvas, boolean withStatusBar, boolean removeDefaultLayers ) { super(new BorderLayout()); // Configuration.setValue(AVKey.INITIAL_LATITUDE, gpsLogShps[0].y); // Configuration.setValue(AVKey.INITIAL_LONGITUDE, gpsLogShps[0].x); // Configuration.setValue(AVKey.INITIAL_ALTITUDE, 1000); // Configuration.setValue(AVKey.INITIAL_PITCH, 45); long t1 = System.currentTimeMillis(); if (useWwGlCanvas) { logger.insertDebug("NwwPanel", "Create GLCanvas"); wwd = new WorldWindowGLCanvas(); } else { logger.insertDebug("NwwPanel", "Create GLJPanel"); wwd = new WorldWindowGLJPanel(); } // ((Component) wwd).setPreferredSize(new Dimension(500, 500)); long t2 = System.currentTimeMillis(); logger.insertDebug("NwwPanel", "Create Canvas - DONE " + (t2 - t1) / 1000); logger.insertDebug("NwwPanel", "Create Model"); Model model = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME); wwd.setModel(model); long t3 = System.currentTimeMillis(); logger.insertDebug("NwwPanel", "Create Model - DONE " + (t3 - t2) / 1000); if (removeDefaultLayers) { logger.insertDebug("NwwPanel", "Remove and add layers"); LayerList layers = model.getLayers(); List<Layer> addBack = new ArrayList<>(); Iterator<Layer> layerIterator = layers.iterator(); List<String> namesToKeep = NwwUtilities.LAYERS_TO_KEEP_FROM_ORIGNALNWW; while( layerIterator.hasNext() ) { Layer layer = layerIterator.next(); if (namesToKeep.contains(layer.getName())) { addBack.add(layer); } } layers.clear(); layers.addAll(addBack); long t4 = System.currentTimeMillis(); logger.insertDebug("NwwPanel", "Remove and add layers - DONE " + (t4 - t3) / 1000); } this.add((Component) wwd, BorderLayout.CENTER); if (withStatusBar) { this.statusBar = new StatusBar(); this.add(statusBar, BorderLayout.PAGE_END); this.statusBar.setEventSource(getWwd()); } }
Example #10
Source File: DefaultProductLayer.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
private void addOutline(final Product product) { final int step = Math.max(16, (product.getSceneRasterWidth() + product.getSceneRasterHeight()) / 250); final GeneralPath[] boundaryPaths = ProductUtils.createGeoBoundaryPaths(product, null, step); final Polyline[] polyLineList = new Polyline[boundaryPaths.length]; int i = 0; int numPoints = 0; float centreLat = 0; float centreLon = 0; for (GeneralPath boundaryPath : boundaryPaths) { final PathIterator it = boundaryPath.getPathIterator(null); final float[] floats = new float[2]; final List<Position> positions = new ArrayList<>(4); it.currentSegment(floats); final Position firstPosition = new Position(Angle.fromDegreesLatitude(floats[1]), Angle.fromDegreesLongitude(floats[0]), 0.0); positions.add(firstPosition); centreLat += floats[1]; centreLon += floats[0]; it.next(); numPoints++; while (!it.isDone()) { it.currentSegment(floats); positions.add(new Position(Angle.fromDegreesLatitude(floats[1]), Angle.fromDegreesLongitude(floats[0]), 0.0)); centreLat += floats[1]; centreLon += floats[0]; it.next(); numPoints++; } // close the loop positions.add(firstPosition); centreLat = centreLat / numPoints; centreLon = centreLon / numPoints; polyLineList[i] = new Polyline(); polyLineList[i].setFollowTerrain(true); polyLineList[i].setPositions(positions); // ADDED //polyLineList[i].setColor(new Color(1f, 0f, 0f, 0.99f)); //polyLineList[i].setLineWidth(10); addRenderable(polyLineList[i]); ++i; } Position centrePos = new Position(Angle.fromDegreesLatitude(centreLat), Angle.fromDegreesLongitude(centreLon), 0.0); PointPlacemark ppm = getLabelPlacemark(centrePos, String.valueOf(product.getRefNo())); ppm.setAltitudeMode(WorldWind.CLAMP_TO_GROUND); ppm.setEnableDecluttering(true); addRenderable(ppm); outlineTable.put(getUniqueName(product), polyLineList); labelTable.put(getUniqueName(product), ppm); }
Example #11
Source File: DefaultProductLayer.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
private void addWaveProduct(final Product product) { final MetadataElement root = AbstractMetadata.getOriginalProductMetadata(product); final MetadataElement ggADS = root.getElement("GEOLOCATION_GRID_ADS"); if (ggADS == null) return; final MetadataElement[] geoElemList = ggADS.getElements(); final Polyline[] lineList = new Polyline[geoElemList.length]; int cnt = 0; int numPoints = 0; float centreLat = 0; float centreLon = 0; for (MetadataElement geoElem : geoElemList) { final double lat = geoElem.getAttributeDouble("center_lat", 0.0) / Constants.oneMillion; final double lon = geoElem.getAttributeDouble("center_long", 0.0) / Constants.oneMillion; final double heading = geoElem.getAttributeDouble("heading", 0.0); final GeoUtils.LatLonHeading r1 = GeoUtils.vincenty_direct(new GeoPos(lat, lon), 5000, heading); final GeoUtils.LatLonHeading corner1 = GeoUtils.vincenty_direct(new GeoPos(r1.lat, r1.lon), 2500, heading - 90.0); final GeoUtils.LatLonHeading corner2 = GeoUtils.vincenty_direct(new GeoPos(r1.lat, r1.lon), 2500, heading + 90.0); final GeoUtils.LatLonHeading r2 = GeoUtils.vincenty_direct(new GeoPos(lat, lon), 5000, heading + 180.0); final GeoUtils.LatLonHeading corner3 = GeoUtils.vincenty_direct(new GeoPos(r2.lat, r2.lon), 2500, heading - 90.0); final GeoUtils.LatLonHeading corner4 = GeoUtils.vincenty_direct(new GeoPos(r2.lat, r2.lon), 2500, heading + 90.0); final List<Position> positions = new ArrayList<>(4); positions.add(new Position(Angle.fromDegreesLatitude(corner1.lat), Angle.fromDegreesLongitude(corner1.lon), 0.0)); positions.add(new Position(Angle.fromDegreesLatitude(corner2.lat), Angle.fromDegreesLongitude(corner2.lon), 0.0)); positions.add(new Position(Angle.fromDegreesLatitude(corner4.lat), Angle.fromDegreesLongitude(corner4.lon), 0.0)); positions.add(new Position(Angle.fromDegreesLatitude(corner3.lat), Angle.fromDegreesLongitude(corner3.lon), 0.0)); positions.add(new Position(Angle.fromDegreesLatitude(corner1.lat), Angle.fromDegreesLongitude(corner1.lon), 0.0)); centreLat += corner1.lat; centreLon += corner1.lon; centreLat += corner2.lat; centreLon += corner2.lon; centreLat += corner3.lat; centreLon += corner3.lon; centreLat += corner4.lat; centreLon += corner4.lon; numPoints += 4; final Polyline line = new Polyline(); line.setFollowTerrain(true); line.setPositions(positions); addRenderable(line); lineList[cnt++] = line; } centreLat = centreLat / numPoints; centreLon = centreLon / numPoints; Position centrePos = new Position(Angle.fromDegreesLatitude(centreLat), Angle.fromDegreesLongitude(centreLon), 0.0); PointPlacemark ppm = getLabelPlacemark(centrePos, String.valueOf(product.getRefNo())); ppm.setAltitudeMode(WorldWind.CLAMP_TO_GROUND); ppm.setEnableDecluttering(true); addRenderable(ppm); outlineTable.put(getUniqueName(product), lineList); labelTable.put(getUniqueName(product), ppm); }