aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin/osm/osm.pbf.update
diff options
context:
space:
mode:
Diffstat (limited to 'bin/osm/osm.pbf.update')
-rwxr-xr-xbin/osm/osm.pbf.update41
1 files changed, 41 insertions, 0 deletions
diff --git a/bin/osm/osm.pbf.update b/bin/osm/osm.pbf.update
new file mode 100755
index 0000000..6c6f445
--- /dev/null
+++ b/bin/osm/osm.pbf.update
@@ -0,0 +1,41 @@
1#!/bin/bash
2
3set -e
4
5GEOFABRIK_SERVER=http://download.geofabrik.de/asia/taiwan-updates
6PBF_FILE=$1
7
8# get latest sequence number
9echo Fetching the latest sequence number
10LATEST_SEQ=$(curl --silent http://download.geofabrik.de/asia/taiwan-updates/state.txt |\
11 tail -1 | cut -d'=' -f2)
12echo Latest sequence number is $LATEST_SEQ
13
14# get current sequence number
15SEQ=$(osmium fileinfo $PBF_FILE |\
16 grep osmosis_replication_sequence_number |\
17 cut -d'=' -f2)
18echo File sequence number is $SEQ
19
20# while server has osc file with given sequence number,
21# get it and do file update
22while
23 (( SEQ++ ))
24 [ $SEQ -le $LATEST_SEQ ]
25do
26 mkdir -p changes
27 SEQ_PATH=$(echo $SEQ | sed -r 's/(.{1})(.{3})/00\1\/\2/')
28 CHANGE_URL=$GEOFABRIK_SERVER/000/$SEQ_PATH.osc.gz
29 echo $CHANGE_URL
30 curl -o changes/$SEQ.osc.gz $CHANGE_URL && \
31 osmium apply-changes $PBF_FILE changes/$SEQ.osc.gz \
32 --output-header=osmosis_replication_sequence_number=$SEQ \
33 --overwrite \
34 --output $SEQ.osm.pbf
35
36 mv $PBF_FILE $((SEQ-1)).osm.pbf
37 mv $SEQ.osm.pbf $PBF_FILE
38done
39
40echo
41echo File sequence number is $((SEQ-1)), already the latest one on Geofrbrik