return NotImplemented when distance annotation is requested for MLD in table plugin
format
This commit is contained in:
parent
d4a1569f0d
commit
248a786d7f
@ -50,6 +50,9 @@ template <typename AlgorithmT> struct HasMapMatching final : std::false_type
|
|||||||
template <typename AlgorithmT> struct HasManyToManySearch final : std::false_type
|
template <typename AlgorithmT> struct HasManyToManySearch final : std::false_type
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
template <typename AlgorithmT> struct SupportsDistanceAnnotationType final : std::false_type
|
||||||
|
{
|
||||||
|
};
|
||||||
template <typename AlgorithmT> struct HasGetTileTurns final : std::false_type
|
template <typename AlgorithmT> struct HasGetTileTurns final : std::false_type
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
@ -73,6 +76,9 @@ template <> struct HasMapMatching<ch::Algorithm> final : std::true_type
|
|||||||
template <> struct HasManyToManySearch<ch::Algorithm> final : std::true_type
|
template <> struct HasManyToManySearch<ch::Algorithm> final : std::true_type
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
template <> struct SupportsDistanceAnnotationType<ch::Algorithm> final : std::true_type
|
||||||
|
{
|
||||||
|
};
|
||||||
template <> struct HasGetTileTurns<ch::Algorithm> final : std::true_type
|
template <> struct HasGetTileTurns<ch::Algorithm> final : std::true_type
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
@ -96,6 +102,9 @@ template <> struct HasMapMatching<mld::Algorithm> final : std::true_type
|
|||||||
template <> struct HasManyToManySearch<mld::Algorithm> final : std::true_type
|
template <> struct HasManyToManySearch<mld::Algorithm> final : std::true_type
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
template <> struct SupportsDistanceAnnotationType<mld::Algorithm> final : std::false_type
|
||||||
|
{
|
||||||
|
};
|
||||||
template <> struct HasGetTileTurns<mld::Algorithm> final : std::true_type
|
template <> struct HasGetTileTurns<mld::Algorithm> final : std::true_type
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|||||||
@ -55,6 +55,7 @@ class RoutingAlgorithmsInterface
|
|||||||
virtual bool HasDirectShortestPathSearch() const = 0;
|
virtual bool HasDirectShortestPathSearch() const = 0;
|
||||||
virtual bool HasMapMatching() const = 0;
|
virtual bool HasMapMatching() const = 0;
|
||||||
virtual bool HasManyToManySearch() const = 0;
|
virtual bool HasManyToManySearch() const = 0;
|
||||||
|
virtual bool SupportsDistanceAnnotationType() const = 0;
|
||||||
virtual bool HasGetTileTurns() const = 0;
|
virtual bool HasGetTileTurns() const = 0;
|
||||||
virtual bool HasExcludeFlags() const = 0;
|
virtual bool HasExcludeFlags() const = 0;
|
||||||
virtual bool IsValid() const = 0;
|
virtual bool IsValid() const = 0;
|
||||||
@ -128,6 +129,11 @@ template <typename Algorithm> class RoutingAlgorithms final : public RoutingAlgo
|
|||||||
return routing_algorithms::HasManyToManySearch<Algorithm>::value;
|
return routing_algorithms::HasManyToManySearch<Algorithm>::value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SupportsDistanceAnnotationType() const final override
|
||||||
|
{
|
||||||
|
return routing_algorithms::SupportsDistanceAnnotationType<Algorithm>::value;
|
||||||
|
}
|
||||||
|
|
||||||
bool HasGetTileTurns() const final override
|
bool HasGetTileTurns() const final override
|
||||||
{
|
{
|
||||||
return routing_algorithms::HasGetTileTurns<Algorithm>::value;
|
return routing_algorithms::HasGetTileTurns<Algorithm>::value;
|
||||||
|
|||||||
@ -85,6 +85,13 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
|||||||
bool request_distance = params.annotations & api::TableParameters::AnnotationsType::Distance;
|
bool request_distance = params.annotations & api::TableParameters::AnnotationsType::Distance;
|
||||||
bool request_duration = params.annotations & api::TableParameters::AnnotationsType::Duration;
|
bool request_duration = params.annotations & api::TableParameters::AnnotationsType::Duration;
|
||||||
|
|
||||||
|
if (request_distance && !algorithms.SupportsDistanceAnnotationType())
|
||||||
|
{
|
||||||
|
return Error("NotImplemented",
|
||||||
|
"The distance annotations calculation is not implemented for the chosen search algorithm.",
|
||||||
|
result);
|
||||||
|
}
|
||||||
|
|
||||||
auto result_tables_pair = algorithms.ManyToManySearch(
|
auto result_tables_pair = algorithms.ManyToManySearch(
|
||||||
snapped_phantoms, params.sources, params.destinations, request_distance, request_duration);
|
snapped_phantoms, params.sources, params.destinations, request_distance, request_duration);
|
||||||
|
|
||||||
|
|||||||
@ -185,7 +185,6 @@ tables.forEach(function(annotation) {
|
|||||||
annotations: [annotation.slice(0,-1)]
|
annotations: [annotation.slice(0,-1)]
|
||||||
};
|
};
|
||||||
osrm.table(options, function(err, table) {
|
osrm.table(options, function(err, table) {
|
||||||
console.log(table);
|
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
|
|
||||||
function assertHasHints(waypoint) {
|
function assertHasHints(waypoint) {
|
||||||
@ -218,7 +217,7 @@ tables.forEach(function(annotation) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('table: ' + annotation + ' table in Monaco without motorways', function(assert) {
|
test('table: ' + annotation + ' table in Monaco without motorways', function(assert) {
|
||||||
assert.plan(2);
|
assert.plan(1);
|
||||||
var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'});
|
var osrm = new OSRM({path: mld_data_path, algorithm: 'MLD'});
|
||||||
var options = {
|
var options = {
|
||||||
coordinates: two_test_coordinates,
|
coordinates: two_test_coordinates,
|
||||||
@ -226,8 +225,8 @@ tables.forEach(function(annotation) {
|
|||||||
annotations: [annotation.slice(0,-1)]
|
annotations: [annotation.slice(0,-1)]
|
||||||
};
|
};
|
||||||
osrm.table(options, function(err, response) {
|
osrm.table(options, function(err, response) {
|
||||||
assert.ifError(err);
|
if (annotation === 'durations') assert.equal(response[annotation].length, 2);
|
||||||
assert.equal(response[annotation].length, 2);
|
else assert.error(response, 'NotImplemented');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user