@@ -95,25 +95,31 @@ PathPolygonIntersectionStatus getPathPolygonIntersectionStatus(
95
95
auto const & is_first_path_point_inside_polygon = bg::within (first_path_point, polygon);
96
96
auto const & is_last_path_point_inside_polygon = bg::within (last_path_point, polygon);
97
97
98
- if (
99
- intersects.empty () && is_first_path_point_inside_polygon && is_last_path_point_inside_polygon) {
100
- polygon_intersection_status.is_path_inside_of_polygon = true ;
101
- } else {
102
- // classify first and second intersection points
103
- for (size_t i = 0 ; i < intersects.size (); ++i) {
104
- const auto & p = intersects.at (i);
105
- if (
106
- (intersects.size () == 2 && i == 0 ) ||
107
- (intersects.size () == 1 && is_last_path_point_inside_polygon)) {
108
- polygon_intersection_status.first_intersection_point = createPoint (p.x (), p.y (), ego_pos.z );
109
- } else if (
110
- (intersects.size () == 2 && i == 1 ) ||
111
- (intersects.size () == 1 && is_first_path_point_inside_polygon)) {
112
- polygon_intersection_status.second_intersection_point =
113
- createPoint (p.x (), p.y (), ego_pos.z );
114
- }
98
+ // classify first and second intersection points
99
+ if (intersects.empty ()) {
100
+ if (is_first_path_point_inside_polygon && is_last_path_point_inside_polygon) {
101
+ polygon_intersection_status.is_path_inside_of_polygon = true ;
102
+ } else {
103
+ // do nothing
104
+ }
105
+ } else if (intersects.size () == 1 ) {
106
+ const auto & p = intersects.at (0 );
107
+ if (is_last_path_point_inside_polygon) {
108
+ polygon_intersection_status.first_intersection_point = createPoint (p.x (), p.y (), ego_pos.z );
109
+ } else if (is_first_path_point_inside_polygon) {
110
+ polygon_intersection_status.second_intersection_point = createPoint (p.x (), p.y (), ego_pos.z );
111
+ } else {
112
+ // do nothing
115
113
}
114
+ } else if (intersects.size () == 2 ) {
115
+ const auto & p0 = intersects.at (0 );
116
+ const auto & p1 = intersects.at (1 );
117
+ polygon_intersection_status.first_intersection_point = createPoint (p0.x (), p0.y (), ego_pos.z );
118
+ polygon_intersection_status.second_intersection_point = createPoint (p1.x (), p1.y (), ego_pos.z );
119
+ } else {
120
+ // do nothing
116
121
}
122
+
117
123
return polygon_intersection_status;
118
124
}
119
125
0 commit comments