fix 2349
This commit is contained in:
parent
78acc6f215
commit
08248e3853
@ -148,6 +148,47 @@ Feature: Via points
|
|||||||
| a,d,c | abc,bd,bd,bd,abc,abc |
|
| a,d,c | abc,bd,bd,bd,abc,abc |
|
||||||
| c,d,a | abc,bd,bd,bd,abc,abc |
|
| c,d,a | abc,bd,bd,bd,abc,abc |
|
||||||
|
|
||||||
|
# See issue #2349
|
||||||
|
Scenario: Via point at a dead end with oneway
|
||||||
|
Given the node map
|
||||||
|
| a | b | c |
|
||||||
|
| | d | |
|
||||||
|
| | e | |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | oneway |
|
||||||
|
| abc | no |
|
||||||
|
| bd | no |
|
||||||
|
| ed | yes |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route |
|
||||||
|
| a,d,c | abc,bd,bd,bd,abc,abc |
|
||||||
|
| c,d,a | abc,bd,bd,bd,abc,abc |
|
||||||
|
|
||||||
|
# See issue #2349
|
||||||
|
@bug
|
||||||
|
Scenario: Via point at a dead end with oneway
|
||||||
|
Given the node map
|
||||||
|
| a | b | c |
|
||||||
|
| | d | |
|
||||||
|
| | e | g |
|
||||||
|
| | f | |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | oneway |
|
||||||
|
| abc | no |
|
||||||
|
| bd | no |
|
||||||
|
| ed | yes |
|
||||||
|
| dg | yes |
|
||||||
|
| ef | no |
|
||||||
|
| fg | yes |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route |
|
||||||
|
| a,d,c | abc,bd,bd,bd,abc,abc |
|
||||||
|
| c,d,a | abc,bd,bd,bd,abc,abc |
|
||||||
|
|
||||||
# See issue #1896
|
# See issue #1896
|
||||||
Scenario: Via point at a dead end with barrier
|
Scenario: Via point at a dead end with barrier
|
||||||
Given the profile "car"
|
Given the profile "car"
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include <boost/range/algorithm/count_if.hpp>
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
namespace extractor
|
namespace extractor
|
||||||
@ -54,6 +56,7 @@ Intersection IntersectionGenerator::getConnectedRoads(const NodeID from_node,
|
|||||||
const bool is_barrier_node = barrier_nodes.find(turn_node) != barrier_nodes.end();
|
const bool is_barrier_node = barrier_nodes.find(turn_node) != barrier_nodes.end();
|
||||||
|
|
||||||
bool has_uturn_edge = false;
|
bool has_uturn_edge = false;
|
||||||
|
bool uturn_could_be_valid = false;
|
||||||
for (const EdgeID onto_edge : node_based_graph.GetAdjacentEdgeRange(turn_node))
|
for (const EdgeID onto_edge : node_based_graph.GetAdjacentEdgeRange(turn_node))
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(onto_edge != SPECIAL_EDGEID);
|
BOOST_ASSERT(onto_edge != SPECIAL_EDGEID);
|
||||||
@ -74,6 +77,7 @@ Intersection IntersectionGenerator::getConnectedRoads(const NodeID from_node,
|
|||||||
auto angle = 0.;
|
auto angle = 0.;
|
||||||
if (from_node == to_node)
|
if (from_node == to_node)
|
||||||
{
|
{
|
||||||
|
uturn_could_be_valid = turn_is_valid;
|
||||||
if (turn_is_valid && !is_barrier_node)
|
if (turn_is_valid && !is_barrier_node)
|
||||||
{
|
{
|
||||||
// we only add u-turns for dead-end streets.
|
// we only add u-turns for dead-end streets.
|
||||||
@ -90,7 +94,7 @@ Intersection IntersectionGenerator::getConnectedRoads(const NodeID from_node,
|
|||||||
++number_of_emmiting_bidirectional_edges;
|
++number_of_emmiting_bidirectional_edges;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// is a dead-end
|
// is a dead-end, only possible road is to go back
|
||||||
turn_is_valid = number_of_emmiting_bidirectional_edges <= 1;
|
turn_is_valid = number_of_emmiting_bidirectional_edges <= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,7 +110,7 @@ Intersection IntersectionGenerator::getConnectedRoads(const NodeID from_node,
|
|||||||
turn_node, to_node, onto_edge, !INVERT, compressed_edge_container, node_info_list);
|
turn_node, to_node, onto_edge, !INVERT, compressed_edge_container, node_info_list);
|
||||||
angle = util::coordinate_calculation::computeAngle(
|
angle = util::coordinate_calculation::computeAngle(
|
||||||
first_coordinate, node_info_list[turn_node], third_coordinate);
|
first_coordinate, node_info_list[turn_node], third_coordinate);
|
||||||
if (angle < std::numeric_limits<double>::epsilon())
|
if (std::abs(angle) < std::numeric_limits<double>::epsilon())
|
||||||
has_uturn_edge = true;
|
has_uturn_edge = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,8 +120,7 @@ Intersection IntersectionGenerator::getConnectedRoads(const NodeID from_node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We hit the case of a street leading into nothing-ness. Since the code here assumes that this
|
// We hit the case of a street leading into nothing-ness. Since the code here assumes that this
|
||||||
// will
|
// will never happen we add an artificial invalid uturn in this case.
|
||||||
// never happen we add an artificial invalid uturn in this case.
|
|
||||||
if (!has_uturn_edge)
|
if (!has_uturn_edge)
|
||||||
{
|
{
|
||||||
intersection.push_back(
|
intersection.push_back(
|
||||||
@ -132,6 +135,11 @@ Intersection IntersectionGenerator::getConnectedRoads(const NodeID from_node,
|
|||||||
BOOST_ASSERT(intersection[0].turn.angle >= 0. &&
|
BOOST_ASSERT(intersection[0].turn.angle >= 0. &&
|
||||||
intersection[0].turn.angle < std::numeric_limits<double>::epsilon());
|
intersection[0].turn.angle < std::numeric_limits<double>::epsilon());
|
||||||
|
|
||||||
|
const auto valid_count =
|
||||||
|
boost::count_if(intersection, [](const ConnectedRoad &road) { return road.entry_allowed; });
|
||||||
|
if (0 == valid_count && uturn_could_be_valid)
|
||||||
|
intersection[0].entry_allowed = true;
|
||||||
|
|
||||||
return mergeSegregatedRoads(std::move(intersection));
|
return mergeSegregatedRoads(std::move(intersection));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +216,7 @@ Intersection IntersectionGenerator::mergeSegregatedRoads(Intersection intersecti
|
|||||||
if (intersection.size() <= 1)
|
if (intersection.size() <= 1)
|
||||||
return intersection;
|
return intersection;
|
||||||
|
|
||||||
const bool is_connected_to_roundabout = [this,&intersection]() {
|
const bool is_connected_to_roundabout = [this, &intersection]() {
|
||||||
for (const auto &road : intersection)
|
for (const auto &road : intersection)
|
||||||
{
|
{
|
||||||
if (node_based_graph.GetEdgeData(road.turn.eid).roundabout)
|
if (node_based_graph.GetEdgeData(road.turn.eid).roundabout)
|
||||||
|
Loading…
Reference in New Issue
Block a user