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