-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdodo.py
72 lines (55 loc) · 2.26 KB
/
dodo.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import os
from doit.action import CmdAction
GEOFABRIK_DATA_URL = 'http://download.geofabrik.de/south-america-latest.osm.pbf'
OUTPUT_DIR = './'
INPUT_DIR = OUTPUT_DIR
def task_download_osmconvert():
def wget_cmd():
return 'wget -O data/osmconvert.c http://m.m.i24.cc/osmconvert.c'
return {
'actions': [CmdAction(wget_cmd)],
'file_dep': [],
'targets': ['data/osmconvert.c'],
'uptodate': [None], # TODO: check with the server filesize or something
}
def task_compile_osmconvert():
def cc_cmd():
return 'cc -x c %(dependencies)s -lz -O3 -o %(targets)s'
return {
'actions': [CmdAction(cc_cmd)],
'file_dep': ['data/osmconvert.c'],
'targets': ['bin/osmconvert'],
'uptodate': [None], # TODO: check with the server filesize or something
}
def task_download_paraguay_poly():
def wget_cmd():
return 'wget "http://polygons.openstreetmap.fr/get_poly.py?id=287077¶ms=0" -O data/paraguay.poly'
return {
'actions': ['rm -f data/paraguay.poly', CmdAction(wget_cmd)],
'file_dep': [],
'targets': ['data/paraguay.poly'],
'uptodate': [None], # TODO: check with the server filesize or something
}
def task_download_data():
def wget_cmd():
return 'wget -c ' + GEOFABRIK_DATA_URL + ' -O %(targets)s'
return {
'actions': [CmdAction(wget_cmd)],
'file_dep': [],
'targets': [os.path.join(INPUT_DIR, 'data/south-america-latest.osm.pbf')],
'uptodate': [False], # TODO: check with the server filesize or something
}
def task_crop_data():
def osmconvert_cmd():
input_file = os.path.join(INPUT_DIR, 'data/south-america-latest.osm.pbf')
poly_file = 'data/paraguay.poly'
return 'bin/osmconvert --hash-memory=400-50-2 ' + input_file.replace(' ', '\ ') + ' -B=' + poly_file + ' -o=%(targets)s'
return {
'actions': [CmdAction(osmconvert_cmd)],
'file_dep': [
'bin/osmconvert',
os.path.join(OUTPUT_DIR, 'data/south-america-latest.osm.pbf'),
'data/paraguay.poly'],
'targets': [os.path.join(OUTPUT_DIR, 'data/south-america-paraguay.osm.pbf').replace(' ', '\ ')],
# 'uptodate': [None], # TODO: check the file timestamp
}