diff options
author | typebrook <typebrook@gmail.com> | 2019-11-17 09:18:07 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2019-11-17 09:18:07 +0800 |
commit | 1d3508f66fddf3f8c6416e59ab9fbde405dbcf25 (patch) | |
tree | 4f703dfa01596c133a4898c88fe837b8971e47e1 /scripts/osm/osm.pbf.update | |
parent | e0673805fc648d47eadf5c76b822ccef5780d241 (diff) |
update
Diffstat (limited to 'scripts/osm/osm.pbf.update')
-rw-r--r-- | scripts/osm/osm.pbf.update | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/osm/osm.pbf.update b/scripts/osm/osm.pbf.update new file mode 100644 index 0000000..694ae4d --- /dev/null +++ b/scripts/osm/osm.pbf.update | |||
@@ -0,0 +1,30 @@ | |||
1 | PBF_FILE=$1 | ||
2 | GEOFABRICK_SERVER=http://download.geofabrik.de/asia/taiwan-updates | ||
3 | |||
4 | # get next sequence number and store it into NEW_SEQ | ||
5 | osmium fileinfo $PBF_FILE | \ | ||
6 | grep osmosis_replication_sequence_number | \ | ||
7 | cut -d'=' -f2 | \ | ||
8 | sed 's/$/+1/' | bc | \ | ||
9 | read NEW_SEQ | ||
10 | |||
11 | # while server has osc file with given sequence number, | ||
12 | # get it and do file update | ||
13 | while | ||
14 | SEQ_PATH=$(echo $NEW_SEQ | sed -r 's/(.{1})(.{3})/00\1\/\2/') | ||
15 | STATE_URL=$GEOFABRICK_SERVER/000/$SEQ_PATH.state.txt | ||
16 | echo $STATE_URL | ||
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 | |||
28 | PBF_FILE=$NEW_SEQ.osm.pbf | ||
29 | ((NEW_SEQ++)) | ||
30 | done | ||