From ddafd9c1f61bb2a359a254e99d637cd6dba4b6ce Mon Sep 17 00:00:00 2001 From: typebrook Date: Sun, 17 Nov 2019 11:11:13 +0800 Subject: update --- scripts/osm/osm.pbf.update | 56 ++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 27 deletions(-) (limited to 'scripts/osm') diff --git a/scripts/osm/osm.pbf.update b/scripts/osm/osm.pbf.update index 694ae4d..599076f 100755 --- a/scripts/osm/osm.pbf.update +++ b/scripts/osm/osm.pbf.update @@ -1,30 +1,32 @@ - PBF_FILE=$1 - GEOFABRICK_SERVER=http://download.geofabrik.de/asia/taiwan-updates +#!/bin/sh - # get next sequence number and store it into NEW_SEQ - osmium fileinfo $PBF_FILE | \ - grep osmosis_replication_sequence_number | \ - cut -d'=' -f2 | \ - sed 's/$/+1/' | bc | \ - read NEW_SEQ +PBF_FILE=$1 +GEOFABRICK_SERVER=http://download.geofabrik.de/asia/taiwan-updates - # while server has osc file with given sequence number, - # get it and do file update - while - SEQ_PATH=$(echo $NEW_SEQ | sed -r 's/(.{1})(.{3})/00\1\/\2/') - STATE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.state.txt - echo $STATE_URL - [ $(curl.code $STATE_URL) != "404" ] - do - mkdir -p changes - CHANGE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.osc.gz - echo $CHANGE_URL - curl -o changes/$NEW_SEQ.osc.gz $CHANGE_URL && \ - osmium apply-changes $PBF_FILE changes/$NEW_SEQ.osc.gz \ - --output-header=osmosis_replication_sequence_number=$NEW_SEQ \ - --overwrite \ - --output $NEW_SEQ.osm.pbf +# get next sequence number and store it into NEW_SEQ +osmium fileinfo $PBF_FILE | \ +grep osmosis_replication_sequence_number | \ +cut -d'=' -f2 | \ +sed 's/$/+1/' | bc | \ +read NEW_SEQ - PBF_FILE=$NEW_SEQ.osm.pbf - ((NEW_SEQ++)) - done +# while server has osc file with given sequence number, +# get it and do file update +while + SEQ_PATH=$(echo $NEW_SEQ | sed -r 's/(.{1})(.{3})/00\1\/\2/') + STATE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.state.txt + echo $STATE_URL + [ $(curl.code $STATE_URL) != "404" ] +do + mkdir -p changes + CHANGE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.osc.gz + echo $CHANGE_URL + curl -o changes/$NEW_SEQ.osc.gz $CHANGE_URL && \ + osmium apply-changes $PBF_FILE changes/$NEW_SEQ.osc.gz \ + --output-header=osmosis_replication_sequence_number=$NEW_SEQ \ + --overwrite \ + --output $NEW_SEQ.osm.pbf + + PBF_FILE=$NEW_SEQ.osm.pbf + ((NEW_SEQ++)) +done -- cgit v1.2.3-70-g09d2