osrm-backend/include/extractor/restriction.hpp

114 lines
3.0 KiB
C++
Raw Normal View History

#ifndef RESTRICTION_HPP
#define RESTRICTION_HPP
2012-08-27 11:40:59 -04:00
2016-01-02 11:13:44 -05:00
#include "util/typedefs.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
{
struct TurnRestriction
{
2016-05-27 15:05:04 -04:00
union WayOrNode {
OSMNodeID_weak node;
OSMEdgeID_weak way;
2014-08-26 11:20:40 -04:00
};
WayOrNode via;
WayOrNode from;
WayOrNode to;
struct Bits
{ // mostly unused
2013-08-14 05:59:46 -04:00
Bits()
2014-08-26 11:20:40 -04:00
: is_only(false), uses_via_way(false), unused2(false), unused3(false), unused4(false),
unused5(false), unused6(false), unused7(false)
{
}
2014-08-26 11:20:40 -04:00
bool is_only : 1;
bool uses_via_way : 1;
bool unused2 : 1;
bool unused3 : 1;
bool unused4 : 1;
bool unused5 : 1;
bool unused6 : 1;
bool unused7 : 1;
2012-08-27 11:40:59 -04:00
} flags;
2014-08-26 11:20:40 -04:00
explicit TurnRestriction(NodeID node)
2013-08-14 05:59:46 -04:00
{
2014-08-26 11:20:40 -04:00
via.node = node;
from.node = SPECIAL_NODEID;
to.node = SPECIAL_NODEID;
2013-08-14 05:59:46 -04:00
}
2012-08-27 11:40:59 -04:00
2014-08-26 11:20:40 -04:00
explicit TurnRestriction(const bool is_only = false)
{
2014-08-26 11:20:40 -04:00
via.node = SPECIAL_NODEID;
from.node = SPECIAL_NODEID;
to.node = SPECIAL_NODEID;
flags.is_only = is_only;
2012-08-27 11:40:59 -04:00
}
};
/**
* This is just a wrapper around TurnRestriction used in the extractor.
2016-01-05 06:04:04 -05:00
*
* Could be merged with TurnRestriction. For now the type-destiction makes sense
* as the format in which the restriction is presented in the extractor and in the
* preprocessing is different. (see restriction_parser.cpp)
*/
struct InputRestrictionContainer
{
TurnRestriction restriction;
InputRestrictionContainer(EdgeID fromWay, EdgeID toWay, EdgeID vw)
{
restriction.from.way = fromWay;
restriction.to.way = toWay;
restriction.via.way = vw;
}
explicit InputRestrictionContainer(bool is_only = false)
{
restriction.from.way = SPECIAL_EDGEID;
restriction.to.way = SPECIAL_EDGEID;
restriction.via.node = SPECIAL_NODEID;
restriction.flags.is_only = is_only;
}
static InputRestrictionContainer min_value() { return InputRestrictionContainer(0, 0, 0); }
static InputRestrictionContainer max_value()
{
return InputRestrictionContainer(SPECIAL_EDGEID, SPECIAL_EDGEID, SPECIAL_EDGEID);
}
};
struct CmpRestrictionContainerByFrom
{
2015-03-23 12:06:10 -04:00
using value_type = InputRestrictionContainer;
bool operator()(const InputRestrictionContainer &a, const InputRestrictionContainer &b) const
{
return a.restriction.from.way < b.restriction.from.way;
}
2015-01-16 05:27:46 -05:00
value_type max_value() const { return InputRestrictionContainer::max_value(); }
value_type min_value() const { return InputRestrictionContainer::min_value(); }
};
struct CmpRestrictionContainerByTo
{
2015-03-23 12:06:10 -04:00
using value_type = InputRestrictionContainer;
bool operator()(const InputRestrictionContainer &a, const InputRestrictionContainer &b) const
{
return a.restriction.to.way < b.restriction.to.way;
}
value_type max_value() const { return InputRestrictionContainer::max_value(); }
value_type min_value() const { return InputRestrictionContainer::min_value(); }
};
2016-01-05 10:51:13 -05:00
}
}
#endif // RESTRICTION_HPP