First steps towards integrating MLD in node bindings
This commit is contained in:
parent
bfc272f3e8
commit
ac0c5c27e7
@ -138,6 +138,34 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
|
||||
return engine_config_ptr();
|
||||
}
|
||||
|
||||
auto algorithm = params->Get(Nan::New("algorithm").ToLocalChecked());
|
||||
if (algorithm->IsString())
|
||||
{
|
||||
auto algorithm_str = *v8::String::Utf8Value(Nan::To<v8::String>(algorithm).ToLocalChecked());
|
||||
if (name == "CH")
|
||||
{
|
||||
engine_config->algorithm = EngineConfig::Algorithm::CH;
|
||||
}
|
||||
else if (name == "CoreCH")
|
||||
{
|
||||
engine_config->algorithm = EngineConfig::Algorithm::CoreCH;
|
||||
}
|
||||
else if (name == "MLD")
|
||||
{
|
||||
engine_config->algorithm = EngineConfig::Algorithm::MLD;
|
||||
}
|
||||
else
|
||||
{
|
||||
Nan::ThrowError("algorithm option must be one of 'CH', 'CoreCH', or 'MLD'.");
|
||||
return engine_config_ptr();
|
||||
}
|
||||
}
|
||||
else if (!algorithm->IsUndefined())
|
||||
{
|
||||
Nan::ThrowError("algorithm option must be a string and one of 'CH', 'CoreCH', or 'MLD'.");
|
||||
return engine_config_ptr();
|
||||
}
|
||||
|
||||
return engine_config;
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,18 @@ test('constructor: throws if given a non-string/obj argument', function(assert)
|
||||
/Parameter must be a path or options object/);
|
||||
});
|
||||
|
||||
test('constructor: throws if given an unkown algorithm', function(assert) {
|
||||
assert.plan(1);
|
||||
assert.throws(function() { var osrm = new OSRM({algorithm: "Foo", shared_memory: true}); },
|
||||
/algorithm option needs to be one of 'CH', 'CoreCH', or 'MLD'/);
|
||||
});
|
||||
|
||||
test('constructor: throws if given an invalid algorithm', function(assert) {
|
||||
assert.plan(1);
|
||||
assert.throws(function() { var osrm = new OSRM({algorithm: 3, shared_memory: true}); },
|
||||
/algorithm option needs to be a string and one of 'CH', 'CoreCH', or 'MLD'/);
|
||||
});
|
||||
|
||||
require('./route.js');
|
||||
require('./trip.js');
|
||||
require('./match.js');
|
||||
|
Loading…
Reference in New Issue
Block a user