From 5eaa62d59ceff6105b8159ba742aa875f3fe579c Mon Sep 17 00:00:00 2001 From: Raphael Geissert Date: Sat, 8 Aug 2015 13:47:05 +0200 Subject: [PATCH 1/3] Use invoke-rc.d to restart lighttpd as per Debian policy --- debian/dump1090-mutability.postinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/dump1090-mutability.postinst b/debian/dump1090-mutability.postinst index ae7935e..d24781f 100644 --- a/debian/dump1090-mutability.postinst +++ b/debian/dump1090-mutability.postinst @@ -126,7 +126,7 @@ case "$1" in if [ -e /etc/lighttpd/conf-enabled/89-dump1090.conf ]; then if dpkg --compare-versions "$2" le "1.14"; then echo "Restarting lighttpd.." >&2 - service lighttpd restart || echo "Warning: lighttpd failed to restart." >&2 + invoke-rc.d lighttpd restart || echo "Warning: lighttpd failed to restart." >&2 fi fi ;; From 6d37952b14b93922236ec98e2b926878ef98edd7 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Mon, 17 Aug 2015 18:06:37 +0100 Subject: [PATCH 2/3] Add tests for surface decoding at the poles/equator. --- cprtests.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cprtests.c b/cprtests.c index 182aa19..751ba80 100644 --- a/cprtests.c +++ b/cprtests.c @@ -73,6 +73,13 @@ static const struct { { 7.00, 0.00, 105730, 9259, 29693, 8997, 0, 52.209984 - 90.0, 0.135269, 0, 52.209976 - 90.0, 0.134299 }, { -52.00, 0.00, 105730, 9259, 29693, 8997, 0, 52.209984 - 90.0, 0.135269, 0, 52.209976 - 90.0, 0.134299 }, { -90.00, 0.00, 105730, 9259, 29693, 8997, 0, 52.209984 - 90.0, 0.135269, 0, 52.209976 - 90.0, 0.134299 }, + + // poles/equator cases + { -46.00, -180.00, 0, 0, 0, 0, 0, -90.0, -180.000000, 0, -90.0, -180.0 }, // south pole + { -44.00, -180.00, 0, 0, 0, 0, 0, 0.0, -180.000000, 0, 0.0, -180.0 }, // equator + { 44.00, -180.00, 0, 0, 0, 0, 0, 0.0, -180.000000, 0, 0.0, -180.0 }, // equator + { 46.00, -180.00, 0, 0, 0, 0, 0, 90.0, -180.000000, 0, 90.0, -180.0 }, // north pole + }; // Relative CPR test data: @@ -138,7 +145,6 @@ static const struct { { 52.00, 1.40, 29693, 8997, 1, 1, 0, 52.209976, 0.176507 }, // odd, surface { 52.00, -1.05, 105730, 9259, 0, 1, 0, 52.209984, 0.176601 }, // even, surface { 52.00, -1.05, 29693, 8997, 1, 1, 0, 52.209976, 0.176507 }, // odd, surface - }; static int testCPRGlobalAirborne() { @@ -215,7 +221,7 @@ static int testCPRGlobalSurface() { || fabs(rlon - cprGlobalSurfaceTests[i].even_rlon) > 1e-6) { ok = 0; fprintf(stderr, - "testCPRGlobalSurface[%d]: FAIL: decodeCPRsurface(%.6f,%.6f,%d,%d,%d,%d,EVEN) failed:\n" + "testCPRGlobalSurface[%d,EVEN]: FAIL: decodeCPRsurface(%.6f,%.6f,%d,%d,%d,%d,EVEN) failed:\n" " result %d (expected %d)\n" " lat %.6f (expected %.6f)\n" " lon %.6f (expected %.6f)\n", From e438e1e0c54f82c8c3489f4d8058941a1672bd3c Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Mon, 17 Aug 2015 18:07:40 +0100 Subject: [PATCH 3/3] Fix decoding of even lat=0 + odd lat=0 which can have 3 results (-90, 0, +90) --- cpr.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/cpr.c b/cpr.c index d641670..3f8187b 100644 --- a/cpr.c +++ b/cpr.c @@ -250,8 +250,26 @@ int decodeCPRsurface(double reflat, double reflon, // reflat=-40, rlat=4, use rlat=4 // reflat=-40, rlat=6, use rlat=6-90 = -84 - if ( (rlat0 - reflat) > 45 ) rlat0 -= 90; - if ( (rlat1 - reflat) > 45 ) rlat1 -= 90; + // As a special case, -90, 0 and +90 all encode to zero, so + // there's a little extra work to do there. + + if (rlat0 == 0) { + if (reflat < -45) + rlat0 = -90; + else if (reflat > 45) + rlat0 = 90; + } else if ((rlat0 - reflat) > 45) { + rlat0 -= 90; + } + + if (rlat1 == 0) { + if (reflat < -45) + rlat1 = -90; + else if (reflat > 45) + rlat1 = 90; + } else if ((rlat1 - reflat) > 45) { + rlat1 -= 90; + } // Check to see that the latitude is in range: -90 .. +90 if (rlat0 < -90 || rlat0 > 90 || rlat1 < -90 || rlat1 > 90)