Geocoder returns inversed latitude and longitude

Hello!

First of all, I’m glad to see the Geocoder is back online, and I understand some issues with geocoding might happen in the close future.

I built an application that uses some reverse geocoding API calls, and since it came back online, the results I’m getting are not what they’re supposed to be.

It appears to be that instead of sending coordinates in the order [latitude, longitude], it returns it the other way around [longitude, latitude].

For example I’m reverse geocoding some place in Quebec and it returns the coordinates: [-73.619025, 45.705809], but that’s a place in Antartica.

Is this normal? If so I’ll just swap my values around in my application but it doesn’t seem right.

Let me know, cheers!

Edit : I’m using the Javascript SDK

Hi @Shokushu

I have just checked on our maps client which uses the same geocoding API and it seems to be ok on there. We have noticed some problems to do with it not using the coarsest level of detail (in one case it gave the centre of europe rather than an address in the UK) so we are in the process of re-downloading the base data to see if something got corrupted in there.

But in general the actual API and settings themselves didnt change during the last problem - it was just the database that had the problems, so I am not sure why it goes weird on yours. Can you try using the same search in the maps client (maps.openrouteservice.org) and on the interactive docs to see if you still have the same problem on those, as if it is fine there then it sounds like something strange with the javascript sdk.

Thanks

Adam

If you are using Openlayers, it may also have to do with how Openlayers interprets the coordinate you’re getting back. That one has caught me out more than once too… :grin:

In my own reverse geocoding I haven’t noticed any switching of ordinates, the location marker I place when searching for a placename ends up in the right location. But I don’t use the SDK, I use my own code (I think that’s more fun :wink: ), so it could indeed be the SDK.

Hello, thanks for the reply!

I have tried the same address with maps.openrouteservice.org, and while it points the right place on the map, the returned values from the search in the json are still inversed (see my screenshot).

It’s returning [-72.7151461, 45.2111538] and the coordinates should be the opposite

Hi @Shokushu,

latitude and longitude do not have an absolute order, the order depends on what packages you are using and what specifications you are working with.
To be aware of this order is one of the main things when working with geographic data.
The response of the geocode/search returns GeoJSON objects which have to be longitude,latitude order according to the specification.

So there’s nothing wrong with the output. If you need them the other way around, just swap them.

Best regards

Hi, thanks for the specification, I will swap them!

I appreciate the quick replies and wish you all a nice day =)