コード例 #1
0
    protected void initializeSphere(
        WorldWindow wwd, SphereAirspace sphere, boolean fitShapeToViewport) {
      // Creates a sphere in the center of the viewport. Attempts to guess at a reasonable size and
      // height.
      Position position = ShapeUtils.getNewShapePosition(wwd);
      double sizeInMeters =
          fitShapeToViewport ? ShapeUtils.getViewportScaleFactor(wwd) : DEFAULT_SHAPE_SIZE_METERS;

      sphere.setLocation(new LatLon(position));
      sphere.setRadius(sizeInMeters / 2.0);
    }
コード例 #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);
    }