Skip to content

Commit 4c0cca3

Browse files
Persaeusjbelien
andauthored
[Photon] Add country codes (#1136)
* Add country codes for photon provider Add country codes in address results for photon provider * Update PhotonTest.php Co-authored-by: Jonathan Beliën <[email protected]>
1 parent a798bbd commit 4c0cca3

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Provider/Photon/Photon.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ private function featureToAddress(\stdClass $feature): Location
142142
$builder->setPostalCode($properties->postcode ?? null);
143143
$builder->setLocality($properties->city ?? null);
144144
$builder->setCountry($properties->country ?? null);
145+
$builder->setCountryCode($properties->countrycode ?? null);
145146

146147
if (isset($properties->extent)) {
147148
$builder->setBounds($properties->extent[0], $properties->extent[2], $properties->extent[1], $properties->extent[3]);

src/Provider/Photon/Tests/PhotonTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ public function testGeocodeQuery()
6868
$this->assertEquals('Avenue Gambetta', $result->getStreetName());
6969
$this->assertEquals('75020', $result->getPostalCode());
7070
$this->assertEquals('Paris', $result->getLocality());
71-
$this->assertEquals('France', $result->getCountry());
71+
$this->assertEquals('France', $result->getCountry()->getName());
72+
$this->assertEquals('FR', $result->getCountry()->getCode());
7273

7374
$this->assertEquals(1988097192, $result->getOSMId());
7475
$this->assertEquals('N', $result->getOSMType());
@@ -105,7 +106,8 @@ public function testReverseQuery()
105106
$this->assertEquals(9.998645, $result->getCoordinates()->getLongitude(), '', 0.00001);
106107
$this->assertEquals('31195', $result->getPostalCode());
107108
$this->assertEquals('Lamspringe', $result->getLocality());
108-
$this->assertEquals('Deutschland', $result->getCountry());
109+
$this->assertEquals('Deutschland', $result->getCountry()->getName());
110+
$this->assertEquals('DE', $result->getCountry()->getCode());
109111

110112
$this->assertEquals(693697564, $result->getOSMId());
111113
$this->assertEquals('N', $result->getOSMType());

0 commit comments

Comments
 (0)