-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Making the turn function more flexible #4789
Changes from 1 commit
9792493
9450f13
6775d86
2a29c64
329187c
2fd9442
76224ef
096f86d
9208fd7
69758c7
5767da9
ac2846d
3651f6b
0ad7169
09ff6ef
73c72ff
62c089e
d1f3146
013d951
0611e55
e51abc8
3ee0d22
d339178
430859c
edc30b0
7898ccb
56754ea
939ac0f
989f633
106874d
98ca829
271915e
12629cd
dd61ce8
a3de95c
9eb80ca
5550f76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,9 +27,9 @@ struct NodeBasedEdgeClassification | |
std::uint8_t startpoint : 1; // 1 | ||
std::uint8_t restricted : 1; // 1 | ||
guidance::RoadClassification road_classification; // 16 2 | ||
std::uint8_t highway_turn_classification; // @CHAUTODO memory? limit to 3 bits? // 8 | ||
std::uint8_t access_turn_classification; // 3 are enough // 8 | ||
std::uint8_t speed; // one bit could be saved here too I guess, so 7 // 8 | ||
std::uint8_t highway_turn_classification : 4; // 4 | ||
std::uint8_t access_turn_classification : 4; // 4 | ||
std::uint8_t speed; // 8 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried calculating speed by edge length and duration. Many calculated speeds are within 10% of the actual speed. Some are not. Here is an extract of the differences running on Berlin:
in favour of using less memory, @oxidase do you think this is preferable? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @chaupow both speeds values have different meaning. For example, an NBG edge from https://www.openstreetmap.org/node/5339762636 to https://www.openstreetmap.org/node/1736058469 consists of two segments:
The The computed speed value is an average that also includes traffic light penalties. I think average values are preferable over speed values of single segments. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Agreed! Done thanks 👍 |
||
|
||
NodeBasedEdgeClassification(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,6 +227,13 @@ function WayHandlers.way_classification_for_turn(profile,way,result,data) | |
local highway = way:get_value_by_key("highway") | ||
local access = way:get_value_by_key("access") | ||
|
||
if profile.highway_turn_classification[highway] then | ||
assert(profile.highway_turn_classification[highway] < 16, "highway_turn_classification must be smaller than 16") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Asserts can can be directly checked before assignments below. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done 👍 |
||
end | ||
if profile.access_turn_classification[highway] then | ||
assert(profile.access_turn_classification[highway] < 16, "access_turn_classification must be smaller than 16") | ||
end | ||
|
||
if highway and profile.highway_turn_classification[highway] then | ||
result.highway_turn_classification = profile.highway_turn_classification[highway] | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -599,14 +599,15 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( | |
|
||
// compute weight and duration penalties | ||
auto is_traffic_light = m_traffic_lights.count(intersection_node); | ||
|
||
std::vector<ExtractionTurnLeg> road_legs_on_the_right; | ||
std::vector<ExtractionTurnLeg> road_legs_on_the_left; | ||
|
||
auto turn_iter = | ||
std::find_if(intersection.begin(), intersection.end(), [&turn](const auto &road) { | ||
return road.eid == turn.eid; | ||
}); | ||
|
||
// if the turn is a u turn, store all information in road_legs_on_the_right | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here can be an edge case for U-turns in left-driving countries. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think I should change this in left-driving countries? I wonder whether it is important whether roads are on the left or right when you do a u turn and want to assign turn weights for u turns. Maybe it doesn't really matter here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree, it should not matter, but would good to mention u-turns in the description of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
if (turn_iter == intersection.begin()) | ||
{ | ||
for (auto connected_edge = intersection.begin() + 1; | ||
|
@@ -627,6 +628,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( | |
connected_edge->entry_allowed); | ||
} | ||
} | ||
// otherwise split roads into the right or left side of the turn and store info | ||
else | ||
{ | ||
for (auto connected_edge = intersection.begin() + 1; connected_edge < turn_iter; | ||
|
@@ -662,13 +664,16 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( | |
connected_edge->entry_allowed); | ||
} | ||
} | ||
|
||
ExtractionTurn extracted_turn( | ||
// general info | ||
turn.angle, | ||
m_node_based_graph.GetOutDegree(intersection_node), | ||
intersection.size(), | ||
turn.instruction.IsUTurn(), | ||
is_traffic_light, | ||
m_edge_based_node_container.GetAnnotation(edge_data1.annotation_data) | ||
.is_left_hand_driving, | ||
// source info | ||
edge_data1.flags.restricted, | ||
m_edge_based_node_container.GetAnnotation(edge_data1.annotation_data).travel_mode, | ||
edge_data1.flags.road_classification.IsMotorwayClass(), | ||
|
@@ -677,6 +682,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( | |
edge_data1.flags.highway_turn_classification, | ||
edge_data1.flags.access_turn_classification, | ||
edge_data1.flags.speed, | ||
// target info | ||
edge_data2.flags.restricted, | ||
m_edge_based_node_container.GetAnnotation(edge_data2.annotation_data).travel_mode, | ||
edge_data2.flags.road_classification.IsMotorwayClass(), | ||
|
@@ -685,6 +691,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( | |
edge_data2.flags.highway_turn_classification, | ||
edge_data2.flags.access_turn_classification, | ||
edge_data2.flags.speed, | ||
// connected roads | ||
road_legs_on_the_right, | ||
road_legs_on_the_left); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍