diff --git a/LibCarla/source/carla/road/Map.cpp b/LibCarla/source/carla/road/Map.cpp index 624ebcea4..3b1841015 100644 --- a/LibCarla/source/carla/road/Map.cpp +++ b/LibCarla/source/carla/road/Map.cpp @@ -750,9 +750,10 @@ namespace road { // =========================================================================== // Checks whether the geometry is straight or not - bool IsLineStraight(const Road &road, - const Lane &lane, - const element::RoadInfoGeometry* geometry) { + bool IsLaneStraight(const Lane &lane) { + Road *road = lane.GetRoad(); + auto *geometry = road->GetInfo(lane.GetDistance()); + DEBUG_ASSERT(geometry != nullptr); auto geometry_type = geometry->GetGeometry().GetType(); if (geometry_type != element::GeometryType::LINE) { return false; @@ -769,7 +770,7 @@ namespace road { return false; } } - auto elevations = road.GetInfos(); + auto elevations = road->GetInfos(); for (auto *elevation : elevations) { if (abs(elevation->GetPolynomial().GetC()) > 0 || abs(elevation->GetPolynomial().GetD()) > 0) { @@ -852,14 +853,12 @@ namespace road { auto current_waypoint = lane_start_waypoint; - const Road &road = _data.GetRoad(current_waypoint.road_id); const Lane &lane = GetLane(current_waypoint); - const auto *geometry = road.GetInfo(current_waypoint.s); geom::Transform current_transform = ComputeTransform(current_waypoint); // Save computation time in straight lines - if (IsLineStraight(road, lane, geometry)) { + if (IsLaneStraight(lane)) { double delta_s = min_delta_s; double remaining_length = GetRemainingLength(lane, current_waypoint.s);