Integrate MLD in node bindings

This commit is contained in:
Patrick Niklaus
2017-03-17 15:19:56 +00:00
parent 7a1a209168
commit 31b6e4b2c3
9 changed files with 293 additions and 227 deletions
+29
View File
@@ -117,6 +117,7 @@ inline engine_config_ptr argumentsToEngineConfig(const Nan::FunctionCallbackInfo
{
engine_config->storage_config =
osrm::StorageConfig(*v8::String::Utf8Value(Nan::To<v8::String>(path).ToLocalChecked()));
engine_config->use_shared_memory = false;
}
if (!shared_memory->IsUndefined())
{
@@ -138,6 +139,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 = Nan::To<v8::String>(algorithm).ToLocalChecked();
if (*v8::String::Utf8Value(algorithm_str) == std::string("CH"))
{
engine_config->algorithm = osrm::EngineConfig::Algorithm::CH;
}
else if (*v8::String::Utf8Value(algorithm_str) == std::string("CoreCH"))
{
engine_config->algorithm = osrm::EngineConfig::Algorithm::CoreCH;
}
else if (*v8::String::Utf8Value(algorithm_str) == std::string("MLD"))
{
engine_config->algorithm = osrm::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;
}