@@ -34,11 +34,13 @@ double getDistanceToNextTrafficLight(
34
34
lanelet::utils::to2D (lanelet_point).basicPoint ());
35
35
36
36
for (const auto & element : current_lanelet.regulatoryElementsAs <lanelet::TrafficLight>()) {
37
- lanelet::ConstLineString3d lanelet_stop_lines = element->stopLine ().value ();
37
+ const auto lanelet_stop_lines = element->stopLine ();
38
+
39
+ if (!lanelet_stop_lines.has_value ()) continue ;
38
40
39
41
const auto to_stop_line = lanelet::geometry::toArcCoordinates (
40
42
lanelet::utils::to2D (current_lanelet.centerline ()),
41
- lanelet::utils::to2D (lanelet_stop_lines).front ().basicPoint ());
43
+ lanelet::utils::to2D (lanelet_stop_lines. value () ).front ().basicPoint ());
42
44
43
45
const auto distance_object_to_stop_line = to_stop_line.length - to_object.length ;
44
46
@@ -61,11 +63,13 @@ double getDistanceToNextTrafficLight(
61
63
}
62
64
63
65
for (const auto & element : llt.regulatoryElementsAs <lanelet::TrafficLight>()) {
64
- lanelet::ConstLineString3d lanelet_stop_lines = element->stopLine ().value ();
66
+ const auto lanelet_stop_lines = element->stopLine ();
67
+
68
+ if (!lanelet_stop_lines.has_value ()) continue ;
65
69
66
70
const auto to_stop_line = lanelet::geometry::toArcCoordinates (
67
71
lanelet::utils::to2D (llt.centerline ()),
68
- lanelet::utils::to2D (lanelet_stop_lines).front ().basicPoint ());
72
+ lanelet::utils::to2D (lanelet_stop_lines. value () ).front ().basicPoint ());
69
73
70
74
return distance + to_stop_line.length - to_object.length ;
71
75
}
0 commit comments