Skip to content

Commit 6ae5a6d

Browse files
committed
OpenStreetMap fix postal code and tests
1 parent 32f4544 commit 6ae5a6d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Geocoder/Provider/Nominatim.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,15 @@ private function xmlResultToArray(\DOMElement $resultNode, \DOMElement $addressN
116116
}
117117
}
118118

119+
// get the first postal-code when there are many
120+
$postalCode = current(explode(';',
121+
$this->getNodeValue($addressNode->getElementsByTagName('postcode'))
122+
));
123+
119124
$result = [
120125
'latitude' => $resultNode->getAttribute('lat'),
121126
'longitude' => $resultNode->getAttribute('lon'),
122-
'postalCode' => $this->getNodeValue($addressNode->getElementsByTagName('postcode')),
127+
'postalCode' => $postalCode,
123128
'adminLevels' => $adminLevels,
124129
'streetNumber' => $this->getNodeValue($addressNode->getElementsByTagName('house_number')),
125130
'streetName' => $this->getNodeValue($addressNode->getElementsByTagName('road')) ?: $this->getNodeValue($addressNode->getElementsByTagName('pedestrian')),

0 commit comments

Comments
 (0)