diff options
author | typebrook <typebrook@gmail.com> | 2019-12-06 14:37:06 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2019-12-06 14:37:06 +0800 |
commit | 6569798bc0ba58a456cd7619cd6c14a136a95c10 (patch) | |
tree | 7d55346f7bea1d98d67ade8514d436c0fc9eaad8 /scripts | |
parent | 8e092292342421a6216983afee2cba27e3b61f76 (diff) |
update
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/match-road.sh | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/scripts/match-road.sh b/scripts/match-road.sh index 1c8f28b..bdbd288 100755 --- a/scripts/match-road.sh +++ b/scripts/match-road.sh | |||
@@ -20,7 +20,7 @@ set -e | |||
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=80 |
24 | # define the lowest confidence of accepted matched points | 24 | # define the lowest confidence of accepted matched points |
25 | THRESHOLD=0.3 | 25 | THRESHOLD=0.3 |
26 | 26 | ||
@@ -29,8 +29,9 @@ ORIGIN_DATA=/tmp/$(basename $1).origin | |||
29 | RESPONSES=/tmp/$(basename $1).responses && true > $RESPONSES | 29 | RESPONSES=/tmp/$(basename $1).responses && true > $RESPONSES |
30 | MATCHED=/tmp/$(basename $1).matched | 30 | MATCHED=/tmp/$(basename $1).matched |
31 | 31 | ||
32 | # extract data from the given gpx file, dump data with format [coordindate] [time_to_second], like: | 32 | # extract data from the given gpx file |
33 | # [121.0179739,14.5515336] 1984-01-01T08:00:46 | 33 | # input: [gpx format] |
34 | # output: [121.0179739,14.5515336] 1984-01-01T08:00:46 | ||
34 | function get_data() { | 35 | function get_data() { |
35 | sed -nr '/<trkpt /, /<\/trkpt>/ {H; /<\/trkpt>/ {x; s/\n/ /g; p; s/.*//; x}}' $1 | | 36 | sed -nr '/<trkpt /, /<\/trkpt>/ {H; /<\/trkpt>/ {x; s/\n/ /g; p; s/.*//; x}}' $1 | |
36 | sed -nr 'h; s/.*lon="([^"]+).*/\1/; H; g | 37 | sed -nr 'h; s/.*lon="([^"]+).*/\1/; H; g |
@@ -45,8 +46,9 @@ function get_data() { | |||
45 | awk '!_[$2]++' | 46 | awk '!_[$2]++' |
46 | } | 47 | } |
47 | 48 | ||
48 | # Output GeoJSON object for Map Matching API from STDIN with format [coordinate] [time], like: | 49 | # Output GeoJSON object for Map Matching API |
49 | # [121.0179739,14.5515336] 1984-01-01T08:00:46 | 50 | # input: [121.0179739,14.5515336] 1984-01-01T08:00:46 |
51 | # output: {type: "Feature", properties: {coordTimes: [...]}, geometry: {type: "LineString", coordinates: [...]}} | ||
50 | function make_geojson() { | 52 | function make_geojson() { |
51 | # change input to format like: [[lon, lat], time] | 53 | # change input to format like: [[lon, lat], time] |
52 | awk '{printf("[%s,\"%s\"]\n", $1, $2)}' | | 54 | awk '{printf("[%s,\"%s\"]\n", $1, $2)}' | |