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
|
|
|
|
|
|
|
#include <limits>
|
2012-08-27 11:40:59 -04:00
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace extractor
|
|
|
|
{
|
|
|
|
|
2014-05-07 11:25:35 -04:00
|
|
|
struct TurnRestriction
|
|
|
|
{
|
2016-05-27 15:05:04 -04:00
|
|
|
union WayOrNode {
|
2015-11-24 19:33:19 -05:00
|
|
|
OSMNodeID_weak node;
|
|
|
|
OSMEdgeID_weak way;
|
2014-08-26 11:20:40 -04:00
|
|
|
};
|
|
|
|
WayOrNode via;
|
|
|
|
WayOrNode from;
|
|
|
|
WayOrNode to;
|
|
|
|
|
2017-05-11 06:13:52 -04:00
|
|
|
std::vector<util::OpeningHours> condition;
|
|
|
|
|
2014-05-07 11:25:35 -04:00
|
|
|
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),
|
2014-05-07 11:25:35 -04:00
|
|
|
unused5(false), unused6(false), unused7(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-08-26 11:20:40 -04:00
|
|
|
bool is_only : 1;
|
|
|
|
bool uses_via_way : 1;
|
2014-05-07 11:25:35 -04:00
|
|
|
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-05-07 11:25:35 -04:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-04-10 09:40:49 -04:00
|
|
|
/**
|
|
|
|
* This is just a wrapper around TurnRestriction used in the extractor.
|
2016-01-05 06:04:04 -05:00
|
|
|
*
|
2015-04-10 09:40:49 -04: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)
|
|
|
|
*/
|
2014-08-26 11:35:31 -04:00
|
|
|
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;
|
2015-02-19 03:19:51 -05:00
|
|
|
bool operator()(const InputRestrictionContainer &a, const InputRestrictionContainer &b) const
|
2014-08-26 11:35:31 -04:00
|
|
|
{
|
|
|
|
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(); }
|
2014-08-26 11:35:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CmpRestrictionContainerByTo
|
|
|
|
{
|
2015-03-23 12:06:10 -04:00
|
|
|
using value_type = InputRestrictionContainer;
|
2015-02-19 03:19:51 -05:00
|
|
|
bool operator()(const InputRestrictionContainer &a, const InputRestrictionContainer &b) const
|
2014-08-26 11:35:31 -04:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-28 06:13:18 -05:00
|
|
|
#endif // RESTRICTION_HPP
|