Add error handling for avoid not implemented
This commit is contained in:
committed by
Patrick Niklaus
parent
20e4096c4b
commit
f93b331817
@@ -4,6 +4,7 @@
|
||||
#include "engine/api/base_parameters.hpp"
|
||||
#include "engine/datafacade/datafacade_base.hpp"
|
||||
#include "engine/phantom_node.hpp"
|
||||
#include "engine/routing_algorithms.hpp"
|
||||
#include "engine/status.hpp"
|
||||
|
||||
#include "util/coordinate.hpp"
|
||||
@@ -36,6 +37,28 @@ class BasePlugin
|
||||
});
|
||||
}
|
||||
|
||||
bool CheckAlgorithms(const api::BaseParameters ¶ms, const RoutingAlgorithmsInterface& algorithms, util::json::Object &result) const
|
||||
{
|
||||
if (algorithms.IsValid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!algorithms.HasAvoidFlags() && !params.avoid.empty())
|
||||
{
|
||||
Error("NotImplemented", "This algorithm does not support avoid flags.", result);
|
||||
return false;
|
||||
}
|
||||
if (algorithms.HasAvoidFlags() && !params.avoid.empty())
|
||||
{
|
||||
Error("InvalidValue", "Avoid flag combination is not supported.", result);
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOST_ASSERT_MSG(false, "There are only two reasons why the algorithm interface can be invalid.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Status Error(const std::string &code,
|
||||
const std::string &message,
|
||||
util::json::Object &json_result) const
|
||||
|
||||
Reference in New Issue
Block a user