 int aprsIndex = 0;
 boolean aprsRdy, aprsChkFlg, aprsErrFlg, aprsBufCurrent, aprsValid;
 boolean aprsFlg, aprsNewFlg;
-long aprsTime, lastAprsTime; // standard time in seconds with decimal fraction to ms
-float aprsLat, aprsLon, aprsAlt, aprsVg, aprsHdg;
-float lastAprsAlt; // needed to keep track of prior value to calculate Vz
+float aprsLat, aprsLon, aprsVg, aprsHdg;
+double aprsAlt;
+
+// Derived aprs parameters
+double aprsTime, lastAprsTime;
+float aprsVlon, aprsVlat, aprsValt; // Derived from aprsVg, aprsHdg 
+double lastAprsAlt = -1; // needed to keep track of prior value to calculate Vz
 
 char term[TERMLEN], aprsfiBuf[APRSFILEN], cmdBuf[CMDLEN];
 int termIndex = 0;

    }
    if ( gpsPosValid ) {
      // Get position, velocity data
      gpsLat = getField( gpsTF, 6, ',' ).toFloat();
      if ( getField( gpsTF, 7, ',' ) == 'S' ) gpsLat *= -1.0;
      gpsLon = getField( gpsTF, 8, ',' ).toFloat();
      if ( getField( gpsTF, 9, ',' ) == 'W' ) gpsLon *= -1.0;
      gpsAlt = getField( gpsTF, 10, ',' ).toFloat();
    }

    Serial.println( "invalid" );
  }
  if ( callSgnFilt ) {
    // Extract and convert params to m, rad, rad/s
    aprsLat = aprsObj.getLatitude() * deg2rad;
    aprsLon = aprsObj.getLongitude() * deg2rad;
    aprsAlt = (double)aprsObj.getAltitude() * ft2m;
    aprsVg = (float)aprsObj.getGroundspeed() * knots2mps * m2rad;
    aprsHdg = (float)aprsObj.getCourse() * deg2rad;
    aprsNewFlg = true;

    // Derived parameters
    aprsVlon = aprsVg * sin( aprsHdg ) / cos( aprsLat );
    aprsVlat = aprsVg * cos( aprsHdg );

    if ( lastAprsTime == 0 ) {
      lastAprsTime = (double)now();
      aprsTime = lastAprsTime;
      aprsValt = 0.0;
    } else {
      aprsTime = (double)now();
      aprsValt = ( aprsAlt - lastAprsAlt ) / ( aprsTime - lastAprsTime );
      Serial.print( "   :" );Serial.print(aprsTime);
      Serial.print( " " );Serial.println( lastAprsTime );
    }
    double deltaZ = aprsAlt - lastAprsAlt;
    double deltaT = aprsTime - lastAprsTime;
    lastAprsTime = aprsTime;
    lastAprsAlt = aprsAlt;
    if ( DEBUG ) {
      digitalClockDisplay( (long)aprsTime );
      Serial.print("APRS: Lon Lat Alt Vg Hdg Vx Vy Vz:");
      Serial.print( aprsLon, 4 );Serial.print(' ');
      Serial.print( aprsLat, 4 );Serial.print(' ');
      Serial.print( aprsAlt);Serial.print(' ');
      Serial.print( aprsVg );Serial.print(' ');
      Serial.print( aprsHdg );Serial.print(' ');
      Serial.print( aprsVlon );Serial.print(' ');
      Serial.print( aprsVlat );Serial.print(' ');
      Serial.println( aprsValt );
    }

  }
  
}

void updateTarget() {
  // if a new APRS fix came in, use it as last target state
  if ( aprsNewFlg ) {
    if ( DEBUG ) Serial.println( "APRS target update" );
    targetValid = true;
    // Set prior target state to new APRS data
    targetTime = aprsTime;
    targetLon = aprsLon;
    targetLat = aprsLat;
    targetAlt = aprsAlt;
    targetVlon = aprsVlon;
    targetVlat = aprsVlat;
    targetValt = aprsValt;
    aprsNewFlg = false;
  }

