X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/3f73a363f42cb3cb6627ddcea371e3a22810daa6..6eb1113dcb569f07367a801e6ac2dcb9565ec7b8:/lib-php/AddressDetails.php diff --git a/lib-php/AddressDetails.php b/lib-php/AddressDetails.php index bf8defc2..cfdd0416 100644 --- a/lib-php/AddressDetails.php +++ b/lib-php/AddressDetails.php @@ -1,4 +1,12 @@ addSubdivisionCode($aAddress, $aLine['admin_level'], $aLine['name']); } } } @@ -167,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']; + } + } }