Skip to content

Commit 64b05f8

Browse files
authoredMar 19, 2025
Merge branch 'master' into photon-bbox-support
2 parents 46a2edf + af1105b commit 64b05f8

File tree

8 files changed

+68
-0
lines changed

8 files changed

+68
-0
lines changed
 

‎src/Provider/AzureMaps/AzureMaps.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ private function formatGeocodeResponse(\stdClass $response): array
225225
$builder->setCountryCode($result->address->countryCode ?? null);
226226
$builder->setCountry($result->address->country ?? null);
227227
$builder->setPostalCode($result->address->extendedPostalCode ?? null);
228+
$builder->setLocality($result->address->municipality ?? null);
228229

229230
return $builder->build();
230231
}, $response->results);

‎src/Provider/AzureMaps/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
44

5+
## 1.3.0
6+
7+
### Added
8+
9+
- Add support for PHP 8.2, 8.3, and 8.4
10+
- Add support for municipality
11+
12+
### Removed
13+
14+
- Drop support for PHP 7.4
15+
516
## 1.2.0
617

718
### Added
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
s:3807:"{"summary":{"query":"via giuseppe garibaldi 62 it italy","queryType":"NON_NEAR","queryTime":159,"numResults":5,"offset":0,"totalResults":735,"fuzzyLevel":1},"results":[{"type":"Point Address","id":"M10ReRZ2hcOXh-6Zf0J61w","score":0.9898217893889455,"matchConfidence":{"score":0.9898217893889455},"address":{"streetNumber":"62","streetName":"Via Giuseppe Garibaldi","municipality":"Scisciano","countrySecondarySubdivision":"Naples","countrySubdivision":"Campania","countrySubdivisionName":"Campania","countrySubdivisionCode":"72","postalCode":"80030","countryCode":"IT","country":"Italy","countryCodeISO3":"ITA","freeformAddress":"Via Giuseppe Garibaldi 62, 80030 Scisciano","localName":"Scisciano"},"position":{"lat":40.9178377,"lon":14.4925806},"viewport":{"topLeftPoint":{"lat":40.91874,"lon":14.49139},"btmRightPoint":{"lat":40.91694,"lon":14.49377}},"entryPoints":[{"type":"main","position":{"lat":40.91789,"lon":14.49264}}]},{"type":"Point Address","id":"sjVXib68Vk_apQocqTtcNw","score":1,"matchConfidence":{"score":1},"address":{"streetNumber":"62","streetName":"Via Giuseppe Garibaldi","municipality":"Rieti","countrySecondarySubdivision":"Rieti","countrySubdivision":"Lazio","countrySubdivisionName":"Lazio","countrySubdivisionCode":"62","postalCode":"02100","countryCode":"IT","country":"Italy","countryCodeISO3":"ITA","freeformAddress":"Via Giuseppe Garibaldi 62, 02100 Rieti","localName":"Rieti"},"position":{"lat":42.4045777,"lon":12.8696648},"viewport":{"topLeftPoint":{"lat":42.40548,"lon":12.86845},"btmRightPoint":{"lat":42.40368,"lon":12.87088}},"entryPoints":[{"type":"main","position":{"lat":42.40462,"lon":12.86965}}]},{"type":"Point Address","id":"4141RKh-zp9rGny90SkbJA","score":1,"matchConfidence":{"score":1},"address":{"streetNumber":"62","streetName":"Via Giuseppe Garibaldi","municipality":"Lariano","countrySecondarySubdivision":"Rome","countrySubdivision":"Lazio","countrySubdivisionName":"Lazio","countrySubdivisionCode":"62","postalCode":"00076","countryCode":"IT","country":"Italy","countryCodeISO3":"ITA","freeformAddress":"Via Giuseppe Garibaldi 62, 00076 Lariano","localName":"Lariano"},"position":{"lat":41.7242695,"lon":12.8408613},"viewport":{"topLeftPoint":{"lat":41.72517,"lon":12.83966},"btmRightPoint":{"lat":41.72337,"lon":12.84207}},"entryPoints":[{"type":"main","position":{"lat":41.72427,"lon":12.84089}}]},{"type":"Point Address","id":"tDn3fkOIetRlG1216sBV9g","score":1,"matchConfidence":{"score":1},"address":{"streetNumber":"62","streetName":"Via Giuseppe Garibaldi","municipality":"Sabaudia","countrySecondarySubdivision":"Latina","countrySubdivision":"Lazio","countrySubdivisionName":"Lazio","countrySubdivisionCode":"62","postalCode":"04016","countryCode":"IT","country":"Italy","countryCodeISO3":"ITA","freeformAddress":"Via Giuseppe Garibaldi 62, 04016 Sabaudia","localName":"Sabaudia"},"position":{"lat":41.2971023,"lon":13.0370044},"viewport":{"topLeftPoint":{"lat":41.298,"lon":13.03581},"btmRightPoint":{"lat":41.2962,"lon":13.0382}},"entryPoints":[{"type":"main","position":{"lat":41.29718,"lon":13.03701}}]},{"type":"Point Address","id":"QI_uwItbuz6PB3ifaRIKVA","score":1,"matchConfidence":{"score":1},"address":{"streetNumber":"62","streetName":"Via Giuseppe Garibaldi","municipality":"Genzano di Roma","countrySecondarySubdivision":"Rome","countrySubdivision":"Lazio","countrySubdivisionName":"Lazio","countrySubdivisionCode":"62","postalCode":"00045","countryCode":"IT","country":"Italy","countryCodeISO3":"ITA","freeformAddress":"Via Giuseppe Garibaldi 62, 00045 Genzano di Roma","localName":"Genzano di Roma"},"position":{"lat":41.7081063,"lon":12.6897159},"viewport":{"topLeftPoint":{"lat":41.70901,"lon":12.68851},"btmRightPoint":{"lat":41.70721,"lon":12.69092}},"entryPoints":[{"type":"main","position":{"lat":41.70807,"lon":12.68968}}]}]}";

‎src/Provider/AzureMaps/Tests/AzureMapsTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,25 @@ public function testReverseWithRealCoordinates(): void
9393
$this->assertEquals('Israel', $result->getCountry()->getName());
9494
$this->assertEquals('IL', $result->getCountry()->getCode());
9595
}
96+
97+
public function testGeocodeIncludesMunicipality(): void
98+
{
99+
if (!isset($_SERVER['AZURE_MAPS_SUBSCRIPTION_KEY'])) {
100+
$this->markTestSkipped('You need to configure the AZURE_MAPS_SUBSCRIPTION_KEY value in phpunit.xml');
101+
}
102+
103+
$subscriptionKey = $_SERVER['AZURE_MAPS_SUBSCRIPTION_KEY'];
104+
$provider = new AzureMaps($this->getHttpClient($subscriptionKey), $subscriptionKey);
105+
106+
$results = $provider->geocodeQuery(GeocodeQuery::create('Via Giuseppe Garibaldi 62, IT, Italy'));
107+
108+
$this->assertInstanceOf(AddressCollection::class, $results);
109+
$this->assertGreaterThan(0, $results->count(), 'No results found');
110+
111+
$result = $results->first();
112+
113+
$this->assertInstanceOf(Address::class, $result);
114+
$this->assertNotNull($result->getLocality(), 'Municipality (city) is missing in the response');
115+
$this->assertEquals('Scisciano', $result->getLocality());
116+
}
96117
}

‎src/Provider/OpenCage/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
44

5+
## 4.7.0
6+
7+
### Added
8+
9+
- Add support for PHP 8.2, 8.3, and 8.4
10+
- Add support for confidence
11+
12+
### Removed
13+
14+
- Drop support for PHP 7.4
15+
516
## 4.6.0
617

718
### Added

‎src/Provider/OpenCage/Model/OpenCageAddress.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ final class OpenCageAddress extends Address
4949
*/
5050
private $formattedAddress;
5151

52+
/**
53+
* @var int|null
54+
*/
55+
private $confidence;
56+
5257
public function withMGRS(?string $mgrs = null): self
5358
{
5459
$new = clone $this;
@@ -128,4 +133,20 @@ public function getFormattedAddress()
128133
{
129134
return $this->formattedAddress;
130135
}
136+
137+
public function withConfidence(?int $confidence = null): self
138+
{
139+
$new = clone $this;
140+
$new->confidence = $confidence;
141+
142+
return $new;
143+
}
144+
145+
/**
146+
* @return int|null
147+
*/
148+
public function getConfidence()
149+
{
150+
return $this->confidence;
151+
}
131152
}

‎src/Provider/OpenCage/OpenCage.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ private function executeQuery(string $url, ?string $locale = null): AddressColle
154154
$address = $address->withGeohash(isset($annotations['geohash']) ? $annotations['geohash'] : null);
155155
$address = $address->withWhat3words(isset($annotations['what3words'], $annotations['what3words']['words']) ? $annotations['what3words']['words'] : null);
156156
$address = $address->withFormattedAddress($location['formatted']);
157+
$address = $address->withConfidence($location['confidence']);
157158

158159
$results[] = $address;
159160
}

‎src/Provider/OpenCage/Tests/OpenCageTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public function testGeocodeWithRealAddress(): void
8383
$this->assertEquals('u09tyr78tz64jdcgfnhe', $result->getGeohash());
8484
$this->assertEquals('listed.emphasis.greeting', $result->getWhat3words());
8585
$this->assertEquals('10 Avenue Gambetta, 75020 Paris, France', $result->getFormattedAddress());
86+
$this->assertEquals(10, $result->getConfidence());
8687
}
8788

8889
public function testReverseWithRealCoordinates(): void

0 commit comments

Comments
 (0)