aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/match.sh37
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 3set -x
4 4
5ACCESS_TOKEN=$(cat ~/settings/tokens/mapbox) 5ACCESS_TOKEN=$(cat ~/settings/tokens/mapbox)
6export MAPBOX_ACCESS_TOKEN=$ACCESS_TOKEN
7LIMIT=10
6 8
7#paste -d' ' \ 9paste -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
11sed -nr 's/.*lon=\"([^\"]+)\" lat=\"([^\"]+)\".*/\1,\2/p' $1 |\ 14while true
12xargs -L100 echo -n |\ 15do
13echo 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
32done
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 \