From 0ee30532eedfdf95ea996a3b03761b9df89e4f60 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 13 Aug 2024 10:30:36 +0200 Subject: [PATCH] #ATIS - Polar circle fixes --- Moose Development/Moose/Core/Point.lua | 4 ++-- Moose Development/Moose/Ops/ATIS.lua | 6 ++++-- Moose Development/Moose/Utilities/Utils.lua | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index 3bf9c0dd1..fd990d7fb 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -2669,7 +2669,7 @@ do -- COORDINATE local date=UTILS.GetDCSMissionDate() -- Debug output. - self:I(string.format("Sun rise at lat=%.3f long=%.3f on %s (DayOfYear=%d): %s (%d sec of the day) (GMT %d)", Latitude, Longitude, date, DayOfYear, tostring(UTILS.SecondsToClock(sunrise)), sunrise, Tdiff)) + --self:I(string.format("Sun rise at lat=%.3f long=%.3f on %s (DayOfYear=%d): %s (%s sec of the day) (GMT %d)", Latitude, Longitude, date, DayOfYear, tostring(UTILS.SecondsToClock(sunrise)), tonumber(sunrise) or "0", Tdiff)) if InSeconds or type(sunrise) == "string" then return sunrise @@ -2837,7 +2837,7 @@ do -- COORDINATE local date=UTILS.GetDCSMissionDate() -- Debug output. - self:I(string.format("Sun set at lat=%.3f long=%.3f on %s (DayOfYear=%d): %s (%d sec of the day) (GMT %d)", Latitude, Longitude, date, DayOfYear, tostring(UTILS.SecondsToClock(sunrise)), sunrise, Tdiff)) + --self:I(string.format("Sun set at lat=%.3f long=%.3f on %s (DayOfYear=%d): %s (%s sec of the day) (GMT %d)", Latitude, Longitude, date, DayOfYear, tostring(UTILS.SecondsToClock(sunrise)), tostring(sunrise) or "0", Tdiff)) if InSeconds or type(sunrise) == "string" then return sunrise diff --git a/Moose Development/Moose/Ops/ATIS.lua b/Moose Development/Moose/Ops/ATIS.lua index a5b577dde..7b0d71961 100644 --- a/Moose Development/Moose/Ops/ATIS.lua +++ b/Moose Development/Moose/Ops/ATIS.lua @@ -1975,8 +1975,9 @@ function ATIS:onafterBroadcast( From, Event, To ) local hours = self.gettext:GetEntry("HOURS",self.locale) local sunrise = coord:GetSunrise() + --self:I(sunrise) local SUNRISE = "no time" - if tostring(sunrise) ~= "N/R" then + if tostring(sunrise) ~= "N/S" and tostring(sunrise) ~= "N/R" then sunrise = UTILS.Split( sunrise, ":" ) SUNRISE = string.format( "%s%s", sunrise[1], sunrise[2] ) if self.useSRS then @@ -1985,8 +1986,9 @@ function ATIS:onafterBroadcast( From, Event, To ) end local sunset = coord:GetSunset() + --self:I(sunset) local SUNSET = "no time" - if tostring(sunset) ~= "N/S" then + if tostring(sunset) ~= "N/S" and tostring(sunset) ~= "N/R" then sunset = UTILS.Split( sunset, ":" ) SUNSET = string.format( "%s%s", sunset[1], sunset[2] ) if self.useSRS then diff --git a/Moose Development/Moose/Utilities/Utils.lua b/Moose Development/Moose/Utilities/Utils.lua index d347cc082..ef92696e6 100644 --- a/Moose Development/Moose/Utilities/Utils.lua +++ b/Moose Development/Moose/Utilities/Utils.lua @@ -1221,7 +1221,7 @@ function UTILS.SecondsToClock(seconds, short) end -- Seconds - local seconds = tonumber(seconds) + local seconds = tonumber(seconds) or 0 -- Seconds of this day. local _seconds=seconds%(60*60*24) @@ -2122,9 +2122,9 @@ function UTILS.GetSunRiseAndSet(DayOfYear, Latitude, Longitude, Rising, Tlocal) local cosH = (cos(zenith) - (sinDec * sin(latitude))) / (cosDec * cos(latitude)) if rising and cosH > 1 then - return "N/R" -- The sun never rises on this location on the specified date + return "N/S" -- The sun never rises on this location on the specified date elseif cosH < -1 then - return "N/S" -- The sun never sets on this location on the specified date + return "N/R" -- The sun never sets on this location on the specified date end -- Finish calculating H and convert into hours