예제 #1
0
    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;
    }
예제 #2
0
 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());
 }
예제 #3
0
  protected void assembleVertexControlPoints(DrawContext dc) {
    Terrain terrain = dc.getTerrain();
    ExtrudedPolygon polygon = this.getPolygon();

    Position refPos = polygon.getReferencePosition();
    Vec4 refPoint = terrain.getSurfacePoint(refPos.getLatitude(), refPos.getLongitude(), 0);

    int altitudeMode = polygon.getAltitudeMode();
    double height = polygon.getHeight();

    Vec4 vaa = null;
    double vaaLength = 0; // used to compute independent length of each cap vertex
    double vaLength = 0;

    int i = 0;
    for (LatLon location : polygon.getOuterBoundary()) {
      Vec4 vert;

      // Compute the top/cap point.
      if (altitudeMode == WorldWind.CONSTANT || !(location instanceof Position)) {
        if (vaa == null) {
          // Compute the vector lengths of the top and bottom points at the reference position.
          vaa = refPoint.multiply3(height / refPoint.getLength3());
          vaaLength = vaa.getLength3();
          vaLength = refPoint.getLength3();
        }

        // Compute the bottom point, which is on the terrain.
        vert = terrain.getSurfacePoint(location.getLatitude(), location.getLongitude(), 0);

        double delta = vaLength - vert.dot3(refPoint) / vaLength;
        vert = vert.add3(vaa.multiply3(1d + delta / vaaLength));
      } else if (altitudeMode == WorldWind.RELATIVE_TO_GROUND) {
        vert =
            terrain.getSurfacePoint(
                location.getLatitude(),
                location.getLongitude(),
                ((Position) location).getAltitude());
      } else // WorldWind.ABSOLUTE
      {
        vert =
            terrain
                .getGlobe()
                .computePointFromPosition(
                    location.getLatitude(),
                    location.getLongitude(),
                    ((Position) location).getAltitude() * terrain.getVerticalExaggeration());
      }

      Position vertexPosition = this.wwd.getModel().getGlobe().computePositionFromPoint(vert);

      this.controlPoints.add(
          new ControlPointMarker(
              MOVE_VERTEX_ACTION, vertexPosition, vert, this.vertexControlAttributes, i));
      i++;
    }
  }
    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());
    }
예제 #5
0
  protected void movePolygon(Point previousMousePoint, Point mousePoint) {
    // Intersect a ray through each mouse point, with a geoid passing through the reference
    // elevation.
    // If either ray fails to intersect the geoid, then ignore this event. Use the difference
    // between the two
    // intersected positions to move the control point's location.

    View view = this.wwd.getView();
    Globe globe = this.wwd.getModel().getGlobe();

    Position refPos = this.polygon.getReferencePosition();
    if (refPos == null) return;

    Line ray = view.computeRayFromScreenPoint(mousePoint.getX(), mousePoint.getY());
    Line previousRay =
        view.computeRayFromScreenPoint(previousMousePoint.getX(), previousMousePoint.getY());

    Vec4 vec = AirspaceEditorUtil.intersectGlobeAt(this.wwd, refPos.getElevation(), ray);
    Vec4 previousVec =
        AirspaceEditorUtil.intersectGlobeAt(this.wwd, refPos.getElevation(), previousRay);

    if (vec == null || previousVec == null) {
      return;
    }

    Position pos = globe.computePositionFromPoint(vec);
    Position previousPos = globe.computePositionFromPoint(previousVec);
    LatLon change = pos.subtract(previousPos);

    this.polygon.move(new Position(change.getLatitude(), change.getLongitude(), 0.0));
  }
예제 #6
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);
    }