-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch_kml.py
executable file
·43 lines (32 loc) · 1.11 KB
/
fetch_kml.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Test the GPX File for coverage, so it is tagged correctly when uploaded
import argparse
import logging
from gpx import gpx_data
from gpx import gpx_store
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
parser = argparse.ArgumentParser(description='Load and create a KML file')
parser.add_argument('--cache_dir', metavar='DIR', type=str,
help='Location of cache', default=gpx_store.cache_dir)
parser.add_argument('obj_id', type=int, help='relation ID of object')
parser.add_argument('obj_level', type=int, help='Level of object')
args = parser.parse_args()
if 'cache_dir' in args:
gpx_store.cache_dir = args.cache_dir
gpx_store.init_cache()
try:
tags = gpx_data.load_tags(args.obj_id, args.obj_level)
except:
tags = dict({ 'name': 'unknown', })
name = str(args.obj_id)
if 'name:en' in tags:
name = tags['name:en']
else:
try:
name = tags['name']
except:
pass
geos = gpx_data.load_geo_shape(args.obj_id, args.obj_level, name)
gpx_store.store_kml(geos, args.obj_id, args.obj_level, name)