DenisCarriere / geocoder-geojson

Geocoding results in GeoJSON format
https://www.npmjs.com/package/geocoder-geojson
MIT License
21 stars 10 forks source link

Mapbox limit not working #8

Closed DenisCarriere closed 7 years ago

DenisCarriere commented 7 years ago

From @terry90

Hello Denis,

It's me again :) I do not want to open too much issues, so I'm gonna ask you by email. What is wrong with the mapbox provider ? I'm getting 422 errors claiming: {"message":"limit must be combined with a single type parameter when reverse geocoding"}%

But this is not the weird part, when I curl the exact same query by replacing "%20" with "\ " it works ! I tried to change the limit option, remove it etc.. the best I can get is a features: [], EMPTY ! It drives me mad haha.

Did you encountered this issue ?

Here are proofs:

curl 'https://api.mapbox.com/geocoding/v5/mapbox.places/9%20rue%20Alphonse%20Penaud%20Paris,%2075020%20France.json?access_token=YOURTOKEN&limit=1'

will return: ..."features":[]...

curl 'https://api.mapbox.com/geocoding/v5/mapbox.places/9%20rue%20Alphonse%20Penaud%20Paris,%2075020%20France.json?access_token=YOURTOKEN&limit=5'

will return: {"message":"limit must be combined with a single type parameter when reverse geocoding"}

curl 'https://api.mapbox.com/geocoding/v5/mapbox.places/9\ rue\ Alphonse\ Penaud\ Paris,\ 75020\ France.json?access_token=YOURTOKEN&limit=1'

will return a single result in features[], and the right one !!!

Have a good day !

DenisCarriere commented 7 years ago

I've got it working using the CLI & geocoder-geojson library.

I simply dropped the postal code.

$ geocode -p mapbox "9 rue Alphonse Penaud Paris, France" --limit 1

It looks like it's a Mapbox issue, when I dropped the postal code it worked, I'm pretty sure it does the following:

Query: 9 rue Alphonse Penaud Paris, 75020 France

Mapbox's Forward & Reverse Geocoding API is very similiar.

Reverse

http://api.tiles.mapbox.com/v3/{mapid}/geocode/{lon},{lat}.json

Forward

http://api.tiles.mapbox.com/v3/{mapid}/geocode/{query}.json

CC: @sbma44

terry90 commented 7 years ago

Oh right ! Nice one. I did not thought about that.

DenisCarriere commented 7 years ago

That one is a strange one, I'm going to close this issue, but this doesn't fix the Mapbox provider issue.

sbma44 commented 7 years ago

Hey, belatedly: thanks for the bug report. I can replicate this issue and we'll be having a closer look.

DenisCarriere commented 7 years ago

@sbma44 Cool stuff! This behaviour looked a bit strange to me, I don't ping you very much. (don't mind my very fast reply, I had just refreshed my email box when you submitted your comment).

ingalls commented 7 years ago

Hey @DenisCarriere, Thanks a ton for finding this bug! Happy to say I've tested and deployed a fix for this as of last night. The fix itself can be seen here: https://github.com/mapbox/carmen/pull/579

Feel free to ping us any time if you have any questions or run into any bugs!

ingalls commented 7 years ago

Afterthought: It can take up to 48 hours for the query to clear out of our cache. If you add something like &cachebuster=1234 to the end of the query it will miss the cache, hitting the server with the fixed result.

terry90 commented 7 years ago

Thanks ! I will use it back :)

DenisCarriere commented 7 years ago

@ingalls Thanks! 👍 The query works now, it's great that you've included the Paris, France example in the Carmen test cases 😄