Exemple #1
0
 /**
  * Format a EarthLocation as a lat/lon/(alt) string.
  *
  * @param el EarthLocation to format
  * @return The formatted lat/lon/alt
  */
 public String formatEarthLocationShort(EarthLocation el) {
   StringBuffer buf = new StringBuffer();
   try {
     LatLonPoint llp = el.getLatLonPoint();
     buf.append(formatLatLonShort(llp));
     buf.append(" ");
     buf.append(formatDistance(el.getAltitude().getValue()));
   } catch (Exception e) {
     return "";
   }
   return buf.toString();
 }
Exemple #2
0
 /**
  * format the earth location
  *
  * @param el the earth location
  * @param includeAlt include the altitude
  * @param includeLabel include that lat/lon label
  * @return formatted earth location
  */
 public String formatEarthLocation(EarthLocation el, boolean includeAlt, boolean includeLabel) {
   StringBuffer buf = new StringBuffer();
   try {
     buf.append(formatLatLonPoint(el.getLatLonPoint(), includeLabel));
   } catch (Exception e) {
     return "";
   }
   if (includeAlt) {
     if (includeLabel) {
       buf.append(" Alt: ");
     } else {
       buf.append(" ");
     }
     try {
       buf.append(formatDistance(el.getAltitude().getValue()));
     } catch (Exception e) {
       buf.append(" ");
     }
   }
   return buf.toString();
 }
Exemple #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);
  }