Exemplo n.º 1
0
    public Airspace createAirspace(WorldWindow wwd, boolean fitShapeToViewport) {
      Polygon poly = new Polygon();
      poly.setAttributes(getDefaultAttributes());
      poly.setValue(AVKey.DISPLAY_NAME, getNextName(toString()));
      poly.setAltitudes(0.0, 0.0);
      poly.setTerrainConforming(true, false);
      this.initializePolygon(wwd, poly, fitShapeToViewport);

      return poly;
    }
Exemplo n.º 2
0
    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);
    }