]> git.openstreetmap.org Git - nominatim.git/commitdiff
use ISO3166-2-lvl<admin_level> instead of typeLabel prefix
authorArtem Ziablytskyi <a.ziablytskyi@sportradar.com>
Wed, 6 Apr 2022 17:24:39 +0000 (19:24 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 7 Apr 2022 14:37:51 +0000 (16:37 +0200)
docs/api/Output.md
lib-php/AddressDetails.php
test/bdd/api/search/params.feature
test/bdd/api/search/queries.feature
test/php/Nominatim/AddressDetailsTest.php
test/php/fixtures/address_details_10_downing_street.json

index 2dd2f55af48e808a203d0dd59238b52fefbe239a..961f48b8eb6bf8178f03adb3522300e86fd08491 100644 (file)
@@ -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.
   </result>
   <addressparts>
      <state>Bavaria</state>
-     <state-ISO3166-2>DE-BY</state_code>
+     <ISO3166-2-lvl4>DE-BY</state_code>
      <country>Germany</country>
      <country_code>de</country_code>
   </addressparts>
@@ -181,7 +181,7 @@ Additional information requested with `addressdetails=1`, `extratags=1` and
     <city>London</city>
     <state_district>Greater London</state_district>
     <state>England</state>
-    <state-ISO3166-2>GB-ENG</state_code>
+    <ISO3166-2-lvl4>GB-ENG</state_code>
     <postcode>SW1A 2DU</postcode>
     <country>United Kingdom</country>
     <country_code>gb</country_code>
@@ -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<admin_level>
  * municipality, city, town, village
  * city_district, district, borough, suburb, subdivision
  * hamlet, croft, isolated_dwelling
index 35786d22691699c7191d05a34ecd38930312b7d0..cfdd04167c259de142147e00846ff1b9546fd8e7 100644 (file)
@@ -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'];
         }
     }
 }
index b3df7d1952b1ca4a90d383ce6db5361f695b7363..cc86e01bb90369a697dcaf2d984bc47382a79fa5 100644 (file)
@@ -34,6 +34,7 @@ Feature: Search queries
           | postcode     | 9495 |
           | country      | Liechtenstein |
           | country_code | li |
+          | ISO3166-2-lvl12 | LI-09 |
 
     Examples:
           | format |
index 8b70dac188ad968e36a9f2d80c3fb21021064b0b..d141122e1c32f145be2ef30b68b76cf574e3dca3 100644 (file)
@@ -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 <format> search query "Gnalpstrasse 0" with address
index 42a51add9f6602925469245b384ab461172271b7..2041dcb4bff2558ee447ef1fb3c15361090f7b39 100644 (file)
@@ -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'
index 0a56beeced93c7805677e3fc787948b9c5cd0903..22d75c2e2ca138829c6d15ad26f17c1ad5ee7aaf 100644 (file)
 {"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,