[osm] adding admin1 ids to the OSM country rtree

This commit is contained in:
Al
2016-10-04 23:12:15 -04:00
parent 2bc109f519
commit 6081df0cd1
2 changed files with 7 additions and 1 deletions

View File

@@ -22,6 +22,8 @@ road_language_overrides = defaultdict(OrderedDict)
languages = set()
all_languages = languages
osm_admin1_ids = set()
languages_initialized = False
@@ -50,6 +52,8 @@ def init_languages(languages_dir=LANGUAGES_DIR):
path = os.path.join(languages_dir, 'regional', 'adm1.tsv')
for country, key, value, langs, default in unicode_csv_reader(open(path), delimiter='\t'):
if key == 'osm':
osm_admin1_ids.add(tuple(value.split(':')))
for lang in langs.split(','):
regional_languages[(country, key, value)][lang] = int(default)
if lang not in country_languages[country]:

View File

@@ -14,8 +14,10 @@ from collections import defaultdict, OrderedDict
from itertools import izip, combinations
from geodata.coordinates.conversion import latlon_to_decimal
from geodata.encoding import safe_encode, safe_decode
from geodata.file_utils import ensure_dir
from geodata.graph.scc import strongly_connected_components
from geodata.i18n.languages import osm_admin1_ids
from geodata.math.floats import isclose
from geodata.osm.extract import *
@@ -312,7 +314,7 @@ class OSMBuildingPolygonReader(OSMPolygonReader):
class OSMCountryPolygonReader(OSMPolygonReader):
def include_polygon(self, props):
return 'ISO3166-1:alpha2' in props
return 'ISO3166-1:alpha2' in props or (props.get('type', 'relation'), safe_encode(props.get('id', ''))) in osm_admin1_ids
class OSMPostalCodesPolygonReader(OSMPolygonReader):