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) 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", 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 ;;