Пример #1
0
  /**
   * Handles internal consequences of a change to the probe position.
   *
   * @param pos The probe's new position.
   */
  public void probeMoved(RealTuple pos) {
    if (!getHaveInitialized()) {
      return;
    }

    try {
      LatLonPoint llp = null;
      RealTupleType rttype = (RealTupleType) pos.getType();

      if (rttype.equals(RealTupleType.SpatialCartesian2DTuple)
          || rttype.equals(RealTupleType.SpatialCartesian3DTuple)) {
        llp = latLon(pos);
      } else if (rttype.equals(RealTupleType.SpatialEarth2DTuple)
          || rttype.equals(RealTupleType.SpatialEarth3DTuple)) {
        Real[] reals = pos.getRealComponents();

        llp = new LatLonTuple(reals[1], reals[0]);
      } else if (rttype.equals(RealTupleType.LatitudeLongitudeTuple)
          || rttype.equals(RealTupleType.LatitudeLongitudeAltitude)) {
        Real[] reals = pos.getRealComponents();

        llp = new LatLonTuple(reals[0], reals[1]);
      } else {
        throw new IllegalArgumentException("Can't convert position to navigable point");
      }

      if (llp != null) {
        dataNode.setLocation(llp); // invokes super.setLocation(llp)
      }
    } catch (Exception ex) {
      logException("probeMoved", ex);
    }
  }