/**
   * Apply the model's position, orientation, and scale to a COLLADA root.
   *
   * @param root COLLADA root to configure.
   */
  protected void configureColladaRoot(ColladaRoot root) {
    root.setResourceResolver(this);

    Position refPosition = this.model.getLocation().getPosition();
    root.setPosition(refPosition);
    root.setAltitudeMode(KMLUtil.convertAltitudeMode(this.model.getAltitudeMode()));

    KMLOrientation orientation = this.model.getOrientation();
    if (orientation != null) {
      Double d = orientation.getHeading();
      if (d != null) root.setHeading(Angle.fromDegrees(d));

      d = orientation.getTilt();
      if (d != null) root.setPitch(Angle.fromDegrees(-d));

      d = orientation.getRoll();
      if (d != null) root.setRoll(Angle.fromDegrees(-d));
    }

    KMLScale scale = this.model.getScale();
    if (scale != null) {
      Double x = scale.getX();
      Double y = scale.getY();
      Double z = scale.getZ();

      Vec4 modelScale = new Vec4(x != null ? x : 1.0, y != null ? y : 1.0, z != null ? z : 1.0);

      root.setModelScale(modelScale);
    }
  }
  protected Tile[] buildTiles(PlaceNameService placeNameService, NavigationTile navTile) {
    final Angle dLat = placeNameService.getTileDelta().getLatitude();
    final Angle dLon = placeNameService.getTileDelta().getLongitude();

    // Determine the row and column offset from the global tiling origin for the southwest tile
    // corner
    int firstRow = Tile.computeRow(dLat, navTile.navSector.getMinLatitude());
    int firstCol = Tile.computeColumn(dLon, navTile.navSector.getMinLongitude());
    int lastRow = Tile.computeRow(dLat, navTile.navSector.getMaxLatitude().subtract(dLat));
    int lastCol = Tile.computeColumn(dLon, navTile.navSector.getMaxLongitude().subtract(dLon));

    int nLatTiles = lastRow - firstRow + 1;
    int nLonTiles = lastCol - firstCol + 1;

    Tile[] tiles = new Tile[nLatTiles * nLonTiles];

    Angle p1 = Tile.computeRowLatitude(firstRow, dLat);
    for (int row = 0; row <= lastRow - firstRow; row++) {
      Angle p2;
      p2 = p1.add(dLat);

      Angle t1 = Tile.computeColumnLongitude(firstCol, dLon);
      for (int col = 0; col <= lastCol - firstCol; col++) {
        Angle t2;
        t2 = t1.add(dLon);
        // Need offset row and column to correspond to total ro/col numbering
        tiles[col + row * nLonTiles] =
            new Tile(placeNameService, new Sector(p1, p2, t1, t2), row + firstRow, col + firstCol);
        t1 = t2;
      }
      p1 = p2;
    }

    return tiles;
  }
 /**
  * Returns the latitude and longitude of the sector's angular center: (minimum latitude + maximum
  * latitude) / 2, (minimum longitude + maximum longitude) / 2.
  *
  * @return The latitude and longitude of the sector's angular center
  */
 public LatLon getCentroid() {
   Angle la =
       Angle.fromDegrees(0.5 * (this.getMaxLatitude().degrees + this.getMinLatitude().degrees));
   Angle lo =
       Angle.fromDegrees(0.5 * (this.getMaxLongitude().degrees + this.getMinLongitude().degrees));
   return new LatLon(la, lo);
 }
  /**
   * Tests the equality of the sectors' angles. Sectors are equal if all of their corresponding
   * angles are equal.
   *
   * @param o the sector to compareTo with <code>this</code>.
   * @return <code>true</code> if the four corresponding angles of each sector are equal, <code>
   *     false</code> otherwise.
   */
  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    final gov.nasa.worldwind.geom.Sector sector = (gov.nasa.worldwind.geom.Sector) o;

    if (!maxLatitude.equals(sector.maxLatitude)) {
      return false;
    }
    if (!maxLongitude.equals(sector.maxLongitude)) {
      return false;
    }
    if (!minLatitude.equals(sector.minLatitude)) {
      return false;
    }
    //noinspection RedundantIfStatement
    if (!minLongitude.equals(sector.minLongitude)) {
      return false;
    }

    return true;
  }
  /**
   * {@inheritDoc}
   *
   * @param positions Control points. This graphic uses only two control point, which determine the
   *     midpoints of two opposite sides of the quad. See Fire Support Area (2.X.4.3.2.1.2) on pg.
   *     652 of MIL-STD-2525C for an example of how these points are interpreted.
   */
  public void setPositions(Iterable<? extends Position> positions) {
    if (positions == null) {
      String message = Logging.getMessage("nullValue.PositionsListIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    Iterator<? extends Position> iterator = positions.iterator();
    try {
      Position pos1 = iterator.next();
      Position pos2 = iterator.next();

      LatLon center = LatLon.interpolateGreatCircle(0.5, pos1, pos2);
      this.quad.setCenter(center);

      Angle heading = LatLon.greatCircleAzimuth(pos2, pos1);
      this.quad.setHeading(heading.subtract(Angle.POS90));

      this.positions = positions;
      this.shapeInvalid = true; // Need to recompute quad size
    } catch (NoSuchElementException e) {
      String message = Logging.getMessage("generic.InsufficientPositions");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }
  }
  /**
   * Select the visible grid elements
   *
   * @param dc the current <code>DrawContext</code>.
   */
  protected void selectRenderables(DrawContext dc) {
    if (dc == null) {
      String message = Logging.getMessage("nullValue.DrawContextIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }
    Sector vs = dc.getVisibleSector();
    OrbitView view = (OrbitView) dc.getView();
    // Compute labels offset from view center
    Position centerPos = view.getCenterPosition();
    Double pixelSizeDegrees =
        Angle.fromRadians(
                view.computePixelSizeAtDistance(view.getZoom())
                    / dc.getGlobe().getEquatorialRadius())
            .degrees;
    Double labelOffsetDegrees = pixelSizeDegrees * view.getViewport().getWidth() / 4;
    Position labelPos =
        Position.fromDegrees(
            centerPos.getLatitude().degrees - labelOffsetDegrees,
            centerPos.getLongitude().degrees - labelOffsetDegrees,
            0);
    Double labelLatDegrees = labelPos.getLatitude().normalizedLatitude().degrees;
    labelLatDegrees = Math.min(Math.max(labelLatDegrees, -76), 78);
    labelPos =
        new Position(
            Angle.fromDegrees(labelLatDegrees), labelPos.getLongitude().normalizedLongitude(), 0);

    if (vs != null) {
      for (GridElement ge : this.gridElements) {
        if (ge.isInView(dc)) {
          if (ge.renderable instanceof GeographicText) {
            GeographicText gt = (GeographicText) ge.renderable;
            if (labelPos.getLatitude().degrees < 72
                || "*32*34*36*".indexOf("*" + gt.getText() + "*") == -1) {
              // Adjust label position according to eye position
              Position pos = gt.getPosition();
              if (ge.type.equals(GridElement.TYPE_LATITUDE_LABEL))
                pos =
                    Position.fromDegrees(
                        pos.getLatitude().degrees,
                        labelPos.getLongitude().degrees,
                        pos.getElevation());
              else if (ge.type.equals(GridElement.TYPE_LONGITUDE_LABEL))
                pos =
                    Position.fromDegrees(
                        labelPos.getLatitude().degrees,
                        pos.getLongitude().degrees,
                        pos.getElevation());

              gt.setPosition(pos);
            }
          }

          this.graticuleSupport.addRenderable(ge.renderable, GRATICULE_UTM);
        }
      }
      // System.out.println("Total elements: " + count + " visible sector: " + vs);
    }
  }
 static Angle computeRowLatitude(int row, Angle delta) {
   if (delta == null) {
     String msg = Logging.getMessage("nullValue.AngleIsNull");
     Logging.logger().severe(msg);
     throw new IllegalArgumentException(msg);
   }
   return Angle.fromDegrees(-90d + delta.getDegrees() * row);
 }
 static Angle computeColumnLongitude(int column, Angle delta) {
   if (delta == null) {
     String msg = Logging.getMessage("nullValue.AngleIsNull");
     Logging.logger().severe(msg);
     throw new IllegalArgumentException(msg);
   }
   return Angle.fromDegrees(-180 + delta.getDegrees() * column);
 }
 /**
  * Creates a new <code>Sector</code> and initializes it to the specified angles. The angles are
  * assumed to be normalized to +/- 90 degrees latitude and +/- 180 degrees longitude, but this
  * method does not verify that.
  *
  * @param minLatitude the sector's minimum latitude in degrees.
  * @param maxLatitude the sector's maximum latitude in degrees.
  * @param minLongitude the sector's minimum longitude in degrees.
  * @param maxLongitude the sector's maximum longitude in degrees.
  * @return the new <code>Sector</code>
  */
 public static Sector fromDegrees(
     double minLatitude, double maxLatitude, double minLongitude, double maxLongitude) {
   return new Sector(
       Angle.fromDegrees(minLatitude),
       Angle.fromDegrees(maxLatitude),
       Angle.fromDegrees(minLongitude),
       Angle.fromDegrees(maxLongitude));
 }
Пример #10
0
 static int computeColumn(Angle delta, Angle longitude) {
   if (delta == null || longitude == null) {
     String msg = Logging.getMessage("nullValue.AngleIsNull");
     Logging.logger().severe(msg);
     throw new IllegalArgumentException(msg);
   }
   return (int) ((longitude.getDegrees() + 180d) / delta.getDegrees());
 }
 /**
  * Computes a hash code from the sector's four angles.
  *
  * @return a hash code incorporating the sector's four angles.
  */
 @Override
 public int hashCode() {
   int result;
   result = minLatitude.hashCode();
   result = 29 * result + maxLatitude.hashCode();
   result = 29 * result + minLongitude.hashCode();
   result = 29 * result + maxLongitude.hashCode();
   return result;
 }
 protected Position computePositionFromUPS(String hemisphere, double easting, double northing) {
   try {
     UPSCoord UPS = UPSCoord.fromUPS(hemisphere, easting, northing, globe);
     return new Position(
         Angle.fromRadiansLatitude(UPS.getLatitude().radians),
         Angle.fromRadiansLongitude(UPS.getLongitude().radians),
         10e3);
   } catch (IllegalArgumentException e) {
     return null;
   }
 }
  public Sector[] subdivide() {
    Angle midLat = Angle.average(this.minLatitude, this.maxLatitude);
    Angle midLon = Angle.average(this.minLongitude, this.maxLongitude);

    Sector[] sectors = new Sector[4];
    sectors[0] = new Sector(this.minLatitude, midLat, this.minLongitude, midLon);
    sectors[1] = new Sector(this.minLatitude, midLat, midLon, this.maxLongitude);
    sectors[2] = new Sector(midLat, this.maxLatitude, this.minLongitude, midLon);
    sectors[3] = new Sector(midLat, this.maxLatitude, midLon, this.maxLongitude);

    return sectors;
  }
  @Override
  protected void doRestoreState(RestorableSupport rs, RestorableSupport.StateObject context) {
    super.doRestoreState(rs, context);

    Double la = rs.getStateValueAsDouble(context, "leftAzimuthDegrees");
    if (la == null) la = this.leftAzimuth.degrees;

    Double ra = rs.getStateValueAsDouble(context, "rightAzimuthDegrees");
    if (ra == null) ra = this.rightAzimuth.degrees;

    this.setAzimuths(Angle.fromDegrees(la), Angle.fromDegrees(ra));
  }
  public Sector(Sector sector) {
    if (sector == null) {
      throw new IllegalArgumentException("Sector Is Null");
    }

    this.minLatitude = new Angle(sector.getMinLatitude());
    this.maxLatitude = new Angle(sector.getMaxLatitude());
    this.minLongitude = new Angle(sector.getMinLongitude());
    this.maxLongitude = new Angle(sector.getMaxLongitude());
    this.deltaLat = Angle.fromDegrees(this.maxLatitude.degrees - this.minLatitude.degrees);
    this.deltaLon = Angle.fromDegrees(this.maxLongitude.degrees - this.minLongitude.degrees);
  }
  /**
   * Creates a new <code>Sector</code> and initializes it to the specified angles. The angles are
   * assumed to be normalized to +/- 90 degrees latitude and +/- 180 degrees longitude, but this
   * method does not verify that.
   *
   * @param minLatitude the sector's minimum latitude.
   * @param maxLatitude the sector's maximum latitude.
   * @param minLongitude the sector's minimum longitude.
   * @param maxLongitude the sector's maximum longitude.
   * @throws IllegalArgumentException if any of the angles are null
   */
  public Sector(Angle minLatitude, Angle maxLatitude, Angle minLongitude, Angle maxLongitude) {
    if (minLatitude == null
        || maxLatitude == null
        || minLongitude == null
        || maxLongitude == null) {
      throw new IllegalArgumentException("Input Angles Null");
    }

    this.minLatitude = minLatitude;
    this.maxLatitude = maxLatitude;
    this.minLongitude = minLongitude;
    this.maxLongitude = maxLongitude;
    this.deltaLat = Angle.fromDegrees(this.maxLatitude.degrees - this.minLatitude.degrees);
    this.deltaLon = Angle.fromDegrees(this.maxLongitude.degrees - this.minLongitude.degrees);
  }
Пример #17
0
 protected static Angle clampAngle(Angle a, Angle min, Angle max) {
   double degrees = a.degrees;
   double minDegrees = min.degrees;
   double maxDegrees = max.degrees;
   return Angle.fromDegrees(
       degrees < minDegrees ? minDegrees : (degrees > maxDegrees ? maxDegrees : degrees));
 }
Пример #18
0
  /**
   * Compute the positions of the arrow head of the graphic's legs.
   *
   * @param dc Current draw context
   * @param base Position of the arrow's starting point.
   * @param tip Position of the arrow head tip.
   * @param arrowLength Length of the arrowhead as a fraction of the total line length.
   * @param arrowAngle Angle of the arrow head.
   * @return Positions required to draw the arrow head.
   */
  protected List<Position> computeArrowheadPositions(
      DrawContext dc, Position base, Position tip, double arrowLength, Angle arrowAngle) {
    // Build a triangle to represent the arrowhead. The triangle is built from two vectors, one
    // parallel to the
    // segment, and one perpendicular to it.

    Globe globe = dc.getGlobe();

    Vec4 ptA = globe.computePointFromPosition(base);
    Vec4 ptB = globe.computePointFromPosition(tip);

    // Compute parallel component
    Vec4 parallel = ptA.subtract3(ptB);

    Vec4 surfaceNormal = globe.computeSurfaceNormalAtPoint(ptB);

    // Compute perpendicular component
    Vec4 perpendicular = surfaceNormal.cross3(parallel);

    double finalArrowLength = arrowLength * parallel.getLength3();
    double arrowHalfWidth = finalArrowLength * arrowAngle.tanHalfAngle();

    perpendicular = perpendicular.normalize3().multiply3(arrowHalfWidth);
    parallel = parallel.normalize3().multiply3(finalArrowLength);

    // Compute geometry of direction arrow
    Vec4 vertex1 = ptB.add3(parallel).add3(perpendicular);
    Vec4 vertex2 = ptB.add3(parallel).subtract3(perpendicular);

    return TacticalGraphicUtil.asPositionList(globe, vertex1, vertex2, ptB);
  }
    public MeshTile[] subdivide(Level nextLevel) {
      Angle p0 = this.getSector().getMinLatitude();
      Angle p2 = this.getSector().getMaxLatitude();
      Angle p1 = Angle.midAngle(p0, p2);

      Angle t0 = this.getSector().getMinLongitude();
      Angle t2 = this.getSector().getMaxLongitude();
      Angle t1 = Angle.midAngle(t0, t2);

      int row = this.getRow();
      int col = this.getColumn();

      MeshCoords[] coords = this.coords.subdivide();

      MeshTile[] subTiles = new MeshTile[4];
      subTiles[0] =
          new MeshTile(
              new Sector(p0, p1, t0, t1),
              nextLevel,
              2 * row,
              2 * col,
              coords[0]); // Lower left quadrant.
      subTiles[1] =
          new MeshTile(
              new Sector(p0, p1, t1, t2),
              nextLevel,
              2 * row,
              2 * col + 1,
              coords[1]); // Lower right quadrant.
      subTiles[2] =
          new MeshTile(
              new Sector(p1, p2, t1, t2),
              nextLevel,
              2 * row + 1,
              2 * col + 1,
              coords[2]); // Upper right quadrant
      subTiles[3] =
          new MeshTile(
              new Sector(p1, p2, t0, t1),
              nextLevel,
              2 * row + 1,
              2 * col,
              coords[3]); // Upper left quadrant.
      return subTiles;
    }
  private static MeshTile[] createTiles(LevelSet levelSet, int levelNumber, MeshCoords coords) {
    Sector sector = levelSet.getSector();
    Level level = levelSet.getLevel(levelNumber);
    Angle dLat = level.getTileDelta().getLatitude();
    Angle dLon = level.getTileDelta().getLongitude();
    Angle latOrigin = levelSet.getTileOrigin().getLatitude();
    Angle lonOrigin = levelSet.getTileOrigin().getLongitude();

    // Determine the row and column offset from the common World Wind global tiling origin.
    int firstRow = Tile.computeRow(dLat, sector.getMinLatitude(), latOrigin);
    int firstCol = Tile.computeColumn(dLon, sector.getMinLongitude(), lonOrigin);
    int lastRow = Tile.computeRow(dLat, sector.getMaxLatitude(), latOrigin);
    int lastCol = Tile.computeColumn(dLon, sector.getMaxLongitude(), lonOrigin);

    int numLatTiles = lastRow - firstRow + 1;
    int numLonTiles = lastCol - firstCol + 1;

    AffineTransform sectorTransform = createTransform(sector, coords);

    MeshTile[] tiles = new MeshTile[numLatTiles * numLonTiles];
    int index = 0;

    Angle p1 = Tile.computeRowLatitude(firstRow, dLat, latOrigin);

    for (int row = firstRow; row <= lastRow; row++) {
      Angle p2 = p1.add(dLat);

      Angle t1 = Tile.computeColumnLongitude(firstCol, dLon, lonOrigin);

      for (int col = firstCol; col <= lastCol; col++) {
        Angle t2 = t1.add(dLon);

        Sector tileSector = new Sector(p1, p2, t1, t2);
        MeshCoords tileCoords = transformSector(sectorTransform, tileSector);
        tiles[index++] = new MeshTile(tileSector, level, row, col, tileCoords);

        t1 = t2;
      }
      p1 = p2;
    }

    return tiles;
  }
Пример #21
0
  protected Angle computeIconRadius(DrawContext dc, double regionPixelSize, Sector drawSector) {
    double minCosLat =
        Math.min(drawSector.getMinLatitude().cos(), drawSector.getMaxLatitude().cos());
    if (minCosLat < 0.001) return Angle.POS180;

    Rectangle2D iconDimension = this.computeDrawDimension(regionPixelSize); // Meter
    double dLat = iconDimension.getHeight() / dc.getGlobe().getRadius();
    double dLon = iconDimension.getWidth() / dc.getGlobe().getRadius() / minCosLat;
    return Angle.fromRadians(Math.sqrt(dLat * dLat + dLon * dLon) / 2);
  }
  private void createTopLevelTiles() {
    MercatorSector sector = (MercatorSector) this.levels.getSector();

    Level level = levels.getFirstLevel();
    Angle dLat = level.getTileDelta().getLatitude();
    Angle dLon = level.getTileDelta().getLongitude();

    Angle latOrigin = this.levels.getTileOrigin().getLatitude();
    Angle lonOrigin = this.levels.getTileOrigin().getLongitude();

    // Determine the row and column offset from the common World Wind global tiling origin.
    int firstRow = Tile.computeRow(dLat, sector.getMinLatitude(), latOrigin);
    int firstCol = Tile.computeColumn(dLon, sector.getMinLongitude(), lonOrigin);
    int lastRow = Tile.computeRow(dLat, sector.getMaxLatitude(), latOrigin);
    int lastCol = Tile.computeColumn(dLon, sector.getMaxLongitude(), lonOrigin);

    int nLatTiles = lastRow - firstRow + 1;
    int nLonTiles = lastCol - firstCol + 1;

    this.topLevels = new ArrayList<MercatorTextureTile>(nLatTiles * nLonTiles);

    // Angle p1 = Tile.computeRowLatitude(firstRow, dLat);
    double deltaLat = dLat.degrees / 90;
    double d1 = -1.0 + deltaLat * firstRow;
    for (int row = firstRow; row <= lastRow; row++) {
      // Angle p2;
      // p2 = p1.add(dLat);
      double d2 = d1 + deltaLat;

      Angle t1 = Tile.computeColumnLongitude(firstCol, dLon, lonOrigin);
      for (int col = firstCol; col <= lastCol; col++) {
        Angle t2;
        t2 = t1.add(dLon);

        this.topLevels.add(
            new MercatorTextureTile(new MercatorSector(d1, d2, t1, t2), level, row, col));
        t1 = t2;
      }
      d1 = d2;
    }
  }
  /**
   * Creates a new <code>Sector</code> and initializes it to the specified angles. The angles are
   * assumed to be normalized to +/- 90 degrees latitude and +/- 180 degrees longitude, but this
   * method does not verify that.
   *
   * @param minLatitude the sector's minimum latitude in degrees.
   * @param maxLatitude the sector's maximum latitude in degrees.
   * @param minLongitude the sector's minimum longitude in degrees.
   * @param maxLongitude the sector's maximum longitude in degrees.
   * @return the new <code>Sector</code>
   */
  public static Sector fromDegreesAndClamp(
      double minLatitude, double maxLatitude, double minLongitude, double maxLongitude) {
    if (minLatitude < -90) {
      minLatitude = -90;
    }
    if (maxLatitude > 90) {
      maxLatitude = 90;
    }
    if (minLongitude < -180) {
      minLongitude = -180;
    }
    if (maxLongitude > 180) {
      maxLongitude = 180;
    }

    return new Sector(
        Angle.fromDegrees(minLatitude),
        Angle.fromDegrees(maxLatitude),
        Angle.fromDegrees(minLongitude),
        Angle.fromDegrees(maxLongitude));
  }
  protected Angle normalizedAzimuth(Angle azimuth) {
    if (azimuth == null) {
      String message = "nullValue.AzimuthIsNull";
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    double degrees = azimuth.degrees;
    double normalizedDegrees =
        degrees < 0.0 ? degrees + 360.0 : (degrees >= 360.0 ? degrees - 360.0 : degrees);
    return Angle.fromDegrees(normalizedDegrees);
  }
  protected double[] computeAngles() {
    // Compute the start and sweep angles such that the partial cylinder shape tranverses a
    // clockwise path from
    // the start angle to the stop angle.
    Angle startAngle, stopAngle, sweepAngle;
    startAngle = normalizedAzimuth(this.leftAzimuth);
    stopAngle = normalizedAzimuth(this.rightAzimuth);

    int i = startAngle.compareTo(stopAngle);
    // Angles are equal, fallback to building a closed cylinder.
    if (i == 0) return null;

    if (i < 0) sweepAngle = stopAngle.subtract(startAngle);
    else // (i > 0)
    sweepAngle = Angle.POS360.subtract(startAngle).add(stopAngle);

    double[] array = new double[3];
    array[0] = startAngle.radians;
    array[1] = stopAngle.radians;
    array[2] = sweepAngle.radians;
    return array;
  }
Пример #26
0
    public void actionPerformed(ActionEvent e) {
      if (!this.isEnabled()) {
        return;
      }

      if (NEW_AIRSPACE.equals(e.getActionCommand())) {
        this.createNewEntry(this.getView().getSelectedFactory());
      } else if (CLEAR_SELECTION.equals(e.getActionCommand())) {
        this.selectEntry(null, true);
      } else if (SIZE_NEW_SHAPES_TO_VIEWPORT.equals(e.getActionCommand())) {
        if (e.getSource() instanceof AbstractButton) {
          boolean selected = ((AbstractButton) e.getSource()).isSelected();
          this.setResizeNewShapesToViewport(selected);
        }
      } else if (ENABLE_EDIT.equals(e.getActionCommand())) {
        if (e.getSource() instanceof AbstractButton) {
          boolean selected = ((AbstractButton) e.getSource()).isSelected();
          this.setEnableEdit(selected);
        }
      } else if (OPEN.equals(e.getActionCommand())) {
        this.openFromFile();
      } else if (OPEN_URL.equals(e.getActionCommand())) {
        this.openFromURL();
      } else if (OPEN_DEMO_AIRSPACES.equals(e.getActionCommand())) {
        this.openFromPath(DEMO_AIRSPACES_PATH);
        this.zoomTo(
            LatLon.fromDegrees(47.6584074779224, -122.3059199579634),
            Angle.fromDegrees(-152),
            Angle.fromDegrees(75),
            750);
      } else if (REMOVE_SELECTED.equals(e.getActionCommand())) {
        this.removeEntries(Arrays.asList(this.getSelectedEntries()));
      } else if (SAVE.equals(e.getActionCommand())) {
        this.saveToFile();
      } else if (SELECTION_CHANGED.equals(e.getActionCommand())) {
        this.viewSelectionChanged();
      }
    }
Пример #27
0
  /**
   * Create the list of positions that describe the arrow.
   *
   * @param dc Current draw context.
   */
  protected void createShapes(DrawContext dc) {
    this.paths = new Path[2];

    int i = 0;

    Angle azimuth1 = LatLon.greatCircleAzimuth(this.position1, this.position2);
    Angle azimuth2 = LatLon.greatCircleAzimuth(this.position1, this.position3);

    Angle delta = azimuth2.subtract(azimuth1);
    int sign = delta.degrees > 0 ? 1 : -1;

    delta = Angle.fromDegrees(sign * 5.0);

    // Create a path for the line part of the arrow
    List<Position> positions = this.computePathPositions(this.position1, this.position2, delta);
    this.paths[i++] = this.createPath(positions);

    // Create a polygon to draw the arrow head.
    double arrowLength = this.getArrowLength();
    Angle arrowAngle = this.getArrowAngle();
    positions =
        this.computeArrowheadPositions(
            dc, positions.get(2), positions.get(3), arrowLength, arrowAngle);
    this.arrowHead1 = this.createPolygon(positions);
    this.arrowHead1.setLocations(positions);

    delta = delta.multiply(-1.0);
    positions = this.computePathPositions(this.position1, this.position3, delta);
    this.paths[i] = this.createPath(positions);

    positions =
        this.computeArrowheadPositions(
            dc, positions.get(2), positions.get(3), arrowLength, arrowAngle);
    this.arrowHead2 = this.createPolygon(positions);
    this.arrowHead2.setLocations(positions);
  }
Пример #28
0
  protected List<Position> computePathPositions(
      Position startPosition, Position endPosition, Angle delta) {
    Angle dist = LatLon.greatCircleDistance(startPosition, endPosition);
    dist = dist.multiply(0.6);

    Angle azimuth = LatLon.greatCircleAzimuth(startPosition, endPosition);

    LatLon locA = LatLon.greatCircleEndPosition(startPosition, azimuth.add(delta), dist);

    dist = dist.multiply(0.9);
    LatLon locB = LatLon.greatCircleEndPosition(startPosition, azimuth.subtract(delta), dist);

    return Arrays.asList(startPosition, new Position(locA, 0), new Position(locB, 0), endPosition);
  }
    public void doActionOnButton2() {
      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));

      Sector sector = Sector.fromDegrees(44d, 46d, -123d, -121d);
      //            Sector sector = Sector.boundingSector( latlons );

      double[] elevations = new double[latlons.size()];

      // request resolution of DTED2 (1degree / 3600 )
      double targetResolution = Angle.fromDegrees(1d).radians / 3600;

      double resolutionAchieved =
          this.wwd
              .getModel()
              .getGlobe()
              .getElevationModel()
              .getElevations(sector, latlons, targetResolution, elevations);

      StringBuffer sb = new StringBuffer();
      for (double e : elevations) {
        sb.append("\n").append(e);
      }
      sb.append("\nresolutionAchieved = ").append(resolutionAchieved);
      sb.append(", requested resolution = ").append(targetResolution);

      Logging.logger().info(sb.toString());
    }
  /** Create the graticule grid elements */
  private void createUTMRenderables() {
    this.gridElements = new ArrayList<GridElement>();

    ArrayList<Position> positions = new ArrayList<Position>();

    // Generate meridians and zone labels
    int lon = -180;
    int zoneNumber = 1;
    int maxLat;
    for (int i = 0; i < 60; i++) {
      Angle longitude = Angle.fromDegrees(lon);
      // Meridian
      positions.clear();
      positions.add(new Position(Angle.fromDegrees(-80), longitude, 10e3));
      positions.add(new Position(Angle.fromDegrees(-60), longitude, 10e3));
      positions.add(new Position(Angle.fromDegrees(-30), longitude, 10e3));
      positions.add(new Position(Angle.ZERO, longitude, 10e3));
      positions.add(new Position(Angle.fromDegrees(30), longitude, 10e3));
      if (lon < 6 || lon > 36) {
        // 'regular' UTM meridians
        maxLat = 84;
        positions.add(new Position(Angle.fromDegrees(60), longitude, 10e3));
        positions.add(new Position(Angle.fromDegrees(maxLat), longitude, 10e3));
      } else {
        // Exceptions: shorter meridians around and north-east of Norway
        if (lon == 6) {
          maxLat = 56;
          positions.add(new Position(Angle.fromDegrees(maxLat), longitude, 10e3));
        } else {
          maxLat = 72;
          positions.add(new Position(Angle.fromDegrees(60), longitude, 10e3));
          positions.add(new Position(Angle.fromDegrees(maxLat), longitude, 10e3));
        }
      }
      Object polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE);
      Sector sector = Sector.fromDegrees(-80, maxLat, lon, lon);
      this.gridElements.add(new GridElement(sector, polyline, GridElement.TYPE_LINE));

      // Zone label
      GeographicText text =
          new UserFacingText(zoneNumber + "", Position.fromDegrees(0, lon + 3, 0));
      sector = Sector.fromDegrees(-90, 90, lon + 3, lon + 3);
      this.gridElements.add(new GridElement(sector, text, GridElement.TYPE_LONGITUDE_LABEL));

      // Increase longitude and zone number
      lon += 6;
      zoneNumber++;
    }

    // Generate special meridian segments for exceptions around and north-east of Norway
    for (int i = 0; i < 5; i++) {
      positions.clear();
      lon = specialMeridians[i][0];
      positions.add(
          new Position(Angle.fromDegrees(specialMeridians[i][1]), Angle.fromDegrees(lon), 10e3));
      positions.add(
          new Position(Angle.fromDegrees(specialMeridians[i][2]), Angle.fromDegrees(lon), 10e3));
      Object polyline = createLineRenderable(positions, Polyline.GREAT_CIRCLE);
      Sector sector = Sector.fromDegrees(specialMeridians[i][1], specialMeridians[i][2], lon, lon);
      this.gridElements.add(new GridElement(sector, polyline, GridElement.TYPE_LINE));
    }

    // Generate parallels - no exceptions
    int lat = -80;
    for (int i = 0; i < 21; i++) {
      Angle latitude = Angle.fromDegrees(lat);
      for (int j = 0; j < 4; j++) {
        // Each prallel is divided into four 90 degrees segments
        positions.clear();
        lon = -180 + j * 90;
        positions.add(new Position(latitude, Angle.fromDegrees(lon), 10e3));
        positions.add(new Position(latitude, Angle.fromDegrees(lon + 30), 10e3));
        positions.add(new Position(latitude, Angle.fromDegrees(lon + 60), 10e3));
        positions.add(new Position(latitude, Angle.fromDegrees(lon + 90), 10e3));
        Object polyline = createLineRenderable(positions, Polyline.LINEAR);
        Sector sector = Sector.fromDegrees(lat, lat, lon, lon + 90);
        this.gridElements.add(new GridElement(sector, polyline, GridElement.TYPE_LINE));
      }
      // Latitude band label
      if (i < 20) {
        GeographicText text =
            new UserFacingText(latBands.charAt(i) + "", Position.fromDegrees(lat + 4, 0, 0));
        Sector sector = Sector.fromDegrees(lat + 4, lat + 4, -180, 180);
        this.gridElements.add(new GridElement(sector, text, GridElement.TYPE_LATITUDE_LABEL));
      }

      // Increase latitude
      lat += lat < 72 ? 8 : 12;
    }
  }