Wrong WvW Objective Coordinates ?
See this thread: https://forum-en.gw2archive.eu/forum/community/api/Event-Details-API-location-coordinates
I made a silly picture
All events are within map_rect of their respective map.
All maps are within continent_rect of their continent.To figure out where something is on the continent you need to know their place within map_rect on the map, then fit map_rect inside continent_rect on the continent.
So you have to do basically this:
I was using a numpy matrix, but even if I only built it once per map your pile of random characters is a lot faster.
All condensed in one ugly block of code so I don’t have to look at it so much:
def continent_coords(continent_rect, map_rect, point, game=False): return ( (point[0]-map_rect[0][0])/(map_rect[1][0]-map_rect[0][0])*(continent_rect[1][0]-continent_rect[0][0])+continent_rect[0][0], ((-point[1] if game else point[1])-map_rect[0][1])/(map_rect[1][1]-map_rect[0][1])*(continent_rect[1][1]-continent_rect[0][1])+continent_rect[0][1] )
PHP version here: https://github.com/codemasher/gw2-database/blob/master/classes/gw2api.class.php#L248
JS version: (can’t find it…)
(edited by smiley.1438)
Don’t worry about the JS version i’m working in C# here, the PHP was clear enough to replicate it on my end
But….
What does this code actually do ?
Gives the objective coordinates in the map_rect ?
Where is the origin point of the resulting coordinates ? (top-left ? center ?)
Just to make sure it’s said : I’m not trying to place the objectives in a Continent map, but in a “Borderlands” map
Just so I know how to handle that afterwards
(Still trying to work things out on my end but in the event you’re faster to answer than me to find out…)
(edited by Side.3489)
Wait no. (it’s been a hard day…)
The above answer is correct when you get the coordinates from ingame, e.g. the Mumble link or the /v1/event_details API. It translates the relative map coordinate system into the continent’s absolute.
The solution to your problem is simpler: just don’t use the map_rect at all. continent_rect is what you need since the coordinates in the /v2/ APIs are already calculated to absolute.
Np, can understand that :p
Ok so what i did in my first post is good, just change the map_rect with continent_rect ?
I think, you’re pretty much looking for this: https://gist.github.com/codemasher/75d8e1a24b2363cabebf
Huuum, nope, don’t think that was what I looked for ^^’
But….
Got that one !
It’ late and i stumbled a little on the map size….. Silly me.
Thanks for the tip for the continent_rect though
For future reference :
https://github.com/sidewinder94/GWvW_Overlay/blob/cb024272cbe41b3ce703434209f78b158d1d34b5/ArenaNET/Objective.cs#L29
Not on topic !
Marked this as a Q/A and it turned to be a discussion…. I don’t seem to be able to remove the Q/A format…. if someone with moderators rights could do this, i’d be grateful