diff --git a/docs/nodejs/api.md b/docs/nodejs/api.md index 29e496da0..68feda7ac 100644 --- a/docs/nodejs/api.md +++ b/docs/nodejs/api.md @@ -194,6 +194,8 @@ if they can not be matched successfully. - `options.overview` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Add overview geometry either `full`, `simplified` according to highest zoom level it could be display on, or not at all (`false`). (optional, default `simplified`) - `options.timestamps` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>?** Timestamp of the input location (integers, UNIX-like timestamp). - `options.radiuses` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)?** Standard deviation of GPS precision used for map matching. If applicable use GPS accuracy. Can be `null` for default value `5` meters or `double >= 0`. + - `options.gaps` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Allows the input track splitting based on huge timestamp gaps between points. Either `split` or `ignore`. (optional, default `split`) + - `options.tidy` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Allows the input track modification to obtain better matching quality for noisy tracks. (optional, default `false`) - `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** **Examples** diff --git a/include/nodejs/node_osrm_support.hpp b/include/nodejs/node_osrm_support.hpp index d64b04d9c..dd67958ec 100644 --- a/include/nodejs/node_osrm_support.hpp +++ b/include/nodejs/node_osrm_support.hpp @@ -1070,6 +1070,51 @@ argumentsToMatchParameter(const Nan::FunctionCallbackInfo &args, } } + if (obj->Has(Nan::New("gaps").ToLocalChecked())) + { + v8::Local gaps = obj->Get(Nan::New("gaps").ToLocalChecked()); + if (gaps.IsEmpty()) + return match_parameters_ptr(); + + if (!gaps->IsString()) + { + Nan::ThrowError("Gaps must be a string: [split, ignore]"); + return match_parameters_ptr(); + } + + const Nan::Utf8String gaps_utf8str(gaps); + std::string gaps_str{*gaps_utf8str, *gaps_utf8str + gaps_utf8str.length()}; + + if (gaps_str == "split") + { + params->gaps = osrm::MatchParameters::GapsType::Split; + } + else if (gaps_str == "ignore") + { + params->gaps = osrm::MatchParameters::GapsType::Ignore; + } + else + { + Nan::ThrowError("'gaps' param must be one of [split, ignore]"); + return match_parameters_ptr(); + } + } + + if (obj->Has(Nan::New("tidy").ToLocalChecked())) + { + v8::Local tidy = obj->Get(Nan::New("tidy").ToLocalChecked()); + if (tidy.IsEmpty()) + return match_parameters_ptr(); + + if (!tidy->IsBoolean()) + { + Nan::ThrowError("tidy must be of type Boolean"); + return match_parameters_ptr(); + } + + params->tidy = tidy->BooleanValue(); + } + bool parsedSuccessfully = parseCommonParameters(obj, params); if (!parsedSuccessfully) {