#!/usr/bin/env bash # # Author: Pham # # This script accepts a single GPX file as parameter and # output the processed GPX body to STDOUT, using Mapbox Map Matching API v4. # read doc at: https://docs.mapbox.com/api/legacy/map-matching-v4/ # # Example: # # match-road.sh raw.gpx > new.gpx # # Hint: # # Remember to put Mapbox Access Token at the top! #set -x set -e ACCESS_TOKEN=$(cat ~/settings/tokens/mapbox) # put yout Mapbox token here LIMIT=10 # number of coordinates for each Mapbox Map Matching API request, Maximum value is 100 ORIGIN_DATA=/tmp/origin RESPONSE=/tmp/response # store data of time and location into tmp file with 2 columns, format is like: # 1970-01-01T08:00:46 [121.0179739,14.5515336] paste -d' ' \ <(sed -nr '//,/<\/trk>/ { s/.*