X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/82dbcbb12a1285e7b345e232196b02b9cae35f9a..82a98f3780e30eda30e2c4a47c70efeb9f6fda43:/lib-php/AddressDetails.php diff --git a/lib-php/AddressDetails.php b/lib-php/AddressDetails.php index 657dc3e2..cfdd0416 100644 --- a/lib-php/AddressDetails.php +++ b/lib-php/AddressDetails.php @@ -94,7 +94,7 @@ class AddressDetails $aAddress[$sTypeLabel] = $sName; if (!empty($aLine['name'])) { - $this->addStateCode($aAddress, $sTypeLabel, $aLine['name']); + $this->addSubdivisionCode($aAddress, $aLine['admin_level'], $aLine['name']); } } } @@ -179,16 +179,13 @@ class AddressDetails return $this->aAddressLines; } - /** - * Add `state_code` field to address details to represent second part of ISO 3166-2 country subdivision code - */ - private function addStateCode(&$aAddress, $sTypeLabel, $nameDetails) + private function addSubdivisionCode(&$aAddress, $iAdminLevel, $nameDetails) { if (is_string($nameDetails)) { $nameDetails = json_decode('{' . str_replace('"=>"', '":"', $nameDetails) . '}', true); } if (!empty($nameDetails['ISO3166-2'])) { - $aAddress["$sTypeLabel:ISO3166-2"] = $nameDetails['ISO3166-2']; + $aAddress["ISO3166-2-lvl$iAdminLevel"] = $nameDetails['ISO3166-2']; } } }