aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/match-road.sh14
1 files changed, 7 insertions, 7 deletions
diff --git a/scripts/match-road.sh b/scripts/match-road.sh
index dc014ac..1f613b2 100755
--- a/scripts/match-road.sh
+++ b/scripts/match-road.sh
@@ -20,17 +20,17 @@ set -e
20# put yout Mapbox token here 20# put yout Mapbox token here
21ACCESS_TOKEN=$(cat ~/settings/tokens/mapbox) 21ACCESS_TOKEN=$(cat ~/settings/tokens/mapbox)
22# number of coordinates for each Mapbox Map Matching API request, Maximum value is 100 22# number of coordinates for each Mapbox Map Matching API request, Maximum value is 100
23LIMIT=50 23LIMIT=100
24# define the lowest confidence of accepted matched points 24# define the lowest confidence of accepted matched points
25THRESHOLD=0.6 25THRESHOLD=0.0001
26 26
27if [[ -z $1 ]]; then echo "You need to give a gpx file!"; exit 1; fi 27if [[ -z $1 ]]; then echo "You need to give a gpx file!"; exit 1; fi
28ORIGIN_DATA=/tmp/$(basename $1).origin 28ORIGIN_DATA=/tmp/$(basename $1).origin
29RESPONSES=/tmp/$(basename $1).responses && true > $RESPONSES 29RESPONSES=/tmp/$(basename $1).responses && true > $RESPONSES
30
31MATCHED=/tmp/$(basename $1).matched 30MATCHED=/tmp/$(basename $1).matched
31
32# extract data from the given gpx file 32# extract data from the given gpx file
33# only keep first point and remove the rest which in the same "seconds" 33# only keep first point and remove the rest which in the same "second"
34# input: [gpx format] 34# input: [gpx format]
35# output: [121.0179739,14.5515336] 1984-01-01T08:00:46 35# output: [121.0179739,14.5515336] 1984-01-01T08:00:46
36function get_data() { 36function get_data() {
@@ -70,7 +70,6 @@ function query_matched_points() {
70# [121.0189339,14.5525931] -1 70# [121.0189339,14.5525931] -1
71function validate_matched_points() { 71function validate_matched_points() {
72 VALID_DATA=$(jq ".features[] | if(.properties.confidence < $THRESHOLD) then .geometry.coordinates=(.properties.indices|map(.+1)) else . end") 72 VALID_DATA=$(jq ".features[] | if(.properties.confidence < $THRESHOLD) then .geometry.coordinates=(.properties.indices|map(.+1)) else . end")
73 #VALID_DATA=$(jq ".features[] | select(.properties.confidence >= $THRESHOLD)")
74 73
75 echo $VALID_DATA | 74 echo $VALID_DATA |
76 jq -cr '.properties | [.matchedPoints, (.indices | map(.+1))] | transpose[] | "\(.[0]) \(.[1])"' > $MATCHED 75 jq -cr '.properties | [.matchedPoints, (.indices | map(.+1))] | transpose[] | "\(.[0]) \(.[1])"' > $MATCHED
@@ -78,7 +77,8 @@ function validate_matched_points() {
78 echo $VALID_DATA | jq -c '.geometry.coordinates[]' | 77 echo $VALID_DATA | jq -c '.geometry.coordinates[]' |
79 while read point; do 78 while read point; do
80 if [[ ${point:0:1} != '[' ]]; then 79 if [[ ${point:0:1} != '[' ]]; then
81 echo $(sed -n "$point p" $ORIGIN_DATA) 80 echo -n abandoned data: > /dev/tty
81 echo $(sed -n "$point p" $ORIGIN_DATA) | tee /dev/tty
82 sed -i 1d $MATCHED 82 sed -i 1d $MATCHED
83 elif head -1 $MATCHED | grep -F $point > /dev/null; then 83 elif head -1 $MATCHED | grep -F $point > /dev/null; then
84 index=$(head -1 $MATCHED | cut -d' ' -f2) 84 index=$(head -1 $MATCHED | cut -d' ' -f2)