summaryrefslogtreecommitdiffhomepage
path: root/scripts/osm
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2019-11-17 11:11:13 +0800
committertypebrook <typebrook@gmail.com>2019-11-17 11:11:13 +0800
commitddafd9c1f61bb2a359a254e99d637cd6dba4b6ce (patch)
tree6e356dbe5290aa70b44b432dba154a67ad7db644 /scripts/osm
parent2f23073cc447ac252a2d84304feb71ca0595f6c8 (diff)
update
Diffstat (limited to 'scripts/osm')
-rwxr-xr-xscripts/osm/osm.pbf.update56
1 files changed, 29 insertions, 27 deletions
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 @@
1 PBF_FILE=$1 1#!/bin/sh
2 GEOFABRICK_SERVER=http://download.geofabrik.de/asia/taiwan-updates
3 2
4 # get next sequence number and store it into NEW_SEQ 3PBF_FILE=$1
5 osmium fileinfo $PBF_FILE | \ 4GEOFABRICK_SERVER=http://download.geofabrik.de/asia/taiwan-updates
6 grep osmosis_replication_sequence_number | \
7 cut -d'=' -f2 | \
8 sed 's/$/+1/' | bc | \
9 read NEW_SEQ
10 5
11 # while server has osc file with given sequence number, 6# get next sequence number and store it into NEW_SEQ
12 # get it and do file update 7osmium fileinfo $PBF_FILE | \
13 while 8grep osmosis_replication_sequence_number | \
14 SEQ_PATH=$(echo $NEW_SEQ | sed -r 's/(.{1})(.{3})/00\1\/\2/') 9cut -d'=' -f2 | \
15 STATE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.state.txt 10sed 's/$/+1/' | bc | \
16 echo $STATE_URL 11read NEW_SEQ
17 [ $(curl.code $STATE_URL) != "404" ]
18 do
19 mkdir -p changes
20 CHANGE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.osc.gz
21 echo $CHANGE_URL
22 curl -o changes/$NEW_SEQ.osc.gz $CHANGE_URL && \
23 osmium apply-changes $PBF_FILE changes/$NEW_SEQ.osc.gz \
24 --output-header=osmosis_replication_sequence_number=$NEW_SEQ \
25 --overwrite \
26 --output $NEW_SEQ.osm.pbf
27 12
28 PBF_FILE=$NEW_SEQ.osm.pbf 13# while server has osc file with given sequence number,
29 ((NEW_SEQ++)) 14# get it and do file update
30 done 15while
16 SEQ_PATH=$(echo $NEW_SEQ | sed -r 's/(.{1})(.{3})/00\1\/\2/')
17 STATE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.state.txt
18 echo $STATE_URL
19 [ $(curl.code $STATE_URL) != "404" ]
20do
21 mkdir -p changes
22 CHANGE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.osc.gz
23 echo $CHANGE_URL
24 curl -o changes/$NEW_SEQ.osc.gz $CHANGE_URL && \
25 osmium apply-changes $PBF_FILE changes/$NEW_SEQ.osc.gz \
26 --output-header=osmosis_replication_sequence_number=$NEW_SEQ \
27 --overwrite \
28 --output $NEW_SEQ.osm.pbf
29
30 PBF_FILE=$NEW_SEQ.osm.pbf
31 ((NEW_SEQ++))
32done