aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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