updateGoGPSUpBodyEntryLeap function
Implementation
void updateGoGPSUpBodyEntryLeap(CLCmdGogpsBodyLeap bodyItem){
slog('updateGoGPSUpBodyEntryLeap entered');
if (GoGpsParam.mbNewSession) {
GoGpsParam.mbNewSession = false;
// every track initializes these parameters only once
GoGpsParam.mfGOGPSPreDis = 0;
GoGpsParam.mlGOGPSTrailStartTime = bodyItem.timestamp;
GoGpsParam.mlGOGPSTrailEndTime = 0;
GoGpsParam.mnGogpsLastSecIndex = 0;
}
GoGpsParam.mnGogpsReceivedBodyCntInBlk++;
if (bodyItem.gpsData[0].secIndex == GoGpsParam.mlLastSecIndex) {
return;
}
GoGpsParam.mlLastSecIndex = bodyItem.gpsData.elementAt(0).secIndex;
for (int i = 0; i < CLCmdGogpsBodyLeap.GOGPS_UP_DATA_ENTRY_SIZE; i++ ) {
if (bodyItem.gpsData[i].secIndex != 0xffff) {
double dGogpsNewLat = GoGpsParam.mdGogpsLastLat + bodyItem.gpsData[i].latDelta;
double dGogpsNewLng = GoGpsParam.mdGogpsLastLng + bodyItem.gpsData[i].lonDelta;
double dDistance = Geolocator.distanceBetween(
GoGpsParam.mdGogpsLastLat / 1000000,
GoGpsParam.mdGogpsLastLng / 1000000,
(dGogpsNewLat) / 1000000,
(dGogpsNewLng) / 1000000
);
slog("updateGoGPSUpBodyEntry: dis=$dDistance");
GoGpsParam.mdGogpsLastLat = dGogpsNewLat;
GoGpsParam.mdGogpsLastLng = dGogpsNewLng;
double currentDist = (GoGpsParam.mfGOGPSPreDis + dDistance);
int nGogpsNewSecIndex = bodyItem.gpsData[i].secIndex;
double dSpeed = 0;
if(nGogpsNewSecIndex - GoGpsParam.mnGogpsLastSecIndex > 0){
dSpeed = dDistance / (nGogpsNewSecIndex - GoGpsParam.mnGogpsLastSecIndex);
}
GoGpsParam.mnGogpsLastSecIndex = nGogpsNewSecIndex;
final pgu = CLCmdGoGpsUpStreamData.fromLeap(
bodyItem,
GoGpsParam.mGogpsUpHeader!.workoutType,
dSpeed,
currentDist.toInt(),
dDistance,
GoGpsParam.mdGogpsLastLat / 1000000,
GoGpsParam.mdGogpsLastLng / 1000000,
i );
GoGpsParam.mfGOGPSPreDis = currentDist;
GoGpsParam.mfGOGPSTrailRunDis = currentDist;
if (GoGpsParam.mlGOGPSTrailEndTime < pgu.timestamp + pgu.secondindex) {
GoGpsParam.mlGOGPSTrailEndTime = pgu.timestamp + pgu.secondindex;
}
//接口回调
CLCmdGoGpsUpStreamData.subject.add(pgu);
}
else{
slog("gogpsUpBody.gpsdata[i].secIndex == 0xffff");
return;
}
}
}