geocoder-php / Geocoder

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

[Photon] Reverse Geocoding with query filters #1195

Open ybert opened 1 year ago

ybert commented 1 year ago

It can be usefull to search precise data from osm when we do reverse geocoding.

For example it can help to search only osm places (locality, city) from a location (latitude, longitude)

ybert commented 1 year ago

Ok, I undersand your position. Actually it is the only way to use reverse geocoding with photon and have specific result types.

I will see if I have time to propose a PR for osm_tag on the Photon repository.

ybert commented 1 year ago

Hello @jbelien,

My PR has just been merged in Photon master branch.

Can I implement geocoding and reverse with osm tags here or should I wait a tagged version in photon ?

jbelien commented 1 year ago

https://github.com/komoot/photon/pull/742 has just been merged in Photon master branch.

Awesome work! 👍

Can I implement geocoding and reverse with osm tags here or should I wait a tagged version in photon ?

Of course, you can definitely already update this PR (or close this PR and open a new one if you prefer).

ybert commented 1 year ago

I just added osm tag feature for both geocode and reverse queries.

You can easily combine multiple osm tag filters like this :

$provider = new Geocoder\Provider\Photon\Photon($httpClient, 'https://your-photon-root-url');
$reverseQuery = \Geocoder\Query\GeocodeQuery::create('Paris')
    ->withData('osm_tag', ['tourism', ':!museum'])
    ->withLimit(5);
// Here we get 5 tourism results in Paris which are not museums
$results = $provider->reverseQuery($reverseQuery);

If it is ok for you I think we can safely release it as the feature has been released on Photon here https://github.com/komoot/photon/releases/tag/0.4.3