From 1d7363d3b1600495dee6eba8fd652a851351029c Mon Sep 17 00:00:00 2001 From: typebrook Date: Thu, 5 Dec 2019 11:16:01 +0800 Subject: update --- scripts/match-road.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'scripts/match-road.sh') 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) # number of coordinates for each Mapbox Map Matching API request, Maximum value is 100 LIMIT=10 -ORIGIN_DATA=/tmp/origin -RESPONSE=/tmp/response +ORIGIN_DATA=/tmp/$(basename $1).origin +RESPONSE=/tmp/$(basename $1).response # extract data from the given gpx file, dump coordindate and time with the following format: # [121.0179739,14.5515336] 1984-01-01T08:00:46.234 function get_data() { - # FIXME sometimes trkpt doesn't contains time, need to return empty line - paste -d' ' \ - <(sed -nE '// s/.*lon="([^"]+).*/\1/p' $1) \ - <(sed -nE '// s/.*lat="([^"]+).*/\1/p' $1) \ - <(sed -nE '// {}' $1) |\ - sed -nE 's/^([^ ]+) ([^ ]+)/[\1,\2\]/p' |\ + sed -nr '// {H; /<\/trkpt>/ {x; s/\n/ /g; p; s/.*//; x}}' $1 |\ + sed -nr 'h; s/.*lon="([^"]+).*/\1/; H; g + s/.*lat="([^"]+).*/\1/; H; g + /time/ { + s/.*