aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2019-12-04 22:48:11 +0800
committertypebrook <typebrook@gmail.com>2019-12-05 09:33:11 +0800
commit7f8da15ad68d2a46b19b27c39d28685de6201fb3 (patch)
treef73d7056b57178030d1c365ea36b1d1f5ac0a9e5
parent3007916bea51530b2b604f6ceffbbea81e4a01e9 (diff)
update
-rwxr-xr-xscripts/match-road.sh22
1 files changed, 14 insertions, 8 deletions
diff --git a/scripts/match-road.sh b/scripts/match-road.sh
index b3f48d2..d733f59 100755
--- a/scripts/match-road.sh
+++ b/scripts/match-road.sh
@@ -23,14 +23,19 @@ LIMIT=10 # number of coordinates for each Mapbox Map Matching API request, Maxim
23ORIGIN_DATA=/tmp/origin 23ORIGIN_DATA=/tmp/origin
24RESPONSE=/tmp/response 24RESPONSE=/tmp/response
25 25
26# store data of time and location into tmp file with 2 columns, format is like: 26# extract data from the given gpx file, dump coordindate and time with the following format:
27# 1970-01-01T08:00:46 [121.0179739,14.5515336] 27# [121.0179739,14.5515336] 1984-01-01T08:00:46.234
28paste -d' ' \ 28function get_data() {
29 <(sed -nE '/<trk>/,/<\/trk>/ s/.*<time>(.*)<\/time>/\1/p' $1 | cut -d'.' -f1) \ 29 paste -d' ' \
30 <(sed -nE '/<trk>/,/<\/trk>/ s/.*lon=\"([^\"]+)\".*/\1/p' $1) \ 30 <(sed -nE '/<trkpt /,/<\/trkpt>/ s/.*lon=\"([^\"]+).*/\1/p' $1) \
31 <(sed -nE '/<trk>/,/<\/trk>/ s/.*lat=\"([^\"]+)\".*/\1/p' $1) |\ 31 <(sed -nE '/<trkpt /,/<\/trkpt>/ s/.*lat=\"([^\"]+).*/\1/p' $1) \
32sed -E 's/ ([^ ]+) ([^ ]+)/ [\1,\2]/' |\ 32 <(sed -nE '/<trkpt /,/<\/trkpt>/ s/.*<time>([^\.]+).*/\1/p' $1) |\
33awk '!_[$1]++' > $ORIGIN_DATA 33 sed -nE 's/^([^ ]+) ([^ ]+)/\[\1,\2\] /' |\
34 awk '!_[$2]++'
35}
36
37get_data $1 # > $ORIGIN_DATA
38exit 0
34 39
35# Consume raw data with serveral request 40# Consume raw data with serveral request
36while [ -s $ORIGIN_DATA ]; do 41while [ -s $ORIGIN_DATA ]; do
@@ -81,3 +86,4 @@ sed "1i \
81 <\/trk>\n\ 86 <\/trk>\n\
82<\/gpx>\n\ 87<\/gpx>\n\
83 " 88 "
89