mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Coordinate stuff
This commit is contained in:
parent
b4f4490805
commit
f7c08e11f9
@ -542,16 +542,59 @@ function POINT_VEC3:ToStringBR( AngleRadians, Distance )
|
|||||||
return s
|
return s
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Provides a Bearing / Range string
|
--- Provides a Lat Lon string
|
||||||
-- @param #POINT_VEC3 self
|
-- @param #POINT_VEC3 self
|
||||||
-- @param #number AngleRadians The angle in randians
|
-- @param #number Accuracy The accurancy of significant numbers behind the comma... So Accurancy of 2 is 0.01.
|
||||||
-- @param #number Distance The distance
|
-- @param #boolean DMS true = Degrees, Minutes, Seconds; false = Degrees, Minutes
|
||||||
-- @return #string The BR Text
|
-- @return #string The LL Text
|
||||||
function POINT_VEC3:ToStringLL( acc, DMS )
|
function POINT_VEC3:ToStringLL( Accuracy, DMS )
|
||||||
|
|
||||||
acc = acc or 3
|
Accuracy = Accuracy or 3
|
||||||
local lat, lon = coord.LOtoLL( self:GetVec3() )
|
local lat, lon = coord.LOtoLL( self:GetVec3() )
|
||||||
return UTILS.tostringLL(lat, lon, acc, DMS)
|
return UTILS.tostringLL( lat, lon, Accuracy, DMS )
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Provides a MGRS string
|
||||||
|
-- @param #POINT_VEC3 self
|
||||||
|
-- @param #number Accuracy of the 5 digit code.
|
||||||
|
-- Precision depends on the Accuracy choosen:
|
||||||
|
-- * 0 = no digits - precision level 100 km
|
||||||
|
-- * 1 = 1 digits - precision level 10 km
|
||||||
|
-- * 2 = 2 digits - precision level 1 km
|
||||||
|
-- * 3 = 3 digits - precision level 100 m
|
||||||
|
-- * 4 = 4 digits - precision level 10 m.
|
||||||
|
-- @return #string The MGRS Text
|
||||||
|
function POINT_VEC3:ToStringMGRS( Accuracy )
|
||||||
|
|
||||||
|
Accuracy = Accuracy or 3
|
||||||
|
local lat, lon = coord.LOtoLL( self:GetVec3() )
|
||||||
|
local MGRS = coord.LLtoMGRS( lat, lon )
|
||||||
|
return UTILS.tostringMGRS( MGRS, Accuracy )
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Provides a coordinate string of the point, based on a coordinate format system:
|
||||||
|
-- * Uses default settings in POINT_VEC3.
|
||||||
|
-- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default.
|
||||||
|
--
|
||||||
|
-- @param #POINT_VEC3 self
|
||||||
|
-- @param Wrapper.Group#GROUP PlayerGroup The specific group with specific settings.
|
||||||
|
-- @return #string The coordinate Text
|
||||||
|
function POINT_VEC3:ToString( PlayerGroup ) --R2.3
|
||||||
|
|
||||||
|
PlayerGroup = PlayerGroup or GROUP
|
||||||
|
|
||||||
|
local CoordFormat = PlayerGroup:GetCoordFormat()
|
||||||
|
|
||||||
|
if CoordFormat == "LL" then
|
||||||
|
return self:ToStringLL( PlayerGroup:GetLLAccuracy(), PlayerGroup:GetLLDMS() )
|
||||||
|
end
|
||||||
|
|
||||||
|
if CoordFormat == "MGRS" then
|
||||||
|
return self:ToStringMGRS( PlayerGroup:GetMGRSAccuracy() )
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Return the altitude text of the POINT_VEC3.
|
--- Return the altitude text of the POINT_VEC3.
|
||||||
|
|||||||
@ -276,6 +276,16 @@ UTILS.tostringLL = function( lat, lon, acc, DMS)
|
|||||||
end
|
end
|
||||||
end
|
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))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- From http://lua-users.org/wiki/SimpleRound
|
--- From http://lua-users.org/wiki/SimpleRound
|
||||||
-- use negative idp for rounding ahead of decimal place, positive for rounding after decimal place
|
-- use negative idp for rounding ahead of decimal place, positive for rounding after decimal place
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user