[hamradio-commits] [dump1090] 308/373: B"H decoding: use last air position to calculate ground position

Matthew Ernisse mernisse-guest at moszumanska.debian.org
Thu Oct 23 14:58:30 UTC 2014


This is an automated email from the git hooks/post-receive script.

mernisse-guest pushed a commit to branch backport
in repository dump1090.

commit d1b37ad1c59cfc19930df245174321eada76147b
Author: hhm <heehooman+vcs-ci at gmail.com>
Date:   Mon Jul 14 04:03:07 2014 -0400

    B"H decoding: use last air position to calculate ground position
---
 mode_s.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/mode_s.c b/mode_s.c
index e92cd9b..61ecda4 100644
--- a/mode_s.c
+++ b/mode_s.c
@@ -2022,12 +2022,24 @@ void decodeCPR(struct aircraft *a, int fflag, int surface) {
     double rlat0 = AirDlat0 * (cprModFunction(j,60) + lat0 / 131072);
     double rlat1 = AirDlat1 * (cprModFunction(j,59) + lat1 / 131072);
 
+    time_t now = time(NULL);
+    double surface_rlat = MODES_USER_LATITUDE_DFLT;
+    double surface_rlon = MODES_USER_LONGITUDE_DFLT;
+
     if (surface) {
-        // If we're on the ground, make sure we have our receiver base station Lat/Lon
-        if (0 == (Modes.bUserFlags & MODES_USER_LATLON_VALID))
-            {return;}
-        rlat0 += floor(Modes.fUserLat / 90.0) * 90.0;  // Move from 1st quadrant to our quadrant
-        rlat1 += floor(Modes.fUserLat / 90.0) * 90.0;
+        // If we're on the ground, make sure we have a (likely) valid Lat/Lon
+        if ((a->bFlags & MODES_ACFLAGS_LATLON_VALID) && (((int)(now - a->seenLatLon)) < Modes.interactive_display_ttl)) {
+            surface_rlat = a->lat;
+            surface_rlon = a->lon;
+        } else if (Modes.bUserFlags & MODES_USER_LATLON_VALID) {
+            surface_rlat = Modes.fUserLat;
+            surface_rlon = Modes.fUserLon;
+        } else {
+            surface_rlat = Modes.fUserLat;
+            return;
+        }
+        rlat0 += floor(surface_rlat / 90.0) * 90.0;  // Move from 1st quadrant to our quadrant
+        rlat1 += floor(surface_rlat / 90.0) * 90.0;
     } else {
         if (rlat0 >= 270) rlat0 -= 360;
         if (rlat1 >= 270) rlat1 -= 360;
@@ -2052,7 +2064,7 @@ void decodeCPR(struct aircraft *a, int fflag, int surface) {
     }
 
     if (surface) {
-        a->lon += floor(Modes.fUserLon / 90.0) * 90.0;  // Move from 1st quadrant to our quadrant
+        a->lon += floor(surface_rlon / 90.0) * 90.0;  // Move from 1st quadrant to our quadrant
     } else if (a->lon > 180) {
         a->lon -= 360;
     }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/dump1090.git



More information about the pkg-hamradio-commits mailing list