Merge branch 'prefer-global-cpr'
This commit is contained in:
commit
d820ae1afc
3 changed files with 24 additions and 22 deletions
13
mode_s.c
13
mode_s.c
|
@ -2062,11 +2062,8 @@ double cprDlonFunction(double lat, int fflag, int surface) {
|
|||
//
|
||||
// A few remarks:
|
||||
// 1) 131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
|
||||
// 2) We assume that we always received the odd packet as last packet for
|
||||
// simplicity. This may provide a position that is less fresh of a few
|
||||
// seconds.
|
||||
//
|
||||
void decodeCPR(struct aircraft *a, int fflag, int surface) {
|
||||
int decodeCPR(struct aircraft *a, int fflag, int surface) {
|
||||
double AirDlat0 = (surface ? 90.0 : 360.0) / 60.0;
|
||||
double AirDlat1 = (surface ? 90.0 : 360.0) / 59.0;
|
||||
double lat0 = a->even_cprlat;
|
||||
|
@ -2092,7 +2089,8 @@ void decodeCPR(struct aircraft *a, int fflag, int surface) {
|
|||
surface_rlat = Modes.fUserLat;
|
||||
surface_rlon = Modes.fUserLon;
|
||||
} else {
|
||||
return;
|
||||
// No local reference, give up
|
||||
return (-1);
|
||||
}
|
||||
rlat0 += floor(surface_rlat / 90.0) * 90.0; // Move from 1st quadrant to our quadrant
|
||||
rlat1 += floor(surface_rlat / 90.0) * 90.0;
|
||||
|
@ -2105,7 +2103,8 @@ void decodeCPR(struct aircraft *a, int fflag, int surface) {
|
|||
if (rlat0 < -90 || rlat0 > 90 || rlat1 < -90 || rlat1 > 90) return;
|
||||
|
||||
// Check that both are in the same latitude zone, or abort.
|
||||
if (cprNLFunction(rlat0) != cprNLFunction(rlat1)) return;
|
||||
if (cprNLFunction(rlat0) != cprNLFunction(rlat1))
|
||||
return (-1);
|
||||
|
||||
// Compute ni and the Longitude Index "m"
|
||||
if (fflag) { // Use odd packet.
|
||||
|
@ -2131,6 +2130,8 @@ void decodeCPR(struct aircraft *a, int fflag, int surface) {
|
|||
a->seenLatLon = a->seen;
|
||||
a->timestampLatLon = a->timestamp;
|
||||
a->bFlags |= (MODES_ACFLAGS_LATLON_VALID | MODES_ACFLAGS_LATLON_REL_OK);
|
||||
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
//=========================================================================
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue