X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/c4f22a42eba499ed1854c5967b2e3932fe9b3896..7d911f9ffbdf63b2b2a45c3a3ee7063d006a5779:/lib-php/AddressDetails.php diff --git a/lib-php/AddressDetails.php b/lib-php/AddressDetails.php index 1bd475ad..cfdd0416 100644 --- a/lib-php/AddressDetails.php +++ b/lib-php/AddressDetails.php @@ -92,6 +92,10 @@ class AddressDetails || $aLine['class'] == 'place') ) { $aAddress[$sTypeLabel] = $sName; + + if (!empty($aLine['name'])) { + $this->addSubdivisionCode($aAddress, $aLine['admin_level'], $aLine['name']); + } } } @@ -174,4 +178,14 @@ class AddressDetails { return $this->aAddressLines; } + + private function addSubdivisionCode(&$aAddress, $iAdminLevel, $nameDetails) + { + if (is_string($nameDetails)) { + $nameDetails = json_decode('{' . str_replace('"=>"', '":"', $nameDetails) . '}', true); + } + if (!empty($nameDetails['ISO3166-2'])) { + $aAddress["ISO3166-2-lvl$iAdminLevel"] = $nameDetails['ISO3166-2']; + } + } }