2014-11-28 06:13:18 -05:00
|
|
|
#ifndef RESTRICTION_HPP
|
|
|
|
#define RESTRICTION_HPP
|
2012-08-27 11:40:59 -04:00
|
|
|
|
2017-05-11 06:13:52 -04:00
|
|
|
#include "util/coordinate.hpp"
|
|
|
|
#include "util/opening_hours.hpp"
|
2016-01-02 11:13:44 -05:00
|
|
|
#include "util/typedefs.hpp"
|
2014-01-29 05:31:39 -05:00
|
|
|
|
2017-07-27 05:42:13 -04:00
|
|
|
#include "mapbox/variant.hpp"
|
2022-08-24 11:19:24 -04:00
|
|
|
#include "turn_path.hpp"
|
2014-01-29 05:31:39 -05:00
|
|
|
#include <limits>
|
2012-08-27 11:40:59 -04:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace extractor
|
|
|
|
{
|
|
|
|
|
2022-08-24 11:19:24 -04:00
|
|
|
// External (OSM) representation of restriction
|
2017-07-06 11:09:24 -04:00
|
|
|
struct InputTurnRestriction
|
|
|
|
{
|
2022-08-24 11:19:24 -04:00
|
|
|
InputTurnPath turn_path;
|
2017-07-11 08:22:28 -04:00
|
|
|
bool is_only;
|
2020-12-20 16:59:57 -05:00
|
|
|
std::vector<util::OpeningHours> condition;
|
2017-07-06 11:09:24 -04:00
|
|
|
};
|
|
|
|
|
2022-08-24 11:19:24 -04:00
|
|
|
// Internal (OSRM) representation of restriction
|
2017-07-06 11:09:24 -04:00
|
|
|
struct TurnRestriction
|
2014-08-26 11:35:31 -04:00
|
|
|
{
|
2022-08-24 11:19:24 -04:00
|
|
|
// The turn sequence that the restriction applies to.
|
|
|
|
TurnPath turn_path;
|
|
|
|
// Indicates if the restriction turn *must* or *must not* be taken.
|
2017-07-11 08:22:28 -04:00
|
|
|
bool is_only;
|
2020-12-20 16:59:57 -05:00
|
|
|
// We represent conditional and unconditional restrictions with the same structure.
|
|
|
|
// Unconditional restrictions will have empty conditions.
|
|
|
|
std::vector<util::OpeningHours> condition;
|
2017-07-06 11:09:24 -04:00
|
|
|
|
2022-08-24 11:19:24 -04:00
|
|
|
explicit TurnRestriction(const TurnPath &turn_path, bool is_only = false)
|
|
|
|
: turn_path(turn_path), is_only(is_only)
|
2017-07-06 11:09:24 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit TurnRestriction()
|
|
|
|
{
|
2022-08-24 11:19:24 -04:00
|
|
|
turn_path = {ViaNodePath{SPECIAL_NODEID, SPECIAL_NODEID, SPECIAL_NODEID}};
|
2020-12-20 16:59:57 -05:00
|
|
|
}
|
|
|
|
|
2022-08-24 11:19:24 -04:00
|
|
|
bool IsTurnRestricted(NodeID to) const
|
2020-12-20 16:59:57 -05:00
|
|
|
{
|
2022-08-24 11:19:24 -04:00
|
|
|
return is_only ? turn_path.To() != to : turn_path.To() == to;
|
2020-12-20 16:59:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool IsUnconditional() const { return condition.empty(); }
|
|
|
|
|
2017-07-06 11:09:24 -04:00
|
|
|
// check if all elements of the edge are considered valid
|
2022-08-24 11:19:24 -04:00
|
|
|
bool Valid() const { return turn_path.Valid(); }
|
2017-07-06 11:09:24 -04:00
|
|
|
|
2017-07-11 08:22:28 -04:00
|
|
|
bool operator==(const TurnRestriction &other) const
|
|
|
|
{
|
|
|
|
if (is_only != other.is_only)
|
|
|
|
return false;
|
|
|
|
|
2022-08-24 11:19:24 -04:00
|
|
|
return turn_path == other.turn_path;
|
2017-07-11 08:22:28 -04:00
|
|
|
}
|
2022-08-24 11:19:24 -04:00
|
|
|
|
|
|
|
static std::string Name() { return "turn restriction"; };
|
2017-07-06 11:09:24 -04:00
|
|
|
};
|
2020-11-26 10:21:39 -05:00
|
|
|
} // namespace extractor
|
|
|
|
} // namespace osrm
|
2016-01-05 10:51:13 -05:00
|
|
|
|
2014-11-28 06:13:18 -05:00
|
|
|
#endif // RESTRICTION_HPP
|