diff options
| author | typebrook <typebrook@gmail.com> | 2019-12-03 16:09:20 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2019-12-03 16:09:20 +0800 |
| commit | d075f340e65c00be15bc6f017a284c8a1622a375 (patch) | |
| tree | c5cb048f13679bc7f484f01353312157269f86b5 /scripts | |
| parent | b6ffa8b746eed0aa2f1032fbc9f2b45a875e6f15 (diff) | |
update
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/match.sh | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/scripts/match.sh b/scripts/match.sh index 22f3658..f48f0a2 100755 --- a/scripts/match.sh +++ b/scripts/match.sh | |||
| @@ -1,16 +1,39 @@ | |||
| 1 | #! /bin/bash | 1 | #! /bin/bash |
| 2 | 2 | ||
| 3 | #set -x | 3 | set -x |
| 4 | 4 | ||
| 5 | ACCESS_TOKEN=$(cat ~/settings/tokens/mapbox) | 5 | ACCESS_TOKEN=$(cat ~/settings/tokens/mapbox) |
| 6 | export MAPBOX_ACCESS_TOKEN=$ACCESS_TOKEN | ||
| 7 | LIMIT=10 | ||
| 6 | 8 | ||
| 7 | #paste -d' ' \ | 9 | paste -d' ' \ |
| 8 | # <(sed -nr '/<trk>/,/<\/trk>/ { s/.*<time>(.*)<\/time>/\1/p }' $1 | xargs -I {} date -d "{}" +%s --utc) \ | 10 | <(sed -nr '/<trk>/,/<\/trk>/ { s/.*<time>(.*)<\/time>/\1/p }' $1) \ |
| 9 | # <(sed -nr 's/.*lon=\"([^\"]+)\" lat=\"([^\"]+)\".*/\1 \2/p' $1) | 11 | <(sed -nr 's/.*lon=\"([^\"]+)\" lat=\"([^\"]+)\".*/[\1,\2]/p' $1) \ |
| 12 | > origin | ||
| 10 | 13 | ||
| 11 | sed -nr 's/.*lon=\"([^\"]+)\" lat=\"([^\"]+)\".*/\1,\2/p' $1 |\ | 14 | while true |
| 12 | xargs -L100 echo -n |\ | 15 | do |
| 13 | echo jojo | 16 | jq --slurp '{type: "Feature", properties: {coordTimes: .[1]}, geometry: {type: "LineString", coordinates: .[0]}}' \ |
| 17 | <(head -$LIMIT origin | cut -d' ' -f2 | jq -n '[inputs]') \ | ||
| 18 | <(head -$LIMIT origin | cut -d' ' -f1 | jq -nR '[inputs]') |\ | ||
| 19 | mapbox mapmatching --profile mapbox.driving - > response | ||
| 20 | |||
| 21 | jq -c '.features[0].geometry.coordinates[]' response |\ | ||
| 22 | while read line | ||
| 23 | do | ||
| 24 | paste -d' ' \ | ||
| 25 | <(jq -c '.features[0].properties.matchedPoints[]' response) \ | ||
| 26 | <(jq -c '.features[0].properties.indices[]' response | xargs -I{} echo {}+1 | bc | tee /dev/tty | xargs -I{} sed -n {}p origin | cut -d' ' -f1) |\ | ||
| 27 | grep -F $line || echo $line | ||
| 28 | done | ||
| 29 | |||
| 30 | sed -i "1,$LIMIT d" origin | ||
| 31 | if [ ! -s origin ]; then exit 0; fi | ||
| 32 | done | ||
| 33 | |||
| 34 | #sed -nr 's/.*lon=\"([^\"]+)\" lat=\"([^\"]+)\".*/\1,\2/p' $1 |\ | ||
| 35 | #xargs -L100 echo -n |\ | ||
| 36 | #echo jojo | ||
| 14 | #tr ' ' ';' |\ | 37 | #tr ' ' ';' |\ |
| 15 | #sed 's/^/coordinates=/' |\ | 38 | #sed 's/^/coordinates=/' |\ |
| 16 | #curl -X POST \ | 39 | #curl -X POST \ |