geocoder-php / Geocoder

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

[Nominatim] add support for optional address fields and extra tags #1127

Closed pschocke closed 3 years ago

pschocke commented 3 years ago

This PR adds support for the optional fields shop, amenity and tourism.

jbelien commented 3 years ago

Hello @pschocke , thank you for your contribution!

Being an OpenStreetMap contributor myself, I understand the point of your PR but I must admit I don't think keeping adding tags like this is a viable solution ; especially with tags that are not directly related to the address itself.

I think we need to find a better way to implement this and registering tags from the location.

pschocke commented 3 years ago

Hey @jbelien, I totally understand that point and I thought about that too. OSM offers a lot of different categories.

Maybe adding a way to access the original response would be an option. I am building an autocomplete where I do not want to use the display name since its very long and has a lot of information that I don't need, but I can't get something like the shop name when not using the display name.

Thanks for this awesome package!

jbelien commented 3 years ago

Just gave a quick thought : maybe adding extratags=1 to the Nominatim request and then storing all the tags key-value in a tags property of NominatimAddress could be a solution. That should allow access to all the information tagged and keep it generic.

pschocke commented 3 years ago

This should work. However, I still have no access to the name of the tourism/store/amenisty. Since the address key-value's are also changing, I would suggest storing the address key-value as well.

jbelien commented 3 years ago

Yes, you're right the name tag doesn't seem to be available in extratags property of the result. I think it does make sense to keep both address and extratags (properties that are already used in Geocoder PHP could be filtered out from address).

pschocke commented 3 years ago

I've updated the pr to store additional address data and added the ability to request extra tags.

jbelien commented 3 years ago

Nice, I'll review it ASAP.

Could you make sure it passes Style CI check ?

pschocke commented 3 years ago

Hey, do you have any eta of a review? I need this in a work project and don't want to temporarily create a fork of the single nominatim package and update this just as a temporary workaround.

Thanks for your time!

jbelien commented 3 years ago

@pschocke I'll try to do this this week but worst case next weekend (19-20 June).

jbelien commented 3 years ago

@pschocke Fixes are ready ; could you give me write access to this PR ? I don't know if it's possible to change maintainer access after the PR is created ; if not, could you give me write access in your repository so I can push my commits ? Thanks!

pschocke commented 3 years ago

Done! You have access to the repo. Thanks for your work!

jbelien commented 3 years ago

🚀 New version 5.5 is released (https://packagist.org/packages/geocoder-php/nominatim-provider) !

Thanks @pschocke !