From cb11de6f9ccfd6fe5bc4a45a624b19212125899d Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 2 Aug 2023 10:53:28 +0200 Subject: [PATCH] Navigation - Added NavFix --- Moose Development/Moose/Modules.lua | 1 + Moose Development/Moose/Navigation/NavFix.lua | 196 ++++++++++++++++++ Moose Development/Moose/Utilities/Utils.lua | 12 ++ 3 files changed, 209 insertions(+) create mode 100644 Moose Development/Moose/Navigation/NavFix.lua diff --git a/Moose Development/Moose/Modules.lua b/Moose Development/Moose/Modules.lua index 3bc9b35dd..1cf658ed6 100644 --- a/Moose Development/Moose/Modules.lua +++ b/Moose Development/Moose/Modules.lua @@ -116,6 +116,7 @@ __Moose.Include( 'Scripts/Moose/Ops/Squadron.lua' ) __Moose.Include( 'Scripts/Moose/Ops/Target.lua' ) __Moose.Include( 'Scripts/Moose/Navigation/Navaid.lua' ) +__Moose.Include( 'Scripts/Moose/Navigation/NavFix.lua' ) __Moose.Include( 'Scripts/Moose/Navigation/FlightPlan.lua' ) __Moose.Include( 'Scripts/Moose/AI/AI_Balancer.lua' ) diff --git a/Moose Development/Moose/Navigation/NavFix.lua b/Moose Development/Moose/Navigation/NavFix.lua new file mode 100644 index 000000000..7ebdee888 --- /dev/null +++ b/Moose Development/Moose/Navigation/NavFix.lua @@ -0,0 +1,196 @@ +--- **NAVIGATION** - Navigation Airspace Fix. +-- +-- **Main Features:** +-- +-- * Stuff +-- * More Stuff +-- +-- === +-- +-- ## Example Missions: +-- +-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Navigation%20-%20NavFix). +-- +-- === +-- +-- ### Author: **funkyfranky** +-- +-- === +-- @module Navigation.NavFix +-- @image NAVIGATION_NavFix.png + + +--- NAVFIX class. +-- @type NAVFIX +-- @field #string ClassName Name of the class. +-- @field #number verbose Verbosity of output. +-- @field #string name Name of the fix. +-- @field Core.Point#COORDINATE coordinate Coordinate of the fix. +-- @field Wrapper.Marker#MARKER marker Marker of fix on F10 map. +-- @field #boolean isCompulsory Is this a compulsory fix. +-- @field #boolean isFlyover Is this a fly over fix. +-- @field #boolean isIAF Is initial approach fix (IAF). +-- @field #boolean isIF Is intermediate fix (IF). +-- +-- @extends Core.Base#BASE + +--- *A fleet of British ships at war are the best negotiators.* -- Horatio Nelson +-- +-- === +-- +-- # The NAVFIX Concept +-- +-- The NAVFIX class has a great concept! +-- +-- # Basic Setup +-- +-- A new `NAVFIX` object can be created with the @{#NAVFIX.New}() function. +-- +-- myTemplate=NAVFIX:New() +-- myTemplate:SetXYZ(X, Y, Z) +-- +-- This is how it works. +-- +-- @field #NAVFIX +NAVFIX = { + ClassName = "NAVFIX", + verbose = 0, +} + +--- Type of navaid +-- @type NAVFIX.Type +-- @field #string VOR VOR +-- @field #string NDB NDB +NAVFIX.Type={ + VOR="VOR", + NDB="NDB", +} + +--- NAVFIX class version. +-- @field #string version +NAVFIX.version="0.0.1" + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- ToDo list +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +-- TODO: A lot... + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- Constructor +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +--- Create a new NAVFIX class instance. +-- @param #NAVFIX self +-- @return #NAVFIX self +function NAVFIX:New(Coordinate, Name) + + -- Inherit everything from SCENERY class. + self=BASE:Inherit(self, BASE:New()) -- #NAVFIX + + self.coordinate=Coordinate + + self.name=Name + + self.marker=MARKER:New(Coordinate, self:_GetMarkerText()) + self.marker:ToAll() + + return self +end + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- User Functions +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +--- Set minimum altitude. +-- @param #NAVFIX self +-- @param #number Altitude Min altitude in feet. +-- @return #NAVFIX self +function NAVFIX:SetAltMin(Altitude) + + self.altMin=Altitude + + return self +end + +--- Set maximum altitude. +-- @param #NAVFIX self +-- @param #number Altitude Max altitude in feet. +-- @return #NAVFIX self +function NAVFIX:SetAltMax(Altitude) + + self.altMax=Altitude + + return self +end + +--- Set whether this fix is compulsory. +-- @param #NAVFIX self +-- @param #boolean Compulsory If `true`, this is a compusory fix. If `false` or nil, it is non-compulsory. +-- @return #NAVFIX self +function NAVFIX:SetCompulsory(Compulsory) + self.isCompulsory=Compulsory + return self +end + +--- Set whether this fix is compulsory. +-- @param #NAVFIX self +-- @param #boolean FlyOver If `true`, this is a fly over fix. If `false` or nil, it is not. +-- @return #NAVFIX self +function NAVFIX:SetFlyOver(FlyOver) + self.isFlyover=FlyOver + return self +end + +--- Set whether this is the intermediate fix. +-- @param #NAVFIX self +-- @param #boolean IntermediateFix If `true`, this is an intermediate fix. +-- @return #NAVFIX self +function NAVFIX:SetIntermediateFix(IntermediateFix) + self.isIF=IntermediateFix + return self +end + +--- Set whether this is an initial approach fix (IAF). +-- @param #NAVFIX self +-- @param #boolean IntermediateFix If `true`, this is an intermediate fix. +-- @return #NAVFIX self +function NAVFIX:SetInitialApproachFix(IntermediateFix) + self.isIAF=IntermediateFix + return self +end + + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- Private Functions +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +--- Get text displayed in the F10 marker. +-- @param #NAVFIX self +-- @return #string Marker text. +function NAVFIX:_GetMarkerText() + + local altmin=self.altMin and tostring(self.altMin) or "" + local altmax=self.altMax and tostring(self.altMax) or "" + local speedmin=self.speedMin and tostring(self.speedMin) or "" + local speedmax=self.speedMax and tostring(self.speedMax) or "" + + + local text=string.format("NAVFIX %s", self.name) + if self.isIAF then + text=text..string.format(" (IAF)") + end + if self.isIF then + text=text..string.format(" (IF)") + end + text=text..string.format("\nAltitude: %s - %s", altmin, altmax) + text=text..string.format("\nSpeed: %s - %s", speedmin, speedmax) + text=text..string.format("\nCompulsory: %s", tostring(self.isCompulsory)) + text=text..string.format("\nFly Over: %s", tostring(self.isFlyover)) + + return text +end + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/Moose Development/Moose/Utilities/Utils.lua b/Moose Development/Moose/Utilities/Utils.lua index 99c643a7a..4980eb48f 100644 --- a/Moose Development/Moose/Utilities/Utils.lua +++ b/Moose Development/Moose/Utilities/Utils.lua @@ -555,6 +555,18 @@ UTILS.kg2lbs = function( kg ) return kg * 2.20462 end +--- Convert latitude or longitude from degrees, minutes, seconds (DMS) to decimal degrees (DD). +-- @param #number Degrees Degrees in grad. +-- @param #number Minutes Minutes. +-- @param #number Seconds Seconds. +-- @return #number Latitude or Longitude in decimal degrees. +UTILS.LLDMSToDD = function(Degrees, Minutes, Seconds) + + local dd=(Degrees or 0) + (Minutes or 0)/60 + (Seconds or 0)/3600 + + return dd +end + --[[acc: in DM: decimal point of minutes. In DMS: decimal point of seconds.