From: Artem Ziablytskyi Date: Wed, 6 Apr 2022 17:24:39 +0000 (+0200) Subject: use ISO3166-2-lvl instead of typeLabel prefix X-Git-Tag: v4.1.0~63^2~1 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/9a56e53d50211be8b34ac1ecddf0e2930f987701 use ISO3166-2-lvl instead of typeLabel prefix --- diff --git a/docs/api/Output.md b/docs/api/Output.md index 2dd2f55a..961f48b8 100644 --- a/docs/api/Output.md +++ b/docs/api/Output.md @@ -28,7 +28,7 @@ a single place (for reverse) of the following format: "city": "London", "state_district": "Greater London", "state": "England", - "state-ISO3166-2": "GB-ENG", + "ISO3166-2-lvl4": "GB-ENG", "postcode": "SW1A 2DU", "country": "United Kingdom", "country_code": "gb" @@ -127,7 +127,7 @@ formats depending on the API call. Bavaria - DE-BY + DE-BY Germany de @@ -181,7 +181,7 @@ Additional information requested with `addressdetails=1`, `extratags=1` and London Greater London England - GB-ENG + GB-ENG SW1A 2DU United Kingdom gb @@ -282,7 +282,7 @@ with a designation label. Per default the following labels may appear: * continent * country, country_code - * region, state, state-ISO3166-2, state_district, county, county-ISO3166-2 + * region, state, state_district, county, ISO3166-2-lvl * municipality, city, town, village * city_district, district, borough, suburb, subdivision * hamlet, croft, isolated_dwelling diff --git a/lib-php/AddressDetails.php b/lib-php/AddressDetails.php index 35786d22..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->addSubdivisionCode($aAddress, $sTypeLabel, $aLine['name']); + $this->addSubdivisionCode($aAddress, $aLine['admin_level'], $aLine['name']); } } } @@ -179,13 +179,13 @@ class AddressDetails return $this->aAddressLines; } - private function addSubdivisionCode(&$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']; } } } diff --git a/test/bdd/api/search/params.feature b/test/bdd/api/search/params.feature index b3df7d19..cc86e01b 100644 --- a/test/bdd/api/search/params.feature +++ b/test/bdd/api/search/params.feature @@ -34,6 +34,7 @@ Feature: Search queries | postcode | 9495 | | country | Liechtenstein | | country_code | li | + | ISO3166-2-lvl12 | LI-09 | Examples: | format | diff --git a/test/bdd/api/search/queries.feature b/test/bdd/api/search/queries.feature index 8b70dac1..d141122e 100644 --- a/test/bdd/api/search/queries.feature +++ b/test/bdd/api/search/queries.feature @@ -15,6 +15,7 @@ Feature: Search queries | postcode | 9497 | | country | Liechtenstein | | country_code | li | + | ISO3166-2-lvl10 | LI-10 | Scenario: House number interpolation When sending json search query "Grosssteg 1023, Triesenberg" with address @@ -41,6 +42,7 @@ Feature: Search queries | town | Triesenberg | | country | Liechtenstein | | country_code | li | + | ISO3166-2-lvl10 | LI-10 | Scenario Outline: Housenumber 0 can be found When sending search query "Gnalpstrasse 0" with address diff --git a/test/php/Nominatim/AddressDetailsTest.php b/test/php/Nominatim/AddressDetailsTest.php index 42a51add..2041dcb4 100644 --- a/test/php/Nominatim/AddressDetailsTest.php +++ b/test/php/Nominatim/AddressDetailsTest.php @@ -86,7 +86,8 @@ class AddressDetailsTest extends \PHPUnit\Framework\TestCase 'city' => 'London', 'state_district' => 'Greater London', 'state' => 'England', - 'state-ISO3166-2' => 'GB-ENG', + 'ISO3166-2-lvl4' => 'GB-ENG', + 'ISO3166-2-lvl6' => 'GB-LND', 'postcode' => 'SW1A 2AA', 'country' => 'United Kingdom', 'country_code' => 'gb' diff --git a/test/php/fixtures/address_details_10_downing_street.json b/test/php/fixtures/address_details_10_downing_street.json index 0a56beec..22d75c2e 100644 --- a/test/php/fixtures/address_details_10_downing_street.json +++ b/test/php/fixtures/address_details_10_downing_street.json @@ -133,7 +133,7 @@ {"place_id":193774423, "osm_type":"R", "osm_id":65606, - "name":{"name": "London", "name:be": "Лондан", "name:ca": "Londres", "name:el": "Λονδίνο", "name:en": "London", "name:eo": "Londono", "name:es": "Londres", "name:fa": "لندن", "name:fi": "Lontoo", "name:fr": "Londres", "name:fy": "Londen", "name:gl": "Londres", "name:hi": "लंदन", "name:lt": "Londonas", "name:nl": "Londen", "name:pl": "Londyn", "name:pt": "Londres", "name:ru": "Лондон", "name:uk": "Лондон", "name:vi": "Luân Đôn", "name:zh": "伦敦", "int_name": "London", "name:szl": "Lůndůn", "name:tzl": "Londra", "name:be-tarask": "Лёндан"}, + "name":{"name": "London", "ISO3166-2": "GB-LND", "name:be": "Лондан", "name:ca": "Londres", "name:el": "Λονδίνο", "name:en": "London", "name:eo": "Londono", "name:es": "Londres", "name:fa": "لندن", "name:fi": "Lontoo", "name:fr": "Londres", "name:fy": "Londen", "name:gl": "Londres", "name:hi": "लंदन", "name:lt": "Londonas", "name:nl": "Londen", "name:pl": "Londyn", "name:pt": "Londres", "name:ru": "Лондон", "name:uk": "Лондон", "name:vi": "Luân Đôn", "name:zh": "伦敦", "int_name": "London", "name:szl": "Lůndůn", "name:tzl": "Londra", "name:be-tarask": "Лёндан"}, "class":"place", "type":"city", "admin_level":6,