blob: 9dec41ceedff2a61f7b54e4b5033a3201c1082c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#!/bin/bash
GEOFABRICK_SERVER=http://download.geofabrik.de/asia/taiwan-updates
PBF_FILE=$1
# get next sequence number and store it into NEW_SEQ
NEW_SEQ=$(osmium fileinfo $PBF_FILE |\
grep osmosis_replication_sequence_number |\
cut -d'=' -f2 |\
sed 's/$/+1/' | bc)
# 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 check state file exists:
echo $STATE_URL
[ $(curl -o /dev/null --silent -Iw "%{http_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
mv $PBF_FILE $((NEW_SEQ-1)).osm.pbf
mv $NEW_SEQ.osm.pbf $PBF_FILE
(( NEW_SEQ++ ))
done
echo
echo File sequence number is $((NEW_SEQ-1)), already the latest one on Geofrbrik
|