private Info[] buildSurfaceShapes() { LatLon position = new LatLon(Angle.fromDegrees(38), Angle.fromDegrees(-105)); ArrayList<LatLon> surfaceLinePositions = new ArrayList<LatLon>(); // surfaceLinePositions.add(LatLon.fromDegrees(37.8484, -119.9754)); // surfaceLinePositions.add(LatLon.fromDegrees(38.3540, -119.1526)); // surfaceLinePositions.add(new LatLon(Angle.fromDegrees(0), // Angle.fromDegrees(-150))); // surfaceLinePositions.add(new LatLon(Angle.fromDegrees(60), // Angle.fromDegrees(0))); surfaceLinePositions.add(position); surfaceLinePositions.add(LatLon.fromDegrees(39, -104)); surfaceLinePositions.add(LatLon.fromDegrees(39, -105)); surfaceLinePositions.add(position); return new Info[] { new Info("Circle", new SurfaceCircle(position, 100e3)), new Info("Ellipse", new SurfaceEllipse(position, 100e3, 90e3, Angle.ZERO)), new Info("Square", new SurfaceSquare(position, 100e3)), new Info("Quad", new SurfaceQuad(position, 100e3, 60e3, Angle.ZERO)), new Info("Sector", new SurfaceSector(Sector.fromDegrees(38, 40, -105, -103))), new Info("Polygon", new SurfacePolygon(surfaceLinePositions)), }; }
protected Vec4 getPoint(LatLon latlon, double elevation) { SceneController sc = this.getApp().getWwd().getSceneController(); Globe globe = this.getApp().getWwd().getModel().getGlobe(); double e = globe.getElevation(latlon.getLatitude(), latlon.getLongitude()); return globe.computePointFromPosition( latlon.getLatitude(), latlon.getLongitude(), (e + elevation) * sc.getVerticalExaggeration()); }
public void doActionOnButton3() { // Sector sector = Sector.fromDegrees( 44d, 46d, -123.3d, -123.2d ); ArrayList<LatLon> latlons = new ArrayList<LatLon>(); latlons.add(LatLon.fromDegrees(45.50d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.51d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.52d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.53d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.54d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.55d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.56d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.57d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.58d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.59d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.60d, -123.3d)); ElevationModel model = this.wwd.getModel().getGlobe().getElevationModel(); StringBuffer sb = new StringBuffer(); for (LatLon ll : latlons) { double e = model.getElevation(ll.getLatitude(), ll.getLongitude()); sb.append("\n").append(e); } Logging.logger().info(sb.toString()); }
protected Vec4 getSurfacePoint(LatLon latlon, double elevation) { Vec4 point = null; SceneController sc = this.getApp().getWwd().getSceneController(); Globe globe = this.getApp().getWwd().getModel().getGlobe(); if (sc.getTerrain() != null) { point = sc.getTerrain() .getSurfacePoint( latlon.getLatitude(), latlon.getLongitude(), elevation * sc.getVerticalExaggeration()); } if (point == null) { double e = globe.getElevation(latlon.getLatitude(), latlon.getLongitude()); point = globe.computePointFromPosition( latlon.getLatitude(), latlon.getLongitude(), (e + elevation) * sc.getVerticalExaggeration()); } return point; }
protected void initializePolygon(WorldWindow wwd, Polygon polygon, boolean fitShapeToViewport) { // Creates a rectangle in the center of the viewport. Attempts to guess at a reasonable size // and height. Position position = ShapeUtils.getNewShapePosition(wwd); Angle heading = ShapeUtils.getNewShapeHeading(wwd, true); double sizeInMeters = fitShapeToViewport ? ShapeUtils.getViewportScaleFactor(wwd) : DEFAULT_SHAPE_SIZE_METERS; java.util.List<LatLon> locations = ShapeUtils.createSquareInViewport(wwd, position, heading, sizeInMeters); double maxElevation = -Double.MAX_VALUE; Globe globe = wwd.getModel().getGlobe(); for (LatLon ll : locations) { double e = globe.getElevation(ll.getLatitude(), ll.getLongitude()); if (e > maxElevation) maxElevation = e; } polygon.setAltitudes(0.0, maxElevation + sizeInMeters); polygon.setTerrainConforming(true, false); polygon.setLocations(locations); }
public void doActionOnButton1() { Logging.logger().info("Zooming to Matterhorn"); View view = this.wwd.getView(); Position matterhorn = new Position(LatLon.fromDegrees(45.9763888888889d, 7.65833333333333d), 0d); // Position eyePos = new Position( LatLon.fromDegrees( 46.01066860997058d, // 7.633097536001656d ), 3363d ); // // view.setEyePosition( eyePos ); // view.setHeading( Angle.fromDegrees( 156d )); // view.setPitch( Angle.fromDegrees( 89.9d )); view.goTo(matterhorn, 5000d); }
public void actionPerformed(ActionEvent e) { if (!this.isEnabled()) { return; } if (NEW_AIRSPACE.equals(e.getActionCommand())) { this.createNewEntry(this.getView().getSelectedFactory()); } else if (CLEAR_SELECTION.equals(e.getActionCommand())) { this.selectEntry(null, true); } else if (SIZE_NEW_SHAPES_TO_VIEWPORT.equals(e.getActionCommand())) { if (e.getSource() instanceof AbstractButton) { boolean selected = ((AbstractButton) e.getSource()).isSelected(); this.setResizeNewShapesToViewport(selected); } } else if (ENABLE_EDIT.equals(e.getActionCommand())) { if (e.getSource() instanceof AbstractButton) { boolean selected = ((AbstractButton) e.getSource()).isSelected(); this.setEnableEdit(selected); } } else if (OPEN.equals(e.getActionCommand())) { this.openFromFile(); } else if (OPEN_URL.equals(e.getActionCommand())) { this.openFromURL(); } else if (OPEN_DEMO_AIRSPACES.equals(e.getActionCommand())) { this.openFromPath(DEMO_AIRSPACES_PATH); this.zoomTo( LatLon.fromDegrees(47.6584074779224, -122.3059199579634), Angle.fromDegrees(-152), Angle.fromDegrees(75), 750); } else if (REMOVE_SELECTED.equals(e.getActionCommand())) { this.removeEntries(Arrays.asList(this.getSelectedEntries())); } else if (SAVE.equals(e.getActionCommand())) { this.saveToFile(); } else if (SELECTION_CHANGED.equals(e.getActionCommand())) { this.viewSelectionChanged(); } }
public void doActionOnButton2() { ArrayList<LatLon> latlons = new ArrayList<LatLon>(); latlons.add(LatLon.fromDegrees(45.50d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.51d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.52d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.53d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.54d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.55d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.56d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.57d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.58d, -123.3d)); // latlons.add( LatLon.fromDegrees( 45.59d, -123.3d ) ); latlons.add(LatLon.fromDegrees(45.60d, -123.3d)); Sector sector = Sector.fromDegrees(44d, 46d, -123d, -121d); // Sector sector = Sector.boundingSector( latlons ); double[] elevations = new double[latlons.size()]; // request resolution of DTED2 (1degree / 3600 ) double targetResolution = Angle.fromDegrees(1d).radians / 3600; double resolutionAchieved = this.wwd .getModel() .getGlobe() .getElevationModel() .getElevations(sector, latlons, targetResolution, elevations); StringBuffer sb = new StringBuffer(); for (double e : elevations) { sb.append("\n").append(e); } sb.append("\nresolutionAchieved = ").append(resolutionAchieved); sb.append(", requested resolution = ").append(targetResolution); Logging.logger().info(sb.toString()); }
public void doActionOnButton4() { ArrayList<LatLon> locations = new ArrayList<LatLon>(); locations.add(LatLon.fromDegrees(45.50d, -123.3d)); locations.add(LatLon.fromDegrees(45.52d, -123.3d)); locations.add(LatLon.fromDegrees(45.54d, -123.3d)); locations.add(LatLon.fromDegrees(45.56d, -123.3d)); locations.add(LatLon.fromDegrees(45.58d, -123.3d)); locations.add(LatLon.fromDegrees(45.60d, -123.3d)); locations.add(LatLon.fromDegrees(40.50d, -120.1d)); locations.add(LatLon.fromDegrees(40.52d, -120.2d)); locations.add(LatLon.fromDegrees(40.54d, -120.3d)); locations.add(LatLon.fromDegrees(40.56d, -120.4d)); locations.add(LatLon.fromDegrees(40.58d, -120.5d)); locations.add(LatLon.fromDegrees(40.60d, -120.6d)); // Now, let's find WMSBasicElevationModel WMSBasicElevationModel wmsbem = null; ElevationModel model = this.wwd.getModel().getGlobe().getElevationModel(); if (model instanceof CompoundElevationModel) { CompoundElevationModel cbem = (CompoundElevationModel) model; for (ElevationModel em : cbem.getElevationModels()) { // you can have additional checks if you know specific model name, etc. if (em instanceof WMSBasicElevationModel) { wmsbem = (WMSBasicElevationModel) em; break; } } } else if (model instanceof WMSBasicElevationModel) { wmsbem = (WMSBasicElevationModel) model; } if (null != wmsbem) { ElevationsRetriever retriever = new ElevationsRetriever(wmsbem, locations, 10000, 30000, new NotifyWhenReady()); retriever.start(); } else { String message = Logging.getMessage( "ElevationModel.ExceptionRequestingElevations", "No instance of WMSBasicElevationModel was found"); Logging.logger().severe(message); } }
protected Angle computeHeading(Position pa, Position pb) { return LatLon.greatCircleAzimuth(pa, pb); }