8000 [Photon] Reverse Geocoding with query filters by ybert · Pull Request #1195 · geocoder-php/Geocoder · GitHub
[go: up one dir, main page]

Skip to content

[Photon] Reverse Geocoding with query filters #1195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add ability to filter reverse query on osm data
  • Loading branch information
ybert committed Jul 31, 2023
commit f498f02ba501f75a703dbef9c2e780d16f1695dc
1 change: 1 addition & 0 deletions src/Provider/Photon/Photon.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public function reverseQuery(ReverseQuery $query): Collection
.http_build_query([
'lat' => $latitude,
'lon' => $longitude,
'query_string_filter' => $query->getData('query_string_filter'),
'lang' => $query->getLocale(),
]);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
s:416:"{"features":[{"geometry":{"coordinates":[6.038995,45.7362133],"type":"Point"},"type":"Feature","properties":{"osm_id":9992954218,"country":"France","city":"Saint-Offenge","countrycode":"FR","postcode":"73100","county":"Savoie","type":"locality","osm_type":"N","osm_key":"place","district":"Saint-Offenge-Dessous","osm_value":"locality","name":"Le Loret","state":"Auvergne-Rhône-Alpes"}}],"type":"FeatureCollection"}";
13 changes: 13 additions & 0 deletions src/Provider/Photon/Tests/PhotonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,17 @@ public function testReverseQuery()
$this->assertEquals('Landkreis Hildesheim', $result->getCounty());
$this->assertEquals('Sehlem', $result->getDistrict());
}

public function testReverseQueryWithOsmDataFilter()
{
$provider = Photon::withKomootServer($this->getHttpClient());
$reverseQuery = ReverseQuery::fromCoordinates(45.73179, 6.03248)
->withData('query_string_filter', 'osm_key:place')
->withLimit(1);
/** @var \Geocoder\Provider\Photon\Model\PhotonAddress $result */
$result = $provider->reverseQuery($reverseQuery)->first();

$this->assertEquals('place', $result->getOSMTag()->key);
$this->assertEquals('locality', $result->getOSMTag()->value);
}
}
0