geocoder-php / Geocoder

The most featured Geocoder library written in PHP.
https://geocoder-php.org
MIT License
3.94k stars 517 forks source link

[Nominatim] Municipality not in list of 'localityFields' #1155

Open uwbas opened 2 years ago

uwbas commented 2 years ago

I came across some reverse geocoding results where Nominatim.php didn't return a 'locality'. In my opinion, this latlng query should have 'Purmerend' as its locality, as it's the municipal boundary:

https://nominatim.openstreetmap.org/ui/reverse.html?lat=52.50741&lon=4.93279&zoom=18 https://nominatim.openstreetmap.org/ui/details.html?osmtype=W&osmid=6593763&class=highway

Upon debugging, I noticed that inside jsonResultToLocation(), on line 209, 'municipality' was not considered a 'locality'.

$localityFields = ['city', 'town', 'village', 'hamlet'];

Is this a matter of definition?

Adding 'municipality' fixes my issue:

$localityFields = ['city', 'town', 'village', 'hamlet', 'municipality'];

jbelien commented 2 years ago

Hello @uwbas , That seems indeed to be a valid point! Could you submit a PR with that change ? Thanks.

uwbas commented 2 years ago

Done: https://github.com/geocoder-php/Geocoder/pull/1156