Translating Mumble coordinates to API:2/maps coordinates — Guild Wars 2 Forums

Translating Mumble coordinates to API:2/maps coordinates

Grax.9204Grax.9204 Member
edited September 8, 2018 in API Development

Hello there

I am struggling to translate the coordinates provided by the mumble file into ones that match the coordinate system used by the API:2/maps.
More precisely, I am working with the coordinates from TacO files which are based on the mumble coordinates.

The mumble coordinates seem to be relative to the current map while the maps API provides coordinates for an entire continent.
So what I tried is to add a maps continent_rect NW x and y values to the map relative coordinates from mumble.
The resulting coordinates are offset though. It appears that the map relative coordinates are not based on the maps NW corner but some seemingly random spot somewhere in the maps middle.

So I tried to calculate the maps center point using the API:2/maps coordinate_rect information.
This almost matches for coordinates in Lions Arch, for example Spirit Vale is waaay off though. So again, it appears to be random as to where the mumble file coordinates are based on.

What am I missing?

Comments

  • darthmaim.6017darthmaim.6017 Member ✭✭
    edited September 8, 2018

    The wiki has a article explaining coordinates: https://wiki-en.guildwars2.com/wiki/API:Maps

    To convert map to continent coordinates you can use something like this:

    function mapCoordinateToContinent(coordinate, map) {
        const cmin = map.continent_rect[0];
        const cmax = map.continent_rect[1];
        const mapMin = map.map_rect[0];
        const mapMax = map.map_rect[1];
    
        return [
            cmin[0] + (cmax[0] - cmin[0]) * ((coordinate[0] - mapMin[0]) / (mapMax[0] - mapMin[0])),
            cmin[1] + (cmax[1] - cmin[1]) * ((coordinate[1] - mapMin[1]) / (mapMax[1] - mapMin[1]))
        ];
    }
    

    You also have to convert the Mumble units to map units:

    const continentCoordinates = mapCoordinateToContinent([marker.xpos * 39.37, -marker.zpos * 39.37], maps[marker.MapID]);
    
  • Thanks, you saved my day

©2010–2018 ArenaNet, LLC. All rights reserved. Guild Wars, Guild Wars 2, Heart of Thorns, Guild Wars 2: Path of Fire, ArenaNet, NCSOFT, the Interlocking NC Logo, and all associated logos and designs are trademarks or registered trademarks of NCSOFT Corporation. All other trademarks are the property of their respective owners.