From 22fa13699524222c91b58db26b87816c8a71c7c5 Mon Sep 17 00:00:00 2001 From: typebrook Date: Thu, 5 Dec 2019 12:08:29 +0800 Subject: update --- scripts/match-road.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'scripts') 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() { awk '!_[$2]++' } -# Read date Make GeoJSON object for Map Matching API +# Read data like the following to make GeoJSON object for Map Matching API: +# [121.0179739,14.5515336] 1984-01-01T08:00:46.234 function make_geojson() { - #jq -nR '{type: "Feature", properties: {coordTimes: .[1]}, geometry: {type: "LineString", coordinates: .[0]}}' - awk '{printf("[%s,\"%s\"]\n", $1, $2)}' |\ - jq '[inputs] | {type: "Feature", properties: {coordTimes: (map(.[1]))}, geometry: {type: "LineString", coordinates: map(.[0])}}' + awk '{printf("[%s,\"%s\"]\n", $1, $2)}' |\ # change input to format like: [[lon, lat], time] + jq '[inputs] | {type: "Feature", properties: {coordTimes: (map(.[1]))}, geometry: {type: "LineString", coordinates: map(.[0])}}' } get_data $1 > $ORIGIN_DATA @@ -53,8 +53,7 @@ get_data $1 > $ORIGIN_DATA # Consume raw data with serveral request while [ -s $ORIGIN_DATA ]; do head -$LIMIT $ORIGIN_DATA |\ - make_geojson - exit 0 + make_geojson |\ # Mapbox Map Matching API, store response into tmp file curl -X POST -s --data @- --header "Content-Type:application/json" https://api.mapbox.com/matching/v4/mapbox.driving.json?access_token=$ACCESS_TOKEN > $RESPONSE -- cgit v1.2.3-70-g09d2