[boundaries] adding use_admin_center to boundary configs right alongside other overrides
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
---
|
||||
admin_level:
|
||||
"2": "country"
|
||||
"3": "country_region"
|
||||
"4": "state"
|
||||
"5": "state_district"
|
||||
"6": "city"
|
||||
"7": "city_district"
|
||||
"8": "city_district"
|
||||
"9": "suburb"
|
||||
|
||||
|
||||
admin_level:
|
||||
"2": "country"
|
||||
"3": "country_region"
|
||||
"4": "state"
|
||||
"5": "state_district"
|
||||
"6": "city"
|
||||
"7": "city_district"
|
||||
"8": "city_district"
|
||||
"9": "suburb"
|
||||
overrides:
|
||||
id:
|
||||
relation:
|
||||
# Bogotá
|
||||
"1387968": "city"
|
||||
|
||||
use_admin_center:
|
||||
- id: 1387968 # Bogotá
|
||||
type: relation
|
||||
# Occasionally use properties/names from the state boundary
|
||||
probability: 0.8
|
||||
@@ -1,15 +1,21 @@
|
||||
---
|
||||
admin_level:
|
||||
"2": "country"
|
||||
"4": "state"
|
||||
"5": "state_district"
|
||||
"6": "state_district"
|
||||
"8": "city"
|
||||
"9": "suburb"
|
||||
admin_level:
|
||||
"2": "country"
|
||||
"4": "state"
|
||||
"5": "state_district"
|
||||
"6": "state_district"
|
||||
"8": "city"
|
||||
"9": "suburb"
|
||||
|
||||
overrides:
|
||||
contained_by:
|
||||
relation:
|
||||
"407489":
|
||||
admin_level:
|
||||
"9": "city_district"
|
||||
relation:
|
||||
# Luxembourg City
|
||||
"407489":
|
||||
admin_level:
|
||||
"9": "city_district"
|
||||
|
||||
use_admin_center:
|
||||
- id: 407489 # Luxembourg City
|
||||
type: relation
|
||||
probability: 0.6
|
||||
@@ -1,16 +1,16 @@
|
||||
---
|
||||
admin_level:
|
||||
"2": "country"
|
||||
"4": "state"
|
||||
"6": "state_district"
|
||||
"8": "city"
|
||||
"9": "city_district"
|
||||
"10": "city_district"
|
||||
|
||||
admin_level:
|
||||
"2": "country"
|
||||
"4": "state"
|
||||
"6": "state_district"
|
||||
"8": "city"
|
||||
"9": "city_district"
|
||||
"10": "city_district"
|
||||
|
||||
overrides:
|
||||
id:
|
||||
relation:
|
||||
# Mexico City
|
||||
"1376330": "city"
|
||||
|
||||
contained_by:
|
||||
@@ -18,3 +18,8 @@
|
||||
"1376330":
|
||||
admin_level:
|
||||
"6": "city_district"
|
||||
|
||||
use_admin_center:
|
||||
- id: 1376330 # Mexico City
|
||||
type: relation
|
||||
probability: 0.6
|
||||
@@ -1,8 +1,76 @@
|
||||
---
|
||||
admin_level:
|
||||
"2": "country"
|
||||
"4": "state"
|
||||
"6": "state_district"
|
||||
"7": "city_district"
|
||||
"8": "city_district"
|
||||
admin_level:
|
||||
"2": "country"
|
||||
"4": "state"
|
||||
"6": "state_district"
|
||||
"8": "city_district"
|
||||
|
||||
overrides:
|
||||
id:
|
||||
relation:
|
||||
# Auckland
|
||||
"2094141": "city"
|
||||
# Wellington
|
||||
"4266321": "city"
|
||||
# Christchurch
|
||||
"1640161": "city"
|
||||
# Hamilton
|
||||
"2595124": "city"
|
||||
# Dunedin
|
||||
"4426790": "city"
|
||||
# Tauranga
|
||||
"4266815": "city"
|
||||
# Lower Hutt
|
||||
"4266371": "city"
|
||||
# Palmerston North
|
||||
"3440209": "city"
|
||||
# Napier
|
||||
"2731991": "city"
|
||||
# Porirua
|
||||
"4266370": "city"
|
||||
# Invercargill
|
||||
"1656388": "city"
|
||||
# Nelson
|
||||
"4266962": "city"
|
||||
# Upper Hutt
|
||||
"4266375": "city"
|
||||
|
||||
use_admin_center:
|
||||
- id: 2094141 # Auckland
|
||||
type: relation
|
||||
- id: 4266321 # Wellington
|
||||
type: relation
|
||||
probability: 0.7
|
||||
- id: 1640161 # Christchurch
|
||||
type: relation
|
||||
probability: 0.7
|
||||
- id: 2595124 # Hamilton
|
||||
type: relation
|
||||
probability: 0.7
|
||||
- id: 4426790 # Dunedin
|
||||
type: relation
|
||||
probability: 0.7
|
||||
- id: 4266815 # Tauranga
|
||||
type: relation
|
||||
probability: 0.7
|
||||
- id: 4266371 # Lower Hutt
|
||||
type: relation
|
||||
probability: 0.7
|
||||
- id: 3440209 # Palmerston North
|
||||
type: relation
|
||||
probability: 0.7
|
||||
- id: 2731991 # Napier
|
||||
type: relation
|
||||
probability: 0.7
|
||||
- id: 4266370 # Porirua
|
||||
type: relation
|
||||
probability: 0.7
|
||||
- id: 1656388 # Invercargill
|
||||
type: relation
|
||||
probability: 0.7
|
||||
- id: 4266962 # Nelson
|
||||
type: relation
|
||||
- id: 4266375 # Upper Hutt
|
||||
type: relation
|
||||
probability: 0.7
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
overrides:
|
||||
id:
|
||||
relation:
|
||||
# Bangkok
|
||||
"92277": "city"
|
||||
contained_by:
|
||||
relation:
|
||||
@@ -16,3 +17,8 @@
|
||||
admin_level:
|
||||
"6": "city_district"
|
||||
"8": "suburb"
|
||||
|
||||
use_admin_center:
|
||||
- id: 92277 # Bangkok
|
||||
type: relation
|
||||
probability: 0.85
|
||||
@@ -109,12 +109,6 @@ category:
|
||||
|
||||
boundaries:
|
||||
abbreviate_toponym_probability: 0.35
|
||||
# OSM relations should inherit properties from their admin_center
|
||||
override_with_admin_center:
|
||||
- id: 92277 # Bangkok, Thailand
|
||||
type: relation
|
||||
- id: 1387968 # Bogotá, Colombia
|
||||
type: relation
|
||||
|
||||
neighborhood:
|
||||
# Usually in Germany, may have e.g. name:prefix=Ortsteil
|
||||
|
||||
@@ -8,6 +8,8 @@ from copy import deepcopy
|
||||
from geodata.address_formatting.formatter import AddressFormatter
|
||||
from geodata.configs.utils import recursive_merge
|
||||
|
||||
from geodata.encoding import safe_encode
|
||||
|
||||
this_dir = os.path.realpath(os.path.dirname(__file__))
|
||||
|
||||
OSM_BOUNDARIES_DIR = os.path.join(this_dir, os.pardir, os.pardir, os.pardir,
|
||||
@@ -61,18 +63,23 @@ class OSMAddressComponents(object):
|
||||
def __init__(self, boundaries_dir=OSM_BOUNDARIES_DIR):
|
||||
self.config = {}
|
||||
|
||||
self.use_admin_center = {}
|
||||
|
||||
for filename in os.listdir(boundaries_dir):
|
||||
if not filename.endswith('.yaml'):
|
||||
continue
|
||||
|
||||
country_code = filename.rsplit('.yaml', 1)[0]
|
||||
data = yaml.load(open(os.path.join(boundaries_dir, filename)))
|
||||
|
||||
for prop, values in six.iteritems(data):
|
||||
for k, v in values.iteritems():
|
||||
if isinstance(v, six.string_types) and v not in AddressFormatter.address_formatter_fields:
|
||||
raise ValueError(u'Invalid value in {} for prop={}, key={}: {}'.format(filename, prop, k, v))
|
||||
|
||||
if prop == 'overrides':
|
||||
self.use_admin_center.update({(r['type'], safe_encode(r['id'])): r.get('probability', 1.0) for r in values.get('use_admin_center', [])})
|
||||
|
||||
containing_overrides = values.get('contained_by', {})
|
||||
|
||||
if not containing_overrides:
|
||||
|
||||
Reference in New Issue
Block a user