Merge pull request #1284 from FlightControl-Master/FF/Develop

MGRS
This commit is contained in:
Frank 2020-02-26 20:52:48 +01:00 committed by GitHub
commit e3d6337481
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 15 deletions

View File

@ -1095,7 +1095,7 @@ do -- COORDINATE
-- Airbase parameters for takeoff and landing points.
if airbase then
local AirbaseID = airbase:GetID()
local AirbaseCategory = airbase:GetDesc().category
local AirbaseCategory = airbase:GetAirbaseCategory()
if AirbaseCategory == Airbase.Category.SHIP or AirbaseCategory == Airbase.Category.HELIPAD then
RoutePoint.linkUnit = AirbaseID
RoutePoint.helipadId = AirbaseID

View File

@ -1545,7 +1545,7 @@ function SPAWN:SpawnAtAirbase( SpawnAirbase, Takeoff, TakeoffAltitude, TerminalT
-- Get airbase ID and category.
local AirbaseID = SpawnAirbase:GetID()
local AirbaseCategory = SpawnAirbase:GetDesc().category
local AirbaseCategory = SpawnAirbase:GetAirbaseCategory()
self:F( { AirbaseCategory = AirbaseCategory } )
-- Set airdromeId.
@ -1983,7 +1983,7 @@ function SPAWN:ParkAircraft( SpawnAirbase, TerminalType, Parkingdata, SpawnIndex
-- Get airbase ID and category.
local AirbaseID = SpawnAirbase:GetID()
local AirbaseCategory = SpawnAirbase:GetDesc().category
local AirbaseCategory = SpawnAirbase:GetAirbaseCategory()
self:F( { AirbaseCategory = AirbaseCategory } )
-- Set airdromeId.

View File

@ -3416,7 +3416,7 @@ function RAT:_GetAirportsOfCoalition()
for _,coalition in pairs(self.ctable) do
for _,_airport in pairs(self.airports_map) do
local airport=_airport --Wrapper.Airbase#AIRBASE
local category=airport:GetDesc().category
local category=airport:GetAirbaseCategory()
if airport:GetCoalition()==coalition then
-- Planes cannot land on FARPs.
--local condition1=self.category==RAT.cat.plane and airport:GetTypeName()=="FARP"
@ -3847,7 +3847,7 @@ function RAT:_OnBirth(EventData)
-- Check if any unit of the group was spawned on top of another unit in the MOOSE data base.
local ontop=false
if self.checkontop and (_airbase and _airbase:GetDesc().category==Airbase.Category.AIRDROME) then
if self.checkontop and (_airbase and _airbase:GetAirbaseCategory()==Airbase.Category.AIRDROME) then
ontop=self:_CheckOnTop(SpawnGroup, self.ontopradius)
end
@ -4457,7 +4457,7 @@ function RAT:_Waypoint(index, description, Type, Coord, Speed, Altitude, Airport
if (Airport~=nil) and (Type~=RAT.wp.air) then
local AirbaseID = Airport:GetID()
local AirbaseCategory = Airport:GetDesc().category
local AirbaseCategory = Airport:GetAirbaseCategory()
if AirbaseCategory == Airbase.Category.SHIP then
RoutePoint.linkUnit = AirbaseID
RoutePoint.helipadId = AirbaseID
@ -5141,7 +5141,7 @@ function RAT:_ModifySpawnTemplate(waypoints, livery, spawnplace, departure, take
local spawnonrunway=false
local spawnonairport=false
if spawnonground then
local AirbaseCategory = departure:GetDesc().category
local AirbaseCategory = departure:GetAirbaseCategory()
if AirbaseCategory == Airbase.Category.SHIP then
spawnonship=true
elseif AirbaseCategory == Airbase.Category.HELIPAD then

View File

@ -282,7 +282,7 @@
--
-- Assets of the warehouse can be requested by other MOOSE warehouses. A request will first be scrutinized to check if can be fulfilled at all. If the request is valid, it is
-- put into the warehouse queue and processed as soon as possible.
--
-- Requested assets spawn in various "Rule of Engagement Rules" (ROE) and Alerts modes. If your assets will cross into dangerous areas, be sure to change these states. You can do this in @{#WAREHOUSE:OnAfterAssetSpawned}(*From, *Event, *To, *group, *asset, *request)) function.
--
-- Initial Spawn states is as follows:
@ -3011,7 +3011,7 @@ end
function WAREHOUSE:GetAirbaseCategory()
local category=-1
if self.airbase then
category=self.airbase:GetDesc().category
category=self.airbase:GetAirbaseCategory()
end
return category
end

View File

@ -471,15 +471,31 @@ end
-- acc- the accuracy of each easting/northing. 0, 1, 2, 3, 4, or 5.
UTILS.tostringMGRS = function(MGRS, acc) --R2.1
if acc == 0 then
return MGRS.UTMZone .. ' ' .. MGRS.MGRSDigraph
else
--return MGRS.UTMZone .. ' ' .. MGRS.MGRSDigraph .. ' ' .. string.format('%0' .. acc .. 'd', UTILS.Round(MGRS.Easting/(10^(5-acc)), 0))
-- .. ' ' .. string.format('%0' .. acc .. 'd', UTILS.Round(MGRS.Northing/(10^(5-acc)), 0))
-- Test if Easting/Northing have less than 4 digits.
--MGRS.Easting=123 -- should be 00123
--MGRS.Northing=5432 -- should be 05432
-- Truncate rather than round MGRS grid!
return string.format("%s %s %s %s", MGRS.UTMZone, MGRS.MGRSDigraph, string.sub(tostring(MGRS.Easting), 1, acc), string.sub(tostring(MGRS.Northing), 1, acc))
-- Truncate rather than round MGRS grid!
local Easting=tostring(MGRS.Easting)
local Northing=tostring(MGRS.Northing)
-- Count number of missing digits. Easting/Northing should have 5 digits. However, it is passed as a number. Therefore, any leading zeros would not be displayed by lua.
local nE=5-string.len(Easting)
local nN=5-string.len(Northing)
-- Get leading zeros (if any).
for i=1,nE do Easting="0"..Easting end
for i=1,nN do Northing="0"..Northing end
-- Return MGRS string.
return string.format("%s %s %s %s", MGRS.UTMZone, MGRS.MGRSDigraph, string.sub(Easting, 1, acc), string.sub(Northing, 1, acc))
end
end

View File

@ -952,7 +952,7 @@ function AIRBASE:CheckOnRunWay(group, radius, despawn)
radius=radius or 50
-- We only check at real airbases (not FARPS or ships).
if self:GetDesc().category~=Airbase.Category.AIRDROME then
if self:GetAirbaseCategory()~=Airbase.Category.AIRDROME then
return false
end

View File

@ -1922,7 +1922,7 @@ function GROUP:RespawnAtCurrentAirbase(SpawnTemplate, Takeoff, Uncontrolled) --
-- Aibase id and category.
local AirbaseID = airbase:GetID()
local AirbaseCategory = airbase:GetDesc().category
local AirbaseCategory = airbase:GetAirbaseCategory()
if AirbaseCategory == Airbase.Category.SHIP or AirbaseCategory == Airbase.Category.HELIPAD then
SpawnPoint.linkUnit = AirbaseID