From 8d0d16c30a02dd577a7cf7f785aa02744f9578ba Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Mon, 12 Jan 2015 16:29:24 +0000 Subject: [PATCH] When sanity-checking relative CPR results, use the correct relative location (which may not be the aircraft location). I suspect this sanity check is, in fact, redundant now that the rest of the algorithm has had some bugs fixed; it should only produce results within half a cell by definition. --- mode_s.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mode_s.c b/mode_s.c index 3515018..decd532 100644 --- a/mode_s.c +++ b/mode_s.c @@ -2630,7 +2630,7 @@ int decodeCPRrelative(struct aircraft *a, int fflag, int surface) { } // Check to see that answer is reasonable - ie no more than 1/2 cell away - if (fabs(rlat - a->lat) > (AirDlat/2)) { + if (fabs(rlat - latr) > (AirDlat/2)) { a->bFlags &= ~MODES_ACFLAGS_LATLON_REL_OK; // This will cause a quick exit next time if no global has been done return (-1); // Time to give up - Latitude error } @@ -2643,7 +2643,7 @@ int decodeCPRrelative(struct aircraft *a, int fflag, int surface) { if (rlon > 180) rlon -= 360; // Check to see that answer is reasonable - ie no more than 1/2 cell away - if (fabs(rlon - a->lon) > (AirDlon/2)) { + if (fabs(rlon - lonr) > (AirDlon/2)) { a->bFlags &= ~MODES_ACFLAGS_LATLON_REL_OK; // This will cause a quick exit next time if no global has been done return (-1); // Time to give up - Longitude error }