public void onSuccess(Position[] positions) {
   for (Position p : positions) {
     Logging.logger()
         .info(
             p.getLatitude().degrees
                 + ","
                 + p.getLongitude().degrees
                 + " --> "
                 + p.getElevation());
   }
 }
  protected void doMoveAirspaceLaterally(
      WorldWindow wwd, Airspace airspace, Point mousePoint, Point previousMousePoint) {
    // Intersect a ray throuh each mouse point, with a geoid passing through the reference
    // elevation. Since
    // most airspace control points follow a fixed altitude, this will track close to the intended
    // mouse position.
    // 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.

    if (!(airspace instanceof Movable)) {
      return;
    }

    Movable movable = (Movable) airspace;
    View view = wwd.getView();
    Globe globe = wwd.getModel().getGlobe();

    Position refPos = movable.getReferencePosition();
    if (refPos == null) return;

    // Convert the reference position into a cartesian point. This assumes that the reference
    // elevation is defined
    // by the airspace's lower altitude.
    Vec4 refPoint = null;
    if (airspace.isTerrainConforming()[LOWER_ALTITUDE])
      refPoint = wwd.getSceneController().getTerrain().getSurfacePoint(refPos);
    if (refPoint == null) refPoint = globe.computePointFromPosition(refPos);

    // Convert back to a position.
    refPos = globe.computePositionFromPoint(refPoint);

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

    Vec4 vec = AirspaceEditorUtil.intersectGlobeAt(wwd, refPos.getElevation(), ray);
    Vec4 previousVec = AirspaceEditorUtil.intersectGlobeAt(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);

    movable.move(new Position(change.getLatitude(), change.getLongitude(), 0.0));

    this.fireAirspaceMoved(new AirspaceEditEvent(wwd, airspace, this));
  }
示例#3
0
    private Info[] buildFreeShapes() {
      double elevation = 10e3;
      ArrayList<Position> positions = new ArrayList<Position>();
      positions.add(
          new Position(Angle.fromDegrees(37.8484), Angle.fromDegrees(-119.9754), elevation));
      positions.add(
          new Position(Angle.fromDegrees(39.3540), Angle.fromDegrees(-110.1526), elevation));
      positions.add(
          new Position(Angle.fromDegrees(38.3540), Angle.fromDegrees(-100.1526), elevation));

      ArrayList<Position> positions2 = new ArrayList<Position>();
      positions2.add(new Position(Angle.fromDegrees(0), Angle.fromDegrees(-150), elevation));
      positions2.add(new Position(Angle.fromDegrees(25), Angle.fromDegrees(-75), elevation));
      positions2.add(new Position(Angle.fromDegrees(50), Angle.fromDegrees(0), elevation));

      ArrayList<Position> positions3 = new ArrayList<Position>();
      for (double lat = 42, lon = -100; lat <= 45; lat += .1, lon += .1) {
        positions3.add(new Position(Angle.fromDegrees(lat), Angle.fromDegrees(lon), elevation));
      }

      ArrayList<Position> positions4 = new ArrayList<Position>();
      positions4.add(new Position(Angle.fromDegrees(90), Angle.fromDegrees(-110), elevation));
      positions4.add(new Position(Angle.fromDegrees(-90), Angle.fromDegrees(-110), elevation));

      ArrayList<Position> positions5 = new ArrayList<Position>();
      for (int i = 0; i < 100; i++) {
        positions5.add(
            Position.fromDegrees(38.0 + i * 0.0001, 30.0 + i * 0.0001, 1000.0 + i * 5.0));
      }

      @SuppressWarnings({"UnnecessaryLocalVariable"})
      Info[] infos =
          new Info[] {
            new Info("Short Path", new Polyline(positions)),
            new Info("Long Path", new Polyline(positions2)),
            new Info("Incremental Path", new Polyline(positions3)),
            new Info("Vertical Path", new Polyline(positions4)),
            new Info("Small-segment Path", new Polyline(positions5)),
            new Info("Quad", new Quadrilateral(Sector.fromDegrees(38, 40, -104, -105), elevation)),
            new Info("None", null)
          };

      return infos;
    }
  protected void doMoveAirspaceVertically(
      WorldWindow wwd, Airspace airspace, Point mousePoint, Point previousMousePoint) {
    // Find the closest points between the rays through each screen point, and the ray from the
    // control point
    // and in the direction of the globe's surface normal. Compute the elevation difference between
    // these two
    // points, and use that as the change in airspace altitude.
    //
    // If the state keepControlPointsAboveTerrain is set, we prevent the control point from passing
    // any lower than
    // the terrain elevation beneath it.

    if (!(airspace instanceof Movable)) {
      return;
    }

    Movable movable = (Movable) airspace;
    Position referencePos = movable.getReferencePosition();
    if (referencePos == null) return;

    Vec4 referencePoint = wwd.getModel().getGlobe().computePointFromPosition(referencePos);

    Vec4 surfaceNormal =
        wwd.getModel()
            .getGlobe()
            .computeSurfaceNormalAtLocation(
                referencePos.getLatitude(), referencePos.getLongitude());
    Line verticalRay = new Line(referencePoint, surfaceNormal);
    Line screenRay =
        wwd.getView()
            .computeRayFromScreenPoint(previousMousePoint.getX(), previousMousePoint.getY());
    Line previousScreenRay =
        wwd.getView().computeRayFromScreenPoint(mousePoint.getX(), mousePoint.getY());

    Vec4 pointOnLine = AirspaceEditorUtil.nearestPointOnLine(verticalRay, screenRay);
    Vec4 previousPointOnLine =
        AirspaceEditorUtil.nearestPointOnLine(verticalRay, previousScreenRay);

    Position pos = wwd.getModel().getGlobe().computePositionFromPoint(pointOnLine);
    Position previousPos = wwd.getModel().getGlobe().computePositionFromPoint(previousPointOnLine);
    double elevationChange = previousPos.getElevation() - pos.getElevation();

    double[] altitudes = this.getAirspace().getAltitudes();
    boolean[] terrainConformance = this.getAirspace().isTerrainConforming();

    if (this.isKeepControlPointsAboveTerrain()) {
      if (terrainConformance[LOWER_ALTITUDE]) {
        if (altitudes[LOWER_ALTITUDE] + elevationChange < 0.0)
          elevationChange = 0.0 - altitudes[LOWER_ALTITUDE];
      } else {
        double height =
            AirspaceEditorUtil.computeLowestHeightAboveSurface(
                wwd, this.getCurrentControlPoints(), LOWER_ALTITUDE);
        if (elevationChange <= -height) {
          elevationChange = -height;
        }
      }
    }

    altitudes[LOWER_ALTITUDE] += elevationChange;
    altitudes[UPPER_ALTITUDE] += elevationChange;
    this.getAirspace().setAltitudes(altitudes[LOWER_ALTITUDE], altitudes[UPPER_ALTITUDE]);

    this.fireAirspaceMoved(new AirspaceEditEvent(wwd, airspace, this));
  }
示例#5
0
    public AppFrame() {
      super(true, true, false);

      // Add detail hint slider panel
      this.getLayerPanel().add(makeDetailHintControlPanel(), BorderLayout.SOUTH);

      RenderableLayer layer = new RenderableLayer();

      // Create and set an attribute bundle.
      ShapeAttributes attrs = new BasicShapeAttributes();
      attrs.setInteriorMaterial(Material.YELLOW);
      attrs.setInteriorOpacity(0.7);
      attrs.setEnableLighting(true);
      attrs.setOutlineMaterial(Material.RED);
      attrs.setOutlineWidth(2d);
      attrs.setDrawInterior(true);
      attrs.setDrawOutline(false);

      // Create and set an attribute bundle.
      ShapeAttributes attrs2 = new BasicShapeAttributes();
      attrs2.setInteriorMaterial(Material.PINK);
      attrs2.setInteriorOpacity(1);
      attrs2.setEnableLighting(true);
      attrs2.setOutlineMaterial(Material.WHITE);
      attrs2.setOutlineWidth(2d);
      attrs2.setDrawOutline(false);

      // ********* sample  Wedges  *******************

      // Wedge with equal axes, ABSOLUTE altitude mode
      Wedge wedge3 =
          new Wedge(Position.fromDegrees(40, -120, 80000), Angle.POS90, 50000, 50000, 50000);
      wedge3.setAltitudeMode(WorldWind.ABSOLUTE);
      wedge3.setAttributes(attrs);
      wedge3.setVisible(true);
      wedge3.setValue(AVKey.DISPLAY_NAME, "Wedge with equal axes, ABSOLUTE altitude mode");
      layer.addRenderable(wedge3);

      // Wedge with equal axes, RELATIVE_TO_GROUND
      Wedge wedge4 =
          new Wedge(Position.fromDegrees(37.5, -115, 50000), Angle.POS90, 50000, 50000, 50000);
      wedge4.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge4.setAttributes(attrs);
      wedge4.setVisible(true);
      wedge4.setValue(
          AVKey.DISPLAY_NAME, "Wedge with equal axes, RELATIVE_TO_GROUND altitude mode");
      layer.addRenderable(wedge4);

      // Wedge with equal axes, CLAMP_TO_GROUND
      Wedge wedge5 =
          new Wedge(Position.fromDegrees(35, -110, 50000), Angle.POS90, 50000, 50000, 50000);
      wedge5.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
      wedge5.setAttributes(attrs);
      wedge5.setVisible(true);
      wedge5.setValue(AVKey.DISPLAY_NAME, "Wedge with equal axes, CLAMP_TO_GROUND altitude mode");
      layer.addRenderable(wedge5);

      // Wedge with a texture, using Wedge(position, angle, height, radius) constructor
      Wedge wedge9 =
          new Wedge(Position.fromDegrees(0, -90, 600000), Angle.fromDegrees(225), 1200000, 600000);
      wedge9.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge9.setImageSources("gov/nasa/worldwindx/examples/images/500px-Checkerboard_pattern.png");
      wedge9.setAttributes(attrs);
      wedge9.setVisible(true);
      wedge9.setValue(AVKey.DISPLAY_NAME, "Wedge with a texture");
      layer.addRenderable(wedge9);

      // Scaled Wedge with default orientation
      Wedge wedge = new Wedge(Position.ZERO, Angle.fromDegrees(125), 500000, 500000, 500000);
      wedge.setAltitudeMode(WorldWind.ABSOLUTE);
      wedge.setAttributes(attrs);
      wedge.setVisible(true);
      wedge.setValue(AVKey.DISPLAY_NAME, "Scaled Wedge with default orientation");
      layer.addRenderable(wedge);

      // Scaled Wedge with a pre-set orientation
      Wedge wedge2 =
          new Wedge(
              Position.fromDegrees(0, 30, 750000),
              Angle.POS90,
              500000,
              500000,
              500000,
              Angle.fromDegrees(90),
              Angle.fromDegrees(45),
              Angle.fromDegrees(30));
      wedge2.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge2.setAttributes(attrs2);
      wedge2.setVisible(true);
      wedge2.setValue(AVKey.DISPLAY_NAME, "Scaled Wedge with a pre-set orientation");
      layer.addRenderable(wedge2);

      // Scaled Wedge with a pre-set orientation
      Wedge wedge6 =
          new Wedge(
              Position.fromDegrees(30, 30, 750000),
              Angle.POS90,
              500000,
              500000,
              500000,
              Angle.fromDegrees(90),
              Angle.fromDegrees(45),
              Angle.fromDegrees(30));
      wedge6.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge6.setImageSources("gov/nasa/worldwindx/examples/images/500px-Checkerboard_pattern.png");
      wedge6.setAttributes(attrs2);
      wedge6.setVisible(true);
      wedge6.setValue(AVKey.DISPLAY_NAME, "Scaled Wedge with a pre-set orientation");
      layer.addRenderable(wedge6);

      // Scaled Wedge with a pre-set orientation
      Wedge wedge7 =
          new Wedge(
              Position.fromDegrees(60, 30, 750000),
              Angle.POS90,
              500000,
              500000,
              500000,
              Angle.fromDegrees(90),
              Angle.fromDegrees(45),
              Angle.fromDegrees(30));
      wedge7.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge7.setAttributes(attrs2);
      wedge7.setVisible(true);
      wedge7.setValue(AVKey.DISPLAY_NAME, "Scaled Wedge with a pre-set orientation");
      layer.addRenderable(wedge7);

      // Scaled, oriented Wedge in 3rd "quadrant" (-X, -Y, -Z)
      Wedge wedge8 =
          new Wedge(
              Position.fromDegrees(-45, -180, 750000),
              Angle.POS90,
              500000,
              1000000,
              500000,
              Angle.fromDegrees(90),
              Angle.fromDegrees(45),
              Angle.fromDegrees(30));
      wedge8.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge8.setAttributes(attrs2);
      wedge8.setVisible(true);
      wedge8.setValue(
          AVKey.DISPLAY_NAME, "Scaled, oriented Wedge with in the 3rd 'quadrant' (-X, -Y, -Z)");
      layer.addRenderable(wedge8);

      // Add the layer to the model.
      insertBeforeCompass(getWwd(), layer);

      // Update layer panel
      this.getLayerPanel().update(this.getWwd());
    }