Compare commits

...

4 Commits

Author SHA1 Message Date
Daniel Paz-Soldan
38b2e8ac57 Bump version to 5.20.0-rc.2 2018-11-01 11:48:16 -04:00
Daniel Paz-Soldan
fa1a55f564 Fix unit test 2018-11-01 10:41:38 -04:00
Daniel Paz-Soldan
e0a784505a Add branch to travis; TODO remove 2018-11-01 10:16:01 -04:00
Daniel Patterson
71bdfd2c6e
Add feature to fill null matrix entries with straight-line estimates. 2018-10-31 22:02:54 -07:00
9 changed files with 106 additions and 6 deletions

View File

@ -13,6 +13,7 @@ notifications:
branches: branches:
only: only:
- master - master
- danpat_table_noroute_estimate
# enable building tags # enable building tags
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/ - /^v\d+\.\d+(\.\d+)?(-\S*)?$/

View File

@ -595,3 +595,27 @@ Feature: Basic Distance Matrix
| d | 1478.9 | 1579 | 1779.1 | 0 | 1280.1 | 882.5 | | d | 1478.9 | 1579 | 1779.1 | 0 | 1280.1 | 882.5 |
| e | 198.8 | 298.9 | 499 | 710.3 | 0 | 1592.8 | | e | 198.8 | 298.9 | 499 | 710.3 | 0 | 1592.8 |
| f | 596.4 | 696.5 | 896.6 | 1107.9 | 397.6 | 0 | | f | 596.4 | 696.5 | 896.6 | 1107.9 | 397.6 | 0 |
Scenario: Testbot - Filling in noroutes with estimates
Given a grid size of 300 meters
Given the extract extra arguments "--small-component-size 4"
Given the query options
| noroute_estimate | 5 |
Given the node map
"""
a b f h
d e g i
"""
And the ways
| nodes |
| abeda |
| fhigf |
When I request a travel distance matrix I should get
| | a | b | f | h |
| a | 0 | 300.2 | 900.7 | 1200.9 |
| b | 300.2 | 0 | 600.5 | 900.7 |
| f | 900.7 | 600.5 | 0 | 302.2 |
| h | 1200.9 | 900.7 | 300.2 | 0 |

View File

@ -510,3 +510,26 @@ Feature: Basic Duration Matrix
| | a | | | a |
| a | 0 | | a | 0 |
| b | 24.1 | | b | 24.1 |
Scenario: Testbot - Filling in noroutes with estimates
Given a grid size of 300 meters
Given the extract extra arguments "--small-component-size 4"
Given the query options
| noroute_estimate | 5 |
Given the node map
"""
a b f h
d e g i
"""
And the ways
| nodes |
| abeda |
| fhigf |
When I request a travel time matrix I should get
| | a | b | f | h |
| a | 0 | 30 | 18 | 24 |
| b | 30 | 0 | 12 | 18 |
| f | 18 | 12 | 0 | 30 |
| h | 24 | 18 | 30 | 0 |

View File

@ -59,6 +59,7 @@ struct TableParameters : public BaseParameters
{ {
std::vector<std::size_t> sources; std::vector<std::size_t> sources;
std::vector<std::size_t> destinations; std::vector<std::size_t> destinations;
std::size_t noroute_estimate = 0;
enum class AnnotationsType enum class AnnotationsType
{ {
@ -74,19 +75,22 @@ struct TableParameters : public BaseParameters
template <typename... Args> template <typename... Args>
TableParameters(std::vector<std::size_t> sources_, TableParameters(std::vector<std::size_t> sources_,
std::vector<std::size_t> destinations_, std::vector<std::size_t> destinations_,
std::size_t noroute_estimate_,
Args... args_) Args... args_)
: BaseParameters{std::forward<Args>(args_)...}, sources{std::move(sources_)}, : BaseParameters{std::forward<Args>(args_)...}, sources{std::move(sources_)},
destinations{std::move(destinations_)} destinations{std::move(destinations_)}, noroute_estimate{noroute_estimate_}
{ {
} }
template <typename... Args> template <typename... Args>
TableParameters(std::vector<std::size_t> sources_, TableParameters(std::vector<std::size_t> sources_,
std::vector<std::size_t> destinations_, std::vector<std::size_t> destinations_,
std::size_t noroute_estimate_,
const AnnotationsType annotations_, const AnnotationsType annotations_,
Args... args_) Args... args_)
: BaseParameters{std::forward<Args>(args_)...}, sources{std::move(sources_)}, : 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_}
{ {
} }

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; return params;
} }

View File

@ -48,10 +48,16 @@ struct TableParametersGrammar : public BaseParametersGrammar<Iterator, Signature
(qi::lit("all") | (qi::lit("all") |
(size_t_ % ';')[ph::bind(&engine::api::TableParameters::sources, qi::_r1) = qi::_1]); (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); table_rule = destinations_rule(qi::_r1) | sources_rule(qi::_r1);
root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") > root_rule =
-('?' > (table_rule(qi::_r1) | base_rule(qi::_r1)) % '&'); 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_) 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> table_rule;
qi::rule<Iterator, Signature> sources_rule; qi::rule<Iterator, Signature> sources_rule;
qi::rule<Iterator, Signature> destinations_rule; qi::rule<Iterator, Signature> destinations_rule;
qi::rule<Iterator, Signature> noroute_estimate_rule;
qi::rule<Iterator, std::size_t()> size_t_; qi::rule<Iterator, std::size_t()> size_t_;
qi::symbols<char, engine::api::TableParameters::AnnotationsType> annotations; qi::symbols<char, engine::api::TableParameters::AnnotationsType> annotations;
qi::rule<Iterator, engine::api::TableParameters::AnnotationsType()> annotations_list; qi::rule<Iterator, engine::api::TableParameters::AnnotationsType()> annotations_list;

View File

@ -1,6 +1,6 @@
{ {
"name": "osrm", "name": "osrm",
"version": "5.20.0-latest.1", "version": "5.20.0-rc.2",
"private": false, "private": false,
"description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.", "description": "The Open Source Routing Machine is a high performance routing engine written in C++14 designed to run on OpenStreetMap data.",
"dependencies": { "dependencies": {

View File

@ -4,6 +4,7 @@
#include "engine/api/table_parameters.hpp" #include "engine/api/table_parameters.hpp"
#include "engine/routing_algorithms/many_to_many.hpp" #include "engine/routing_algorithms/many_to_many.hpp"
#include "engine/search_engine_data.hpp" #include "engine/search_engine_data.hpp"
#include "util/coordinate_calculation.hpp"
#include "util/json_container.hpp" #include "util/json_container.hpp"
#include "util/string_util.hpp" #include "util/string_util.hpp"
@ -94,6 +95,33 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
return Error("NoTable", "No table found", result); return Error("NoTable", "No table found", result);
} }
// Scan table for null results - if any exist, replace with distance estimates
if (params.noroute_estimate > 0)
{
for (std::size_t row = 0; row < num_sources; row++)
{
for (std::size_t column = 0; column < num_destinations; column++)
{
if (result_tables_pair.first[row * num_sources + column] == MAXIMAL_EDGE_DURATION)
{
auto distance_estimate = util::coordinate_calculation::fccApproximateDistance(
snapped_phantoms[params.sources.empty() ? row : params.sources[row]]
.location,
snapped_phantoms[params.destinations.empty() ? column
: params.destinations[column]]
.location);
result_tables_pair.first[row * num_sources + column] =
distance_estimate / (double)params.noroute_estimate;
if (!result_tables_pair.second.empty())
{
result_tables_pair.second[row * num_sources + column] = distance_estimate;
}
}
}
}
}
api::TableAPI table_api{facade, params}; api::TableAPI table_api{facade, params};
table_api.MakeResponse(result_tables_pair, snapped_phantoms, result); table_api.MakeResponse(result_tables_pair, snapped_phantoms, result);

View File

@ -507,7 +507,7 @@ BOOST_AUTO_TEST_CASE(valid_table_urls)
std::vector<std::size_t> sources_2 = {1, 2, 3}; std::vector<std::size_t> sources_2 = {1, 2, 3};
std::vector<std::size_t> destinations_2 = {4, 5}; std::vector<std::size_t> destinations_2 = {4, 5};
TableParameters reference_2{sources_2, destinations_2}; TableParameters reference_2{sources_2, destinations_2, 0};
reference_2.coordinates = coords_1; reference_2.coordinates = coords_1;
auto result_2 = parseParameters<TableParameters>("1,2;3,4?sources=1;2;3&destinations=4;5"); auto result_2 = parseParameters<TableParameters>("1,2;3,4?sources=1;2;3&destinations=4;5");
BOOST_CHECK(result_2); BOOST_CHECK(result_2);