aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/osm
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2019-11-20 11:41:16 +0800
committertypebrook <typebrook@gmail.com>2019-11-20 11:41:16 +0800
commit751b9255cf86afeee77e4cbb77a538399ef5d35a (patch)
tree3b725594563a93b547c2dc495837897bedf7ab5d /scripts/osm
parent637bd6227402f8dcddbdb8d6931a88009b433770 (diff)
update
Diffstat (limited to 'scripts/osm')
-rwxr-xr-xscripts/osm/osm.pbf.update20
1 files changed, 10 insertions, 10 deletions
diff --git a/scripts/osm/osm.pbf.update b/scripts/osm/osm.pbf.update
index 102d158..c7d0b2b 100755
--- a/scripts/osm/osm.pbf.update
+++ b/scripts/osm/osm.pbf.update
@@ -1,13 +1,13 @@
1#!/bin/sh 1#!/bin/bash
2 2
3GEOFABRICK_SERVER=http://download.geofabrik.de/asia/taiwan-updates 3GEOFABRICK_SERVER=http://download.geofabrik.de/asia/taiwan-updates
4PBF_FILE=$1
4 5
5# get next sequence number and store it into NEW_SEQ 6# get next sequence number and store it into NEW_SEQ
6osmium fileinfo $PBF_FILE | \ 7NEW_SEQ=$(osmium fileinfo $PBF_FILE |\
7grep osmosis_replication_sequence_number | \ 8grep osmosis_replication_sequence_number |\
8cut -d'=' -f2 | \ 9cut -d'=' -f2 |\
9sed 's/$/+1/' | bc | \ 10sed 's/$/+1/' | bc)
10read NEW_SEQ
11 11
12# while server has osc file with given sequence number, 12# while server has osc file with given sequence number,
13# get it and do file update 13# get it and do file update
@@ -15,7 +15,7 @@ while
15 SEQ_PATH=$(echo $NEW_SEQ | sed -r 's/(.{1})(.{3})/00\1\/\2/') 15 SEQ_PATH=$(echo $NEW_SEQ | sed -r 's/(.{1})(.{3})/00\1\/\2/')
16 STATE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.state.txt 16 STATE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.state.txt
17 echo $STATE_URL 17 echo $STATE_URL
18 [ $(curl.code $STATE_URL) != "404" ] 18 [ $(curl -o /dev/null --silent -Iw "%{http_code}" $STATE_URL) != "404" ]
19do 19do
20 mkdir -p changes 20 mkdir -p changes
21 CHANGE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.osc.gz 21 CHANGE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.osc.gz
@@ -26,7 +26,7 @@ do
26 --overwrite \ 26 --overwrite \
27 --output $NEW_SEQ.osm.pbf 27 --output $NEW_SEQ.osm.pbf
28 28
29 mv $1 $((NEW_SEQ-1)).osm.pbf 29 mv $PBF_FILE $((NEW_SEQ-1)).osm.pbf
30 mv $NEW_SEQ.osm.pbf $1 30 mv $NEW_SEQ.osm.pbf $PBF_FILE
31 ((NEW_SEQ++)) 31 (( NEW_SEQ++ ))
32done 32done