Compare commits

...

26 Commits

Author SHA1 Message Date
Moritz Kobitzsch
7aaf60d05f set correct version 2016-08-31 14:08:48 +02:00
Moritz Kobitzsch
97b2c053eb mark broken case todo 2016-08-31 11:09:34 +02:00
Moritz Kobitzsch
47957f3407 Revert "mark broken case todo"
This reverts commit 872054da00.
2016-08-31 11:09:02 +02:00
Moritz Kobitzsch
2e7149c9d7 Revert "TODO -> todo"
This reverts commit 5ae5fd8d81.
2016-08-31 11:08:39 +02:00
Moritz Kobitzsch
5ae5fd8d81 TODO -> todo 2016-08-31 11:05:38 +02:00
Moritz Kobitzsch
872054da00 mark broken case todo 2016-08-31 10:56:56 +02:00
Michael Krasnyk
fa80197df0 Fix ambiguity in edges by using names lexicographical order 2016-08-31 08:47:22 +02:00
Moritz Kobitzsch
b4c78f9c38 adjusting u-turn handling in lane matching to fully fix 2706 2016-08-30 19:25:54 +02:00
Moritz Kobitzsch
1f4425df74 Prepare Release of 5.3.3 2016-08-30 18:56:26 +02:00
Patrick Niklaus
4e9f5b61ac Always overwrite m_is_core_node on data swap
This fixes a seg fault when swapping between core/no core datasets
2016-08-30 18:52:50 +02:00
Patrick Niklaus
4638b32be4 Set parent nodes of core entry nodes not to themselves 2016-08-30 18:52:36 +02:00
Moritz Kobitzsch
400dd42780 fix segmentation fault for via-routes with invalid intermediate segments 2016-08-26 12:11:09 +02:00
Moritz Kobitzsch
1a22e7da2b update version to 5.3.2 2016-08-09 12:06:47 +02:00
Moritz Kobitzsch
40a86d43cd fix 2754 2016-08-09 12:04:26 +02:00
Moritz Kobitzsch
68d20c6ccc fix removal of multiple geometries for first vertex 2016-08-09 12:03:29 +02:00
Daniel J. Hofmann
fe491bf92c Allow Travis builds for this branch 2016-08-04 15:22:51 +02:00
Daniel J. Hofmann
7b432b34bb Update CMakeLists.txt version to 5.3.1 2016-08-04 15:12:48 +02:00
Daniel J. Hofmann
6983cd0de2 Adapt Changelog for v5.3.1 2016-08-04 15:06:44 +02:00
Daniel J. Hofmann
fe8177077c Disable our added failing cucumber tests for now 2016-08-04 14:58:06 +02:00
Daniel J. Hofmann
5f339f4ed6 Fall back to generic match finding if not a reverse-lane 2016-08-04 14:57:59 +02:00
Daniel J. Hofmann
3c0b52c637 Skip handling none values for our edge cases for now..
Conflicts:
	src/extractor/guidance/turn_lane_augmentation.cpp
2016-08-04 14:57:53 +02:00
Daniel Patterson
877fc5b42c Add a minimal version of the failing test case. 2016-08-04 14:57:47 +02:00
Daniel J. Hofmann
e28785e399 Reproducing breaking intersection in cucumber scenario
Conflicts:
	src/extractor/guidance/turn_lane_augmentation.cpp
2016-08-04 14:57:39 +02:00
Daniel J. Hofmann
2c4a54ce05 Try to come up with a small test case 2016-08-04 14:57:32 +02:00
Michael Krasnyk
a8afc74590
Fix #2706 by using correct fallback u-turn
Regression is due to a combination of 08248e3853
and http://www.openstreetmap.org/changeset/40938983
where in ways http://www.openstreetmap.org/way/27292481
and http://www.openstreetmap.org/way/432488408
nodes
4315134884 (part of way 432488408)
4315134891 (part of way 432488408)
4315134886 (part of way 432488408)
form a u-turn that has index 0 after sorting and used as an allowed one
with a reversed edge.
A u-turn that corresponds to the condition uturn_could_be_valid == true has index 1
and ignored.
2016-07-31 22:46:10 +02:00
Daniel J. Hofmann
d195eee7c4
Lane Handling for multiple indications per lane as in left;left|, fixes #2694
Before we asserted on unique lane indications per lane. Turns out the
OSM data contains lane strings such as:

    left;left|right

Which represents two lanes as in:

    <<     >
     ||    |

The two left indications _on a single lane_ look like data issue.
And we can't represent this with our enum-approach at the moment.

We don't want to crash there, so silently swallow this and
generate a single left|right for it.
2016-07-26 12:18:15 +02:00
16 changed files with 427 additions and 90 deletions

View File

@ -13,6 +13,7 @@ notifications:
branches:
only:
- master
- "5.3"
cache:
ccache: true

View File

@ -1,3 +1,22 @@
# 5.3.3
Changes from 5.3.2
- Bugfixes
- Fixed an issue that would result in segfaults for viaroutes with an invalid intermediate segment when u-turns were allowed at the via-location
- Fixed an issue that could result in segfaults when querying roads that could require looping back to the start of a way while using a core factor
- Fixed an issue that could break some testcases when using a core factor
- Fixed an issue with parallel edges that could result in weird routes
# 5.3.2
Changes from 5.3.1
- Bugfixes
- fixed a bug that occurred when trimming very short segments at the begin/end of a route (less than 1 meter)
# 5.3.1
Changes from 5.3.1
- Bugfixes:
- Disabled broken lane handling for complex uturn/oneway combinations for now (190 intersections affected on the planet)
- Fixed a bug with overlaping geometries, which broke OSRM on recent Egypt extracts with data-modelling issues
# 5.3.0
Changes from 5.3.0-rc.3
- Guidance

View File

@ -10,7 +10,7 @@ endif()
project(OSRM C CXX)
set(OSRM_VERSION_MAJOR 5)
set(OSRM_VERSION_MINOR 3)
set(OSRM_VERSION_PATCH 0)
set(OSRM_VERSION_PATCH 3)
# these two functions build up custom variables:
# OSRM_INCLUDE_PATHS and OSRM_DEFINES

View File

@ -0,0 +1,52 @@
@routing @guidance @post-processing
Feature: General Post-Processing related features
Background:
Given the profile "car"
Given a grid size of 0.1 meters
# this testcase used to crash geometry generation (at that time handled during intersection generation)
Scenario: Regression Test 2754
Given the node map
| a | b | c | d | e | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | f | g | h | i | j |
And the ways
| nodes |
| abcde |
| ef |
| fghij |
When I route I should get
| waypoints | route |
| a,j | ef,ef |

View File

@ -724,8 +724,8 @@ Feature: Turn Lane Guidance
And the ways
| nodes | name | highway | turn:lanes:forward |
| ab | road | primary | through,right |
| bc | road | primary | through,right |
| ab | road | primary | through;right |
| bc | road | primary | through;right |
| cd | road | primary | |
| xa | road | primary | |
| be | turn | primary | |
@ -736,4 +736,134 @@ Feature: Turn Lane Guidance
| x,d | road,road | depart,arrive | , |
Scenario: Lane Parsing Issue #2694
Given the node map
| | c |
| a | b |
| | d |
And the ways
| nodes | highway | turn:lanes:forward |
| ab | primary | left;left\|right |
| bc | primary | |
| bd | primary | |
When I route I should get
| waypoints | route | turns | lanes |
| a,c | ab,bc,bc | depart,turn left,arrive | ,left:true right:false, |
# http://www.openstreetmap.org/#map=19/47.97685/7.82933&layers=D
@bug @todo
Scenario: Lane Parsing Issue #2706: None Assignments I
Given the node map
| | f | | | j | |
| | | | | | |
| a | b | c | | d | e |
| | | | | | |
| | | | | i | |
| | g | | | h | |
And the nodes
| node | highway |
| a | traffic_signals |
| i | traffic_signals |
And the ways
| nodes | highway | name | oneway | turn:lanes:forward |
| ab | secondary | Wiesentalstr | | through;left\|right |
| bc | secondary | Wiesentalstr | | none\|left;through |
| cd | secondary | Wiesentalstr | | none\|left;through |
| de | residential | Wippertstr | | |
| fb | secondary | Merzhauser Str | yes | through\|through\|right |
| bg | secondary | Merzhauser Str | yes | |
| hi | secondary | Merzhauser Str | yes | left;reverse\|none\|none |
| ic | secondary_link | Merzhauser Str | yes | |
| id | secondary | Merzhauser Str | yes | through;right\|none |
| dj | secondary | Merzhauser Str | yes | |
And the relations
| type | way:from | way:to | node:via | restriction |
| restriction | fb | fb | b | no_left_turn |
| restriction | ic | cb | c | only_left_turn |
| restriction | id | dc | d | no_left_turn |
When I route I should get
| waypoints | route | turns | lanes |
| h,a ||||
# Note: at the moment we don't care about routes, we care about the extract process triggering assertions
# https://www.openstreetmap.org/#map=19/47.99257/7.83276&layers=D
@bug @todo
Scenario: Lane Parsing Issue #2706: None Assignments II
Given the node map
| | k | l | |
| j | a | b | f |
| i | c | d | e |
| | h | g | |
And the ways
| nodes | highway | name | oneway | turn:lanes |
| ka | secondary | Eschholzstr | yes | left;reverse\|through\|through\|none |
| kj | unclassified | kj | yes | |
| ac | secondary | Eschholzstr | yes | left;reverse\|none\|none\|none |
| ch | secondary | Eschholzstr | yes | |
| gd | secondary | Eschholzstr | yes | left;reverse\|through\|through\|none |
| db | secondary | Eschholzstr | yes | left;reverse\|through\|through\|none |
| bl | secondary | Eschholzstr | yes | |
| fb | residential | Haslacher Str | yes | left;reverse\|left;through\|right |
| ba | secondary_link | Haslacher Str | yes | left;reverse\|left;through |
| aj | unclassified | Haslacher Str | yes | |
| ic | unclassified | Haslacher Str | yes | left;reverse\|left\|through |
| cd | secondary_link | Haslacher Str | yes | left;reverse\|left\|through |
| de | residential | Haslacher Str | yes | |
And the relations
| type | way:from | way:to | node:via | restriction |
| restriction | ka | ac | a | only_straight_on |
| restriction | ic | cd | c | only_straight_on |
| restriction | gd | db | d | only_straight_on |
When I route I should get
| waypoints | route | turns | lanes |
| i,e ||||
# Note: at the moment we don't care about routes, we care about the extract process triggering assertions
@bug @todo
Scenario: Lane Parsing Issue #2706: None Assignments III - Minimal reproduction recipe
Given the node map
| | | l | |
| | a | b | |
| | | d | |
| | | | |
And the ways
| nodes | highway | name | oneway | turn:lanes |
| db | secondary | Eschholzstr | yes | left;reverse\|through\|through\|none |
| bl | secondary | Eschholzstr | yes | |
| ba | secondary_link | Haslacher Str | yes | |
When I route I should get
| waypoints | route | turns | lanes |
| d,a ||||
# Note: at the moment we don't care about routes, we care about the extract process triggering assertions
@reverse @2730
Scenario: Reverse on the right
Given the node map
| a | | | c | |
| | | | b | d |
| f | | | e | |
And the ways
| nodes | highway | name | turn:lanes:forward | oneway |
| ab | primary | in | left\|through\|right;reverse | yes |
| bc | primary | left | | no |
| bd | primary | through | | no |
| be | primary | right | | no |
| bf | primary | in | | yes |
When I route I should get
| waypoints | route | turns | lanes |
| a,c | in,left,left | depart,turn left,arrive | ,left:true straight:false right;uturn:false, |
| a,d | in,through,through | depart,new name straight,arrive | ,left:false straight:true right;uturn:false, |
| a,e | in,right,right | depart,turn right,arrive | ,left:false straight:false right;uturn:true, |

View File

@ -262,3 +262,38 @@ Feature: Via points
| 3,2,1 | ab,bc,cd,da,ab,ab,ab,bc,cd,da,ab,ab | 3000m +-1 |
| 6,5,4 | bc,cd,da,ab,bc,bc,bc,cd,da,ab,bc,bc | 3000m +-1 |
| 9,8,7 | cd,da,ab,bc,cd,cd,cd,da,ab,bc,cd,cd | 3000m +-1 |
# See issue #2706
# this case is currently broken. It simply works as put here due to staggered intersections triggering a name collapse.
# See 2824 for further information
@todo
Scenario: Incorrect ordering of nodes can produce multiple U-turns
Given the node map
| | a | | | |
| e | b | c | d | f |
And the ways
| nodes | oneway |
| abcd | no |
| ebbdcf | yes |
When I route I should get
| from | to | route |
| e | f | ebbdcf,ebbdcf |
@2798
Scenario: UTurns Enabled
Given the node map
| a | b | c | d | e |
And the query options
| continue_straight | false |
And the ways
| nodes | oneway |
| abc | yes |
| edc | yes |
When I route I should get
| waypoints | route |
| a,b,e | |

View File

@ -276,11 +276,6 @@ class SharedDataFacade final : public BaseDataFacade
void LoadCoreInformation()
{
if (data_layout->num_entries[storage::SharedDataLayout::CORE_MARKER] <= 0)
{
return;
}
auto core_marker_ptr = data_layout->GetBlockPtr<unsigned>(
shared_memory, storage::SharedDataLayout::CORE_MARKER);
util::ShM<bool, true>::vector is_core_node(

View File

@ -90,14 +90,11 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
if (new_distance < upper_bound)
{
// if loops are forced, they are so at the source
if (new_distance >= 0 &&
(!force_loop_forward || forward_heap.GetData(node).parent != node) &&
(!force_loop_reverse || reverse_heap.GetData(node).parent != node))
{
middle_node_id = node;
upper_bound = new_distance;
}
else
if ((force_loop_forward && forward_heap.GetData(node).parent == node) ||
(force_loop_reverse && reverse_heap.GetData(node).parent == node) ||
// in this case we are looking at a bi-directional way where the source
// and target phantom are on the same edge based node
new_distance < 0)
{
// check whether there is a loop present at the node
for (const auto edge : facade->GetAdjacentEdgeRange(node))
@ -121,6 +118,13 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
}
}
}
else
{
BOOST_ASSERT(new_distance >= 0);
middle_node_id = node;
upper_bound = new_distance;
}
}
}
@ -513,7 +517,12 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
std::vector<NodeID> &packed_path) const
{
NodeID current_node_id = middle_node_id;
while (current_node_id != search_heap.GetData(current_node_id).parent)
// all initial nodes will have itself as parent, or a node not in the heap
// in case of a core search heap. We need a distinction between core entry nodes
// and start nodes since otherwise start node specific code that assumes
// node == node.parent (e.g. the loop code) might get actived.
while (current_node_id != search_heap.GetData(current_node_id).parent &&
search_heap.WasInserted(search_heap.GetData(current_node_id).parent))
{
current_node_id = search_heap.GetData(current_node_id).parent;
packed_path.emplace_back(current_node_id);
@ -625,8 +634,9 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
NodeID middle = SPECIAL_NODEID;
distance = duration_upper_bound;
std::vector<std::pair<NodeID, EdgeWeight>> forward_entry_points;
std::vector<std::pair<NodeID, EdgeWeight>> reverse_entry_points;
using CoreEntryPoint = std::tuple<NodeID, EdgeWeight, NodeID>;
std::vector<CoreEntryPoint> forward_entry_points;
std::vector<CoreEntryPoint> reverse_entry_points;
// get offset to account for offsets on phantom nodes on compressed edges
const auto min_edge_offset = std::min(0, forward_heap.MinKey());
@ -643,7 +653,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
{
const NodeID node = forward_heap.DeleteMin();
const int key = forward_heap.GetKey(node);
forward_entry_points.emplace_back(node, key);
forward_entry_points.emplace_back(node, key, forward_heap.GetData(node).parent);
}
else
{
@ -664,7 +674,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
{
const NodeID node = reverse_heap.DeleteMin();
const int key = reverse_heap.GetKey(node);
reverse_entry_points.emplace_back(node, key);
reverse_entry_points.emplace_back(node, key, reverse_heap.GetData(node).parent);
}
else
{
@ -680,36 +690,27 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
}
}
}
// TODO check if unordered_set might be faster
// sort by id and increasing by distance
auto entry_point_comparator = [](const std::pair<NodeID, EdgeWeight> &lhs,
const std::pair<NodeID, EdgeWeight> &rhs) {
return lhs.first < rhs.first || (lhs.first == rhs.first && lhs.second < rhs.second);
};
std::sort(forward_entry_points.begin(), forward_entry_points.end(), entry_point_comparator);
std::sort(reverse_entry_points.begin(), reverse_entry_points.end(), entry_point_comparator);
NodeID last_id = SPECIAL_NODEID;
const auto insertInCoreHeap =
[](const CoreEntryPoint &p, SearchEngineData::QueryHeap &core_heap) {
NodeID id;
EdgeWeight weight;
NodeID parent;
// TODO this should use std::apply when we get c++17 support
std::tie(id, weight, parent) = p;
core_heap.Insert(id, weight, parent);
};
forward_core_heap.Clear();
reverse_core_heap.Clear();
for (const auto &p : forward_entry_points)
{
if (p.first == last_id)
{
continue;
}
forward_core_heap.Insert(p.first, p.second, p.first);
last_id = p.first;
insertInCoreHeap(p, forward_core_heap);
}
last_id = SPECIAL_NODEID;
reverse_core_heap.Clear();
for (const auto &p : reverse_entry_points)
{
if (p.first == last_id)
{
continue;
}
reverse_core_heap.Insert(p.first, p.second, p.first);
last_id = p.first;
insertInCoreHeap(p, reverse_core_heap);
}
// get offset to account for offsets on phantom nodes on compressed edges

View File

@ -114,7 +114,11 @@ class ShortestPathRouting final
needs_loop_forwad,
needs_loop_backwards);
}
new_total_distance += std::min(total_distance_to_forward, total_distance_to_reverse);
// if no route is found between two parts of the via-route, the entire route becomes
// invalid. Adding to invalid edge weight sadly doesn't return an invalid edge weight. Here
// we prevent the possible overflow, faking the addition of infinity + x == infinity
if (new_total_distance != INVALID_EDGE_WEIGHT)
new_total_distance += std::min(total_distance_to_forward, total_distance_to_reverse);
}
// searches shortest path between:

View File

@ -878,25 +878,34 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
geometry.locations[0], geometry.locations[1]) <= 1;
if (zero_length_step || duplicated_coordinate)
{
// fixup the coordinate
geometry.locations.erase(geometry.locations.begin());
geometry.annotations.erase(geometry.annotations.begin());
geometry.osm_node_ids.erase(geometry.osm_node_ids.begin());
// remove the initial distance value
geometry.segment_distances.erase(geometry.segment_distances.begin());
const auto offset = zero_length_step ? geometry.segment_offsets[1] : 1;
if (offset > 0)
{
// fixup the coordinates/annotations/ids
geometry.locations.erase(geometry.locations.begin(),
geometry.locations.begin() + offset);
geometry.annotations.erase(geometry.annotations.begin(),
geometry.annotations.begin() + offset);
geometry.osm_node_ids.erase(geometry.osm_node_ids.begin(),
geometry.osm_node_ids.begin() + offset);
}
// We have to adjust the first step both for its name and the bearings
if (zero_length_step)
{
// since we are not only checking for epsilon but for a full meter, we can have multiple
// coordinates here.
// move offsets to front
BOOST_ASSERT(geometry.segment_offsets[1] == 1);
// geometry offsets have to be adjusted. Move all offsets to the front and reduce by
// one. (This is an inplace forward one and reduce by one)
std::transform(geometry.segment_offsets.begin() + 1,
geometry.segment_offsets.end(),
geometry.segment_offsets.begin(),
[](const std::size_t val) { return val - 1; });
[offset](const std::size_t val) { return val - offset; });
geometry.segment_offsets.pop_back();
const auto &current_depart = steps.front();
@ -937,9 +946,9 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
}
// and update the leg geometry indices for the removed entry
std::for_each(steps.begin(), steps.end(), [](RouteStep &step) {
--step.geometry_begin;
--step.geometry_end;
std::for_each(steps.begin(), steps.end(), [offset](RouteStep &step) {
step.geometry_begin -= offset;
step.geometry_end -= offset;
});
auto &first_step = steps.front();
@ -971,10 +980,12 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
// all zero-length instructions
if (next_to_last_step.distance <= 1 && steps.size() > 2)
{
geometry.locations.pop_back();
geometry.annotations.pop_back();
geometry.osm_node_ids.pop_back();
geometry.segment_offsets.pop_back();
// remove all the last coordinates from the geometry
geometry.locations.resize(geometry.segment_offsets.back() + 1);
geometry.annotations.resize(geometry.segment_offsets.back() + 1);
geometry.osm_node_ids.resize(geometry.segment_offsets.back() + 1);
BOOST_ASSERT(geometry.segment_distances.back() <= 1);
geometry.segment_distances.pop_back();
@ -983,6 +994,7 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
next_to_last_step.maneuver.bearing_after = 0;
next_to_last_step.intersections.front().lanes = util::guidance::LaneTupel();
next_to_last_step.intersections.front().lane_description.clear();
next_to_last_step.geometry_end = next_to_last_step.geometry_begin + 1;
BOOST_ASSERT(next_to_last_step.intersections.size() == 1);
auto &last_intersection = next_to_last_step.intersections.back();
last_intersection.bearings = {last_intersection.bearings[last_intersection.in]};
@ -1030,6 +1042,8 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
last_step.intersections.front().bearings.front() = util::bearing::reverseBearing(bearing);
}
BOOST_ASSERT(steps.back().geometry_end == geometry.locations.size());
BOOST_ASSERT(steps.front().intersections.size() >= 1);
BOOST_ASSERT(steps.front().intersections.front().bearings.size() == 1);
BOOST_ASSERT(steps.front().intersections.front().entry.size() == 1);

View File

@ -1,8 +1,8 @@
#include "extractor/extractor_callbacks.hpp"
#include "extractor/external_memory_node.hpp"
#include "extractor/extraction_containers.hpp"
#include "extractor/extraction_node.hpp"
#include "extractor/extraction_way.hpp"
#include "extractor/extractor_callbacks.hpp"
#include "extractor/restriction.hpp"
#include "util/for_each_pair.hpp"
@ -193,7 +193,8 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
for (auto token_itr = inner_tokens.begin(); token_itr != inner_tokens.end();
++token_itr)
{
auto position = std::find(osm_lane_strings, osm_lane_strings + num_osm_tags, *token_itr);
auto position =
std::find(osm_lane_strings, osm_lane_strings + num_osm_tags, *token_itr);
const auto translated_mask =
masks_by_osm_string[std::distance(osm_lane_strings, position)];
if (translated_mask == TurnLaneType::empty)
@ -203,7 +204,10 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
<< *token_itr << "\"";
return {};
}
BOOST_ASSERT((lane_mask & translated_mask) == 0); // make sure the mask is valid
// In case of multiple times the same lane indicators withn a lane, as in
// "left;left|.." or-ing the masks generates a single "left" enum.
// Which is fine since this is data issue and we can't represent it anyway.
lane_mask |= translated_mask;
}
// add the lane to the description
@ -265,8 +269,8 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
// name_offsets already has an offset of a new name, take the offset index as the name id
name_id = external_memory.name_offsets.size() - 1;
external_memory.name_char_data.reserve(external_memory.name_char_data.size() + name_length
+ destinations_length + pronunciation_length);
external_memory.name_char_data.reserve(external_memory.name_char_data.size() + name_length +
destinations_length + pronunciation_length);
std::copy(parsed_way.name.c_str(),
parsed_way.name.c_str() + name_length,
@ -306,7 +310,9 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
std::transform(input_way.nodes().begin(),
input_way.nodes().end(),
std::back_inserter(external_memory.used_node_id_list),
[](const osmium::NodeRef &ref) { return OSMNodeID{static_cast<std::uint64_t>(ref.ref())}; });
[](const osmium::NodeRef &ref) {
return OSMNodeID{static_cast<std::uint64_t>(ref.ref())};
});
const bool is_opposite_way = TRAVEL_MODE_INACCESSIBLE == parsed_way.forward_travel_mode;
@ -338,7 +344,8 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
external_memory.way_start_end_id_list.push_back(
{OSMWayID{static_cast<std::uint32_t>(input_way.id())},
OSMNodeID{static_cast<std::uint64_t>(input_way.nodes().back().ref())},
OSMNodeID{static_cast<std::uint64_t>(input_way.nodes()[input_way.nodes().size() - 2].ref())},
OSMNodeID{
static_cast<std::uint64_t>(input_way.nodes()[input_way.nodes().size() - 2].ref())},
OSMNodeID{static_cast<std::uint64_t>(input_way.nodes()[1].ref())},
OSMNodeID{static_cast<std::uint64_t>(input_way.nodes()[0].ref())}});
}
@ -372,27 +379,28 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
input_way.nodes().cbegin(),
input_way.nodes().cend(),
[&](const osmium::NodeRef &first_node, const osmium::NodeRef &last_node) {
external_memory.all_edges_list.push_back(
InternalExtractorEdge(OSMNodeID{static_cast<std::uint64_t>(first_node.ref())},
OSMNodeID{static_cast<std::uint64_t>(last_node.ref())},
name_id,
backward_weight_data,
false,
true,
parsed_way.roundabout,
parsed_way.is_access_restricted,
parsed_way.is_startpoint,
parsed_way.backward_travel_mode,
true,
turn_lane_id_backward,
road_classification));
external_memory.all_edges_list.push_back(InternalExtractorEdge(
OSMNodeID{static_cast<std::uint64_t>(first_node.ref())},
OSMNodeID{static_cast<std::uint64_t>(last_node.ref())},
name_id,
backward_weight_data,
false,
true,
parsed_way.roundabout,
parsed_way.is_access_restricted,
parsed_way.is_startpoint,
parsed_way.backward_travel_mode,
true,
turn_lane_id_backward,
road_classification));
});
}
external_memory.way_start_end_id_list.push_back(
{OSMWayID{static_cast<std::uint32_t>(input_way.id())},
OSMNodeID{static_cast<std::uint64_t>(input_way.nodes().back().ref())},
OSMNodeID{static_cast<std::uint64_t>(input_way.nodes()[input_way.nodes().size() - 2].ref())},
OSMNodeID{
static_cast<std::uint64_t>(input_way.nodes()[input_way.nodes().size() - 2].ref())},
OSMNodeID{static_cast<std::uint64_t>(input_way.nodes()[1].ref())},
OSMNodeID{static_cast<std::uint64_t>(input_way.nodes()[0].ref())}});
}

View File

@ -143,7 +143,20 @@ Intersection IntersectionGenerator::getConnectedRoads(const NodeID from_node,
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;
{
// after intersections sorting by angles, find the u-turn with (from_node == to_node)
// that was inserted together with setting uturn_could_be_valid flag
std::size_t self_u_turn = 0;
while (self_u_turn < intersection.size()
&& intersection[self_u_turn].turn.angle < std::numeric_limits<double>::epsilon()
&& from_node != node_based_graph.GetTarget(intersection[self_u_turn].turn.eid))
{
++self_u_turn;
}
BOOST_ASSERT(from_node == node_based_graph.GetTarget(intersection[self_u_turn].turn.eid));
intersection[self_u_turn].entry_allowed = true;
}
return mergeSegregatedRoads(std::move(intersection));
}
@ -264,7 +277,7 @@ Intersection IntersectionGenerator::mergeSegregatedRoads(Intersection intersecti
{
const double correction_factor = (intersection[1].turn.angle) / 2;
for (std::size_t i = 2; i < intersection.size(); ++i)
intersection[i].turn.angle += correction_factor;
intersection[i].turn.angle -= correction_factor;
intersection[0] = merge(intersection[0], intersection[1]);
intersection[0].turn.angle = 0;
intersection.erase(intersection.begin() + 1);

View File

@ -282,7 +282,14 @@ LaneDataVector handleNoneValueAtSimpleTurn(LaneDataVector lane_data,
// a pgerequisite is simple turns. Larger differences should not end up here
// an additional line at the side is only reasonable if it is targeting public
// service vehicles. Otherwise, we should not have it
BOOST_ASSERT(connection_count + 1 == lane_data.size());
//
// TODO(mokob): #2730 have a look please
// BOOST_ASSERT(connection_count + 1 == lane_data.size());
//
if (connection_count + 1 != lane_data.size())
{
goto these_intersections_are_clearly_broken_at_the_moment;
}
lane_data = mergeNoneTag(none_index, std::move(lane_data));
}
@ -292,6 +299,9 @@ LaneDataVector handleNoneValueAtSimpleTurn(LaneDataVector lane_data,
{
lane_data = handleRenamingSituations(none_index, std::move(lane_data), intersection);
}
these_intersections_are_clearly_broken_at_the_moment:
// finally make sure we are still sorted
std::sort(lane_data.begin(), lane_data.end());
return lane_data;

View File

@ -38,6 +38,28 @@ bool TurnLaneData::operator<(const TurnLaneData &other) const
TurnLaneType::left,
TurnLaneType::sharp_left,
TurnLaneType::uturn};
// U-Turns are supposed to be on the outside. So if the first lane is 0 and we are looking at a
// u-turn, it has to be on the very left. If it is equal to the number of lanes, it has to be on
// the right. These sorting function assume reverse to be on the outside always. Might need to
// be reconsidered if there are situations that offer a reverse from some middle lane (seems
// improbable)
if (tag == TurnLaneType::uturn)
{
if (from == 0)
return true;
else
return false;
}
if (other.tag == TurnLaneType::uturn)
{
if (other.from == 0)
return false;
else
return true;
}
return std::find(tag_by_modifier, tag_by_modifier + 8, this->tag) <
std::find(tag_by_modifier, tag_by_modifier + 8, other.tag);
}

View File

@ -118,9 +118,8 @@ Intersection TurnLaneHandler::assignTurnLanes(const NodeID at,
if (!lane_data.empty() && canMatchTrivially(intersection, lane_data) &&
lane_data.size() !=
static_cast<std::size_t>(
lane_data.back().tag != TurnLaneType::uturn && intersection[0].entry_allowed ? 1
: 0) +
static_cast<std::size_t>((
!hasTag(TurnLaneType::uturn, lane_data) && intersection[0].entry_allowed ? 1 : 0)) +
possible_entries &&
intersection[0].entry_allowed && !hasTag(TurnLaneType::none, lane_data))
lane_data.push_back({TurnLaneType::uturn, lane_data.back().to, lane_data.back().to});

View File

@ -134,17 +134,17 @@ typename Intersection::const_iterator findBestMatch(const TurnLaneType::Mask &ta
// possible that it is forbidden. In addition, the best u-turn angle does not necessarily represent
// the u-turn, since it could be a sharp-left turn instead on a road with a middle island.
typename Intersection::const_iterator
findBestMatchForReverse(const TurnLaneType::Mask &leftmost_tag, const Intersection &intersection)
findBestMatchForReverse(const TurnLaneType::Mask &neighbor_tag, const Intersection &intersection)
{
const auto leftmost_itr = findBestMatch(leftmost_tag, intersection);
if (leftmost_itr + 1 == intersection.cend())
const auto neighbor_itr = findBestMatch(neighbor_tag, intersection);
if ((neighbor_itr + 1 == intersection.cend()) || (neighbor_itr == intersection.cbegin() + 1))
return intersection.begin();
const constexpr double idealized_turn_angles[] = {0, 35, 90, 135, 180, 225, 270, 315};
const TurnLaneType::Mask tag = TurnLaneType::uturn;
const auto idealized_angle = idealized_turn_angles[getMatchingModifier(tag)];
return std::min_element(
intersection.begin() + std::distance(intersection.begin(), leftmost_itr),
intersection.begin() + std::distance(intersection.begin(), neighbor_itr),
intersection.end(),
[idealized_angle, &tag](const ConnectedRoad &lhs, const ConnectedRoad &rhs) {
// prefer valid matches
@ -165,6 +165,12 @@ findBestMatchForReverse(const TurnLaneType::Mask &leftmost_tag, const Intersecti
bool canMatchTrivially(const Intersection &intersection, const LaneDataVector &lane_data)
{
std::size_t road_index = 1, lane = 0;
if (!lane_data.empty() && lane_data.front().tag == TurnLaneType::uturn)
{
// the very first is a u-turn to the right
if (intersection[0].entry_allowed)
lane = 1;
}
for (; road_index < intersection.size() && lane < lane_data.size(); ++road_index)
{
if (intersection[road_index].entry_allowed)
@ -207,6 +213,34 @@ Intersection triviallyMatchLanesToTurns(Intersection intersection,
road.turn.lane_data_id = lane_data_id;
};
if (!lane_data.empty() && lane_data.front().tag == TurnLaneType::uturn)
{
// the very first is a u-turn to the right
if (intersection[0].entry_allowed)
{
std::size_t u_turn = 0;
if (node_based_graph.GetEdgeData(intersection[0].turn.eid).reversed)
{
if (intersection.size() <= 1 || !intersection[1].entry_allowed ||
intersection[1].turn.instruction.direction_modifier !=
DirectionModifier::SharpRight)
{
// cannot match u-turn in a valid way
return intersection;
}
u_turn = 1;
road_index = 2;
}
intersection[u_turn].entry_allowed = true;
intersection[u_turn].turn.instruction.type = TurnType::Turn;
intersection[u_turn].turn.instruction.direction_modifier = DirectionModifier::UTurn;
matchRoad(intersection[u_turn], lane_data.back());
// continue with the first lane
lane = 1;
}
}
for (; road_index < intersection.size() && lane < lane_data.size(); ++road_index)
{
if (intersection[road_index].entry_allowed)
@ -231,7 +265,7 @@ Intersection triviallyMatchLanesToTurns(Intersection intersection,
std::size_t u_turn = 0;
if (node_based_graph.GetEdgeData(intersection[0].turn.eid).reversed)
{
if (intersection.back().entry_allowed ||
if (!intersection.back().entry_allowed ||
intersection.back().turn.instruction.direction_modifier !=
DirectionModifier::SharpLeft)
{