-
Notifications
You must be signed in to change notification settings - Fork 1
/
ignite.py
47 lines (39 loc) · 1.63 KB
/
ignite.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
44
45
46
47
"""IGNite: generate the geo-referenced IGN map of an area.
Usage: ignite.py [options] <upper_left> <lower_right> <zoom>
Options:
-h --help Show this screen.
--processes <p> Number of processes used for requests [default: 4].
--out <file> Output filename [default: out].
--cache-folder <folder> Cache directory [default: cache].
--capabilities <file> Capabilities filename [default: capabilities.xml]
--no-caching Do not save temporary tiles for caching and fast reloading.
--backend <backend> Which backend to use, between ign and cyclosm [default: cyclosm].
Note:
Coordinates should be given as latitude,longitude in decimal degrees.
"""
from docopt import docopt
import functools
import numpy as np
from backend.ign import IGNMap
from backend.cyclosm import CyclOSMMap
def parse_position(location: str) -> np.ndarray:
return np.array(tuple(map(float, location.split(","))))
if __name__ == '__main__':
args = docopt(__doc__, version='IGNite 1.0')
if args['--backend'] == 'ign':
map_class = IGNMap
map_class = functools.partial(map_class, capabilities=args['--capabilities'])
elif args['--backend'] == 'cyclosm':
map_class = CyclOSMMap
else:
raise ValueError('Invalid backend')
tiled_map = map_class(
min_point=parse_position(args["<upper_left>"]),
max_point=parse_position(args["<lower_right>"]),
zoom=int(args["<zoom>"]),
output_path=args['--out'],
cache_folder=args['--cache-folder'],
no_caching=args['--no-caching'],
processes=args['--processes'],
)
tiled_map.run()