Exemple #1
0
  /**
   * Given that the center point and the axis are set, calculate the new lat/lon points all around
   * the ellipse from the center.
   */
  public float[] createLatLonPoints() {
    // First, need to calculate the lat/lon points for the
    // ellipse.
    int i;
    int nMax = 72;
    double angle = -Math.PI;
    double angleInc = 2.0 * Math.PI / nMax;
    double[] distance = new double[nMax + 1];
    double x;
    double y;
    double a;
    double b;
    float[] azimuth = new float[nMax + 1];
    float[] llPoints = new float[2 * (nMax + 1)];

    a = majorAxisSpan / 2.0;
    b = minorAxisSpan / 2.0;

    for (i = 0; i < nMax; i++) {

      x = Math.sqrt((a * a * b * b) / ((b * b) + ((a * a) * Math.pow(Math.tan(angle), 2))));
      double yt = (x * x) / (a * a);
      if (yt > 1.0) {
        yt = 1.0;
      }
      y = Math.sqrt((1.0 - yt) * (b * b));

      distance[i] = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
      azimuth[i] = (float) angle + com.bbn.openmap.MoreMath.HALF_PI + (float) getRotationAngle();

      if (Debug.debugging("ellipse")) {
        Debug.output(
            " "
                + i
                + " "
                + (azimuth[i] * 180 / Math.PI)
                + " ( "
                + distance[i]
                + " ) "
                + (Debug.debugging("ellipsedetail")
                    ? ("[from x:" + x + ", y:" + y + ", a:" + a + ", b:" + b + "]")
                    : ""));
      }
      angle += angleInc;
    }

    distance[nMax] = distance[0];
    azimuth[nMax] = azimuth[0];
    int nCounter = 0;

    for (i = 0; i < nMax + 1; i++) {

      LatLonPoint llPt =
          GreatCircle.spherical_between(
              center.radlat_, center.radlon_, (float) distance[i], azimuth[i]);
      llPoints[nCounter++] = llPt.radlat_;
      llPoints[nCounter++] = llPt.radlon_;
    }

    return llPoints;
  }