コード例 #1
0
  protected void dragWholeShape(DragSelectEvent dragEvent, Movable dragObject) {
    View view = getWwd().getView();
    EllipsoidalGlobe globe = (EllipsoidalGlobe) getWwd().getModel().getGlobe();

    // Compute ref-point position in screen coordinates.
    Position refPos = dragObject.getReferencePosition();
    if (refPos == null) return;

    Vec4 refPoint = globe.computePointFromPosition(refPos);
    Vec4 screenRefPoint = view.project(refPoint);

    // Compute screen-coord delta since last event.
    int dx = dragEvent.getPickPoint().x - dragEvent.getPreviousPickPoint().x;
    int dy = dragEvent.getPickPoint().y - dragEvent.getPreviousPickPoint().y;

    // Find intersection of screen coord ref-point with globe.
    double x = screenRefPoint.x + dx;
    double y =
        dragEvent.getMouseEvent().getComponent().getSize().height - screenRefPoint.y + dy - 1;
    Line ray = view.computeRayFromScreenPoint(x, y);
    Intersection inters[] = globe.intersect(ray, refPos.getElevation());

    if (inters != null) {
      // Intersection with globe. Move reference point to the intersection point.
      Position p = globe.computePositionFromPoint(inters[0].getIntersectionPoint());
      dragObject.moveTo(p);
    }
  }
コード例 #2
0
  /**
   * Setup the view to a first person mode (zoom = 0)
   *
   * @param view the orbit view to set into a first person view.
   */
  protected void setupFirstPersonView(OrbitView view) {
    if (view.getZoom() == 0) // already in first person mode
    return;

    Vec4 eyePoint = view.getEyePoint();
    // Center pos at eye pos
    Position centerPosition = wwd.getModel().getGlobe().computePositionFromPoint(eyePoint);
    // Compute pitch and heading relative to center position
    Vec4 normal =
        wwd.getModel()
            .getGlobe()
            .computeSurfaceNormalAtLocation(
                centerPosition.getLatitude(), centerPosition.getLongitude());
    Vec4 north =
        wwd.getModel()
            .getGlobe()
            .computeNorthPointingTangentAtLocation(
                centerPosition.getLatitude(), centerPosition.getLongitude());
    // Pitch
    view.setPitch(Angle.POS180.subtract(view.getForwardVector().angleBetween3(normal)));
    // Heading
    Vec4 perpendicular = view.getForwardVector().perpendicularTo3(normal);
    Angle heading = perpendicular.angleBetween3(north);
    double direction = Math.signum(-normal.cross3(north).dot3(perpendicular));
    view.setHeading(heading.multiply(direction));
    // Zoom
    view.setZoom(0);
    // Center pos
    view.setCenterPosition(centerPosition);
  }
コード例 #3
0
  protected int determineAdjustmentSide(Movable dragObject, double factor) {
    if (dragObject instanceof SurfaceSector) {
      SurfaceSector quad = (SurfaceSector) dragObject;
      Sector s = quad.getSector(); // TODO: go over all sectors
      Position p = this.getWwd().getCurrentPosition();

      if (p == null) {
        return NONE;
      }

      double dN = abs(s.getMaxLatitude().subtract(p.getLatitude()).degrees);
      double dS = abs(s.getMinLatitude().subtract(p.getLatitude()).degrees);
      double dW = abs(s.getMinLongitude().subtract(p.getLongitude()).degrees);
      double dE = abs(s.getMaxLongitude().subtract(p.getLongitude()).degrees);

      double sLat = factor * s.getDeltaLatDegrees();
      double sLon = factor * s.getDeltaLonDegrees();

      if (dN < sLat && dW < sLon) return NORTHWEST;
      if (dN < sLat && dE < sLon) return NORTHEAST;
      if (dS < sLat && dW < sLon) return SOUTHWEST;
      if (dS < sLat && dE < sLon) return SOUTHEAST;
      if (dN < sLat) return NORTH;
      if (dS < sLat) return SOUTH;
      if (dW < sLon) return WEST;
      if (dE < sLon) return EAST;
    }

    return NONE;
  }
コード例 #4
0
  protected Angle computePanAmount(
      Globe globe, OrbitView view, ScreenAnnotation control, double panStep) {
    // Compute last pick point distance relative to pan control center
    double size = control.getAttributes().getSize().width * control.getAttributes().getScale();
    Vec4 center = new Vec4(control.getScreenPoint().x, control.getScreenPoint().y + size / 2, 0);
    double px = lastPickPoint.x - center.x;
    double py = view.getViewport().getHeight() - lastPickPoint.y - center.y;
    double pickDistance = Math.sqrt(px * px + py * py);
    double pickDistanceFactor = Math.min(pickDistance / 10, 5);

    // Compute globe angular distance depending on eye altitude
    Position eyePos = view.getEyePosition();
    double radius = globe.getRadiusAt(eyePos);
    double minValue = 0.5 * (180.0 / (Math.PI * radius)); // Minimum change ~0.5 meters
    double maxValue = 1.0; // Maximum change ~1 degree

    // Compute an interpolated value between minValue and maxValue, using (eye altitude)/(globe
    // radius) as
    // the interpolant. Interpolation is performed on an exponential curve, to keep the value from
    // increasing too quickly as eye altitude increases.
    double a = eyePos.getElevation() / radius;
    a = (a < 0 ? 0 : (a > 1 ? 1 : a));
    double expBase = 2.0; // Exponential curve parameter.
    double value =
        minValue + (maxValue - minValue) * ((Math.pow(expBase, a) - 1.0) / (expBase - 1.0));

    return Angle.fromDegrees(value * pickDistanceFactor * panStep);
  }
コード例 #5
0
ファイル: IconRenderer.java プロジェクト: maduhu/gaeaplus
  protected void setDepthFunc(DrawContext dc, OrderedIcon uIcon, Vec4 screenPoint) {
    GL gl = dc.getGL();

    if (uIcon.icon.isAlwaysOnTop()) {
      gl.glDepthFunc(GL.GL_ALWAYS);
      return;
    }

    Position eyePos = dc.getView().getEyePosition();
    if (eyePos == null) {
      gl.glDepthFunc(GL.GL_ALWAYS);
      return;
    }

    double altitude = eyePos.getElevation();
    if (altitude < (dc.getGlobe().getMaxElevation() * dc.getVerticalExaggeration())) {
      double depth = screenPoint.z - (8d * 0.00048875809d);
      depth = depth < 0d ? 0d : (depth > 1d ? 1d : depth);
      gl.glDepthFunc(GL.GL_LESS);
      gl.glDepthRange(depth, depth);
    } else if (uIcon.eyeDistance > uIcon.horizonDistance) {
      gl.glDepthFunc(GL.GL_EQUAL);
      gl.glDepthRange(1d, 1d);
    } else {
      gl.glDepthFunc(GL.GL_ALWAYS);
    }
  }
コード例 #6
0
  /**
   * Sets the vector element at the specified position, as a geographic Position. This buffer's
   * logical vector size must be at least 2.
   *
   * @param position the logical vector position.
   * @param p the geographic Position to set.
   * @throws IllegalArgumentException if the position is out of range, if the Position is null, or
   *     if this buffer cannot store a Position.
   */
  public void putPosition(int position, Position p) {
    if (position < 0 || position >= this.getSize()) {
      String message =
          Logging.getMessage("generic.ArgumentOutOfRange", "position < 0 or position >= size");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (p == null) {
      String message = Logging.getMessage("nullValue.PositionIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (this.coordsPerVec < 2) {
      String message = Logging.getMessage("generic.BufferIncompatible", this);
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    double[] compArray = new double[3];
    compArray[1] = p.getLatitude().degrees;
    compArray[0] = p.getLongitude().degrees;
    compArray[2] = p.getElevation();

    this.put(position, compArray);
  }
コード例 #7
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));
  }
コード例 #8
0
  private void makeRadialWallTerrainConformant(
      DrawContext dc,
      int pillars,
      int stacks,
      float[] verts,
      double[] altitudes,
      boolean[] terrainConformant,
      Vec4 referenceCenter) {
    Globe globe = dc.getGlobe();
    Matrix transform = this.computeTransform(dc.getGlobe(), dc.getVerticalExaggeration());

    for (int p = 0; p <= pillars; p++) {
      int index = p;
      index = 3 * index;
      Vec4 vec = new Vec4(verts[index], verts[index + 1], verts[index + 2]);
      vec = vec.transformBy4(transform);
      Position pos = globe.computePositionFromPoint(vec);

      for (int s = 0; s <= stacks; s++) {
        double elevation = altitudes[s];
        if (terrainConformant[s])
          elevation += this.computeElevationAt(dc, pos.getLatitude(), pos.getLongitude());
        vec = globe.computePointFromPosition(pos.getLatitude(), pos.getLongitude(), elevation);

        index = p + s * (pillars + 1);
        index = 3 * index;
        verts[index] = (float) (vec.x - referenceCenter.x);
        verts[index + 1] = (float) (vec.y - referenceCenter.y);
        verts[index + 2] = (float) (vec.z - referenceCenter.z);
      }
    }
  }
コード例 #9
0
  protected static boolean isTileVisible(
      DrawContext dc, Tile tile, double minDistanceSquared, double maxDistanceSquared) {
    if (!tile.getSector().intersects(dc.getVisibleSector())) return false;

    View view = dc.getView();
    Position eyePos = view.getEyePosition();
    if (eyePos == null) return false;

    Angle lat =
        clampAngle(
            eyePos.getLatitude(),
            tile.getSector().getMinLatitude(),
            tile.getSector().getMaxLatitude());
    Angle lon =
        clampAngle(
            eyePos.getLongitude(),
            tile.getSector().getMinLongitude(),
            tile.getSector().getMaxLongitude());
    Vec4 p = dc.getGlobe().computePointFromPosition(lat, lon, 0d);
    double distSquared = dc.getView().getEyePoint().distanceToSquared3(p);
    //noinspection RedundantIfStatement
    if (minDistanceSquared > distSquared || maxDistanceSquared < distSquared) return false;

    return true;
  }
コード例 #10
0
  private void applyModify() {
    layer.setName(layerNameTextField.getText());
    Color choosenColor = colorBtn.getBackground();
    color = new Color(choosenColor.getRed(), choosenColor.getGreen(), choosenColor.getBlue());
    List<Position> positions = new ArrayList<Position>();
    for (int i = 0; i < latTexts.size(); i++) {
      Position p = layer.getPositions().get(i);
      double lat = Double.valueOf(latTexts.get(i).getText());
      double lng = Double.valueOf(lngTexts.get(i).getText());
      Position newP =
          new Position(Angle.fromDegrees(lat), Angle.fromDegrees(lng), p.getElevation());
      positions.add(newP);
    }
    layer.setPositions(positions);
    path.setPositions(positions);

    // Create and set an attribute bundle.
    ShapeAttributes attrs = new BasicShapeAttributes();
    Material material = new Material(color);
    attrs.setOutlineMaterial(material);
    attrs.setOutlineWidth(Double.valueOf(sizeTextField.getText()));
    attrs.setOutlineOpacity(Double.valueOf(opacityTextField.getText()));
    //		path.setColor(color);
    //		path.setLineWidth(Double.valueOf(sizeTextField.getText()));
    path.setAttributes(attrs);

    layer.refresh();
    frame.getLayerPanelDialog().getLayerPanel().update();
  }
コード例 #11
0
  private void buildPointPanels() {
    deleteBtns.clear();
    latTexts.clear();
    lngTexts.clear();
    points = layer.getPositions();
    if (pointPanels.size() != 0) {
      for (JPanel p : pointPanels) {
        this.remove(p);
      }
    }
    pointPanels.clear();

    if (points.size() > 1) {

      for (int i = 0; i < points.size(); i++) {
        JPanel panel = new JPanel();
        panel.setLayout(new FlowLayout(FlowLayout.LEFT));
        Position p = points.get(i);
        final int index = i;
        JLabel label = new JLabel("点" + i + ":");
        label.setPreferredSize(labelDimension);
        panel.add(label);
        JTextField lngTextField = new JTextField();
        lngTextField.setText(p.getLongitude().getDegrees() + "");
        lngTextField.setPreferredSize(smallComponentDimension);
        panel.add(lngTextField);
        lngTexts.add(lngTextField);
        JTextField latTextField = new JTextField();
        latTextField.setText(p.getLatitude().getDegrees() + "");
        latTextField.setPreferredSize(smallComponentDimension);
        panel.add(latTextField);
        latTexts.add(latTextField);
        JButton deleteBtn = new JButton();
        deleteBtn.setText("删除");
        deleteBtn.setPreferredSize(deleteComponentDimension);
        ActionListener deleteListener =
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent event) {
                if (deleteBtns.size() > 2) {
                  deleteBtns.remove(index);
                  points.remove(index);
                  refreshPointsPanel();
                  layer.refresh();
                  if (deleteBtns.size() <= 2) {
                    for (JButton btn : deleteBtns) {
                      btn.setEnabled(false);
                    }
                  }
                }
              }
            };
        deleteBtn.addActionListener(deleteListener);
        deleteBtns.add(deleteBtn);
        panel.add(deleteBtn);
        pointPanels.add(panel);
        this.add(panel, pointPanels.size() + 1);
      }
    }
  }
コード例 #12
0
 FollowPath(String name) {
   super(name);
   path.add(Position.fromDegrees(0, 0, 1e5));
   path.add(Position.fromDegrees(1, 3, 1e5));
   path.add(Position.fromDegrees(2, 4, 1e5));
   path.add(Position.fromDegrees(3, 5, 1e5));
 }
コード例 #13
0
  private void makePartialCylinderTerrainConformant(
      DrawContext dc,
      int slices,
      int stacks,
      float[] verts,
      double[] altitudes,
      boolean[] terrainConformant,
      Vec4 referenceCenter) {
    Globe globe = dc.getGlobe();
    Matrix transform = this.computeTransform(dc.getGlobe(), dc.getVerticalExaggeration());

    for (int i = 0; i <= slices; i++) {
      int index = i * (stacks + 1);
      index = 3 * index;
      Vec4 vec = new Vec4(verts[index], verts[index + 1], verts[index + 2]);
      vec = vec.transformBy4(transform);
      Position p = globe.computePositionFromPoint(vec);

      for (int j = 0; j <= stacks; j++) {
        double elevation = altitudes[j];
        if (terrainConformant[j])
          elevation += this.computeElevationAt(dc, p.getLatitude(), p.getLongitude());
        vec = globe.computePointFromPosition(p.getLatitude(), p.getLongitude(), elevation);

        index = j + i * (stacks + 1);
        index = 3 * index;
        verts[index] = (float) (vec.x - referenceCenter.x);
        verts[index + 1] = (float) (vec.y - referenceCenter.y);
        verts[index + 2] = (float) (vec.z - referenceCenter.z);
      }
    }
  }
コード例 #14
0
  public void goTo(Position lookAtPos, double distance) {

    Globe globe = this.getView().getGlobe();
    BasicFlyView view = (BasicFlyView) this.getView();

    Position lookFromPos =
        new Position(
            lookAtPos,
            globe.getElevation(lookAtPos.getLatitude(), lookAtPos.getLongitude()) + distance);

    // TODO: scale on mid-altitude?
    final long MIN_LENGTH_MILLIS = 4000;
    final long MAX_LENGTH_MILLIS = 16000;
    long timeToMove =
        AnimationSupport.getScaledTimeMillisecs(
            view.getEyePosition(), lookFromPos, MIN_LENGTH_MILLIS, MAX_LENGTH_MILLIS);
    FlyToFlyViewAnimator panAnimator =
        FlyToFlyViewAnimator.createFlyToFlyViewAnimator(
            view,
            view.getEyePosition(),
            lookFromPos,
            view.getHeading(),
            Angle.ZERO,
            view.getPitch(),
            Angle.ZERO,
            view.getEyePosition().getElevation(),
            lookFromPos.getElevation(),
            timeToMove,
            WorldWind.ABSOLUTE);

    this.gotoAnimControl.put(VIEW_ANIM_PAN, panAnimator);

    this.getView().firePropertyChange(AVKey.VIEW, null, this.getView());
  }
コード例 #15
0
  private void makePartialDiskTerrainConformant(
      DrawContext dc,
      int numCoords,
      float[] verts,
      double altitude,
      boolean terrainConformant,
      Vec4 referenceCenter) {
    Globe globe = dc.getGlobe();
    Matrix transform = this.computeTransform(dc.getGlobe(), dc.getVerticalExaggeration());

    for (int i = 0; i < numCoords; i += 3) {
      Vec4 vec = new Vec4(verts[i], verts[i + 1], verts[i + 2]);
      vec = vec.transformBy4(transform);
      Position p = globe.computePositionFromPoint(vec);

      double elevation = altitude;
      if (terrainConformant)
        elevation += this.computeElevationAt(dc, p.getLatitude(), p.getLongitude());

      vec = globe.computePointFromPosition(p.getLatitude(), p.getLongitude(), elevation);
      verts[i] = (float) (vec.x - referenceCenter.x);
      verts[i + 1] = (float) (vec.y - referenceCenter.y);
      verts[i + 2] = (float) (vec.z - referenceCenter.z);
    }
  }
コード例 #16
0
  /** 生成DEML,即将这个多边形输出到DEML文件中 */
  public Element exportAsDeml() throws IOException {

    Document _document = DocumentHelper.createDocument();
    Element _feature = _document.addElement("Feature");

    Element _type = _feature.addElement("Type");
    _type.setText("Polygon");

    Element _lName = _feature.addElement("LayerName");
    _lName.setText(this.getName());

    Element _pointList = _feature.addElement("PointList");

    for (Position pos : this.getPositions()) {
      Element _point = _pointList.addElement("Point");
      _point.addAttribute("Lat", pos.getLatitude().degrees + "");
      _point.addAttribute("Lng", pos.getLongitude().degrees + "");
    }

    Element _attributes = _feature.addElement("Attributes");

    Element _outlineMaterial = _attributes.addElement("InteriorMaterial");
    _outlineMaterial.addAttribute(
        "r", this.getPolygon().getAttributes().getInteriorMaterial().getDiffuse().getRed() + "");
    _outlineMaterial.addAttribute(
        "g", this.getPolygon().getAttributes().getInteriorMaterial().getDiffuse().getGreen() + "");
    _outlineMaterial.addAttribute(
        "b", this.getPolygon().getAttributes().getInteriorMaterial().getDiffuse().getBlue() + "");

    return _feature;
  }
コード例 #17
0
    /**
     * Performs one line of sight calculation between the reference position and a specified grid
     * position.
     *
     * @param gridPosition the grid position.
     * @throws InterruptedException if the operation is interrupted.
     */
    protected void performIntersection(Position gridPosition) throws InterruptedException {
      // Intersect the line between this grid point and the selected position.
      Intersection[] intersections = this.terrain.intersect(this.referencePosition, gridPosition);
      if (intersections == null || intersections.length == 0) {
        // No intersection, so the line goes from the center to the grid point.
        this.sightLines.add(new Position[] {this.referencePosition, gridPosition});
        return;
      }

      // Only the first intersection is shown.
      Vec4 iPoint = intersections[0].getIntersectionPoint();
      Vec4 gPoint =
          terrain.getSurfacePoint(
              gridPosition.getLatitude(), gridPosition.getLongitude(), gridPosition.getAltitude());

      // Check to see whether the intersection is beyond the grid point.
      if (iPoint.distanceTo3(this.referencePoint) >= gPoint.distanceTo3(this.referencePoint)) {
        // Intersection is beyond the grid point; the line goes from the center to the grid point.
        this.addSightLine(this.referencePosition, gridPosition);
        return;
      }

      // Compute the position corresponding to the intersection.
      Position iPosition = this.terrain.getGlobe().computePositionFromPoint(iPoint);

      // The sight line goes from the user-selected position to the intersection position.
      this.addSightLine(this.referencePosition, new Position(iPosition, 0));

      // Keep track of the intersection positions.
      this.addIntersectionPosition(iPosition);

      this.updateProgress();
    }
コード例 #18
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++;
    }
  }
コード例 #19
0
 public void onSuccess(Position[] positions) {
   for (Position p : positions) {
     Logging.logger()
         .info(
             p.getLatitude().degrees
                 + ","
                 + p.getLongitude().degrees
                 + " --> "
                 + p.getElevation());
   }
 }
コード例 #20
0
    private void fillPointsPanel() {
      int i = 0;
      for (Position pos : lineBuilder.getLine().getPositions()) {
        if (i == this.pointLabels.length) break;

        String las = String.format("Lat %7.4f\u00B0", pos.getLatitude().getDegrees());
        String los = String.format("Lon %7.4f\u00B0", pos.getLongitude().getDegrees());
        pointLabels[i++].setText(las + "  " + los);
      }
      for (; i < this.pointLabels.length; i++) pointLabels[i++].setText("");
    }
コード例 #21
0
  protected static boolean isNameVisible(
      DrawContext dc, PlaceNameService service, Position namePosition) {
    double elevation = dc.getVerticalExaggeration() * namePosition.getElevation();
    Vec4 namePoint =
        dc.getGlobe()
            .computePointFromPosition(
                namePosition.getLatitude(), namePosition.getLongitude(), elevation);
    Vec4 eyeVec = dc.getView().getEyePoint();

    double dist = eyeVec.distanceTo3(namePoint);
    return dist >= service.getMinDisplayDistance() && dist <= service.getMaxDisplayDistance();
  }
コード例 #22
0
  protected static void writeReferencePositions(String filePath, ArrayList<Position> positions)
      throws FileNotFoundException {
    PrintStream os = new PrintStream(new File(filePath));

    for (Position pos : positions) {
      os.format(
          "%.5f %.5f %.4f\n",
          pos.getLatitude().degrees, pos.getLongitude().degrees, pos.getElevation());
    }

    os.flush();
  }
コード例 #23
0
  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));
  }
コード例 #24
0
  private boolean atMaxLevel(DrawContext dc) {
    Position vpc = dc.getViewportCenterPosition();
    if (dc.getView() == null || this.getLevels() == null || vpc == null) return false;

    if (!this.getLevels().getSector().contains(vpc.getLatitude(), vpc.getLongitude())) return true;

    Level nextToLast = this.getLevels().getNextToLastLevel();
    if (nextToLast == null) return true;

    Sector centerSector =
        nextToLast.computeSectorForPosition(
            vpc.getLatitude(), vpc.getLongitude(), this.getLevels().getTileOrigin());
    return this.needToSplit(dc, centerSector);
  }
コード例 #25
0
  /** {@inheritDoc} */
  @Override
  public void moveTo(Position position) {
    Position delta;
    Position ref1 = this.path.getReferencePosition();
    Position ref2 = this.path2.getReferencePosition();
    if (ref1 != null && ref2 != null) delta = ref2.subtract(ref1);
    else delta = Position.ZERO;

    // Move the first path
    super.moveTo(position);

    // Move the second path
    this.path2.moveTo(position.add(delta));
  }
コード例 #26
0
  private Vec4 computeReferencePoint(DrawContext dc) {
    if (dc.getViewportCenterPosition() != null)
      return dc.getGlobe().computePointFromPosition(dc.getViewportCenterPosition());

    java.awt.geom.Rectangle2D viewport = dc.getView().getViewport();
    int x = (int) viewport.getWidth() / 2;
    for (int y = (int) (0.5 * viewport.getHeight()); y >= 0; y--) {
      Position pos = dc.getView().computePositionFromScreenPoint(x, y);
      if (pos == null) continue;

      return dc.getGlobe().computePointFromPosition(pos.getLatitude(), pos.getLongitude(), 0d);
    }

    return null;
  }
コード例 #27
0
  private static Position clampedCenter(Position unclampedCenter) {
    if (unclampedCenter == null) return null;

    // Clamp latitude to the range [-90, 90],
    // Normalize longitude to the range [-180, 180],
    // Don't change elevation.
    double lat = unclampedCenter.getLatitude().degrees;
    double lon = unclampedCenter.getLongitude().degrees;
    double elev = unclampedCenter.getElevation();
    lon = lon % 360;
    return Position.fromDegrees(
        lat > 90 ? 90 : (lat < -90 ? -90 : lat),
        lon > 180 ? lon - 360 : (lon < -180 ? 360 + lon : lon),
        elev);
  }
コード例 #28
0
ファイル: WorldMapLayer.java プロジェクト: ubdsgroup/wglobe
  /**
   * Compute the lat/lon position of the view center
   *
   * @param dc the current DrawContext
   * @param view the current View
   * @return the ground position of the view center or null
   */
  protected Position computeGroundPosition(DrawContext dc, View view) {
    if (view == null) return null;

    Position groundPos =
        view.computePositionFromScreenPoint(
            view.getViewport().getWidth() / 2, view.getViewport().getHeight() / 2);
    if (groundPos == null) return null;

    double elevation =
        dc.getGlobe().getElevation(groundPos.getLatitude(), groundPos.getLongitude());
    return new Position(
        groundPos.getLatitude(),
        groundPos.getLongitude(),
        elevation * dc.getVerticalExaggeration());
  }
コード例 #29
0
  protected void onVerticalTranslate(
      double translateChange,
      double totalTranslateChange,
      ViewInputAttributes.DeviceAttributes deviceAttributes,
      ViewInputAttributes.ActionAttributes actionAttribs) {
    this.stopGoToAnimators();
    double elevChange =
        -(totalTranslateChange * getScaleValueElevation(deviceAttributes, actionAttribs));
    View view = this.getView();
    Position position = view.getEyePosition();
    Position newPos = new Position(position, position.getElevation() + (elevChange));
    this.setEyePosition(uiAnimControl, view, newPos, actionAttribs);

    view.firePropertyChange(AVKey.VIEW, null, view);
  }
コード例 #30
0
  private void makeCap(
      DrawContext dc,
      GeometryBuilder.IndexedTriangleArray ita,
      double altitude,
      boolean terrainConformant,
      int orientation,
      Matrix locationTransform,
      Vec4 referenceCenter,
      int indexPos,
      int[] indices,
      int vertexPos,
      float[] vertices,
      float[] normals) {
    GeometryBuilder gb = this.getGeometryBuilder();
    Globe globe = dc.getGlobe();

    int indexCount = ita.getIndexCount();
    int vertexCount = ita.getVertexCount();
    int[] locationIndices = ita.getIndices();
    float[] locationVerts = ita.getVertices();

    this.copyIndexArray(
        indexCount,
        (orientation == GeometryBuilder.INSIDE),
        locationIndices,
        vertexPos,
        indexPos,
        indices);

    for (int i = 0; i < vertexCount; i++) {
      int index = 3 * i;
      Vec4 vec = new Vec4(locationVerts[index], locationVerts[index + 1], locationVerts[index + 2]);
      vec = vec.transformBy4(locationTransform);

      Position pos = globe.computePositionFromPoint(vec);
      vec =
          this.computePointFromPosition(
              dc, pos.getLatitude(), pos.getLongitude(), altitude, terrainConformant);

      index = 3 * (vertexPos + i);
      vertices[index] = (float) (vec.x - referenceCenter.x);
      vertices[index + 1] = (float) (vec.y - referenceCenter.y);
      vertices[index + 2] = (float) (vec.z - referenceCenter.z);
    }

    gb.makeIndexedTriangleArrayNormals(
        indexPos, indexCount, indices, vertexPos, vertexCount, vertices, normals);
  }