mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-12 22:04:07 +00:00
Merge pull request #2466 from I70l0teN4ik/state-code
add ISO3166-2-lvl<admin_level> field to response address details
This commit is contained in:
@@ -42,9 +42,9 @@ is.
|
|||||||
|
|
||||||
```
|
```
|
||||||
# inside the virtual machine:
|
# inside the virtual machine:
|
||||||
cd build
|
cd nominatim-project
|
||||||
wget --no-verbose --output-document=/tmp/monaco.osm.pbf http://download.geofabrik.de/europe/monaco-latest.osm.pbf
|
wget --no-verbose --output-document=monaco.osm.pbf http://download.geofabrik.de/europe/monaco-latest.osm.pbf
|
||||||
./utils/setup.php --osm-file /tmp/monaco.osm.pbf --osm2pgsql-cache 1000 --all 2>&1 | tee monaco.$$.log
|
nominatim import --osm-file monaco.osm.pbf 2>&1 | tee monaco.$$.log
|
||||||
```
|
```
|
||||||
|
|
||||||
To repeat an import you'd need to delete the database first
|
To repeat an import you'd need to delete the database first
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ a single place (for reverse) of the following format:
|
|||||||
"city": "London",
|
"city": "London",
|
||||||
"state_district": "Greater London",
|
"state_district": "Greater London",
|
||||||
"state": "England",
|
"state": "England",
|
||||||
|
"ISO3166-2-lvl4": "GB-ENG",
|
||||||
"postcode": "SW1A 2DU",
|
"postcode": "SW1A 2DU",
|
||||||
"country": "United Kingdom",
|
"country": "United Kingdom",
|
||||||
"country_code": "gb"
|
"country_code": "gb"
|
||||||
@@ -126,6 +127,7 @@ formats depending on the API call.
|
|||||||
</result>
|
</result>
|
||||||
<addressparts>
|
<addressparts>
|
||||||
<state>Bavaria</state>
|
<state>Bavaria</state>
|
||||||
|
<ISO3166-2-lvl4>DE-BY</ISO3166-2-lvl4>
|
||||||
<country>Germany</country>
|
<country>Germany</country>
|
||||||
<country_code>de</country_code>
|
<country_code>de</country_code>
|
||||||
</addressparts>
|
</addressparts>
|
||||||
@@ -179,6 +181,7 @@ Additional information requested with `addressdetails=1`, `extratags=1` and
|
|||||||
<city>London</city>
|
<city>London</city>
|
||||||
<state_district>Greater London</state_district>
|
<state_district>Greater London</state_district>
|
||||||
<state>England</state>
|
<state>England</state>
|
||||||
|
<ISO3166-2-lvl4>GB-ENG</ISO3166-2-lvl4>
|
||||||
<postcode>SW1A 2DU</postcode>
|
<postcode>SW1A 2DU</postcode>
|
||||||
<country>United Kingdom</country>
|
<country>United Kingdom</country>
|
||||||
<country_code>gb</country_code>
|
<country_code>gb</country_code>
|
||||||
@@ -279,7 +282,7 @@ with a designation label. Per default the following labels may appear:
|
|||||||
|
|
||||||
* continent
|
* continent
|
||||||
* country, country_code
|
* country, country_code
|
||||||
* region, state, state_district, county
|
* region, state, state_district, county, ISO3166-2-lvl<admin_level>
|
||||||
* municipality, city, town, village
|
* municipality, city, town, village
|
||||||
* city_district, district, borough, suburb, subdivision
|
* city_district, district, borough, suburb, subdivision
|
||||||
* hamlet, croft, isolated_dwelling
|
* hamlet, croft, isolated_dwelling
|
||||||
|
|||||||
@@ -92,6 +92,10 @@ class AddressDetails
|
|||||||
|| $aLine['class'] == 'place')
|
|| $aLine['class'] == 'place')
|
||||||
) {
|
) {
|
||||||
$aAddress[$sTypeLabel] = $sName;
|
$aAddress[$sTypeLabel] = $sName;
|
||||||
|
|
||||||
|
if (!empty($aLine['name'])) {
|
||||||
|
$this->addSubdivisionCode($aAddress, $aLine['admin_level'], $aLine['name']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,4 +178,14 @@ class AddressDetails
|
|||||||
{
|
{
|
||||||
return $this->aAddressLines;
|
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'];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ Feature: Search queries
|
|||||||
| postcode | 9495 |
|
| postcode | 9495 |
|
||||||
| country | Liechtenstein |
|
| country | Liechtenstein |
|
||||||
| country_code | li |
|
| country_code | li |
|
||||||
|
| ISO3166-2-lvl8 | LI-09 |
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
| format |
|
| format |
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ Feature: Search queries
|
|||||||
| postcode | 9497 |
|
| postcode | 9497 |
|
||||||
| country | Liechtenstein |
|
| country | Liechtenstein |
|
||||||
| country_code | li |
|
| country_code | li |
|
||||||
|
| ISO3166-2-lvl8 | LI-10 |
|
||||||
|
|
||||||
Scenario: House number interpolation
|
Scenario: House number interpolation
|
||||||
When sending json search query "Grosssteg 1023, Triesenberg" with address
|
When sending json search query "Grosssteg 1023, Triesenberg" with address
|
||||||
@@ -41,6 +42,7 @@ Feature: Search queries
|
|||||||
| town | Triesenberg |
|
| town | Triesenberg |
|
||||||
| country | Liechtenstein |
|
| country | Liechtenstein |
|
||||||
| country_code | li |
|
| country_code | li |
|
||||||
|
| ISO3166-2-lvl8 | LI-10 |
|
||||||
|
|
||||||
Scenario Outline: Housenumber 0 can be found
|
Scenario Outline: Housenumber 0 can be found
|
||||||
When sending <format> search query "Gnalpstrasse 0" with address
|
When sending <format> search query "Gnalpstrasse 0" with address
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ class AddressDetailsTest extends \PHPUnit\Framework\TestCase
|
|||||||
'city' => 'London',
|
'city' => 'London',
|
||||||
'state_district' => 'Greater London',
|
'state_district' => 'Greater London',
|
||||||
'state' => 'England',
|
'state' => 'England',
|
||||||
|
'ISO3166-2-lvl4' => 'GB-ENG',
|
||||||
|
'ISO3166-2-lvl6' => 'GB-LND',
|
||||||
'postcode' => 'SW1A 2AA',
|
'postcode' => 'SW1A 2AA',
|
||||||
'country' => 'United Kingdom',
|
'country' => 'United Kingdom',
|
||||||
'country_code' => 'gb'
|
'country_code' => 'gb'
|
||||||
|
|||||||
@@ -133,7 +133,7 @@
|
|||||||
{"place_id":193774423,
|
{"place_id":193774423,
|
||||||
"osm_type":"R",
|
"osm_type":"R",
|
||||||
"osm_id":65606,
|
"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",
|
"class":"place",
|
||||||
"type":"city",
|
"type":"city",
|
||||||
"admin_level":6,
|
"admin_level":6,
|
||||||
@@ -157,7 +157,7 @@
|
|||||||
{"place_id":194325361,
|
{"place_id":194325361,
|
||||||
"osm_type":"R",
|
"osm_type":"R",
|
||||||
"osm_id":58447,
|
"osm_id":58447,
|
||||||
"name":{"name": "England", "name:be": "Англія", "name:br": "Bro-Saoz", "name:ca": "Anglaterra", "name:cs": "Anglie", "name:cy": "Lloegr", "name:de": "England", "name:el": "Αγγλία", "name:en": "England", "name:eo": "Anglujo", "name:es": "Inglaterra", "name:fi": "Englanti", "name:fr": "Angleterre", "name:fy": "Ingelân", "name:ga": "Sasana", "name:gd": "Sasainn", "name:gv": "Sostyn", "name:he": "אנגליה", "name:hu": "Anglia", "name:ia": "Anglaterra", "name:io": "Anglia", "name:it": "Inghilterra", "name:la": "Anglia", "name:lt": "Anglija", "name:nl": "Engeland", "name:pl": "Anglia", "name:pt": "Inglaterra", "name:ru": "Англия", "name:sk": "Anglicko", "name:sv": "England", "name:tr": "İngiltere", "name:uk": "Англія", "name:vi": "Anh", "name:vo": "Linglän", "name:zh": "英格蘭", "name:hsb": "Jendźelska", "name:nds": "England", "name:tok": "ma Inli", "name:tzl": "Anglatzara", "alt_name:eo": "Anglio", "alt_name:ia": "Anglia", "old_name:vi": "Anh Quốc", "alt_name:nds": "Ingland", "name:be-tarask": "Ангельшчына", "name:zh-classical": "英格蘭", "name:zh-simplified": "英格兰", "name:zh-traditional": "英格蘭"},
|
"name":{"ref": "ENG", "ISO3166-2": "GB-ENG", "name": "England", "name:be": "Англія", "name:br": "Bro-Saoz", "name:ca": "Anglaterra", "name:cs": "Anglie", "name:cy": "Lloegr", "name:de": "England", "name:el": "Αγγλία", "name:en": "England", "name:eo": "Anglujo", "name:es": "Inglaterra", "name:fi": "Englanti", "name:fr": "Angleterre", "name:fy": "Ingelân", "name:ga": "Sasana", "name:gd": "Sasainn", "name:gv": "Sostyn", "name:he": "אנגליה", "name:hu": "Anglia", "name:ia": "Anglaterra", "name:io": "Anglia", "name:it": "Inghilterra", "name:la": "Anglia", "name:lt": "Anglija", "name:nl": "Engeland", "name:pl": "Anglia", "name:pt": "Inglaterra", "name:ru": "Англия", "name:sk": "Anglicko", "name:sv": "England", "name:tr": "İngiltere", "name:uk": "Англія", "name:vi": "Anh", "name:vo": "Linglän", "name:zh": "英格蘭", "name:hsb": "Jendźelska", "name:nds": "England", "name:tok": "ma Inli", "name:tzl": "Anglatzara", "alt_name:eo": "Anglio", "alt_name:ia": "Anglia", "old_name:vi": "Anh Quốc", "alt_name:nds": "Ingland", "name:be-tarask": "Ангельшчына", "name:zh-classical": "英格蘭", "name:zh-simplified": "英格兰", "name:zh-traditional": "英格蘭"},
|
||||||
"class":"boundary",
|
"class":"boundary",
|
||||||
"type":"administrative",
|
"type":"administrative",
|
||||||
"admin_level":4,
|
"admin_level":4,
|
||||||
@@ -214,4 +214,4 @@
|
|||||||
"rank_address":4,
|
"rank_address":4,
|
||||||
"distance":0,
|
"distance":0,
|
||||||
"localname":"gb"}
|
"localname":"gb"}
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user