Ejemplo n.º 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);
    }
  }
Ejemplo n.º 2
0
 public void doAction() throws VisADException, RemoteException {
   Tuple tuple = (Tuple) ref.getData();
   float lon = (float) ((Real) tuple.getComponent(0)).getValue();
   float lat = (float) ((Real) tuple.getComponent(1)).getValue();
   RealTuple wind = (RealTuple) tuple.getComponent(2);
   float windx = (float) ((Real) wind.getComponent(0)).getValue();
   float windy = (float) ((Real) wind.getComponent(1)).getValue();
   System.out.println("wind = (" + windx + ", " + windy + ") at (" + +lat + ", " + lon + ")");
   /* a testing hack
       count--;
       if (count < 0) {
         count = 20;
         scale = 0.15f * 0.3f / scale;
         flow_control.setFlowScale(scale);
       }
   */
 }