aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/match-road.sh
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2019-12-05 10:26:15 +0800
committertypebrook <typebrook@gmail.com>2019-12-05 10:26:15 +0800
commitff7e4a3259f3e241360e176a90e297116f551e58 (patch)
treef8be43dc7244d0e3f8c75594e2d9409c6301d721 /scripts/match-road.sh
parent78a1b3284888109c6c6a0d52a807630ea0408fdd (diff)
update
Diffstat (limited to 'scripts/match-road.sh')
-rwxr-xr-xscripts/match-road.sh11
1 files changed, 6 insertions, 5 deletions
diff --git a/scripts/match-road.sh b/scripts/match-road.sh
index 7c61f58..ba94ee2 100755
--- a/scripts/match-road.sh
+++ b/scripts/match-road.sh
@@ -19,7 +19,7 @@ set -e
19 19
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=10 23LIMIT=10
24 24
25ORIGIN_DATA=/tmp/origin 25ORIGIN_DATA=/tmp/origin
@@ -28,11 +28,12 @@ RESPONSE=/tmp/response
28# extract data from the given gpx file, dump coordindate and time with the following format: 28# extract data from the given gpx file, dump coordindate and time with the following format:
29# [121.0179739,14.5515336] 1984-01-01T08:00:46.234 29# [121.0179739,14.5515336] 1984-01-01T08:00:46.234
30function get_data() { 30function get_data() {
31 # FIXME sometimes trkpt doesn't contains time, need to return empty line
31 paste -d' ' \ 32 paste -d' ' \
32 <(sed -nE '/<trkpt /,/<\/trkpt>/ s/.*lon=\"([^\"]+).*/\1/p' $1) \ 33 <(sed -nE '/<trkpt /,/<\/trkpt>/ s/.*lon="([^"]+).*/\1/p' $1) \
33 <(sed -nE '/<trkpt /,/<\/trkpt>/ s/.*lat=\"([^\"]+).*/\1/p' $1) \ 34 <(sed -nE '/<trkpt /,/<\/trkpt>/ s/.*lat="([^"]+).*/\1/p' $1) \
34 <(sed -nE '/<trkpt /,/<\/trkpt>/ s/.*<time>([^\.]+).*/\1/p' $1) |\ 35 <(sed -nE '/<trkpt /,/<\/trkpt>/ {}' $1) |\
35 sed -nE 's/^([^ ]+) ([^ ]+)/\[\1,\2\] /' |\ 36 sed -nE 's/^([^ ]+) ([^ ]+)/[\1,\2\]/p' |\
36 awk '!_[$2]++' 37 awk '!_[$2]++'
37} 38}
38 39