From f2c5f5c30fc985c08db91e9229b2750348e3f0c2 Mon Sep 17 00:00:00 2001 From: Jason Milldrum Date: Mon, 19 Jul 2021 13:32:51 -0700 Subject: [PATCH] Add simple lat/lon bounds check --- src/JTEncode.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/JTEncode.cpp b/src/JTEncode.cpp index 6f11b49..fcb7723 100644 --- a/src/JTEncode.cpp +++ b/src/JTEncode.cpp @@ -462,6 +462,20 @@ void JTEncode::latlon_to_grid(float lat, float lon, char* ret_grid) char grid[7]; memset(grid, 0, 7); + // Bounds checks + if(lat < -90.0) { + lat = -90.0; + } + if(lat > 90.0) { + lat = 90.0; + } + if(lon < -180.0) { + lon = -180.0; + } + if(lon > 180.0) { + lon = 180.0; + } + // Normalize lat and lon lon += 180.0; lat += 90.0;