Skip to content

Commit

Permalink
initial version of handling via-way turn restrictions (this is dirty)
Browse files Browse the repository at this point in the history
 - requires update of data structures
 - requires clean-up
 - requires optimisation
  • Loading branch information
Moritz Kobitzsch committed Jul 13, 2017
1 parent 3ae0590 commit 07459e9
Show file tree
Hide file tree
Showing 7 changed files with 402 additions and 77 deletions.
34 changes: 19 additions & 15 deletions features/car/restrictions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ Feature: Car - Turn restrictions
| from | to | route |
| a | h | abc,cde,efc,cgh,cgh |

@restriction
@restriction-way
Scenario: Car - prohibit turn
Given the node map
"""
Expand All @@ -563,9 +563,11 @@ Feature: Car - Turn restrictions
| restriction | ab | be | de | no_right_turn |

When I route I should get
| from | to | route |
| a | d | ab,be,de,de |
| a | f | ab,be,ef,ef |
| from | to | route | turns | locations |
| a | d | ab,be,ef,ef,de,de | depart,turn right,turn left,continue uturn,new name straight,arrive | a,b,e,f,e,d |
| a | f | ab,be,ef,ef | depart,turn right,turn left,arrive | a,b,e,f |
| c | d | bc,be,de,de | depart,turn left,turn right,arrive | c,b,e,d |
| c | f | bc,be,ef,ef | depart,turn left,turn left,arrive | c,b,e,f |

@restriction
Scenario: Car - allow only turn
Expand Down Expand Up @@ -593,9 +595,11 @@ Feature: Car - Turn restrictions
| restriction | ab | be | ef | only_left_on |

When I route I should get
| from | to | route |
| a | d | ab,be,de,de |

| from | to | route | turns | locations |
| a | d | ab,be,ef,ef,de,de | depart,turn right,turn left,continue uturn,new name straight,arrive | a,b,e,f,e,d |
| a | f | ab,be,ef,ef | depart,turn right,turn left,arrive | a,b,e,f |
| c | d | bc,be,de,de | depart,turn left,turn right,arrive | c,b,e,d |
| c | f | bc,be,ef,ef | depart,turn left,turn left,arrive | c,b,e,f |

@restriction
Scenario: Car - allow only turn
Expand Down Expand Up @@ -692,11 +696,11 @@ Feature: Car - Turn restrictions
| restriction | gf | fb,bc | cd | only_u_turn |

When I route I should get
| from | to | route |
| a | d | abcd,abcd |
| a | e | abcd,ce,ce |
| a | f | abcd,hfb,hfb |
| g | e | gf,hfb,abcd,ce,ce |
| g | d | gf,hfb,abcd,abcd |
| h | e | hfb,abcd,ce,ce |
| h | d | hfb,abcd,abcd |
| from | to | route | turns | locations |
| a | d | abcd,ce,ce,abcd,abcd | depart,turn left,continue uturn,turn left,arrive | a,c,e,c,d |
| a | e | abcd,ce,ce | depart,turn left,arrive | a,c,e |
| a | f | abcd,hfb,hfb | depart,turn right,arrive | a,b,f |
| g | e | gf,hfb,abcd,ce,ce | depart,turn right,turn right,turn left,arrive | g,f,b,c,e |
| g | d | gf,hfb,abcd,abcd | depart,turn right,turn right,arrive | g,f,b,d |
| h | e | hfb,abcd,ce,ce | depart,end of road right,turn left,arrive | h,b,c,e |
| h | d | hfb,abcd,abcd | depart,end of road right,arrive | h,b,d |
12 changes: 9 additions & 3 deletions include/extractor/edge_based_graph_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "extractor/profile_properties.hpp"
#include "extractor/query_node.hpp"
#include "extractor/restriction_map.hpp"
#include "extractor/way_restriction_map.hpp"

#include "util/concurrent_id_map.hpp"
#include "util/deallocating_vector.hpp"
Expand Down Expand Up @@ -91,7 +92,8 @@ class EdgeBasedGraphFactory
const std::string &turn_duration_penalties_filename,
const std::string &turn_penalties_index_filename,
const std::string &cnbg_ebg_mapping_path,
const RestrictionMap & restriction_map);
const RestrictionMap &restriction_map,
const WayRestrictionMap &way_restriction_map);

// The following get access functions destroy the content in the factory
void GetEdgeBasedEdges(util::DeallocatingVector<EdgeBasedEdge> &edges);
Expand Down Expand Up @@ -151,15 +153,16 @@ class EdgeBasedGraphFactory

unsigned RenumberEdges();

std::vector<NBGToEBG> GenerateEdgeExpandedNodes();
std::vector<NBGToEBG> GenerateEdgeExpandedNodes(const WayRestrictionMap &way_restriction_map);

void GenerateEdgeExpandedEdges(ScriptingEnvironment &scripting_environment,
const std::string &original_edge_data_filename,
const std::string &turn_lane_data_filename,
const std::string &turn_weight_penalties_filename,
const std::string &turn_duration_penalties_filename,
const std::string &turn_penalties_index_filename,
const RestrictionMap & restriction_map);
const RestrictionMap &restriction_map,
const WayRestrictionMap &way_restriction_map);

NBGToEBG InsertEdgeBasedNode(const NodeID u, const NodeID v);

Expand All @@ -170,6 +173,9 @@ class EdgeBasedGraphFactory
util::ConcurrentIDMap<util::guidance::BearingClass, BearingClassID> bearing_class_hash;
std::vector<BearingClassID> bearing_class_by_node_based_node;
util::ConcurrentIDMap<util::guidance::EntryClass, EntryClassID> entry_class_hash;

// a mapping from a restriction way to the duplicate node
std::vector<NodeID> edge_based_node_by_via_way;
};
} // namespace extractor
} // namespace osrm
Expand Down
12 changes: 12 additions & 0 deletions include/extractor/way_restriction_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,26 @@ class WayRestrictionMap
public:
WayRestrictionMap(const std::vector<TurnRestriction> &turn_restrictions);

bool IsViaWay(const NodeID from, const NodeID to) const;

// 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;

std::vector<std::pair<NodeID,NodeID>> ViaWays() const;

std::size_t Size() const;
std::size_t GetID(const NodeID from, const NodeID to) const;

TurnRestriction const& GetRestriction(std::size_t) 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;

boost::unordered_multimap<std::pair<NodeID,NodeID>, std::size_t> via_ways;

std::vector<TurnRestriction> restriction_data;
};

} // namespace extractor
Expand Down
3 changes: 3 additions & 0 deletions src/engine/guidance/post_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <limits>
#include <utility>

#include "util/debug.hpp"

using osrm::util::angularDeviation;
using osrm::extractor::guidance::getTurnDirection;
using osrm::extractor::guidance::hasRampType;
Expand Down Expand Up @@ -251,6 +253,7 @@ void closeOffRoundabout(const bool on_roundabout,
// that we come across.
std::vector<RouteStep> postProcess(std::vector<RouteStep> steps)
{
util::guidance::print(steps);
// the steps should always include the first/last step in form of a location
BOOST_ASSERT(steps.size() >= 2);
if (steps.size() == 2)
Expand Down
Loading

0 comments on commit 07459e9

Please sign in to comment.