From 00b136155183ae522ca458e540a8cf29bf525e74 Mon Sep 17 00:00:00 2001 From: typebrook Date: Thu, 27 Feb 2020 16:32:37 +0800 Subject: update --- tools/osm/osm.pbf.update | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 tools/osm/osm.pbf.update (limited to 'tools/osm/osm.pbf.update') 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 @@ +#!/bin/bash + +GEOFABRICK_SERVER=http://download.geofabrik.de/asia/taiwan-updates +PBF_FILE=$1 + +# get latest sequence number +echo Fetching the latest sequence number +LATEST_SEQ=$(curl --silent http://download.geofabrik.de/asia/taiwan-updates/state.txt |\ + tail -1 | cut -d'=' -f2) +echo Latest sequence number is $LATEST_SEQ + +# get current sequence number +SEQ=$(osmium fileinfo $PBF_FILE |\ + grep osmosis_replication_sequence_number |\ + cut -d'=' -f2) +echo File sequence number is $SEQ + +# while server has osc file with given sequence number, +# get it and do file update +while + (( SEQ++ )) + [ $SEQ -le $LATEST_SEQ ] +do + mkdir -p changes + SEQ_PATH=$(echo $SEQ | sed -r 's/(.{1})(.{3})/00\1\/\2/') + CHANGE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.osc.gz + echo $CHANGE_URL + curl -o changes/$SEQ.osc.gz $CHANGE_URL && \ + osmium apply-changes $PBF_FILE changes/$SEQ.osc.gz \ + --output-header=osmosis_replication_sequence_number=$SEQ \ + --overwrite \ + --output $SEQ.osm.pbf + + mv $PBF_FILE $((SEQ-1)).osm.pbf + mv $SEQ.osm.pbf $PBF_FILE +done + +echo +echo File sequence number is $((SEQ-1)), already the latest one on Geofrbrik -- cgit v1.2.3-70-g09d2