Difference between revisions of "DCS func MGRStoLL"
From DCS World Wiki - Hoggitworld.com
m (1 revision imported) |
|||
(2 intermediate revisions 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 | ||
+ | |||
Line 45: | Line 83: | ||
}} | }} | ||
[[Category:Singleton Functions|MGRStoLL]] | [[Category:Singleton Functions|MGRStoLL]] | ||
+ | [[Category:Game Patch 1.2.0|MGRStoLL]] |