diff --git a/src/Provider/Photon/Photon.php b/src/Provider/Photon/Photon.php index caed4ecab..1da16efb6 100644 --- a/src/Provider/Photon/Photon.php +++ b/src/Provider/Photon/Photon.php @@ -71,6 +71,8 @@ public function geocodeQuery(GeocodeQuery $query): Collection 'layer' => $query->getData('layer'), 'limit' => $query->getLimit(), 'lang' => $query->getLocale(), + 'lat' => $query->getData('lat'), + 'lon' => $query->getData('lon'), ]); $osmTagFilters = $this->buildOsmTagFilterQuery($query->getData('osm_tag')); if (!empty($osmTagFilters)) { diff --git a/src/Provider/Photon/Tests/.cached_responses/photon.komoot.io_83d30d7d0b77d2526ba7d750ad29a2daae002647 b/src/Provider/Photon/Tests/.cached_responses/photon.komoot.io_83d30d7d0b77d2526ba7d750ad29a2daae002647 new file mode 100644 index 000000000..7296f064e --- /dev/null +++ b/src/Provider/Photon/Tests/.cached_responses/photon.komoot.io_83d30d7d0b77d2526ba7d750ad29a2daae002647 @@ -0,0 +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"}"; \ No newline at end of file diff --git a/src/Provider/Photon/Tests/.cached_responses/photon.komoot.io_e564cba10f78e298ecde7f804fbfb15d7d430ebc b/src/Provider/Photon/Tests/.cached_responses/photon.komoot.io_e564cba10f78e298ecde7f804fbfb15d7d430ebc new file mode 100644 index 000000000..80cb7b8b9 --- /dev/null +++ b/src/Provider/Photon/Tests/.cached_responses/photon.komoot.io_e564cba10f78e298ecde7f804fbfb15d7d430ebc @@ -0,0 +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"}"; \ No newline at end of file diff --git a/src/Provider/Photon/Tests/PhotonTest.php b/src/Provider/Photon/Tests/PhotonTest.php index 2ae88c655..721df89da 100644 --- a/src/Provider/Photon/Tests/PhotonTest.php +++ b/src/Provider/Photon/Tests/PhotonTest.php @@ -13,6 +13,7 @@ namespace Geocoder\Provider\Photon\Tests; use Geocoder\IntegrationTest\BaseTestCase; +use Geocoder\Model\AddressCollection; use Geocoder\Provider\Photon\Model\PhotonAddress; use Geocoder\Provider\Photon\Photon; use Geocoder\Query\GeocodeQuery; @@ -135,6 +136,25 @@ public function testGeocodeQueryWithMultipleOsmTagFilter(): void $this->assertGreaterThan(0, $countGalleries); } + public function testGeocodeQueryWithLatLon(): void + { + $provider = Photon::withKomootServer($this->getHttpClient()); + + $query = GeocodeQuery::create('Paris')->withLimit(1); + $results = $provider->geocodeQuery($query); + $this->assertInstanceOf(AddressCollection::class, $results); + $this->assertCount(1, $results); + $this->assertEquals('France', $results->first()->getCountry()); + + $query = $query + ->withData('lat', 33.661426) + ->withData('lon', -95.556321); + $results = $provider->geocodeQuery($query); + $this->assertInstanceOf(AddressCollection::class, $results); + $this->assertCount(1, $results); + $this->assertEquals('United States', $results->first()->getCountry()); + } + public function testReverseQuery(): void { $provider = Photon::withKomootServer($this->getHttpClient());