From b885085a746291121ae1db7f99f86c1ef6f6184b Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 8 Apr 2013 09:43:04 +0200 Subject: [PATCH] Fix longitude error for southern hemisphere. The problem was the cprModFunction() not calculating the absolute value of the latitude, so the table only worked for the northen hemisphere. Thanks to @pwarren for finding the bug. This fixes issue #13. --- dump1090.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dump1090.c b/dump1090.c index 801bd70..04ed42e 100644 --- a/dump1090.c +++ b/dump1090.c @@ -1610,6 +1610,7 @@ int cprModFunction(int a, int b) { /* The NL function uses the precomputed table from 1090-WP-9-14 */ int cprNLFunction(double lat) { + if (lat < 0) lat = -lat; /* Table is simmetric about the equator. */ if (lat < 10.47047130) return 59; if (lat < 14.82817437) return 58; if (lat < 18.18626357) return 57;