public int countImagesInSector(Sector sector, int levelNumber) {
    if (sector == null) {
      String msg = Logging.getMessage("nullValue.SectorIsNull");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    Level targetLevel = this.levels.getLastLevel();
    if (levelNumber >= 0) {
      for (int i = levelNumber; i < this.getLevels().getLastLevel().getLevelNumber(); i++) {
        if (this.levels.isLevelEmpty(i)) continue;

        targetLevel = this.levels.getLevel(i);
        break;
      }
    }

    // Collect all the tiles intersecting the input sector.
    LatLon delta = targetLevel.getTileDelta();
    Angle latOrigin = this.levels.getTileOrigin().getLatitude();
    Angle lonOrigin = this.levels.getTileOrigin().getLongitude();
    final int nwRow = Tile.computeRow(delta.getLatitude(), sector.getMaxLatitude(), latOrigin);
    final int nwCol = Tile.computeColumn(delta.getLongitude(), sector.getMinLongitude(), lonOrigin);
    final int seRow = Tile.computeRow(delta.getLatitude(), sector.getMinLatitude(), latOrigin);
    final int seCol = Tile.computeColumn(delta.getLongitude(), sector.getMaxLongitude(), lonOrigin);

    int numRows = nwRow - seRow + 1;
    int numCols = seCol - nwCol + 1;

    return numRows * numCols;
  }
    private void adjustDateLineCrossingPoints() {
      ArrayList<LatLon> corners = new ArrayList<LatLon>(Arrays.asList(sw, se, nw, ne));
      if (!LatLon.locationsCrossDateLine(corners)) return;

      double lonSign = 0;
      for (LatLon corner : corners) {
        if (Math.abs(corner.getLongitude().degrees) != 180)
          lonSign = Math.signum(corner.getLongitude().degrees);
      }

      if (lonSign == 0) return;

      if (Math.abs(sw.getLongitude().degrees) == 180
          && Math.signum(sw.getLongitude().degrees) != lonSign)
        sw = new Position(sw.getLatitude(), sw.getLongitude().multiply(-1), sw.getElevation());
      if (Math.abs(se.getLongitude().degrees) == 180
          && Math.signum(se.getLongitude().degrees) != lonSign)
        se = new Position(se.getLatitude(), se.getLongitude().multiply(-1), se.getElevation());
      if (Math.abs(nw.getLongitude().degrees) == 180
          && Math.signum(nw.getLongitude().degrees) != lonSign)
        nw = new Position(nw.getLatitude(), nw.getLongitude().multiply(-1), nw.getElevation());
      if (Math.abs(ne.getLongitude().degrees) == 180
          && Math.signum(ne.getLongitude().degrees) != lonSign)
        ne = new Position(ne.getLatitude(), ne.getLongitude().multiply(-1), ne.getElevation());
    }
Пример #3
0
 @Test
 public void testKnownAzimuthC() {
   LatLon begin = LatLon.fromDegrees(-12.0, 87.0);
   LatLon end = LatLon.fromDegrees(-12.0000001, 86.9999999);
   double azimuth = LatLon.rhumbAzimuth(begin, end).degrees;
   assertEquals("Known Azimuth C", -135.63291443992495, azimuth, THRESHOLD);
 }
Пример #4
0
 @Test
 public void testTrivialSouth() {
   LatLon begin = LatLon.fromDegrees(0.0, 0.0);
   LatLon end = LatLon.fromDegrees(-90.0, 0.0);
   double azimuth = LatLon.greatCircleAzimuth(begin, end).degrees;
   assertEquals("Trivial South greatCircleAzimuth", 180.0, azimuth, THRESHOLD);
 }
Пример #5
0
 @Test
 public void testKnownAzimuthB() {
   LatLon begin = LatLon.fromDegrees(53.0902505, 112.8935442);
   LatLon end = LatLon.fromDegrees(-53.0902505, -67.1064558);
   double azimuth = LatLon.rhumbAzimuth(begin, end).degrees;
   assertEquals("Known Azimuth B", -124.94048502315054, azimuth, THRESHOLD);
 }
  /**
   * {@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);
    }
  }
  private void drawTileIDs(DrawContext dc, ArrayList<MercatorTextureTile> tiles) {
    java.awt.Rectangle viewport = dc.getView().getViewport();
    if (this.textRenderer == null) {
      this.textRenderer = new TextRenderer(java.awt.Font.decode("Arial-Plain-13"), true, true);
      this.textRenderer.setUseVertexArrays(false);
    }

    dc.getGL().glDisable(GL.GL_DEPTH_TEST);
    dc.getGL().glDisable(GL.GL_BLEND);
    dc.getGL().glDisable(GL.GL_TEXTURE_2D);

    this.textRenderer.setColor(java.awt.Color.YELLOW);
    this.textRenderer.beginRendering(viewport.width, viewport.height);
    for (MercatorTextureTile tile : tiles) {
      String tileLabel = tile.getLabel();

      if (tile.getFallbackTile() != null) tileLabel += "/" + tile.getFallbackTile().getLabel();

      LatLon ll = tile.getSector().getCentroid();
      Vec4 pt =
          dc.getGlobe()
              .computePointFromPosition(
                  ll.getLatitude(),
                  ll.getLongitude(),
                  dc.getGlobe().getElevation(ll.getLatitude(), ll.getLongitude()));
      pt = dc.getView().project(pt);
      this.textRenderer.draw(tileLabel, (int) pt.x, (int) pt.y);
    }
    this.textRenderer.endRendering();
  }
Пример #8
0
 @Test
 public void testTrivialAntipodalPointsC() {
   LatLon begin = LatLon.fromDegrees(-90.0, -180.0);
   LatLon end = LatLon.fromDegrees(90.0, 180.0);
   double distance = LatLon.greatCircleDistance(begin, end).degrees;
   assertEquals("Trivial antipodal points C", 180.0, distance, THRESHOLD);
 }
Пример #9
0
 @Test
 public void testAntipodalPointsB() {
   LatLon begin = LatLon.fromDegrees(-12.0, 87.0);
   LatLon end = LatLon.fromDegrees(12.0, -93.0);
   double distance = LatLon.greatCircleDistance(begin, end).degrees;
   assertEquals("Antipodal points B", 180.0, distance, THRESHOLD);
 }
Пример #10
0
 @Test
 public void testTrivialEquivalentPointsC() {
   LatLon begin = LatLon.fromDegrees(0.0, 0.0);
   LatLon end = LatLon.fromDegrees(0.0, 360.0);
   double distance = LatLon.rhumbDistance(begin, end).degrees;
   assertEquals("Trivial equivalent points C", 0.0, distance, THRESHOLD);
 }
Пример #11
0
 @Test
 public void testProblemPointsA() {
   LatLon begin = LatLon.fromDegrees(36.0, -118.0);
   LatLon end = LatLon.fromDegrees(36.0, -117.0);
   double distance = LatLon.rhumbDistance(begin, end).degrees;
   assertEquals("Problem points A", 0.8090169943749475, distance, THRESHOLD);
 }
Пример #12
0
 @Test
 public void testKnownAzimuthE() {
   LatLon begin = LatLon.fromDegrees(-12.0, 87.0);
   LatLon end = LatLon.fromDegrees(53.0902505, -67.1064558);
   double azimuth = LatLon.greatCircleAzimuth(begin, end).degrees;
   assertEquals("Known Azimuth E", -21.38356223882703, azimuth, THRESHOLD);
 }
Пример #13
0
 @Test
 public void testTrivialEquivalentPointsB() {
   LatLon begin = LatLon.fromDegrees(0.0, -180.0);
   LatLon end = LatLon.fromDegrees(0.0, 180.0);
   double distance = LatLon.greatCircleDistance(begin, end).degrees;
   assertEquals("Trivial equivalent points B", 0.0, distance, THRESHOLD);
 }
Пример #14
0
 @Test
 public void testKnownAzimuthD() {
   LatLon begin = LatLon.fromDegrees(-12.0, 87.0);
   LatLon end = LatLon.fromDegrees(11.9999999, -93.0000001);
   double azimuth = LatLon.greatCircleAzimuth(begin, end).degrees;
   assertEquals("Known Azimuth D", 135.6329170162944, azimuth, THRESHOLD);
 }
Пример #15
0
 @Test
 public void testKnownAzimuthC() {
   LatLon begin = LatLon.fromDegrees(-12.0, 87.0);
   LatLon end = LatLon.fromDegrees(-12.0000001, 86.9999999);
   double azimuth = LatLon.greatCircleAzimuth(begin, end).degrees;
   assertEquals("Known Azimuth C", -135.6329170237546, azimuth, THRESHOLD);
 }
Пример #16
0
 @Test
 public void testKnownAzimuthB() {
   LatLon begin = LatLon.fromDegrees(53.0902505, 112.8935442);
   LatLon end = LatLon.fromDegrees(-53.0902505, -67.1064558);
   double azimuth = LatLon.greatCircleAzimuth(begin, end).degrees;
   assertEquals("Known Azimuth B", -90.0, azimuth, THRESHOLD);
 }
Пример #17
0
 @Test
 public void testKnownAzimuthD() {
   LatLon begin = LatLon.fromDegrees(-12.0, 87.0);
   LatLon end = LatLon.fromDegrees(11.9999999, -93.0000001);
   double azimuth = LatLon.rhumbAzimuth(begin, end).degrees;
   assertEquals("Known Azimuth D", 82.34987931207793, azimuth, THRESHOLD);
 }
Пример #18
0
 @Test
 public void testEquivalentPoints() {
   LatLon begin = LatLon.fromDegrees(53.0902505, 112.8935442);
   LatLon end = LatLon.fromDegrees(53.0902505, 112.8935442);
   double distance = LatLon.greatCircleDistance(begin, end).degrees;
   assertEquals("Equivalent points", 0.0, distance, THRESHOLD);
 }
Пример #19
0
 @Test
 public void testKnownAzimuthE() {
   LatLon begin = LatLon.fromDegrees(-12.0, 87.0);
   LatLon end = LatLon.fromDegrees(53.0902505, -67.1064558);
   double azimuth = LatLon.rhumbAzimuth(begin, end).degrees;
   assertEquals("Known Azimuth E", -64.05846977747626, azimuth, THRESHOLD);
 }
Пример #20
0
 @Test
 public void testTrivialWest() {
   LatLon begin = LatLon.fromDegrees(0.0, 0.0);
   LatLon end = LatLon.fromDegrees(0.0, -90.0);
   double azimuth = LatLon.rhumbAzimuth(begin, end).degrees;
   assertEquals("Trivial West rhumbAzimuth", -90.0, azimuth, THRESHOLD);
 }
Пример #21
0
 @Test
 public void testAntipodalPointsA() {
   LatLon begin = LatLon.fromDegrees(53.0902505, 112.8935442);
   LatLon end = LatLon.fromDegrees(-53.0902505, -67.1064558);
   double distance = LatLon.greatCircleDistance(begin, end).degrees;
   assertEquals("Antipodal points A", 180.0, distance, THRESHOLD);
 }
Пример #22
0
 @Test
 public void testTrivialEquivalentPointsC() {
   LatLon begin = LatLon.fromDegrees(90.0, 0.0);
   LatLon end = LatLon.fromDegrees(90.0, 0.0);
   double azimuth = LatLon.rhumbAzimuth(begin, end).degrees;
   assertEquals("Trivial equivalent points C", 0.0, azimuth, THRESHOLD);
 }
Пример #23
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));
  }
Пример #24
0
    private Info[] buildSurfaceShapes() {
      LatLon position = new LatLon(Angle.fromDegrees(38), Angle.fromDegrees(-105));

      ArrayList<LatLon> surfaceLinePositions = new ArrayList<LatLon>();
      //            surfaceLinePositions.add(LatLon.fromDegrees(37.8484, -119.9754));
      //            surfaceLinePositions.add(LatLon.fromDegrees(38.3540, -119.1526));

      //            surfaceLinePositions.add(new LatLon(Angle.fromDegrees(0),
      // Angle.fromDegrees(-150)));
      //            surfaceLinePositions.add(new LatLon(Angle.fromDegrees(60),
      // Angle.fromDegrees(0)));

      surfaceLinePositions.add(position);
      surfaceLinePositions.add(LatLon.fromDegrees(39, -104));
      surfaceLinePositions.add(LatLon.fromDegrees(39, -105));
      surfaceLinePositions.add(position);

      return new Info[] {
        new Info("Circle", new SurfaceCircle(position, 100e3)),
        new Info("Ellipse", new SurfaceEllipse(position, 100e3, 90e3, Angle.ZERO)),
        new Info("Square", new SurfaceSquare(position, 100e3)),
        new Info("Quad", new SurfaceQuad(position, 100e3, 60e3, Angle.ZERO)),
        new Info("Sector", new SurfaceSector(Sector.fromDegrees(38, 40, -105, -103))),
        new Info("Polygon", new SurfacePolygon(surfaceLinePositions)),
      };
    }
Пример #25
0
  /**
   * Sets the vector element at the specified position, as a geographic LatLon. This buffer's
   * logical vector size must be at least 2.
   *
   * @param position the logical vector position.
   * @param ll the geographic location to set.
   * @throws IllegalArgumentException if the position is out of range, if the LatLon is null, or if
   *     this buffer cannot store a LatLon.
   */
  public void putLocation(int position, LatLon ll) {
    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 (ll == null) {
      String message = Logging.getMessage("nullValue.LatLonIsNull");
      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[2];
    compArray[1] = ll.getLatitude().degrees;
    compArray[0] = ll.getLongitude().degrees;

    this.put(position, compArray);
  }
Пример #26
0
 @Test
 public void testKnownDistanceCloseTo180() {
   LatLon begin = LatLon.fromDegrees(-12.0, 87.0);
   LatLon end = LatLon.fromDegrees(11.9999999, -93.0000001);
   double distance = LatLon.greatCircleDistance(begin, end).degrees;
   assertEquals("Known spherical distance (close to 180)", 180.0, distance, THRESHOLD);
 }
Пример #27
0
 @Test
 public void testEquivalentPoints() {
   LatLon begin = LatLon.fromDegrees(53.0902505, 112.8935442);
   LatLon end = LatLon.fromDegrees(53.0902505, 112.8935442);
   double azimuth = LatLon.rhumbAzimuth(begin, end).degrees;
   assertEquals("Equivalent points", 0.0, azimuth, THRESHOLD);
 }
Пример #28
0
 @Test
 public void testProblemPointsA() {
   LatLon begin = LatLon.fromDegrees(36.0, -118.0);
   LatLon end = LatLon.fromDegrees(36.0, -117.0);
   double distance = LatLon.greatCircleDistance(begin, end).degrees;
   assertEquals("Problem points A", 0.8090134466773318, distance, THRESHOLD);
 }
Пример #29
0
 @Test
 public void testKnownAzimuthA() {
   LatLon begin = LatLon.fromDegrees(-90.0, -180.0);
   LatLon end = LatLon.fromDegrees(90.0, 180.0);
   double azimuth = LatLon.rhumbAzimuth(begin, end).degrees;
   assertEquals("Known Azimuth A", 0.0, azimuth, THRESHOLD);
 }
Пример #30
0
 @Test
 public void testKnownDistance() {
   LatLon begin = LatLon.fromDegrees(90.0, 45.0);
   LatLon end = LatLon.fromDegrees(36.0, 180.0);
   double distance = LatLon.greatCircleDistance(begin, end).degrees;
   assertEquals("Known spherical distance", 54.0, distance, THRESHOLD);
 }