diff options
| -rw-r--r-- | utils/osm.utils.sh | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/utils/osm.utils.sh b/utils/osm.utils.sh index 403675c..5be47cc 100644 --- a/utils/osm.utils.sh +++ b/utils/osm.utils.sh | |||
| @@ -86,16 +86,19 @@ osm.pbf.update() { | |||
| 86 | PBF_FILE=$1 | 86 | PBF_FILE=$1 |
| 87 | SERVER=http://download.geofabrik.de/asia/taiwan-updates | 87 | SERVER=http://download.geofabrik.de/asia/taiwan-updates |
| 88 | 88 | ||
| 89 | # get next sequence number and store it into NEW_SEQ | ||
| 89 | osmium fileinfo $PBF_FILE | \ | 90 | osmium fileinfo $PBF_FILE | \ |
| 90 | grep osmosis_replication_sequence_number | \ | 91 | grep osmosis_replication_sequence_number | \ |
| 91 | cut -d'=' -f2 | \ | 92 | cut -d'=' -f2 | \ |
| 93 | sed 's/$/+1/' | bc | \ | ||
| 92 | read NEW_SEQ | 94 | read NEW_SEQ |
| 93 | 95 | ||
| 96 | # while server has osc file with given sequence number, | ||
| 97 | # get it and do file update | ||
| 94 | while | 98 | while |
| 95 | (( NEW_SEQ++ )) | ||
| 96 | SEQ_PATH=$(echo $NEW_SEQ | sed -r 's/(.{1})(.{3})/00\1\/\2/') | 99 | SEQ_PATH=$(echo $NEW_SEQ | sed -r 's/(.{1})(.{3})/00\1\/\2/') |
| 97 | STATE_URL=$SERVER/000/$SEQ_PATH.state.txt | 100 | STATE_URL=$SERVER/000/$SEQ_PATH.state.txt |
| 98 | (( $(curl.code $STATE_URL) != "404" )) | 101 | [ $(curl.code $STATE_URL) != "404" ] |
| 99 | do | 102 | do |
| 100 | CHANGE_URL=$SERVER/000/$SEQ_PATH.osc.gz | 103 | CHANGE_URL=$SERVER/000/$SEQ_PATH.osc.gz |
| 101 | echo $CHANGE_URL | 104 | echo $CHANGE_URL |
| @@ -106,5 +109,6 @@ osm.pbf.update() { | |||
| 106 | --output $NEW_SEQ.osm.pbf | 109 | --output $NEW_SEQ.osm.pbf |
| 107 | 110 | ||
| 108 | PBF_FILE=$NEW_SEQ.osm.pbf | 111 | PBF_FILE=$NEW_SEQ.osm.pbf |
| 112 | (( NEW_SEQ++ )) | ||
| 109 | done | 113 | done |
| 110 | } | 114 | } |