-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy pathMakefile-prepare-data.jinja2
More file actions
72 lines (52 loc) · 2.55 KB
/
Makefile-prepare-data.jinja2
File metadata and controls
72 lines (52 loc) · 2.55 KB
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
# clip input to the bounds of EPSG:3857 _before_ projecting. this ensures that
# there are no unprojectable points, but that the data fills the all the way to
# the corners of the world.
OGR_CLIP_OPTS=
all: download shapefiles
upload: shapefiles
if aws s3 ls s3://{{ bucket }}/{{ datestamp }}/shapefiles.tar.gz; then echo 'shapefiles.tar.gz already exists for {{ datestamp }}'; exit 1; else exit 0; fi
aws s3 cp shapefiles.tar.gz s3://{{ bucket }}/{{ datestamp }}/shapefiles.tar.gz
shapefiles: shapefiles.tar.gz
shapefiles.tar.gz: {{ tgt_shapefile_zips }} wof_snapshot.sql wikidata_snapshot.sql
tar czf shapefiles.tar.gz $^
download: {{ src_shapefile_zips }}
{% for download in downloads %}
{{ download.tgt }}:
wget '{{ download.url }}' -O {{ download.tgt }}
{% endfor %}
{% for shapefile in reproj_shapefiles %}
{{ shapefile.src_shp }}: {{ shapefile.src_zip }}
unzip {% if shapefile.junk_dirs %}-j{% endif %} -o {{ shapefile.src_zip }} '{% if shapefile.junk_dirs %}*/{% endif %}{{ shapefile.src_wildcard }}'
# touch -c means don't create the file if it doesn't already exist
touch -c {{ shapefile.src_shp }}
[ -f {{ shapefile.src_shp }} ]
{{ shapefile.tgt_shp }}: {{ shapefile.src_shp }}
ogr2ogr $(OGR_CLIP_OPTS) -t_srs EPSG:3857 -lco encoding=utf8 {{ shapefile.tgt_shp }} {{ shapefile.src_shp }}
{% if shapefile.tile %}
python tile-shapefile.py {{ shapefile.tgt_shp }} tiled-{{ shapefile.tgt_shp }}
rm -f {{ shapefile.tgt_shp_wildcard }}
for i in tiled-{{ shapefile.tgt_shp_wildcard }}; do mv -f $$i `echo $$i | sed s/tiled-//`; done
{% endif %}
{{ shapefile.tgt_zip }}: {{ shapefile.tgt_shp }}
zip {{ shapefile.tgt_zip }} {{ shapefile.tgt_shp_wildcard }}
{% endfor %}
{% for shapefile in tile_shapefiles %}
{{ shapefile.src_shp }}: {{ shapefile.src_zip }}
unzip -o {{ shapefile.src_zip }} '{{ shapefile.src_wildcard }}'
touch {{ shapefile.src_shp }}
{{ shapefile.tgt_shp }}: {{ shapefile.src_shp }}
python tile-shapefile.py {{ shapefile.src_shp }} {{ shapefile.tgt_shp }}
{{ shapefile.tgt_zip }}: {{ shapefile.tgt_shp }}
zip {{ shapefile.tgt_zip }} {{ shapefile.tgt_shp_wildcard }}
{% endfor %}
{% for query in queries %}
{{ query.output_file }}:
curl -o $@ '{{ query.url }}'
{% endfor %}
wikidata_snapshot.sql: {{ query_output_files }}
python wikidata_merge.py --output $@ $^
wof_snapshot.sql:
python wof_snapshot.py
clean:
rm -rf shapefiles.tar.gz {{ tgt_shapefile_zips }} {{ tgt_shapefile_wildcards }} {{ src_shapefile_zips }} {{ src_shapefile_wildcards }} wof_snapshot.sql {{ query_output_files }} wikidata_snapshot.sql
.PHONY: all download upload shapefiles