diff options
author | typebrook <typebrook@gmail.com> | 2019-12-05 12:08:29 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2019-12-05 12:08:29 +0800 |
commit | 22fa13699524222c91b58db26b87816c8a71c7c5 (patch) | |
tree | 16413ceaa576ce347f96ef4d7b91a6dc241528b9 | |
parent | 10b67a44f4cb630b3dff628f0b11ebe0e043926b (diff) |
update
-rwxr-xr-x | scripts/match-road.sh | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/scripts/match-road.sh b/scripts/match-road.sh index 1846102..8de23ed 100755 --- a/scripts/match-road.sh +++ b/scripts/match-road.sh | |||
@@ -41,11 +41,11 @@ function get_data() { | |||
41 | awk '!_[$2]++' | 41 | awk '!_[$2]++' |
42 | } | 42 | } |
43 | 43 | ||
44 | # Read date Make GeoJSON object for Map Matching API | 44 | # Read data like the following to make GeoJSON object for Map Matching API: |
45 | # [121.0179739,14.5515336] 1984-01-01T08:00:46.234 | ||
45 | function make_geojson() { | 46 | function make_geojson() { |
46 | #jq -nR '{type: "Feature", properties: {coordTimes: .[1]}, geometry: {type: "LineString", coordinates: .[0]}}' | 47 | awk '{printf("[%s,\"%s\"]\n", $1, $2)}' |\ # change input to format like: [[lon, lat], time] |
47 | awk '{printf("[%s,\"%s\"]\n", $1, $2)}' |\ | 48 | jq '[inputs] | {type: "Feature", properties: {coordTimes: (map(.[1]))}, geometry: {type: "LineString", coordinates: map(.[0])}}' |
48 | jq '[inputs] | {type: "Feature", properties: {coordTimes: (map(.[1]))}, geometry: {type: "LineString", coordinates: map(.[0])}}' | ||
49 | } | 49 | } |
50 | 50 | ||
51 | get_data $1 > $ORIGIN_DATA | 51 | get_data $1 > $ORIGIN_DATA |
@@ -53,8 +53,7 @@ get_data $1 > $ORIGIN_DATA | |||
53 | # Consume raw data with serveral request | 53 | # Consume raw data with serveral request |
54 | while [ -s $ORIGIN_DATA ]; do | 54 | while [ -s $ORIGIN_DATA ]; do |
55 | head -$LIMIT $ORIGIN_DATA |\ | 55 | head -$LIMIT $ORIGIN_DATA |\ |
56 | make_geojson | 56 | make_geojson |\ |
57 | exit 0 | ||
58 | # Mapbox Map Matching API, store response into tmp file | 57 | # Mapbox Map Matching API, store response into tmp file |
59 | curl -X POST -s --data @- --header "Content-Type:application/json" https://api.mapbox.com/matching/v4/mapbox.driving.json?access_token=$ACCESS_TOKEN > $RESPONSE | 58 | curl -X POST -s --data @- --header "Content-Type:application/json" https://api.mapbox.com/matching/v4/mapbox.driving.json?access_token=$ACCESS_TOKEN > $RESPONSE |
60 | 59 | ||