Add error handling for avoid not implemented

This commit is contained in:
Patrick Niklaus
2017-07-28 15:55:38 +00:00
committed by Patrick Niklaus
parent 20e4096c4b
commit f93b331817
12 changed files with 127 additions and 29 deletions
+23
View File
@@ -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 &params, 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