This change unblocks the osrm-extract debug build, which is currently failing on a maneuver override assertion. The processing of maneuver overrides currently has three issues - It assumes the via node(s) can't be compressed (the failing assertion) - It can't handle via-paths containing incompressible nodes - It doesn't interop with turn restriction on the same path Turn restrictions and maneuver overrides both use the same from-via-to path representation. Therefore, we can fix these issues by consolidating their structures and reusing the path representation for turn restrictions, which already is robust to the above issues. This also simplifies some of the codebase by removing maneuver override specific path processing. There are ~100 maneuver overrides in the OSM database, so the impact on processing and routing will be minimal.
70 lines
1.7 KiB
C++
70 lines
1.7 KiB
C++
#ifndef RESTRICTION_HPP
|
|
#define RESTRICTION_HPP
|
|
|
|
#include "util/coordinate.hpp"
|
|
#include "util/opening_hours.hpp"
|
|
#include "util/typedefs.hpp"
|
|
|
|
#include "mapbox/variant.hpp"
|
|
#include "turn_path.hpp"
|
|
#include <limits>
|
|
|
|
namespace osrm
|
|
{
|
|
namespace extractor
|
|
{
|
|
|
|
// External (OSM) representation of restriction
|
|
struct InputTurnRestriction
|
|
{
|
|
InputTurnPath turn_path;
|
|
bool is_only;
|
|
std::vector<util::OpeningHours> condition;
|
|
};
|
|
|
|
// Internal (OSRM) representation of restriction
|
|
struct TurnRestriction
|
|
{
|
|
// The turn sequence that the restriction applies to.
|
|
TurnPath turn_path;
|
|
// Indicates if the restriction turn *must* or *must not* be taken.
|
|
bool is_only;
|
|
// We represent conditional and unconditional restrictions with the same structure.
|
|
// Unconditional restrictions will have empty conditions.
|
|
std::vector<util::OpeningHours> condition;
|
|
|
|
explicit TurnRestriction(const TurnPath &turn_path, bool is_only = false)
|
|
: turn_path(turn_path), is_only(is_only)
|
|
{
|
|
}
|
|
|
|
explicit TurnRestriction()
|
|
{
|
|
turn_path = {ViaNodePath{SPECIAL_NODEID, SPECIAL_NODEID, SPECIAL_NODEID}};
|
|
}
|
|
|
|
bool IsTurnRestricted(NodeID to) const
|
|
{
|
|
return is_only ? turn_path.To() != to : turn_path.To() == to;
|
|
}
|
|
|
|
bool IsUnconditional() const { return condition.empty(); }
|
|
|
|
// check if all elements of the edge are considered valid
|
|
bool Valid() const { return turn_path.Valid(); }
|
|
|
|
bool operator==(const TurnRestriction &other) const
|
|
{
|
|
if (is_only != other.is_only)
|
|
return false;
|
|
|
|
return turn_path == other.turn_path;
|
|
}
|
|
|
|
static std::string Name() { return "turn restriction"; };
|
|
};
|
|
} // namespace extractor
|
|
} // namespace osrm
|
|
|
|
#endif // RESTRICTION_HPP
|