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