Limit reported GPS precision (#1304)

This commit is contained in:
Tim Wilkinson 2024-08-17 20:37:38 -07:00 committed by GitHub
parent 65209f1c98
commit 7cf522de47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -583,8 +583,12 @@ function hardware.gps_read_llt(gps, maxlines)
local j = gps_read(s)
if j.class == "TPV" then
info.time = j.time:gsub("T", " "):gsub(".000Z", "")
info.lat = j.lat
info.lon = j.lon
if j.lat then
info.lat = tonumber(string.format("%.5f", j.lat))
end
if j.lon then
info.lon = tonumber(string.format("%.5f", j.lon))
end
break
end
maxlines = maxlines - 1

View File

@ -85,6 +85,7 @@ function app.run()
local clat = tonumber(c:get("aredn", "@location[0]", "lat") or 0)
local clon = tonumber(c:get("aredn", "@location[0]", "lon") or 0)
if math.abs(clat - j.lat) > CHANGEMARGIN or math.abs(clon - j.lon) > CHANGEMARGIN then
nixio.syslog("notice", "Updating lat/lon: " .. j.lat .. "," .. j.lon)
-- Calculate gridsquare from lat/lon
local alat = j.lat + 90
local flat = 65 + math.floor(alat / 10)