-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-winter.sh
executable file
·57 lines (44 loc) · 1.37 KB
/
build-winter.sh
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
#!/bin/sh
echo "========================================================"
echo "Starting winter build on `date`"
echo "========================================================"
NAME=winter
QUERY_FILE=./osm/$NAME.query
OSM_FILE=./osm/$NAME.osm
JSON_FILE=./osm/$NAME.json
JSON_OLD_FILE=./osm/$NAME-old.json
#MAPBOX=mapbox #for Mac
MAPBOX=~/.local/bin/mapbox #for Linux
export MAPBOX_ACCESS_TOKEN="[PRIVATE_MAPBOX_TOKEN]"
OSMTOGEOJSON=/usr/local/bin/osmtogeojson
#OSMTOGEOJSON=osmtogeojson
GEOJSONPICK=/usr/local/bin/geojson-pick
#GEOJSONPICK=geojson-pick
PICKTAGS="winter_service id"
cd ~/backend.bikeottawa.ca
echo "Processing and uploading winter pathways data ..."
if [ ! -e $QUERY_FILE ]; then
echo "Error: Missing winter pathways query file $QUERY_FILE"
exit 1
fi
rm $OSM_FILE
mv $JSON_FILE $JSON_OLD_FILE
wget -nv -O $OSM_FILE --post-file=$QUERY_FILE "http://overpass-api.de/api/interpreter"
if [ $? -ne 0 ]; then
echo "Error: There was a problem running wget."
exit 1
fi
$OSMTOGEOJSON -m $OSM_FILE | $GEOJSONPICK $PICKTAGS > $JSON_FILE
if [ $? -ne 0 ]; then
echo "Error: There was a problem running osmtogeojson."
exit 1
fi
if cmp -s $JSON_FILE $JSON_OLD_FILE; then
echo 'No changes'
exit 0
fi
$MAPBOX upload bikeottawa.0lwwjb4e $JSON_FILE
if [ $? -ne 0 ]; then
echo "Error: Failed to upload winter pathways tileset to Mapbox."
exit 1
fi