[osm] adding admin1 ids to the OSM country rtree
This commit is contained in:
@@ -22,6 +22,8 @@ road_language_overrides = defaultdict(OrderedDict)
|
|||||||
languages = set()
|
languages = set()
|
||||||
all_languages = languages
|
all_languages = languages
|
||||||
|
|
||||||
|
osm_admin1_ids = set()
|
||||||
|
|
||||||
languages_initialized = False
|
languages_initialized = False
|
||||||
|
|
||||||
|
|
||||||
@@ -50,6 +52,8 @@ def init_languages(languages_dir=LANGUAGES_DIR):
|
|||||||
path = os.path.join(languages_dir, 'regional', 'adm1.tsv')
|
path = os.path.join(languages_dir, 'regional', 'adm1.tsv')
|
||||||
|
|
||||||
for country, key, value, langs, default in unicode_csv_reader(open(path), delimiter='\t'):
|
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(','):
|
for lang in langs.split(','):
|
||||||
regional_languages[(country, key, value)][lang] = int(default)
|
regional_languages[(country, key, value)][lang] = int(default)
|
||||||
if lang not in country_languages[country]:
|
if lang not in country_languages[country]:
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ from collections import defaultdict, OrderedDict
|
|||||||
from itertools import izip, combinations
|
from itertools import izip, combinations
|
||||||
|
|
||||||
from geodata.coordinates.conversion import latlon_to_decimal
|
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.file_utils import ensure_dir
|
||||||
from geodata.graph.scc import strongly_connected_components
|
from geodata.graph.scc import strongly_connected_components
|
||||||
|
from geodata.i18n.languages import osm_admin1_ids
|
||||||
from geodata.math.floats import isclose
|
from geodata.math.floats import isclose
|
||||||
from geodata.osm.extract import *
|
from geodata.osm.extract import *
|
||||||
|
|
||||||
@@ -312,7 +314,7 @@ class OSMBuildingPolygonReader(OSMPolygonReader):
|
|||||||
|
|
||||||
class OSMCountryPolygonReader(OSMPolygonReader):
|
class OSMCountryPolygonReader(OSMPolygonReader):
|
||||||
def include_polygon(self, props):
|
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):
|
class OSMPostalCodesPolygonReader(OSMPolygonReader):
|
||||||
|
|||||||
Reference in New Issue
Block a user