Skip to content

Commit f498f02

Browse files
committed
Add ability to filter reverse query on osm data
1 parent 30ae77f commit f498f02

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/Provider/Photon/Photon.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public function reverseQuery(ReverseQuery $query): Collection
9898
.http_build_query([
9999
'lat' => $latitude,
100100
'lon' => $longitude,
101+
'query_string_filter' => $query->getData('query_string_filter'),
101102
'lang' => $query->getLocale(),
102103
]);
103104

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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"}";

src/Provider/Photon/Tests/PhotonTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,17 @@ public function testReverseQuery()
120120
$this->assertEquals('Landkreis Hildesheim', $result->getCounty());
121121
$this->assertEquals('Sehlem', $result->getDistrict());
122122
}
123+
124+
public function testReverseQueryWithOsmDataFilter()
125+
{
126+
$provider = Photon::withKomootServer($this->getHttpClient());
127+
$reverseQuery = ReverseQuery::fromCoordinates(45.73179, 6.03248)
128+
->withData('query_string_filter', 'osm_key:place')
129+
->withLimit(1);
130+
/** @var \Geocoder\Provider\Photon\Model\PhotonAddress $result */
131+
$result = $provider->reverseQuery($reverseQuery)->first();
132+
133+
$this->assertEquals('place', $result->getOSMTag()->key);
134+
$this->assertEquals('locality', $result->getOSMTag()->value);
135+
}
123136
}

0 commit comments

Comments
 (0)