[boundaries] adding use_admin_center to boundary configs right alongside other overrides
This commit is contained in:
@@ -1,17 +1,21 @@
|
|||||||
---
|
---
|
||||||
admin_level:
|
admin_level:
|
||||||
"2": "country"
|
"2": "country"
|
||||||
"3": "country_region"
|
"3": "country_region"
|
||||||
"4": "state"
|
"4": "state"
|
||||||
"5": "state_district"
|
"5": "state_district"
|
||||||
"6": "city"
|
"6": "city"
|
||||||
"7": "city_district"
|
"7": "city_district"
|
||||||
"8": "city_district"
|
"8": "city_district"
|
||||||
"9": "suburb"
|
"9": "suburb"
|
||||||
|
|
||||||
|
|
||||||
overrides:
|
overrides:
|
||||||
id:
|
id:
|
||||||
relation:
|
relation:
|
||||||
# Bogotá
|
# Bogotá
|
||||||
"1387968": "city"
|
"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:
|
admin_level:
|
||||||
"2": "country"
|
"2": "country"
|
||||||
"4": "state"
|
"4": "state"
|
||||||
"5": "state_district"
|
"5": "state_district"
|
||||||
"6": "state_district"
|
"6": "state_district"
|
||||||
"8": "city"
|
"8": "city"
|
||||||
"9": "suburb"
|
"9": "suburb"
|
||||||
|
|
||||||
overrides:
|
overrides:
|
||||||
contained_by:
|
contained_by:
|
||||||
relation:
|
relation:
|
||||||
"407489":
|
# Luxembourg City
|
||||||
admin_level:
|
"407489":
|
||||||
"9": "city_district"
|
admin_level:
|
||||||
|
"9": "city_district"
|
||||||
|
|
||||||
|
use_admin_center:
|
||||||
|
- id: 407489 # Luxembourg City
|
||||||
|
type: relation
|
||||||
|
probability: 0.6
|
||||||
@@ -1,20 +1,25 @@
|
|||||||
---
|
---
|
||||||
admin_level:
|
admin_level:
|
||||||
"2": "country"
|
"2": "country"
|
||||||
"4": "state"
|
"4": "state"
|
||||||
"6": "state_district"
|
"6": "state_district"
|
||||||
"8": "city"
|
"8": "city"
|
||||||
"9": "city_district"
|
"9": "city_district"
|
||||||
"10": "city_district"
|
"10": "city_district"
|
||||||
|
|
||||||
|
|
||||||
overrides:
|
overrides:
|
||||||
id:
|
id:
|
||||||
relation:
|
relation:
|
||||||
|
# Mexico City
|
||||||
"1376330": "city"
|
"1376330": "city"
|
||||||
|
|
||||||
contained_by:
|
contained_by:
|
||||||
relation:
|
relation:
|
||||||
"1376330":
|
"1376330":
|
||||||
admin_level:
|
admin_level:
|
||||||
"6": "city_district"
|
"6": "city_district"
|
||||||
|
|
||||||
|
use_admin_center:
|
||||||
|
- id: 1376330 # Mexico City
|
||||||
|
type: relation
|
||||||
|
probability: 0.6
|
||||||
@@ -8,4 +8,4 @@
|
|||||||
id:
|
id:
|
||||||
relation:
|
relation:
|
||||||
# Niamey
|
# Niamey
|
||||||
"3218804": "city"
|
"3218804": "city"
|
||||||
|
|||||||
@@ -1,8 +1,76 @@
|
|||||||
---
|
---
|
||||||
admin_level:
|
admin_level:
|
||||||
"2": "country"
|
"2": "country"
|
||||||
"4": "state"
|
"4": "state"
|
||||||
"6": "state_district"
|
"6": "state_district"
|
||||||
"7": "city_district"
|
"8": "city_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,10 +9,16 @@
|
|||||||
overrides:
|
overrides:
|
||||||
id:
|
id:
|
||||||
relation:
|
relation:
|
||||||
|
# Bangkok
|
||||||
"92277": "city"
|
"92277": "city"
|
||||||
contained_by:
|
contained_by:
|
||||||
relation:
|
relation:
|
||||||
"92277":
|
"92277":
|
||||||
admin_level:
|
admin_level:
|
||||||
"6": "city_district"
|
"6": "city_district"
|
||||||
"8": "suburb"
|
"8": "suburb"
|
||||||
|
|
||||||
|
use_admin_center:
|
||||||
|
- id: 92277 # Bangkok
|
||||||
|
type: relation
|
||||||
|
probability: 0.85
|
||||||
@@ -109,12 +109,6 @@ category:
|
|||||||
|
|
||||||
boundaries:
|
boundaries:
|
||||||
abbreviate_toponym_probability: 0.35
|
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:
|
neighborhood:
|
||||||
# Usually in Germany, may have e.g. name:prefix=Ortsteil
|
# 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.address_formatting.formatter import AddressFormatter
|
||||||
from geodata.configs.utils import recursive_merge
|
from geodata.configs.utils import recursive_merge
|
||||||
|
|
||||||
|
from geodata.encoding import safe_encode
|
||||||
|
|
||||||
this_dir = os.path.realpath(os.path.dirname(__file__))
|
this_dir = os.path.realpath(os.path.dirname(__file__))
|
||||||
|
|
||||||
OSM_BOUNDARIES_DIR = os.path.join(this_dir, os.pardir, os.pardir, os.pardir,
|
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):
|
def __init__(self, boundaries_dir=OSM_BOUNDARIES_DIR):
|
||||||
self.config = {}
|
self.config = {}
|
||||||
|
|
||||||
|
self.use_admin_center = {}
|
||||||
|
|
||||||
for filename in os.listdir(boundaries_dir):
|
for filename in os.listdir(boundaries_dir):
|
||||||
if not filename.endswith('.yaml'):
|
if not filename.endswith('.yaml'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
country_code = filename.rsplit('.yaml', 1)[0]
|
country_code = filename.rsplit('.yaml', 1)[0]
|
||||||
data = yaml.load(open(os.path.join(boundaries_dir, filename)))
|
data = yaml.load(open(os.path.join(boundaries_dir, filename)))
|
||||||
|
|
||||||
for prop, values in six.iteritems(data):
|
for prop, values in six.iteritems(data):
|
||||||
for k, v in values.iteritems():
|
for k, v in values.iteritems():
|
||||||
if isinstance(v, six.string_types) and v not in AddressFormatter.address_formatter_fields:
|
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))
|
raise ValueError(u'Invalid value in {} for prop={}, key={}: {}'.format(filename, prop, k, v))
|
||||||
|
|
||||||
if prop == 'overrides':
|
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', {})
|
containing_overrides = values.get('contained_by', {})
|
||||||
|
|
||||||
if not containing_overrides:
|
if not containing_overrides:
|
||||||
|
|||||||
Reference in New Issue
Block a user