/**
   * @param refPt The geodetic position of the reference point.
   * @param neiPt The holder for the geodetic position of the neighboring grid point.
   * @param lat The latitude of the neighboring grid point.
   * @param lon The longitude of the neighboring grid point.
   * @param azTerm An amount in degrees to be added to the computed azimuth.
   * @param bearing The holder for the computed range and bearing from the reference point to the
   *     neighboring grid point.
   * @param hat 2-element output array for computed (x,y) components of unit vector.
   */
  private static void compute(
      LatLonPointImpl refPt,
      LatLonPointImpl neiPt,
      float lat,
      float lon,
      float azTerm,
      Bearing bearing,
      float[] hat) {

    neiPt.set(lat, lon);
    Bearing.calculateBearing(refPt, neiPt, bearing);

    float az = (float) Math.toRadians(bearing.getAngle() + azTerm);
    // System.out.println("bearing.Angle = " + bearing.getAngle() + "; azTerm = " + azTerm+ ";
    // result= " + Math.toDegrees(az));

    hat[0] = (float) Math.sin(az);
    hat[1] = (float) Math.cos(az);
  }
  /**
   * @param refPt The geodetic position of the reference point.
   * @param neiPt The holder for the geodetic position of the neighboring grid point.
   * @param lat The latitude of the neighboring grid point.
   * @param lon The longitude of the neighboring grid point.
   * @param azTerm An amount in degrees to be added to the computed azimuth.
   * @param wind Magnitude of grid-relative wind component.
   * @param bearing The holder for the computed range and bearing from the reference point to the
   *     neighboring grid point.
   * @param uv 2-element output array for computed (U,V) wind components.
   */
  private static void compute(
      LatLonPointImpl refPt,
      LatLonPointImpl neiPt,
      float lat,
      float lon,
      float azTerm,
      float wind,
      Bearing bearing,
      float[] uv) {

    neiPt.set(lat, lon);
    Bearing.calculateBearing(refPt, neiPt, bearing);

    float az = (float) Math.toRadians(bearing.getAngle() + azTerm);
    float xhat = (float) Math.sin(az);
    float yhat = (float) Math.cos(az);

    uv[0] = xhat * wind;
    uv[1] = yhat * wind;
  }
Beispiel #3
0
  /**
   * Handle glyph moved
   *
   * @throws RemoteException On badness
   * @throws VisADException On badness
   */
  public void updateLocation() throws VisADException, RemoteException {
    super.updateLocation();
    if (points.size() < 2) {
      return;
    }
    if (showText) {
      setText(startTextDisplayable, 0, startText, startTextType);
      setText(endTextDisplayable, 1, endText, endTextType);
    }

    checkBoxVisibility();
    if ((maxDataDistance == null) || (maxDistanceBox == null)) {
      return;
    }
    double km = maxDataDistance.getValue(CommonUnit.meter) / 1000.0;
    if (km > 2000) {
      return;
    }

    EarthLocation p1 = (EarthLocation) points.get(0);
    EarthLocation p2 = (EarthLocation) points.get(1);

    MathType mathType = RealTupleType.LatitudeLongitudeAltitude;

    Bearing baseBearing =
        Bearing.calculateBearing(
            p1.getLatitude().getValue(),
            p1.getLongitude().getValue(),
            p2.getLatitude().getValue(),
            p2.getLongitude().getValue(),
            null);

    double baseAngle = baseBearing.getAngle();

    LatLonPointImpl[] llps =
        new LatLonPointImpl[] {
          Bearing.findPoint(
              p1.getLatitude().getValue(),
              p1.getLongitude().getValue(),
              baseAngle + 90.0,
              km,
              null),
          Bearing.findPoint(
              p2.getLatitude().getValue(),
              p2.getLongitude().getValue(),
              baseAngle + 90.0,
              km,
              null),
          Bearing.findPoint(
              p2.getLatitude().getValue(), p2.getLongitude().getValue(), baseAngle - 90, km, null),
          Bearing.findPoint(
              p1.getLatitude().getValue(), p1.getLongitude().getValue(), baseAngle - 90, km, null),
          Bearing.findPoint(
              p1.getLatitude().getValue(), p1.getLongitude().getValue(), baseAngle + 90.0, km, null)
        };

    float[][] lineVals = getPointValues();
    float alt = lineVals[2][0];
    lineVals = new float[3][llps.length];
    for (int i = 0; i < lineVals[0].length; i++) {
      lineVals[0][i] = (float) llps[i].getLatitude();
      lineVals[1][i] = (float) llps[i].getLongitude();
    }

    float[][] tmp = new float[3][];

    for (int i = 0; i < lineVals[0].length - 1; i++) {
      tmp[0] =
          Misc.merge(
              tmp[0],
              Misc.interpolate(
                  2 + getNumInterpolationPoints(), lineVals[0][i], lineVals[0][i + 1]));
      tmp[1] =
          Misc.merge(
              tmp[1],
              Misc.interpolate(
                  2 + getNumInterpolationPoints(), lineVals[1][i], lineVals[1][i + 1]));
    }

    tmp[2] = new float[tmp[0].length];
    lineVals = tmp;

    for (int i = 0; i < lineVals[0].length; i++) {
      lineVals[2][i] = alt;
    }

    Data theData = new Gridded3DSet(mathType, lineVals, lineVals[0].length);
    maxDistanceBox.setData(theData);
  }