diff options
| author | typebrook <typebrook@gmail.com> | 2019-12-05 11:16:01 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2019-12-05 11:16:01 +0800 |
| commit | 1d7363d3b1600495dee6eba8fd652a851351029c (patch) | |
| tree | 47d64da0d26d3d4452536e6098d7e7aa8b691f73 | |
| parent | ff7e4a3259f3e241360e176a90e297116f551e58 (diff) | |
update
| -rwxr-xr-x | scripts/match-road.sh | 18 |
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 |
| 23 | LIMIT=10 | 23 | LIMIT=10 |
| 24 | 24 | ||
| 25 | ORIGIN_DATA=/tmp/origin | 25 | ORIGIN_DATA=/tmp/$(basename $1).origin |
| 26 | RESPONSE=/tmp/response | 26 | RESPONSE=/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 |
| 30 | function get_data() { | 30 | function 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 | ||