mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-23 19:45:29 +00:00
Update Beacons.lua
- Added excludelist to GetClosestBeacon function
This commit is contained in:
@@ -90,7 +90,7 @@ BEACONS = {
|
|||||||
|
|
||||||
--- BEACONS class version.
|
--- BEACONS class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
BEACONS.version="0.0.3"
|
BEACONS.version="0.0.4"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- ToDo list
|
-- ToDo list
|
||||||
@@ -209,20 +209,24 @@ end
|
|||||||
-- @param #BEACONS self
|
-- @param #BEACONS self
|
||||||
-- @param Core.Point#COORDINATE Coordinate The reference coordinate.
|
-- @param Core.Point#COORDINATE Coordinate The reference coordinate.
|
||||||
-- @param #number TypeID (Optional) Only search for specific beacon types, *e.g.* `BEACON.Type.TACAN`.
|
-- @param #number TypeID (Optional) Only search for specific beacon types, *e.g.* `BEACON.Type.TACAN`.
|
||||||
|
-- @param #number DistMax (Optional) Max search distance in meters.
|
||||||
|
-- @param #table ExcludeList (Optional) List of beacons to exclude.
|
||||||
-- @return #BEACONS.Beacon The closest beacon.
|
-- @return #BEACONS.Beacon The closest beacon.
|
||||||
function BEACONS:GetClosestBeacon(Coordinate, TypeID)
|
function BEACONS:GetClosestBeacon(Coordinate, TypeID, DistMax, ExcludeList)
|
||||||
|
|
||||||
local beacon=nil --#BEACONS.Beacon
|
local beacon=nil --#BEACONS.Beacon
|
||||||
local distmin=math.huge
|
local distmin=math.huge
|
||||||
|
|
||||||
|
ExcludeList=ExcludeList or {}
|
||||||
|
|
||||||
for _,_beacon in pairs(self.beacons) do
|
for _,_beacon in pairs(self.beacons) do
|
||||||
local bc=_beacon --#BEACONS.Beacon
|
local bc=_beacon --#BEACONS.Beacon
|
||||||
|
|
||||||
if TypeID==nil or TypeID==bc.type then
|
if (TypeID==nil or TypeID==bc.type) and (not UTILS.IsInTable(ExcludeList, bc, "beaconId")) then
|
||||||
|
|
||||||
local dist=Coordinate:Get2DDistance(bc.vec3)
|
local dist=Coordinate:Get2DDistance(bc.vec3)
|
||||||
|
|
||||||
if dist<distmin then
|
if dist<distmin and (DistMax==nil or dist<=DistMax) then
|
||||||
distmin=dist
|
distmin=dist
|
||||||
beacon=bc
|
beacon=bc
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user