Skip to content
This repository has been archived by the owner on Aug 1, 2020. It is now read-only.
/ readsb Public archive

Dev #21

Closed
wants to merge 9 commits into from
Prev Previous commit
Next Next commit
Make receiver and aircraft relative CPR stats functional
  • Loading branch information
wiedehopf committed Oct 26, 2019
commit e1f694bd46a7874a0984615a649d45ed2a1d74eb
14 changes: 12 additions & 2 deletions track.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ static int doLocalCPR(struct aircraft *a, struct modesMessage *mm, double *lat,
int result;
int fflag = mm->cpr_odd;
int surface = (mm->cpr_type == CPR_SURFACE);
int relative_to = 0; // aircraft(1) or receiver(2) relative

if (fflag) {
*nic = a->cpr_odd_nic;
Expand All @@ -414,6 +415,7 @@ static int doLocalCPR(struct aircraft *a, struct modesMessage *mm, double *lat,
*rc = a->pos_rc;

range_limit = 50e3;
relative_to = 1;
} else if (!surface && (Modes.bUserFlags & MODES_USER_LATLON_VALID)) {
reflat = Modes.fUserLat;
reflon = Modes.fUserLon;
Expand All @@ -436,6 +438,7 @@ static int doLocalCPR(struct aircraft *a, struct modesMessage *mm, double *lat,
} else {
return (-1); // Can't do receiver-centered checks at all
}
relative_to = 2;
} else {
// No local reference, give up
return (-1);
Expand Down Expand Up @@ -468,7 +471,7 @@ static int doLocalCPR(struct aircraft *a, struct modesMessage *mm, double *lat,
return -1;
}

return 0;
return relative_to;
}

static uint64_t time_between(uint64_t t1, uint64_t t2) {
Expand Down Expand Up @@ -548,10 +551,17 @@ static void updatePosition(struct aircraft *a, struct modesMessage *mm) {
Modes.stats_current.cpr_local_ok++;
mm->cpr_relative = 1;
accept_data(&a->position_valid, mm->source);

if (location_result == 1) {
Modes.stats_current.cpr_local_aircraft_relative++;
}
if (location_result == 2) {
Modes.stats_current.cpr_local_receiver_relative++;
}
}
}

if (location_result == 0) {
if (location_result >= 0) {
// If we sucessfully decoded, back copy the results to mm so that we can print them in list output
mm->cpr_decoded = 1;
mm->decoded_lat = new_lat;
Expand Down