Add support node_osrm support for skip_waypoints parameter

This commit is contained in:
Maciej Bukczynski 2021-06-21 21:16:34 -06:00
parent f7478ba80f
commit 598b8a54ae
3 changed files with 35 additions and 0 deletions

View File

@ -1,4 +1,7 @@
# Unreleased # Unreleased
- Changes from 5.25.0
- Misc:
- FIXED: Support `skip_waypoints` in Node bindings [#6060](https://github.com/Project-OSRM/osrm-backend/pull/6060)
# 5.25.0 # 5.25.0
- Changes from 5.24.0 - Changes from 5.24.0

View File

@ -675,6 +675,22 @@ inline bool argumentsToParameter(const Nan::FunctionCallbackInfo<v8::Value> &arg
params->generate_hints = Nan::To<bool>(generate_hints).FromJust(); params->generate_hints = Nan::To<bool>(generate_hints).FromJust();
} }
if (Nan::Has(obj, Nan::New("skip_waypoints").ToLocalChecked()).FromJust())
{
v8::Local<v8::Value> skip_waypoints =
Nan::Get(obj, Nan::New("skip_waypoints").ToLocalChecked()).ToLocalChecked();
if (skip_waypoints.IsEmpty())
return false;
if (!skip_waypoints->IsBoolean())
{
Nan::ThrowError("skip_waypoints must be of type Boolean");
return false;
}
params->skip_waypoints = Nan::To<bool>(skip_waypoints).FromJust();
}
if (Nan::Has(obj, Nan::New("exclude").ToLocalChecked()).FromJust()) if (Nan::Has(obj, Nan::New("exclude").ToLocalChecked()).FromJust())
{ {
v8::Local<v8::Value> exclude = v8::Local<v8::Value> exclude =

View File

@ -190,6 +190,8 @@ tables.forEach(function(annotation) {
assert.throws(function() { osrm.route({coordinates: two_test_coordinates, generate_hints: null}, function(err, route) {}) }, assert.throws(function() { osrm.route({coordinates: two_test_coordinates, generate_hints: null}, function(err, route) {}) },
/generate_hints must be of type Boolean/); /generate_hints must be of type Boolean/);
assert.throws(function() { osrm.route({coordinates: two_test_coordinates, skip_waypoints: null}, function(err, route) {}) },
/skip_waypoints must be of type Boolean/);
}); });
test('table: throws on invalid arguments', function(assert) { test('table: throws on invalid arguments', function(assert) {
@ -239,6 +241,20 @@ tables.forEach(function(annotation) {
}); });
}); });
test('table: ' + annotation + ' table in Monaco without waypoints', function(assert) {
assert.plan(2);
var osrm = new OSRM(data_path);
var options = {
coordinates: two_test_coordinates,
skip_waypoints: true, // false is default
annotations: [annotation.slice(0,-1)]
};
osrm.table(options, function(err, table) {
assert.strictEqual(table.sources, undefined);
assert.strictEqual(table.destinations, undefined);
});
});
test('table: ' + annotation + ' table in Monaco without motorways', function(assert) { test('table: ' + annotation + ' table in Monaco without motorways', function(assert) {
assert.plan(2); assert.plan(2);
var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'}); var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'});