@@ -42,7 +42,7 @@ void insert_marker_array(
42
42
}
43
43
44
44
lanelet::ConstLanelet combine_lanelets_with_shoulder (
45
- const lanelet::ConstLanelets & lanelets, const lanelet::ConstLanelets & shoulder_lanelets )
45
+ const lanelet::ConstLanelets & lanelets, const route_handler::RouteHandler & route_handler )
46
46
{
47
47
lanelet::Points3d lefts;
48
48
lanelet::Points3d rights;
@@ -57,30 +57,18 @@ lanelet::ConstLanelet combine_lanelets_with_shoulder(
57
57
}
58
58
}
59
59
60
+ // lambda to add bound to target_bound
61
+ const auto add_bound = [](const auto & bound, auto & target_bound) {
62
+ std::transform (
63
+ bound.begin (), bound.end (), std::back_inserter (target_bound),
64
+ [](const auto & pt) { return lanelet::Point3d (pt); });
65
+ };
60
66
for (const auto & llt : lanelets) {
61
- // lambda to check if shoulder lane which share left bound with lanelets exist
62
- const auto find_bound_shared_shoulder =
63
- [&shoulder_lanelets](const auto & lanelet_bound, const auto & get_shoulder_bound) {
64
- return std::find_if (
65
- shoulder_lanelets.begin (), shoulder_lanelets.end (),
66
- [&lanelet_bound, &get_shoulder_bound](const auto & shoulder_llt) {
67
- return lanelet_bound.id () == get_shoulder_bound (shoulder_llt).id ();
68
- });
69
- };
70
-
71
- // lambda to add bound to target_bound
72
- const auto add_bound = [](const auto & bound, auto & target_bound) {
73
- std::transform (
74
- bound.begin (), bound.end (), std::back_inserter (target_bound),
75
- [](const auto & pt) { return lanelet::Point3d (pt); });
76
- };
77
-
78
67
// check if shoulder lanelets which has RIGHT bound same to LEFT bound of lanelet exist
79
- const auto left_shared_shoulder_it = find_bound_shared_shoulder (
80
- llt.leftBound (), [](const auto & shoulder_llt) { return shoulder_llt.rightBound (); });
81
- if (left_shared_shoulder_it != shoulder_lanelets.end ()) {
68
+ const auto left_shared_shoulder = route_handler.getLeftShoulderLanelet (llt);
69
+ if (left_shared_shoulder) {
82
70
// if exist, add left bound of SHOULDER lanelet to lefts
83
- add_bound (left_shared_shoulder_it ->leftBound (), lefts);
71
+ add_bound (left_shared_shoulder ->leftBound (), lefts);
84
72
} else if (
85
73
// if not exist, add left bound of lanelet to lefts
86
74
// if the **left** of this lanelet does not match any of the **right** bounds of `lanelets`,
@@ -90,11 +78,10 @@ lanelet::ConstLanelet combine_lanelets_with_shoulder(
90
78
}
91
79
92
80
// check if shoulder lanelets which has LEFT bound same to RIGHT bound of lanelet exist
93
- const auto right_shared_shoulder_it = find_bound_shared_shoulder (
94
- llt.rightBound (), [](const auto & shoulder_llt) { return shoulder_llt.leftBound (); });
95
- if (right_shared_shoulder_it != shoulder_lanelets.end ()) {
81
+ const auto right_shared_shoulder = route_handler.getRightShoulderLanelet (llt);
82
+ if (right_shared_shoulder) {
96
83
// if exist, add right bound of SHOULDER lanelet to rights
97
- add_bound (right_shared_shoulder_it ->rightBound (), rights);
84
+ add_bound (right_shared_shoulder ->rightBound (), rights);
98
85
} else if (
99
86
// if not exist, add right bound of lanelet to rights
100
87
// if the **right** of this lanelet does not match any of the **left** bounds of `lanelets`,
0 commit comments