Jump to content

Converting GPS coordinates to X/Y ?


gromit190

Recommended Posts

Tried this code, but I the LAV spawned somewhere faaaaar out north west

 

local coordinate = coord.LLtoLO(42.13982, 42.39503)

local lat, long, alt = coord.LOtoLL(coordinate)
local msg = lat .. ", " .. long .. "\n" .. coordinate.x .. ", " .. coordinate.y .. ", " .. coordinate.z
trigger.action.outText(msg, 10)

  local groupData = {
["visible"] = false,
["taskSelected"] = true,
["route"] = 
{
}, -- end of ["route"]
["groupId"] = 2,
["tasks"] = 
{
}, -- end of ["tasks"]
["hidden"] = false,
["units"] = 
{
	[1] = 
	{
		["type"] = "LAV-25",
		["transportable"] = 
		{
			["randomTransportable"] = false,
		}, -- end of ["transportable"]
		["x"] = coordinate.x,
		["y"] = coordinate.y,
		["z"] = coordinate.z,
		["unitId"] = 2,
		["skill"] = "Excellent",
		["name"] = "Ground Unit1",
		["playerCanDrive"] = true,
		["heading"] = 0.28605144170571,
	}, -- end of [1]
}, -- end of ["units"]
["x"] = coordinate.x,
["y"] = coordinate.y,
["z"] = coordinate.z,
["name"] = "Ground Group",
["start_time"] = 0,
["task"] = "Ground Nothing",
 } -- end of [1]

 coalition.addGroup(country.id.USA, Group.Category.GROUND, groupData)

 

 

 

 

EDIT:

 

This is where it is spawning:

 

XuBO8DS.jpg


Edited by gromit190
Link to comment
Share on other sites

Also there is no "z" coordinate, it is labeled as "alt" and only applies to aircraft.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Hi

...I know I want it to spawn at...

Cheers from Norway

 

You know where you want it to spawn. Go into a mission and press LCntrl-Y, Info Bar Toggle, and it will cycle through the coordinate systems.

 

Cheers from Colorado!

Visit the Hollo Pointe DCS World server -- an open server with a variety of COOP & H2H missions including Combined Arms. All released missions are available for free download, modification and public hosting, from my Wrecking Crew Projects site.

Link to comment
Share on other sites

Thanks guys! It's strange, even though I map the Y coordinate to Z, it still seems very "off" from my lat/long coordinates.

 

You know where you want it to spawn. Go into a mission and press LCntrl-Y, Info Bar Toggle, and it will cycle through the coordinate systems.

 

Cheers from Colorado!

 

Strange, the info bar comes up, but it doesn't change coordinate systems when I toggle it again. On the third toggle it disappears again so there's obviously some toggle inbetween... But all I see is lat/long coordinates.

 

 

 

 

Okay so I tried to figure what lat/long coordinates that are correct to get the group to spawn where I want. This is the code:

 

-- Initialization
if (initialized == nil) then
initialized = true

end

function test()

local coordinate3 = coord.LLtoLO(42.24, 42.66)
local coordinate2 = {
	x = coordinate3.x,
	y = coordinate3.z
}

local lat, long, alt = coord.LOtoLL(coordinate3)
local msg = coordinate2.x .. "," .. coordinate2.y
trigger.action.outText(msg, 1)



local groupData = {
	["visible"] = false,
	["taskSelected"] = true,
	["route"] = 
	{
	}, -- end of ["route"]
	["groupId"] = 2,
	["tasks"] = 
	{
	}, -- end of ["tasks"]
	["hidden"] = false,
	["units"] = 
	{
		[1] = 
		{
			["type"] = "LAV-25",
			["transportable"] = 
			{
				["randomTransportable"] = false,
			}, -- end of ["transportable"]
			["x"] = coordinate2.x,
			["y"] = coordinate2.y,
			["unitId"] = 2,
			["skill"] = "Excellent",
			["name"] = "Ground Unit1",
			["playerCanDrive"] = true,
			["heading"] = 0.28605144170571,
		}, -- end of [1]
	}, -- end of ["units"]
	["name"] = "Ground Group",
	["start_time"] = 0,
	["task"] = "Ground Nothing",
} -- end of [1]
	
coalition.addGroup(country.id.USA, Group.Category.GROUND, groupData)			

end
test();

 

So now it's spawning in the correct location, but why can't I use the lat/long coordinates that I read from the F10 map?

 

See where it spawned:

 

6rCuHvn.jpg

 

EDIT: and yes, my mouse pointer is positioned directly above the unit


Edited by gromit190
Link to comment
Share on other sites

coord.LLtoLO takes latitude and longitute in (decimal) degrees. The display in the DCS map shows degrees and (decimal) minutes.

 

latitude of 42.24 degrees:

42 degrees and (60 * 0.24) = 14.400 minutes

 

longitude of 42.66 degrees:

42 degrees and (60 * 0.66) = 39.600 minutes

 

 

To convert the other way, from coordinates displayed in the DCS map to parameters for coord.LLtoLO:

 

latitude of 42 degrees and 14.4 minutes:

(42 + (14.4/60)) = 42.24

 

longitude of 42 degrees and 39.6 minutes:

(42 + (39.6/60)) = 42.66

Link to comment
Share on other sites

  • 1 month later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...