Prefer to use global CPR decoding where possible.
There is a danger in always using relative decoding where possible. If there is an undetected error in the first pair of messages received, then global CPR decoding will give a bad position, and subsequent relative decoding will just walk around near that bad position even though many error-free pairs of odd/even messages may have been received. The first pair of position messages also tends to be the most error-prone, as they are usually received at the extreme edge of receiver range. (I see this happen at least once a day in practice) So, instead, prefer to use global decoding when we have sufficiently recent data. With recent data this should always be as good as relative decoding, and it avoids getting stuck with bad data for long periods of time. If we don't have enough recent data for a global solution, fall back to relative decoding.
This commit is contained in:
parent
a82df07c0c
commit
661246d347
3 changed files with 24 additions and 22 deletions
|
|
@ -343,6 +343,7 @@ struct aircraft *interactiveReceiveData(struct modesMessage *mm) {
|
|||
|
||||
// If we've got a new cprlat or cprlon
|
||||
if (mm->bFlags & MODES_ACFLAGS_LLEITHER_VALID) {
|
||||
int location_ok = 0;
|
||||
|
||||
if (mm->bFlags & MODES_ACFLAGS_LLODD_VALID) {
|
||||
a->odd_cprlat = mm->raw_latitude;
|
||||
|
|
@ -354,23 +355,23 @@ struct aircraft *interactiveReceiveData(struct modesMessage *mm) {
|
|||
a->even_cprtime = mstime();
|
||||
}
|
||||
|
||||
if (((mm->bFlags | a->bFlags) & MODES_ACFLAGS_LLEITHER_VALID) == MODES_ACFLAGS_LLBOTH_VALID) {
|
||||
// If we now have both even and odd, decode the CPR
|
||||
|
||||
// Try relative CPR first
|
||||
if (decodeCPRrelative(a, (mm->bFlags & MODES_ACFLAGS_LLODD_VALID), (mm->bFlags & MODES_ACFLAGS_AOG))) {
|
||||
// If relative CPR fails then try global if the two data are less than 10 seconds apart
|
||||
if (abs((int)(a->even_cprtime - a->odd_cprtime)) <= 10000) {
|
||||
decodeCPR(a, (mm->bFlags & MODES_ACFLAGS_LLODD_VALID), (mm->bFlags & MODES_ACFLAGS_AOG));
|
||||
}
|
||||
// If we have enough recent data, try global CPR
|
||||
if (((mm->bFlags | a->bFlags) & MODES_ACFLAGS_LLEITHER_VALID) == MODES_ACFLAGS_LLBOTH_VALID && abs((int)(a->even_cprtime - a->odd_cprtime)) <= 10000) {
|
||||
if (decodeCPR(a, (mm->bFlags & MODES_ACFLAGS_LLODD_VALID), (mm->bFlags & MODES_ACFLAGS_AOG)) == 0) {
|
||||
location_ok = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//If we sucessfully decoded, back copy the results to mm so that we can print them in list output
|
||||
if (a->bFlags & MODES_ACFLAGS_LATLON_VALID) {
|
||||
mm->bFlags |= MODES_ACFLAGS_LATLON_VALID;
|
||||
mm->fLat = a->lat;
|
||||
mm->fLon = a->lon;
|
||||
}
|
||||
// Otherwise try relative CPR.
|
||||
if (!location_ok && decodeCPRrelative(a, (mm->bFlags & MODES_ACFLAGS_LLODD_VALID), (mm->bFlags & MODES_ACFLAGS_AOG)) == 0) {
|
||||
location_ok = 1;
|
||||
}
|
||||
|
||||
//If we sucessfully decoded, back copy the results to mm so that we can print them in list output
|
||||
if (location_ok) {
|
||||
mm->bFlags |= MODES_ACFLAGS_LATLON_VALID;
|
||||
mm->fLat = a->lat;
|
||||
mm->fLon = a->lon;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue