From a834db5f1fc47ac4c5c485a7fc8ee5fe2cb6f2a1 Mon Sep 17 00:00:00 2001 From: Richard Meadows Date: Mon, 29 Jun 2015 22:08:31 +0100 Subject: [PATCH] Fix point_in_poly. We need to interpolate along diagonal boarder lines which is kinda going to need floating point --- firmware/src/location.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/firmware/src/location.c b/firmware/src/location.c index 36f514d..160164b 100644 --- a/firmware/src/location.c +++ b/firmware/src/location.c @@ -59,7 +59,7 @@ bool point_in_polygon(const int32_t* poly, uint32_t points, int32_t x, int32_t y if (((polyY(i) < y && polyY(j) >= y) || (polyY(j) < y && polyY(i) >= y)) && (polyX(i) <= x || polyX(j) <= x)) { - if (polyX(i) + (y-polyY(i)) / (polyY(j) - polyY(i)) * (polyX(j)-polyX(i)) < x) { + if (polyX(i) + (float)(y-polyY(i)) / (polyY(j) - polyY(i)) * (polyX(j)-polyX(i)) < x) { oddNodes =! oddNodes; } } @@ -98,10 +98,8 @@ bool latlon_in_aprs_zone(int32_t aprs_zone, int32_t aprs_zone_outline, float lon */ bool aprs_location_tx_allow(void) { - /* Not in any zone, or in a zone other than Alpha, or not airbourne */ - return (current_aprs_zone == -1) || - (current_aprs_zone > 0) || - (_altitude < 200); + /* Not in any zone, or in a zone other than Alpha */ + return (current_aprs_zone == -1) || (current_aprs_zone > 0); } /** * Returns the aprs frequency in the current zone.