Showing Posts For datinc.7584:
Thanks for the fast replies. It works perfectly now. Silly minus 1. I am not sure why they did that unless it is to cause developers sleepless nights.
I am trying to use the event_details to plot events on the world map. The issue the x,y,z returned in the event_details.json API is in map coordinates (I am guessing) and to plot them I need them in continent coordinates. To achieve this I get the details from maps.json which has map_rect and continent_rect. I am obviously doing something wrong because my events don’t plot correctly.
Using the shatterer as an example: event_details.json and maps.json
My math looks like:
map_width = map_rect[1][0] - map_rect[0][0];
map_height = map_rect[1][1] - map_rect[0][1];
continent_width = continent_rect[1][0] - continent_rect[0][0];
continent_height = continent_rect[1][1] - continent_rect[0][1];
xMap = (event_location["center"][0] - map_rect[0][0])/map_width;
yMap = (event_location["center"][1] - map_rect[0][1] )/map_height;
xContinent = continent_rect[0][0] + xMap * continent_width;
yContinent = continent_rect[0][1] + yMap * continent_height;
: xContinent = 29753.250000
: yContinent = 15739.083008
This gets me near the bottom of the map! Am I doing it wrong or is there a better way to get the continent coordinate for an event?
Here is a fiddle so you can see the math in action
THE FIX:
yMap = 1 – yMap;
(edited by datinc.7584)
For API /v1/events.json it would be nice if event_id could accept a list of event ids.