-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add data structure to allow identification of via-way turns during cr…
…eation of edge-based-graph
- Loading branch information
Moritz Kobitzsch
committed
Jul 12, 2017
1 parent
c5e4c66
commit 3ae0590
Showing
5 changed files
with
112 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#ifndef OSRM_EXTRACTOR_WAY_RESTRICTION_MAP_HPP_ | ||
#define OSRM_EXTRACTOR_WAY_RESTRICTION_MAP_HPP_ | ||
|
||
#include <utility> | ||
#include <vector> | ||
|
||
// to access the turn restrictions | ||
#include <boost/unordered_map.hpp> | ||
|
||
#include "extractor/restriction.hpp" | ||
#include "util/typedefs.hpp" | ||
|
||
// Given the compressed representation of via-way turn restrictions, we provide a fast access into | ||
// the restrictions to indicate which turns may be restricted due to a way in between | ||
namespace osrm | ||
{ | ||
namespace extractor | ||
{ | ||
|
||
class WayRestrictionMap | ||
{ | ||
public: | ||
WayRestrictionMap(const std::vector<TurnRestriction> &turn_restrictions); | ||
|
||
// check if an edge between two nodes is a restricted turn | ||
bool IsStart(const NodeID from, const NodeID to) const; | ||
bool IsEnd(const NodeID from, const NodeID to) const; | ||
|
||
private: | ||
// acces to the turn restrictions based on the via way they use | ||
boost::unordered_multimap<std::pair<NodeID, NodeID>, std::size_t> restriction_starts; | ||
boost::unordered_multimap<std::pair<NodeID, NodeID>, std::size_t> restriction_ends; | ||
}; | ||
|
||
} // namespace extractor | ||
} // namespace osrm | ||
|
||
#endif // OSRM_EXTRACTOR_WAY_RESTRICTION_MAP_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "extractor/way_restriction_map.hpp" | ||
|
||
namespace osrm | ||
{ | ||
namespace extractor | ||
{ | ||
|
||
WayRestrictionMap::WayRestrictionMap(const std::vector<TurnRestriction> &turn_restrictions) | ||
{ | ||
// map all way restrictions into access containers | ||
const auto prepare_way_restriction = [this](const auto &restriction) { | ||
if (restriction.Type() != RestrictionType::WAY_RESTRICTION) | ||
return; | ||
|
||
const auto &way = restriction.AsWayRestriction(); | ||
restriction_starts.insert( | ||
std::make_pair(std::make_pair(way.in_restriction.via, way.in_restriction.to), 0)); | ||
restriction_ends.insert( | ||
std::make_pair(std::make_pair(way.out_restriction.from, way.out_restriction.via), 0)); | ||
}; | ||
std::for_each(turn_restrictions.begin(), turn_restrictions.end(), prepare_way_restriction); | ||
} | ||
|
||
// check if an edge between two nodes is a restricted turn | ||
bool WayRestrictionMap::IsStart(const NodeID from, const NodeID to) const | ||
{ | ||
return restriction_starts.count(std::make_pair(from, to)) > 0; | ||
} | ||
bool WayRestrictionMap::IsEnd(const NodeID from, const NodeID to) const | ||
{ | ||
return restriction_ends.count(std::make_pair(from, to)) > 0; | ||
} | ||
|
||
} // namespace extractor | ||
} // namespace osrm |