Add feature to fill null matrix entries with straight-line estimates.

This commit is contained in:
Daniel Patterson
2018-10-31 22:02:54 -07:00
parent cb1db646f2
commit 71bdfd2c6e
6 changed files with 103 additions and 4 deletions
+6 -2
View File
@@ -59,6 +59,7 @@ struct TableParameters : public BaseParameters
{
std::vector<std::size_t> sources;
std::vector<std::size_t> destinations;
std::size_t noroute_estimate = 0;
enum class AnnotationsType
{
@@ -74,19 +75,22 @@ struct TableParameters : public BaseParameters
template <typename... Args>
TableParameters(std::vector<std::size_t> sources_,
std::vector<std::size_t> destinations_,
std::size_t noroute_estimate_,
Args... args_)
: BaseParameters{std::forward<Args>(args_)...}, sources{std::move(sources_)},
destinations{std::move(destinations_)}
destinations{std::move(destinations_)}, noroute_estimate{noroute_estimate_}
{
}
template <typename... Args>
TableParameters(std::vector<std::size_t> sources_,
std::vector<std::size_t> destinations_,
std::size_t noroute_estimate_,
const AnnotationsType annotations_,
Args... args_)
: BaseParameters{std::forward<Args>(args_)...}, sources{std::move(sources_)},
destinations{std::move(destinations_)}, annotations{annotations_}
destinations{std::move(destinations_)}, noroute_estimate{noroute_estimate_},
annotations{annotations_}
{
}
+13
View File
@@ -1183,6 +1183,19 @@ argumentsToTableParameter(const Nan::FunctionCallbackInfo<v8::Value> &args,
}
}
if (obj->Has(Nan::New("noroute_estimate").ToLocalChecked()))
{
auto noroute_estimate = obj->Get(Nan::New("noroute_estimate").ToLocalChecked());
if (!noroute_estimate->IsNumber() && !noroute_estimate->IsUint32())
{
Nan::ThrowError("noroute_estimate must be an integral number");
return table_parameters_ptr();
}
params->noroute_estimate = static_cast<size_t>(noroute_estimate->NumberValue());
}
return params;
}
@@ -48,10 +48,16 @@ struct TableParametersGrammar : public BaseParametersGrammar<Iterator, Signature
(qi::lit("all") |
(size_t_ % ';')[ph::bind(&engine::api::TableParameters::sources, qi::_r1) = qi::_1]);
noroute_estimate_rule =
qi::lit("noroute_estimate=") >
(size_t_)[ph::bind(&engine::api::TableParameters::noroute_estimate, qi::_r1) = qi::_1];
table_rule = destinations_rule(qi::_r1) | sources_rule(qi::_r1);
root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") >
-('?' > (table_rule(qi::_r1) | base_rule(qi::_r1)) % '&');
root_rule =
BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") >
-('?' >
(table_rule(qi::_r1) | base_rule(qi::_r1) | noroute_estimate_rule(qi::_r1)) % '&');
}
TableParametersGrammar(qi::rule<Iterator, Signature> &root_rule_) : BaseGrammar(root_rule_)
@@ -77,6 +83,7 @@ struct TableParametersGrammar : public BaseParametersGrammar<Iterator, Signature
qi::rule<Iterator, Signature> table_rule;
qi::rule<Iterator, Signature> sources_rule;
qi::rule<Iterator, Signature> destinations_rule;
qi::rule<Iterator, Signature> noroute_estimate_rule;
qi::rule<Iterator, std::size_t()> size_t_;
qi::symbols<char, engine::api::TableParameters::AnnotationsType> annotations;
qi::rule<Iterator, engine::api::TableParameters::AnnotationsType()> annotations_list;