From 7e57495c220ae40d95d22923e1202c75ca0b69c6 Mon Sep 17 00:00:00 2001 From: Freenerd Date: Wed, 20 Jan 2016 20:25:54 +0100 Subject: [PATCH] Add gps precision to url --- README.md | 3 ++- src/match.js | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ea9acb0..325cf74 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,8 @@ name | required? | description ---- | --------- | ----------- `profile` | required | Profile to match trace against. Options are `driving`, `walking` and `cycling` `mapMatchAPI` | optional | Custom API endpoint to query. Overrides the `profile` option` -`gpsPrecision` | optional | Integer indicating the precision of the input geometries in metres (default: 5) +`gpsPrecision` | optional | Integer indicating the precision of the gps device capturing the input geometries, sensitivity in metres (default: 5) +`minimumDistance` | optional | When tidying up input geometries what is the minimum distance between points in meters (default: 10) `return` | optional | Type of object to return after matching. Options are `layer` (default) returns a leaflet featureLayer, `geojson` returns a geojson feature collection ## Development diff --git a/src/match.js b/src/match.js index ddedb47..f1b637e 100644 --- a/src/match.js +++ b/src/match.js @@ -5,7 +5,6 @@ var xhr = require('xhr'), polyline = require('polyline'), queue = require('queue-async'); - var VALID_PROFILES = [ 'driving', 'walking', @@ -26,6 +25,10 @@ function match(geojson, options, callback) { } var xhrUrl = mapMatchAPI + "?access_token=" + L.mapbox.accessToken + "&geometry=polyline"; + if (options.gpsPrecision) { + xhrUrl += "&gps_precision=" + options.gpsPrecision; + } + // empty queue for storing responses var q = queue(); @@ -66,7 +69,7 @@ function match(geojson, options, callback) { // First tidy the input geojson to remove noisy points and match every feature using the API var inputGeometries = tidy.tidy(geojson, { - "minimumDistance": options.gpsPrecision || 10, + "minimumDistance": options.minimumDistance || 10, "minimumTime": 5, "maximumPoints": 100 }); @@ -102,4 +105,4 @@ module.exports = function (feature, options, callback) { options = {}; } return new match(feature, options, callback); -}; \ No newline at end of file +};