]> git.openstreetmap.org Git - nominatim.git/commitdiff
Change the key to `<addresspart_type>-ISO3166-2` to support xml response correctly
authorArtem Ziablytskyi <a.ziablytskyi@sportradar.com>
Wed, 26 Jan 2022 16:40:39 +0000 (17:40 +0100)
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/php/Nominatim/AddressDetailsTest.php

index d3ecf8d7570f6c066cc0aa898ac19cf2a70ed6f6..a584d2510e9a0b167a8efe451e006f8d72f9eeaa 100644 (file)
@@ -28,7 +28,7 @@ a single place (for reverse) of the following format:
       "city": "London",
       "state_district": "Greater London",
       "state": "England",
       "city": "London",
       "state_district": "Greater London",
       "state": "England",
-      "ISO3166-2": "GB-ENG",
+      "state-ISO3166-2": "GB-ENG",
       "postcode": "SW1A 2DU",
       "country": "United Kingdom",
       "country_code": "gb"
       "postcode": "SW1A 2DU",
       "country": "United Kingdom",
       "country_code": "gb"
@@ -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>
     <city>London</city>
     <state_district>Greater London</state_district>
     <state>England</state>
-    <state_code>ENG</state_code>
+    <state-ISO3166-2>GB-ENG</state_code>
     <postcode>SW1A 2DU</postcode>
     <country>United Kingdom</country>
     <country_code>gb</country_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
 
  * continent
  * country, country_code
- * region, state, state_code, state_district, county
+ * region, state, state-ISO3166-2, state_district, county, county-ISO3166-2
  * municipality, city, town, village
  * city_district, district, borough, suburb, subdivision
  * hamlet, croft, isolated_dwelling
  * municipality, city, town, village
  * city_district, district, borough, suburb, subdivision
  * hamlet, croft, isolated_dwelling
index 657dc3e26a687af457d7c82f40c5ace30d07c1aa..35786d22691699c7191d05a34ecd38930312b7d0 100644 (file)
@@ -94,7 +94,7 @@ class AddressDetails
                 $aAddress[$sTypeLabel] = $sName;
 
                 if (!empty($aLine['name'])) {
                 $aAddress[$sTypeLabel] = $sName;
 
                 if (!empty($aLine['name'])) {
-                    $this->addStateCode($aAddress, $sTypeLabel, $aLine['name']);
+                    $this->addSubdivisionCode($aAddress, $sTypeLabel, $aLine['name']);
                 }
             }
         }
                 }
             }
         }
@@ -179,16 +179,13 @@ class AddressDetails
         return $this->aAddressLines;
     }
 
         return $this->aAddressLines;
     }
 
-    /**
-     * Add `state_code` field to address details to represent second part of ISO 3166-2 country subdivision code
-     */
-    private function addStateCode(&$aAddress, $sTypeLabel, $nameDetails)
+    private function addSubdivisionCode(&$aAddress, $sTypeLabel, $nameDetails)
     {
         if (is_string($nameDetails)) {
             $nameDetails = json_decode('{' . str_replace('"=>"', '":"', $nameDetails) . '}', true);
         }
         if (!empty($nameDetails['ISO3166-2'])) {
     {
         if (is_string($nameDetails)) {
             $nameDetails = json_decode('{' . str_replace('"=>"', '":"', $nameDetails) . '}', true);
         }
         if (!empty($nameDetails['ISO3166-2'])) {
-            $aAddress["$sTypeLabel:ISO3166-2"] = $nameDetails['ISO3166-2'];
+            $aAddress["$sTypeLabel-ISO3166-2"] = $nameDetails['ISO3166-2'];
         }
     }
 }
         }
     }
 }
index 02813286bb0c0a9b94fe7a4fcb556fb95eb6cfba..42a51add9f6602925469245b384ab461172271b7 100644 (file)
@@ -86,7 +86,7 @@ class AddressDetailsTest extends \PHPUnit\Framework\TestCase
                      'city' => 'London',
                      'state_district' => 'Greater London',
                      'state' => 'England',
                      'city' => 'London',
                      'state_district' => 'Greater London',
                      'state' => 'England',
-                     'state:ISO3166-2' => 'GB-ENG',
+                     'state-ISO3166-2' => 'GB-ENG',
                      'postcode' => 'SW1A 2AA',
                      'country' => 'United Kingdom',
                      'country_code' => 'gb'
                      'postcode' => 'SW1A 2AA',
                      'country' => 'United Kingdom',
                      'country_code' => 'gb'