From 73d18a578b14f367b8087cd38b7ca813923d5143 Mon Sep 17 00:00:00 2001 From: typebrook Date: Wed, 4 Dec 2019 01:36:41 +0800 Subject: update --- scripts/match.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'scripts') diff --git a/scripts/match.sh b/scripts/match.sh index 876b78d..e76ddec 100755 --- a/scripts/match.sh +++ b/scripts/match.sh @@ -14,8 +14,7 @@ paste -d' ' \ <(sed -nr 's/.*lon=\"([^\"]+)\".*/\1/p' $1) \ <(sed -nr 's/.*lat=\"([^\"]+)\".*/\1/p' $1) |\ sed -r 's/ ([^ ]+) ([^ ]+)/ [\1,\2]/' |\ -awk '!_[$1]++' |\ -awk '!_[$2]++' > origin +awk '!_[$1]++' > origin while [ -s origin ] do @@ -24,19 +23,22 @@ do <(head -$LIMIT origin | cut -d' ' -f1 | jq -nR '[inputs]') |\ curl -X POST -s --header "Content-Type:application/json" --data @- https://api.mapbox.com/matching/v4/mapbox.driving.json?access_token=$ACCESS_TOKEN > response + TIMESTAMP=0 + paste -d' ' \ + <(jq -c '.features[0].properties.matchedPoints[]' response) \ + <(jq -c '.features[0].properties.indices[]' response | xargs -I{} echo {}+1 | bc | xargs -I{} sed -n {}p origin | cut -d' ' -f1 | date -f - +%s) \ + > matched jq -c '.features[0].geometry.coordinates[]' response |\ while read line do - paste -d' ' \ - <(jq -c '.features[0].properties.matchedPoints[]' response) \ - <(jq -c '.features[0].properties.indices[]' response | xargs -I{} echo {}+1 | bc | xargs -I{} sed -n {}p origin | cut -d' ' -f1 | date -f - +%s) |\ - grep -F $line | head -1 || echo $line + TIMESTAMP=$(head -1 matched | cut -d' ' -f2) + (head -1 matched | grep -F $line && sed -i 1d matched) || echo $line $TIMESTAMP jojo done |\ - tee /dev/tty + tee /dev/tty && rm matched sed -i "1,$LIMIT d" origin done |\ -sed -r 's/\[([^,]+),([^,]+)\] (.*)/