aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/match-road.sh18
1 files changed, 10 insertions, 8 deletions
diff --git a/scripts/match-road.sh b/scripts/match-road.sh
index ba94ee2..f7d27cc 100755
--- a/scripts/match-road.sh
+++ b/scripts/match-road.sh
@@ -22,18 +22,20 @@ 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
23LIMIT=10 23LIMIT=10
24 24
25ORIGIN_DATA=/tmp/origin 25ORIGIN_DATA=/tmp/$(basename $1).origin
26RESPONSE=/tmp/response 26RESPONSE=/tmp/$(basename $1).response
27 27
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 sed -nr '/<trkpt /, /<\/trkpt>/ {H; /<\/trkpt>/ {x; s/\n/ /g; p; s/.*//; x}}' $1 |\
32 paste -d' ' \ 32 sed -nr 'h; s/.*lon="([^"]+).*/\1/; H; g
33 <(sed -nE '/<trkpt /,/<\/trkpt>/ s/.*lon="([^"]+).*/\1/p' $1) \ 33 s/.*lat="([^"]+).*/\1/; H; g
34 <(sed -nE '/<trkpt /,/<\/trkpt>/ s/.*lat="([^"]+).*/\1/p' $1) \ 34 /time/ {
35 <(sed -nE '/<trkpt /,/<\/trkpt>/ {}' $1) |\ 35 s/.*<time>([^.]+).*<\/time>.*/\1/
36 sed -nE 's/^([^ ]+) ([^ ]+)/[\1,\2\]/p' |\ 36 H; g
37 }
38 s/^[^\n]+\n//; s/\n/ /g; p' |\
37 awk '!_[$2]++' 39 awk '!_[$2]++'
38} 40}
39 41