Update Nav

This commit is contained in:
Frank 2023-11-02 23:42:59 +01:00
parent 23947b7c30
commit befc8207f5
2 changed files with 35 additions and 7 deletions

View File

@ -564,7 +564,6 @@ function NAVPOINT:SetAltMax(Altitude)
return self
end
--- Set mandatory altitude (min alt = max alt).
-- @param #NAVPOINT self
-- @param #number Altitude Altitude in feet.
@ -588,7 +587,6 @@ function NAVPOINT:SetSpeedMin(Speed)
return self
end
--- Set maximum speed.
-- @param #NAVPOINT self
-- @param #number Speed Max speed in knots.
@ -600,6 +598,19 @@ function NAVPOINT:SetSpeedMax(Speed)
return self
end
--- Set mandatory speed (min speed = max speed).
-- @param #NAVPOINT self
-- @param #number Altitude Mandatory speed in knots.
-- @return #NAVPOINT self
function NAVPOINT:SetSpeedMandatory(Speed)
self.speedMin=Speed
self.speedMax=Speed
return self
end
--- Set whether this fix is compulsory.
-- @param #NAVPOINT self
-- @param #boolean Compulsory If `true`, this is a compusory fix. If `false` or nil, it is non-compulsory.
@ -636,6 +647,24 @@ function NAVPOINT:GetAltitude()
return alt
end
--- Get the speed. If min and max speeds are set, it will return a random speed between min and max.
-- @param #NAVPOINT self
-- @return #number Speed in knots. Can be `nil`, if neither min nor max speeds have beeen set.
function NAVPOINT:GetSpeed()
local speed=nil
if self.speedMin and self.speedMax and self.speedMin~=self.speedMax then
speed=math.random(self.speedMin, self.speedMax)
elseif self.speedMin then
speed=self.speedMin
elseif self.speedMax then
speed=self.speedMax
end
return speed
end
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Private Functions
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -3713,15 +3713,14 @@ function FLIGHTGROUP:_SetFlightPlan(FlightPlan)
self:SetDestinationbase(self.flightplan.destinationAirbase)
for i,_fix in pairs(FlightPlan.fixes) do
local fix=_fix --Navigation.NavFix#NAVFIX
local fix=_fix --Navigation.Point#NAVFIX
--fix.coordinate
local speed=fix:GetSpeed() or FlightPlan:GetCruiseSpeed()
local speed=fix.altMin
local altitude=fix:GetAltitude() or FlightPlan:GetCruiseAltitude()
local altitude=(fix.altMin or fix.altMax)~=nil and fix:GetAltitude() or FlightPlan:GetCruiseAltitude()
local wp=self:AddWaypoint(fix.vector, Speed, AfterWaypointWithID, altitude or 10000, false)
local wp=self:AddWaypoint(fix.vector, speed, nil, altitude or 10000, false)
wp.flightplan=FlightPlan
end