Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions src/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var xhr = require('xhr'),
polyline = require('polyline'),
queue = require('queue-async');


var VALID_PROFILES = [
'driving',
'walking',
Expand All @@ -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();

Expand Down Expand Up @@ -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
});
Expand Down Expand Up @@ -102,4 +105,4 @@ module.exports = function (feature, options, callback) {
options = {};
}
return new match(feature, options, callback);
};
};