Difference between revisions of "DCS func MGRStoLL"

From DCS World Wiki - Hoggitworld.com
 
(One intermediate revision by the same user not shown)
Line 10: Line 10:
  
 
|desc= Returns multiple values of a given in MGRS coordinates and converts it to latitude, longitude, and altitude
 
|desc= Returns multiple values of a given in MGRS coordinates and converts it to latitude, longitude, and altitude
 +
MGRS Table:
 +
MGRS = {
 +
  UTMZone = string,
 +
  MGRSDigraph = string,
 +
  Easting = number,
 +
  Northing = number
 +
}
  
 
|rtnType= latitude, longitude, altitude
 
|rtnType= latitude, longitude, altitude
Line 34: Line 41:
  
 
|optType2=
 
|optType2=
 +
  
  
Line 39: Line 47:
 
[[DCS_singleton_coord|'''Coord Functions:''']] {{listOfCoordFuncs}}
 
[[DCS_singleton_coord|'''Coord Functions:''']] {{listOfCoordFuncs}}
  
|examples=  
+
|examples= The following will use multiple functions, starting with coord.MGRStoLL to convert the values to LL which then converts them to LO, which will be used to draw a flag oriented with the MGRS grids over a location of no significance on the coast of the Black Sea. 
 +
 
 +
 
 +
    local mId = 0
 +
    local function id()
 +
        mId = mId + 1
 +
        return mId
 +
    end
 +
    local colors = {{0.894, 0.012, 0.012, .8},{1, 0.549, 0, .8},{1, 0.929, 0, .8},{0, 0.502, 0.149, .8},{0.141, 0.251, 0.557, .8},{0.451, 0.161, 0.51, .8}}
 +
    local wMod = {-1, 1, 1, -1}
 +
    local hMod = {1, 1, -1, -1}
 +
    local mgrs = {UTMZone = "37T", MGRSDigraph = "DK",}
 +
    local w = -15000
 +
    local h = -1000
 +
    local startEast = 40000
 +
    for i = 1, 6 do
 +
        local startNorth = 29000 + (h * i * 2)
 +
        local tbl = {-1, id()}
 +
        for j = 1, 4 do
 +
            mgrs.Easting = startEast + (w * wMod[j])
 +
            mgrs.Northing = startNorth + (h * hMod[j])
 +
            local lat, lon = coord.MGRStoLL(mgrs)
 +
            local point = coord.LLtoLO(lat, lon, 0)
 +
            table.insert(tbl,point)
 +
        end
 +
        table.insert(tbl, {0, 0, 0, 0} ) 
 +
        table.insert(tbl, colors[i])
 +
        table.insert(tbl,  math.random(0, 6))
 +
        trigger.action.quadToAll(unpack(tbl))
 +
    end
 +
 
  
  

Latest revision as of 10:48, 2 August 2022

Scripting Root

Envrioment: Mission Scripting
Function: MGRStoLL Added with: 1.2.0
Member Of: coord
Syntax: latitude, longitude, altitude coord.MGRStoLL(table MGRS )
Description: Returns multiple values of a given in MGRS coordinates and converts it to latitude, longitude, and altitude

MGRS Table:

MGRS = {
  UTMZone = string,
  MGRSDigraph = string,
  Easting = number,
  Northing = number
}


Return Value: latitude, longitude, altitude
Return Example:
Examples: The following will use multiple functions, starting with coord.MGRStoLL to convert the values to LL which then converts them to LO, which will be used to draw a flag oriented with the MGRS grids over a location of no significance on the coast of the Black Sea.


   local mId = 0
   local function id()
       mId = mId + 1
       return mId
   end
   local colors = {{0.894, 0.012, 0.012, .8},{1, 0.549, 0, .8},{1, 0.929, 0, .8},{0, 0.502, 0.149, .8},{0.141, 0.251, 0.557, .8},{0.451, 0.161, 0.51, .8}}
   local wMod = {-1, 1, 1, -1}
   local hMod = {1, 1, -1, -1}
   local mgrs = {UTMZone = "37T", MGRSDigraph = "DK",}
   local w = -15000
   local h = -1000
   local startEast = 40000 
   for i = 1, 6 do
       local startNorth = 29000 + (h * i * 2)
       local tbl = {-1, id()}
       for j = 1, 4 do
           mgrs.Easting = startEast + (w * wMod[j])
           mgrs.Northing = startNorth + (h * hMod[j])
           local lat, lon = coord.MGRStoLL(mgrs)
           local point = coord.LLtoLO(lat, lon, 0)
           table.insert(tbl,point)
       end
       table.insert(tbl, {0, 0, 0, 0} )   
       table.insert(tbl, colors[i])
       table.insert(tbl,  math.random(0, 6))
       trigger.action.quadToAll(unpack(tbl))
   end
Related Functions: Coord Functions: LLtoLO, LOtoLL, LLtoMGRS, MGRStoLL
Notes: