Skip to content

Commit 7cb656c

Browse files
committed
feat: [Photon] support lat/lon in geocode query
1 parent af1105b commit 7cb656c

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

src/Provider/Photon/Photon.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public function geocodeQuery(GeocodeQuery $query): Collection
7171
'layer' => $query->getData('layer'),
7272
'limit' => $query->getLimit(),
7373
'lang' => $query->getLocale(),
74+
'lat' => $query->getData('lat'),
75+
'lon' => $query->getData('lon'),
7476
]);
7577
$osmTagFilters = $this->buildOsmTagFilterQuery($query->getData('osm_tag'));
7678
if (!empty($osmTagFilters)) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
s:535:"{"features":[{"geometry":{"coordinates":[2.3200410217200766,48.8588897],"type":"Point"},"type":"Feature","properties":{"osm_type":"R","osm_id":7444,"extent":[2.224122,48.902156,2.4697602,48.8155755],"country":"France","osm_key":"boundary","city":"Paris","countrycode":"FR","osm_value":"administrative","postcode":"75000;75001;75002;75003;75004;75005;75006;75007;75008;75009;75010;75011;75012;75013;75014;75015;75016;75017;75018;75019;75020;75116","name":"Paris","state":"Île-de-France","type":"district"}}],"type":"FeatureCollection"}";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
s:373:"{"features":[{"geometry":{"coordinates":[-95.555513,33.6617962],"type":"Point"},"type":"Feature","properties":{"osm_type":"R","osm_id":115357,"extent":[-95.6279396,33.7383866,-95.4354115,33.6206345],"country":"United States","osm_key":"place","countrycode":"US","osm_value":"town","name":"Paris","county":"Lamar","state":"Texas","type":"city"}}],"type":"FeatureCollection"}";

src/Provider/Photon/Tests/PhotonTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,25 @@ public function testGeocodeQueryWithMultipleOsmTagFilter(): void
135135
$this->assertGreaterThan(0, $countGalleries);
136136
}
137137

138+
public function testGeocodeQueryWithLatLon(): void
139+
{
140+
$provider = Photon::withKomootServer($this->getHttpClient());
141+
142+
$query = GeocodeQuery::create('Paris')->withLimit(1);
143+
$results = $provider->geocodeQuery($query);
144+
$this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
145+
$this->assertCount(1, $results);
146+
$this->assertEquals('France', $results->first()->getCountry());
147+
148+
$query = $query
149+
->withData('lat', 33.661426)
150+
->withData('lon', -95.556321);
151+
$results = $provider->geocodeQuery($query);
152+
$this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
153+
$this->assertCount(1, $results);
154+
$this->assertEquals('United States', $results->first()->getCountry());
155+
}
156+
138157
public function testReverseQuery(): void
139158
{
140159
$provider = Photon::withKomootServer($this->getHttpClient());

0 commit comments

Comments
 (0)