Skip to content

Commit

Permalink
Adapts Match
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-j-h committed Mar 30, 2017
1 parent 449f7b0 commit e8c5d98
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
4 changes: 3 additions & 1 deletion test/nodejs/locations.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Somewhere in Monaco ..
// http://www.openstreetmap.org/#map=18/43.73185/7.41772

exports.locations = [[7.41337, 43.72956],
[7.41546, 43.73077]];
[7.41546, 43.73077],
[7.41862, 43.73216]];

exports.route = exports.locations.slice(0, 2)
39 changes: 21 additions & 18 deletions test/nodejs/match.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
var OSRM = require('../../');
var test = require('tape');
var data_path = require('./osrm-data-path').data_path;
var kLocations = require('./locations').locations;
var kRoute = require('./locations').route;

test('match: match in Berlin', function(assert) {
test('match: match in Monaco', function(assert) {
assert.plan(5);
var osrm = new OSRM(data_path);
var options = {
coordinates: [[13.393252,52.542648],[13.39478,52.543079],[13.397389,52.542107]],
coordinates: kLocations.slice(0, 3),
timestamps: [1424684612, 1424684616, 1424684620]
};
osrm.match(options, function(err, response) {
Expand All @@ -22,11 +24,11 @@ test('match: match in Berlin', function(assert) {
});
});

test('match: match in Berlin without timestamps', function(assert) {
test('match: match in Monaco without timestamps', function(assert) {
assert.plan(3);
var osrm = new OSRM(data_path);
var options = {
coordinates: [[13.393252,52.542648],[13.39478,52.543079],[13.397389,52.542107]]
coordinates: kLocations.slice(0, 3)
};
osrm.match(options, function(err, response) {
assert.ifError(err);
Expand All @@ -35,11 +37,11 @@ test('match: match in Berlin without timestamps', function(assert) {
});
});

test('match: match in Berlin without geometry compression', function(assert) {
test('match: match in Monaco without geometry compression', function(assert) {
assert.plan(4);
var osrm = new OSRM(data_path);
var options = {
coordinates: [[13.393252,52.542648],[13.39478,52.543079],[13.397389,52.542107]],
coordinates: kLocations.slice(0, 3),
geometries: 'geojson'
};
osrm.match(options, function(err, response) {
Expand All @@ -50,11 +52,11 @@ test('match: match in Berlin without geometry compression', function(assert) {
});
});

test('match: match in Berlin with geometry compression', function(assert) {
test('match: match in Monaco with geometry compression', function(assert) {
assert.plan(3);
var osrm = new OSRM(data_path);
var options = {
coordinates: [[13.393252,52.542648],[13.39478,52.543079],[13.397389,52.542107]]
coordinates: kLocations.slice(0, 3),
};
osrm.match(options, function(err, response) {
assert.ifError(err);
Expand All @@ -63,11 +65,11 @@ test('match: match in Berlin with geometry compression', function(assert) {
});
});

test('match: match in Berlin with speed annotations options', function(assert) {
test('match: match in Monaco with speed annotations options', function(assert) {
assert.plan(12);
var osrm = new OSRM(data_path);
var options = {
coordinates: [[13.393252,52.542648],[13.39478,52.543079],[13.397389,52.542107]],
coordinates: kLocations.slice(0, 3),
timestamps: [1424684612, 1424684616, 1424684620],
radiuses: [4.07, 4.07, 4.07],
steps: true,
Expand All @@ -92,11 +94,12 @@ test('match: match in Berlin with speed annotations options', function(assert) {
});


test('match: match in Berlin with several (duration, distance, nodes) annotations options', function(assert) {
test('match: match in Monaco with several (duration, distance, nodes) annotations options', function(assert) {
assert.plan(12);
var osrm = new OSRM(data_path);
var options = {
coordinates: [[13.393252,52.542648],[13.39478,52.543079],[13.397389,52.542107]],
timestamps: [1424684612, 1424684616, 1424684620],
coordinates: kLocations.slice(0, 3),
timestamps: [1424684612, 1424684616, 1424684620],
radiuses: [4.07, 4.07, 4.07],
steps: true,
Expand All @@ -120,11 +123,11 @@ test('match: match in Berlin with several (duration, distance, nodes) annotation
});
});

test('match: match in Berlin with all options', function(assert) {
test('match: match in Monaco with all options', function(assert) {
assert.plan(8);
var osrm = new OSRM(data_path);
var options = {
coordinates: [[13.393252,52.542648],[13.39478,52.543079],[13.397389,52.542107]],
coordinates: kLocations.slice(0, 3),
timestamps: [1424684612, 1424684616, 1424684620],
radiuses: [4.07, 4.07, 4.07],
steps: true,
Expand Down Expand Up @@ -166,13 +169,13 @@ test('match: throws on invalid coordinates param', function(assert) {
};
assert.throws(function() { osrm.match(options, function(err, response) {}) },
/Coordinates must be an array of \(lon\/lat\) pairs/);
options.coordinates = [[13.393252,52.542648]];
options.coordinates = [kLocations[0]];
assert.throws(function() { osrm.match(options, function(err, response) {}) },
/At least two coordinates must be provided/);
options.coordinates = [13.393252,52.542648];
options.coordinates = kLocations[0]
assert.throws(function() { osrm.match(options, function(err, response) {}) },
/Coordinates must be an array of \(lon\/lat\) pairs/);
options.coordinates = [[13.393252],[52.542648]];
options.coordinates = [kLocations[0][0], kLocations[0][1]];
assert.throws(function() { osrm.match(options, function(err, response) {}) },
/Coordinates must be an array of \(lon\/lat\) pairs/);
});
Expand All @@ -181,7 +184,7 @@ test('match: throws on invalid timestamps param', function(assert) {
assert.plan(3);
var osrm = new OSRM(data_path);
var options = {
coordinates: [[13.393252,52.542648],[13.39478,52.543079],[13.397389,52.542107]],
coordinates: kLocations.slice(0, 3),
timestamps: 'timestamps'
};
assert.throws(function() { osrm.match(options, function(err, response) {}) },
Expand Down
4 changes: 2 additions & 2 deletions test/nodejs/trip.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ test('trip: routes Monaco using shared memory', function(assert) {
});
});

test('trip: routes Berlin with hints', function(assert) {
test('trip: routes Monaco with hints', function(assert) {
assert.plan(5);
var osrm = new OSRM(data_path);
var options = {
Expand Down Expand Up @@ -233,7 +233,7 @@ test('trip: trip through Monaco with options', function(assert) {
});
});

test('trip: routes Berlin with null hints', function(assert) {
test('trip: routes Monaco with null hints', function(assert) {
assert.plan(1);
var osrm = new OSRM(data_path);
var options = {
Expand Down

0 comments on commit e8c5d98

Please sign in to comment.