Skip to content

Commit

Permalink
add missing FR-10 geojson
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperknot committed Apr 11, 2020
1 parent 78048b9 commit bb85205
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
8 changes: 7 additions & 1 deletion country_levels_lib/wam/wam_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from country_levels_lib.config import geojson_dir, fixes_dir
from country_levels_lib.utils import read_json, osm_url, wikidata_url, write_json
from country_levels_lib.wam.wam_download import wam_geojson_download_dir, wam_data_dir
from country_levels_lib.wam.wam_missing import get_osm_missing_features
from country_levels_lib.wikidata.wikidata_iso import (
get_osm_iso1_map,
get_osm_wd_map,
Expand Down Expand Up @@ -51,7 +52,7 @@ def collect_iso():

wd_ids_collected = set()

for f in itertools.islice(geojson_files_sorted, None, None):
for f in geojson_files_sorted:
print(f.parent.stem, f.stem)
try:
features = read_json(f)['features']
Expand All @@ -61,6 +62,11 @@ def collect_iso():
new_wd_ids = add_iso(features, iso1_found, iso2_found)
wd_ids_collected = wd_ids_collected.union(new_wd_ids)

# add features from osm_missing
osm_missing_features = get_osm_missing_features()
new_wd_ids = add_iso(osm_missing_features, iso1_found, iso2_found)
wd_ids_collected = wd_ids_collected.union(new_wd_ids)

wam_data_dir.mkdir(parents=True, exist_ok=True)
write_json(wam_data_dir / 'wd_ids_collected.json', list(wd_ids_collected))

Expand Down
2 changes: 1 addition & 1 deletion country_levels_lib/wam/wam_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def split_geojson(iso_level: int, simp_level, *, debug: bool = False):
if wikipedia_from_prop:
wikipedia_id = wikipedia_from_prop

del feature['bbox']
feature.pop('bbox', None)

for key in ['boundary', 'note', 'rpath', 'srid', 'timestamp']:
prop.pop(key, None)
Expand Down
30 changes: 30 additions & 0 deletions country_levels_lib/wam/wam_missing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from country_levels_lib.config import fixes_dir
from country_levels_lib.utils import read_json


def get_osm_missing_features():
osm_missing_dir = fixes_dir / 'osm_missing'
geojson_paths = osm_missing_dir.glob('*.geojson')

features = []
for geojson_path in geojson_paths:
feature = read_json(geojson_path)
process_overpass_turbo_geojson(feature)
features.append(feature)

return features


def process_overpass_turbo_geojson(feature):
props = feature['properties']
props['id'] = int(props.pop('@id').split('/')[1])

keys_to_alltags = ['ISO3166-1', 'ISO3166-2']
keys_to_alltags.extend({k for k in props.keys() if k.startswith('name:')})

alltags = {}
for key in keys_to_alltags:
if key in props:
alltags[key] = props.pop(key)

props['alltags'] = alltags
1 change: 1 addition & 0 deletions fixes/osm_missing/fr10.geojson

Large diffs are not rendered by default.

0 comments on commit bb85205

Please sign in to comment.