diff options
| author | typebrook <typebrook@gmail.com> | 2019-12-06 17:58:35 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2019-12-06 17:58:35 +0800 |
| commit | eaab7e066d9bed1ff68d72b837b3362a0b54e326 (patch) | |
| tree | c9fa8cbe0efa208c0e32439107e975f6008a7566 /scripts | |
| parent | d7e4b488d28a187741cda8beb664db9f5ab482b9 (diff) | |
update
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/match-road.sh | 14 |
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 |
| 21 | ACCESS_TOKEN=$(cat ~/settings/tokens/mapbox) | 21 | ACCESS_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 |
| 23 | LIMIT=50 | 23 | LIMIT=100 |
| 24 | # define the lowest confidence of accepted matched points | 24 | # define the lowest confidence of accepted matched points |
| 25 | THRESHOLD=0.6 | 25 | THRESHOLD=0.0001 |
| 26 | 26 | ||
| 27 | if [[ -z $1 ]]; then echo "You need to give a gpx file!"; exit 1; fi | 27 | if [[ -z $1 ]]; then echo "You need to give a gpx file!"; exit 1; fi |
| 28 | ORIGIN_DATA=/tmp/$(basename $1).origin | 28 | ORIGIN_DATA=/tmp/$(basename $1).origin |
| 29 | RESPONSES=/tmp/$(basename $1).responses && true > $RESPONSES | 29 | RESPONSES=/tmp/$(basename $1).responses && true > $RESPONSES |
| 30 | |||
| 31 | MATCHED=/tmp/$(basename $1).matched | 30 | MATCHED=/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 |
| 36 | function get_data() { | 36 | function get_data() { |
| @@ -70,7 +70,6 @@ function query_matched_points() { | |||
| 70 | # [121.0189339,14.5525931] -1 | 70 | # [121.0189339,14.5525931] -1 |
| 71 | function validate_matched_points() { | 71 | function 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) |