diff options
Diffstat (limited to 'tools/osm/sequence_number.sh')
-rwxr-xr-x | tools/osm/sequence_number.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/osm/sequence_number.sh b/tools/osm/sequence_number.sh new file mode 100755 index 0000000..eb365d0 --- /dev/null +++ b/tools/osm/sequence_number.sh | |||
@@ -0,0 +1,22 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # $1 as --hour or --minute, $2 as timestamp | ||
4 | # return the latest sequence number | ||
5 | |||
6 | case $1 in | ||
7 | # hour difference with Tue Jun 4 03:00:00 UTC 2019 | ||
8 | # sequence number=58940 | ||
9 | --hour) | ||
10 | echo $[($2 - 1559617200)/3600 + 58940] | ||
11 | ;; | ||
12 | |||
13 | # minute difference with latest planet state file | ||
14 | --minute) | ||
15 | benchmark=benchmark | ||
16 | curl https://planet.openstreetmap.org/replication/minute/state > $benchmark | ||
17 | timeString=$(tail -1 $benchmark | tr -d 'timestamp=\\') | ||
18 | timestamp=$(date -d "$timeString" +%s) | ||
19 | seq=$(sed -n 2p $benchmark | tr -d "sequenceNumber=") | ||
20 | rm $benchmark | ||
21 | echo $[$seq - ($timestamp - $2)/60 - 1 ] | ||
22 | esac | ||