diff options
| author | typebrook <typebrook@gmail.com> | 2019-12-05 10:26:15 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2019-12-05 10:26:15 +0800 |
| commit | ff7e4a3259f3e241360e176a90e297116f551e58 (patch) | |
| tree | f8be43dc7244d0e3f8c75594e2d9409c6301d721 /scripts | |
| parent | 78a1b3284888109c6c6a0d52a807630ea0408fdd (diff) | |
update
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/match-road.sh | 11 |
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 |
| 21 | ACCESS_TOKEN=$(cat ~/settings/tokens/mapbox) | 21 | 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 |
| 23 | LIMIT=10 | 23 | LIMIT=10 |
| 24 | 24 | ||
| 25 | ORIGIN_DATA=/tmp/origin | 25 | ORIGIN_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 |
| 30 | function get_data() { | 30 | function 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 | ||