Exposes EngineConfig system-wide limits in Node.js bindings, resolves #4226

This commit is contained in:
Daniel J. Hofmann
2017-07-13 12:55:18 +02:00
committed by Patrick Niklaus
parent 30b8225812
commit 58b61c68a3
3 changed files with 116 additions and 0 deletions
+31
View File
@@ -98,6 +98,37 @@ test('constructor: throws if data doesn\'t match algorithm', function(assert) {
assert.throws(function() { new OSRM({algorithm: 'MLD', path: monaco_path}); });
});
test('constructor: parses custom limits', function(assert) {
assert.plan(1);
var osrm = new OSRM({
path: monaco_mld_path,
algorithm: 'MLD',
max_locations_trip: 1,
max_locations_viaroute: 1,
max_locations_distance_table: 1,
max_locations_map_matching: 1,
max_results_nearest: 1,
max_alternatives: 1,
});
assert.ok(osrm);
});
test('constructor: throws on invalid custom limits', function(assert) {
assert.plan(1);
assert.throws(function() {
var osrm = new OSRM({
path: monaco_mld_path,
algorithm: 'MLD',
max_locations_trip: 'unlimited',
max_locations_viaroute: true,
max_locations_distance_table: false,
max_locations_map_matching: 'a lot',
max_results_nearest: null,
max_alternatives: '10'
})
});
});
require('./route.js');
require('./trip.js');
require('./match.js');
+27
View File
@@ -549,3 +549,30 @@ test('route: throws on bad approaches', function(assert) {
}, function(err, route) {}) },
/Approach must be a string: \[curb, unrestricted\] or null/);
});
test('route: routes Monaco with custom limits on MLD', function(assert) {
assert.plan(2);
var osrm = new OSRM({
path: monaco_mld_path,
algorithm: 'MLD',
max_alternatives: 10,
});
osrm.route({coordinates: two_test_coordinates, alternatives: 10}, function(err, route) {
assert.ifError(err);
assert.ok(Array.isArray(route.routes));
});
});
test('route: in Monaco with custom limits on MLD', function(assert) {
assert.plan(1);
var osrm = new OSRM({
path: monaco_mld_path,
algorithm: 'MLD',
max_alternatives: 10,
});
osrm.route({coordinates: two_test_coordinates, alternatives: 11}, function(err, route) {
console.log(err)
assert.equal(err.message, 'TooBig');
});
});