From 5dde72b9b032521b5b71e8db085207059c17c209 Mon Sep 17 00:00:00 2001 From: typebrook Date: Thu, 5 Dec 2019 17:23:33 +0800 Subject: update --- scripts/match-road.sh | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) (limited to 'scripts') diff --git a/scripts/match-road.sh b/scripts/match-road.sh index 6c2f242..7b6dad4 100755 --- a/scripts/match-road.sh +++ b/scripts/match-road.sh @@ -74,27 +74,20 @@ function get_valid_data() { if head -1 $MATCHED| grep -F $point; then sed -i 1d $MATCHED else - echo $point + echo $point -1 fi done } -get_data $1 > $ORIGIN_DATA - -# Consume raw data with serveral request -while [ -s $ORIGIN_DATA ]; do - - head -$LIMIT $ORIGIN_DATA | make_geojson | query_matched_road | get_valid_data - exit 0 - # Put existing timestamps to matched points, and interpolate new timestamps into new points +# Put existing timestamps to matched points, and interpolate new timestamps into new points +function complete_data() { while read coor index; do if [ $index -gt -1 ]; then echo $coor $(sed -n "$index p" $ORIGIN_DATA | cut -d' ' -f2 | date -f - +%s) else echo $coor $index fi - done - exit 0 + done|\ # interpolate timestamps to newly added points awk '{COOR[NR][0]=$1; N++; COOR[NR][1]=$2} END{for (i=1; i<=N; i++) {printf COOR[i][0]; if (COOR[i][1] != -1) {print " "COOR[i][1]; LAST=i} else {while(COOR[i+n][1] == -1) n++; print " "COOR[LAST][1]+(COOR[i+n][1]-COOR[LAST][1])*(i-LAST)/(i+n-LAST)}}}' |\ while read coor unix_time; do @@ -103,13 +96,13 @@ while [ -s $ORIGIN_DATA ]; do # Into [121.018088,14.5516] 1970-01-01T08:00:18.50Z echo $coor $(date -d @$unix_time +'%Y-%m-%dT%H:%M:%S.%2NZ') done +} - # Remove processed raw data - sed -i "1,$LIMIT d" $ORIGIN_DATA -done #|\ # Make GPX format for output -sed -E 's/\[([^,]+),([^,]+)\] (.*)/