Add support for multiple via-way restrictions (#5907)

Currently OSRM only supports turn restrictions with a single via-node or one
via-way. OSM allows for multiple via-ways to represent longer and more
complex restrictions.

This PR extends the use of duplicate nodes for representng via-way turn
restrictions to also support multi via-way restrictions. Effectively, this
increases the edge-based graph size by the number of edges in multi via-way
restrictions. However, given the low number of these restrictions it
has little effect on total graph size.

In addition, we add a new step in the extraction phase that constructs
a restriction graph to support more complex relationships between restrictions,
such as nested restrictions and overlapping restrictions.
This commit is contained in:
Michael Bell
2020-12-20 21:59:57 +00:00
committed by GitHub
parent eb1d399f3b
commit 5266ac1635
48 changed files with 3170 additions and 1406 deletions
+31
View File
@@ -0,0 +1,31 @@
#ifndef FOR_EACH_INDEXED_HPP
#define FOR_EACH_INDEXED_HPP
#include <iterator>
#include <numeric>
#include <utility>
namespace osrm
{
namespace util
{
template <typename ForwardIterator, typename Function>
void for_each_indexed(ForwardIterator first, ForwardIterator last, Function function)
{
for (size_t i = 0; first != last; ++first, ++i)
{
function(i, *first);
}
}
template <class ContainerT, typename Function>
void for_each_pair(ContainerT &container, Function function)
{
for_each_indexed(std::begin(container), std::end(container), function);
}
} // namespace util
} // namespace osrm
#endif /* FOR_EACH_INDEXED_HPP */
+2 -2
View File
@@ -61,8 +61,8 @@ void inplacePermutation(RandomAccessIterator begin,
template <typename IndexT>
std::vector<IndexT> orderingToPermutation(const std::vector<IndexT> &ordering)
{
std::vector<std::uint32_t> permutation(ordering.size());
for (auto index : util::irange<std::uint32_t>(0, ordering.size()))
std::vector<IndexT> permutation(ordering.size());
for (auto index : util::irange<IndexT>(0, ordering.size()))
permutation[ordering[index]] = index;
return permutation;
+1
View File
@@ -103,6 +103,7 @@ static const NodeID SPECIAL_NODEID = std::numeric_limits<NodeID>::max();
static const NodeID SPECIAL_SEGMENTID = std::numeric_limits<NodeID>::max() >> 1;
static const NodeID SPECIAL_GEOMETRYID = std::numeric_limits<NodeID>::max() >> 1;
static const EdgeID SPECIAL_EDGEID = std::numeric_limits<EdgeID>::max();
static const RestrictionID SPECIAL_RESTRICTIONID = std::numeric_limits<RestrictionID>::max();
static const NameID INVALID_NAMEID = std::numeric_limits<NameID>::max();
static const NameID EMPTY_NAMEID = 0;
static const unsigned INVALID_COMPONENTID = 0;