diff options
Diffstat (limited to 'scripts/match-road.sh')
-rwxr-xr-x | scripts/match-road.sh | 22 |
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 | |||
23 | ORIGIN_DATA=/tmp/origin | 23 | ORIGIN_DATA=/tmp/origin |
24 | RESPONSE=/tmp/response | 24 | RESPONSE=/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 |
28 | paste -d' ' \ | 28 | function 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) \ |
32 | sed -E 's/ ([^ ]+) ([^ ]+)/ [\1,\2]/' |\ | 32 | <(sed -nE '/<trkpt /,/<\/trkpt>/ s/.*<time>([^\.]+).*/\1/p' $1) |\ |
33 | awk '!_[$1]++' > $ORIGIN_DATA | 33 | sed -nE 's/^([^ ]+) ([^ ]+)/\[\1,\2\] /' |\ |
34 | awk '!_[$2]++' | ||
35 | } | ||
36 | |||
37 | get_data $1 # > $ORIGIN_DATA | ||
38 | exit 0 | ||
34 | 39 | ||
35 | # Consume raw data with serveral request | 40 | # Consume raw data with serveral request |
36 | while [ -s $ORIGIN_DATA ]; do | 41 | while [ -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 | |||