fixes issue #1019:
- fix ignored turn restriction on chains of degree-2 nodes - add a cucumber test to test for potential regressions
This commit is contained in:
parent
75a2d4d00a
commit
d028a30f87
@ -305,6 +305,12 @@ void EdgeBasedGraphFactory::CompressGeometry()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if v is a via node for a turn restriction, i.e. a 'directed' barrier node
|
||||||
|
if (m_restriction_map->IsNodeAViaNode(v))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const bool reverse_edge_order =
|
const bool reverse_edge_order =
|
||||||
!(m_node_based_graph->GetEdgeData(m_node_based_graph->BeginEdges(v)).forward);
|
!(m_node_based_graph->GetEdgeData(m_node_based_graph->BeginEdges(v)).forward);
|
||||||
const EdgeID forward_e2 = m_node_based_graph->BeginEdges(v) + reverse_edge_order;
|
const EdgeID forward_e2 = m_node_based_graph->BeginEdges(v) + reverse_edge_order;
|
||||||
|
@ -1,6 +1,40 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2013, Project OSRM, Dennis Luxen, others
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright notice, this list
|
||||||
|
of conditions and the following disclaimer.
|
||||||
|
Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
#include "RestrictionMap.h"
|
#include "RestrictionMap.h"
|
||||||
#include "NodeBasedGraph.h"
|
#include "NodeBasedGraph.h"
|
||||||
|
|
||||||
|
#include "../Util/SimpleLogger.h"
|
||||||
|
|
||||||
|
bool RestrictionMap::IsNodeAViaNode(const NodeID node) const
|
||||||
|
{
|
||||||
|
return m_no_turn_via_node_set.find(node) != m_no_turn_via_node_set.end();
|
||||||
|
}
|
||||||
|
|
||||||
RestrictionMap::RestrictionMap(const std::shared_ptr<NodeBasedDynamicGraph> &graph,
|
RestrictionMap::RestrictionMap(const std::shared_ptr<NodeBasedDynamicGraph> &graph,
|
||||||
const std::vector<TurnRestriction> &input_restrictions_list)
|
const std::vector<TurnRestriction> &input_restrictions_list)
|
||||||
: m_count(0), m_graph(graph)
|
: m_count(0), m_graph(graph)
|
||||||
@ -9,8 +43,14 @@ RestrictionMap::RestrictionMap(const std::shared_ptr<NodeBasedDynamicGraph> &gra
|
|||||||
// and all end-nodes
|
// and all end-nodes
|
||||||
for (auto &restriction : input_restrictions_list)
|
for (auto &restriction : input_restrictions_list)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
m_no_turn_via_node_set.insert(restriction.viaNode);
|
||||||
|
|
||||||
std::pair<NodeID, NodeID> restriction_source =
|
std::pair<NodeID, NodeID> restriction_source =
|
||||||
std::make_pair(restriction.fromNode, restriction.viaNode);
|
std::make_pair(restriction.fromNode, restriction.viaNode);
|
||||||
|
|
||||||
|
SimpleLogger().Write(logDEBUG) << "restr from: " << restriction.fromNode << ", v: " << restriction.viaNode << ", to: " << restriction.toNode << ", is_only_: " << (restriction.flags.isOnly ? "y" : "n");
|
||||||
|
|
||||||
unsigned index;
|
unsigned index;
|
||||||
auto restriction_iter = m_restriction_map.find(restriction_source);
|
auto restriction_iter = m_restriction_map.find(restriction_source);
|
||||||
if (restriction_iter == m_restriction_map.end())
|
if (restriction_iter == m_restriction_map.end())
|
||||||
@ -70,8 +110,11 @@ void RestrictionMap::FixupArrivingTurnRestriction(const NodeID u, const NodeID v
|
|||||||
const std::pair<NodeID, NodeID> restr_start = std::make_pair(x, u);
|
const std::pair<NodeID, NodeID> restr_start = std::make_pair(x, u);
|
||||||
auto restriction_iterator = m_restriction_map.find(restr_start);
|
auto restriction_iterator = m_restriction_map.find(restr_start);
|
||||||
if (restriction_iterator == m_restriction_map.end())
|
if (restriction_iterator == m_restriction_map.end())
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleLogger().Write(logDEBUG) << "fixing arriving instruction at turn <" << u << "," << v << "," << w << ">";
|
||||||
const unsigned index = restriction_iterator->second;
|
const unsigned index = restriction_iterator->second;
|
||||||
auto &bucket = m_restriction_bucket_list.at(index);
|
auto &bucket = m_restriction_bucket_list.at(index);
|
||||||
for (RestrictionTarget &restriction_target : bucket)
|
for (RestrictionTarget &restriction_target : bucket)
|
||||||
@ -98,6 +141,7 @@ void RestrictionMap::FixupStartingTurnRestriction(const NodeID u, const NodeID v
|
|||||||
auto restriction_iterator = m_restriction_map.find(old_start);
|
auto restriction_iterator = m_restriction_map.find(old_start);
|
||||||
if (restriction_iterator != m_restriction_map.end())
|
if (restriction_iterator != m_restriction_map.end())
|
||||||
{
|
{
|
||||||
|
SimpleLogger().Write(logDEBUG) << "fixing restr start at turn <" << u << "," << v << "," << w << ">";
|
||||||
const unsigned index = restriction_iterator->second;
|
const unsigned index = restriction_iterator->second;
|
||||||
// remove old restriction start (v,w)
|
// remove old restriction start (v,w)
|
||||||
m_restriction_map.erase(restriction_iterator);
|
m_restriction_map.erase(restriction_iterator);
|
||||||
@ -141,6 +185,7 @@ NodeID RestrictionMap::CheckForEmanatingIsOnlyTurn(const NodeID u, const NodeID
|
|||||||
*/
|
*/
|
||||||
bool RestrictionMap::CheckIfTurnIsRestricted(const NodeID u, const NodeID v, const NodeID w) const
|
bool RestrictionMap::CheckIfTurnIsRestricted(const NodeID u, const NodeID v, const NodeID w) const
|
||||||
{
|
{
|
||||||
|
// SimpleLogger().Write(logDEBUG) << "checking turn <" << u << "," << v << "," << w << ">";
|
||||||
BOOST_ASSERT(u != std::numeric_limits<unsigned>::max());
|
BOOST_ASSERT(u != std::numeric_limits<unsigned>::max());
|
||||||
BOOST_ASSERT(v != std::numeric_limits<unsigned>::max());
|
BOOST_ASSERT(v != std::numeric_limits<unsigned>::max());
|
||||||
BOOST_ASSERT(w != std::numeric_limits<unsigned>::max());
|
BOOST_ASSERT(w != std::numeric_limits<unsigned>::max());
|
||||||
|
@ -36,11 +36,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "NodeBasedGraph.h"
|
#include "NodeBasedGraph.h"
|
||||||
|
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
/*!
|
|
||||||
* Makee it efficent to look up if an edge is the start + via node of a TurnRestriction.
|
// Make it efficent to look up if an edge is the start + via node of a TurnRestriction
|
||||||
* Is needed by EdgeBasedGraphFactory.
|
// EdgeBasedEdgeFactory decides by it if edges are inserted or geometry is compressed
|
||||||
*/
|
|
||||||
class RestrictionMap
|
class RestrictionMap
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -51,7 +51,7 @@ class RestrictionMap
|
|||||||
void FixupStartingTurnRestriction(const NodeID u, const NodeID v, const NodeID w);
|
void FixupStartingTurnRestriction(const NodeID u, const NodeID v, const NodeID w);
|
||||||
NodeID CheckForEmanatingIsOnlyTurn(const NodeID u, const NodeID v) const;
|
NodeID CheckForEmanatingIsOnlyTurn(const NodeID u, const NodeID v) const;
|
||||||
bool CheckIfTurnIsRestricted(const NodeID u, const NodeID v, const NodeID w) const;
|
bool CheckIfTurnIsRestricted(const NodeID u, const NodeID v, const NodeID w) const;
|
||||||
|
bool IsNodeAViaNode(const NodeID node) const;
|
||||||
unsigned size() { return m_count; }
|
unsigned size() { return m_count; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -66,6 +66,7 @@ class RestrictionMap
|
|||||||
std::vector<EmanatingRestrictionsVector> m_restriction_bucket_list;
|
std::vector<EmanatingRestrictionsVector> m_restriction_bucket_list;
|
||||||
//! maps (start, via) -> bucket index
|
//! maps (start, via) -> bucket index
|
||||||
boost::unordered_map<RestrictionSource, unsigned> m_restriction_map;
|
boost::unordered_map<RestrictionSource, unsigned> m_restriction_map;
|
||||||
|
std::unordered_set<NodeID> m_no_turn_via_node_set;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,6 +30,35 @@ Feature: Car - Turn restrictions
|
|||||||
| s | n | sj,nj |
|
| s | n | sj,nj |
|
||||||
| s | e | sj,ej |
|
| s | e | sj,ej |
|
||||||
|
|
||||||
|
@no_turning
|
||||||
|
Scenario: Car - No straight on
|
||||||
|
Given the node map
|
||||||
|
| a | b | j | d | e |
|
||||||
|
| v | | | | z |
|
||||||
|
| | w | x | y | |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | oneway |
|
||||||
|
| ab | no |
|
||||||
|
| bj | no |
|
||||||
|
| jd | no |
|
||||||
|
| de | no |
|
||||||
|
| ej | no |
|
||||||
|
| av | yes |
|
||||||
|
| vw | yes |
|
||||||
|
| wx | yes |
|
||||||
|
| xy | yes |
|
||||||
|
| yz | yes |
|
||||||
|
| ze | yes |
|
||||||
|
|
||||||
|
And the relations
|
||||||
|
| type | way:from | way:to | node:via | restriction |
|
||||||
|
| restriction | bj | jd | j | no_straight_on |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| from | to | route |
|
||||||
|
| a | e | av,vw,wx,xy,yz,ze |
|
||||||
|
|
||||||
@no_turning
|
@no_turning
|
||||||
Scenario: Car - No right turn
|
Scenario: Car - No right turn
|
||||||
Given the node map
|
Given the node map
|
||||||
@ -248,4 +277,4 @@ Feature: Car - Turn restrictions
|
|||||||
When I route I should get
|
When I route I should get
|
||||||
| from | to | route |
|
| from | to | route |
|
||||||
| s | a | sj,aj |
|
| s | a | sj,aj |
|
||||||
| s | b | sj,bj |
|
| s | b | sj,bj |
|
||||||
|
Loading…
Reference in New Issue
Block a user