-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
This problem affects modules that use DMS precision=0, such as AV8 Harrier. A latlon entry with 60 seconds is invalid and will not be accepted by AV8 nav system.
Repro:
- slot into Harrier, or other DMS precision=0 module
- enable 'L/L'
- in F10 map go to a lat or lon location that has seconds > 59.5
- click 'L/L'
- Notice the reported lat/lon will have seconds = 60
Cause: Lua's string.format() will round to the nearest decimal whole number to accomodate precision spec. However in the case of sexagesimal systems it will not know to rollover 60 seconds to the next minute+1, seconds=0.
Fix:
diff --git a/Scripts/Hooks/scratchpad-hook.lua b/Scripts/Hooks/scratchpad-hook.lua
index 8c262e5..b63e53c 100644
--- a/Scripts/Hooks/scratchpad-hook.lua
+++ b/Scripts/Hooks/scratchpad-hook.lua
@@ -610,6 +610,14 @@ local function loadScratchpad()
m = math.floor(m)
local s = d * 3600 - g * 3600 - m * 60
s = math.floor(s * 100) / 100
+ if precision == 0 and s >= 59.5 then
+ s = 0
+ m = m + 1
+ if m > 59 then
+ m = 0
+ g = g + 1
+ end
+ end
return string.format('%s %0'..degreesWidth..'d°%.2d\'%0'..(precision+2)..'.'..precision..'f', h, g, m, s)
elseif format == "DDM" then -- Degree Decimal Minutes
Metadata
Metadata
Assignees
Labels
No labels