55 return road->UpperBound(s) - s;
60 const auto width_info = GetInfo<element::RoadInfoLaneWidth>(s);
61 if(width_info !=
nullptr){
62 return width_info->GetPolynomial().Evaluate(s);
72 auto geometry_type = geometry->GetGeometry().GetType();
78 geometry->GetDistance() + geometry->GetGeometry().GetLength()) {
81 auto lane_offsets = GetInfos<element::RoadInfoLaneOffset>();
82 for (
auto *lane_offset : lane_offsets) {
83 if (std::abs(lane_offset->GetPolynomial().GetC()) > 0 ||
84 std::abs(lane_offset->GetPolynomial().GetD()) > 0) {
89 for (
auto *elevation : elevations) {
90 if (std::abs(elevation->GetPolynomial().GetC()) > 0 ||
91 std::abs(elevation->GetPolynomial().GetD()) > 0) {
100 template <
typename T>
109 const bool negative_lane_id = lane_id < 0;
111 double tangent = 0.0;
112 for (
const auto &lane : container) {
113 auto info = lane.second.template GetInfo<element::RoadInfoLaneWidth>(s);
115 const auto current_polynomial = info->GetPolynomial();
116 auto current_dist = current_polynomial.Evaluate(s);
117 auto current_tang = current_polynomial.Tangent(s);
118 if (lane.first != lane_id) {
119 dist += negative_lane_id ? current_dist : -current_dist;
120 tangent += negative_lane_id ? current_tang : -current_tang;
123 dist += negative_lane_id ? current_dist : -current_dist;
124 tangent += (negative_lane_id ? current_tang : -current_tang) * 0.5;
128 return std::make_pair(dist, tangent);
141 const std::map<LaneId, Lane> &lanes = lane_section->GetLanes();
151 float lane_t_offset = 0.0f;
152 float lane_tangent = 0.0f;
157 std::make_reverse_iterator(lanes.lower_bound(0)), lanes.rend());
158 const auto computed_width =
160 lane_t_offset =
static_cast<float>(computed_width.first);
161 lane_tangent =
static_cast<float>(computed_width.second);
162 }
else if (
GetId() > 0) {
164 const auto side_lanes =
MakeListView(lanes.lower_bound(1), lanes.end());
165 const auto computed_width =
167 lane_t_offset =
static_cast<float>(computed_width.first);
168 lane_tangent =
static_cast<float>(computed_width.second);
173 const auto lane_offset_tangent =
174 static_cast<float>(lane_offset_info->GetPolynomial().Tangent(s));
177 lane_tangent -= lane_offset_tangent;
207 const double s,
const float extra_width)
const {
213 const std::map<LaneId, Lane> &lanes = lane_section->GetLanes();
220 float lane_t_offset = 0.0f;
225 std::make_reverse_iterator(lanes.lower_bound(0)), lanes.rend());
226 const auto computed_width =
228 lane_t_offset =
static_cast<float>(computed_width.first);
229 }
else if (
GetId() > 0) {
231 const auto side_lanes =
MakeListView(lanes.lower_bound(1), lanes.end());
232 const auto computed_width =
234 lane_t_offset =
static_cast<float>(computed_width.first);
237 float lane_width =
static_cast<float>(
GetWidth(s)) / 2.0f;
239 lane_width += extra_width;
std::vector< const T * > GetInfos() const
double GetDistance() const
The lane offset record defines a lateral shift of the lane reference line(which is usually identical ...
double GetDistance() const
This file contains definitions of common data structures used in traffic manager. ...
double GetWidth(const double s) const
Returns the total lane width given a s.
const T * GetInfo(const double s) const
#define DEBUG_ASSERT(predicate)
LaneSection * _lane_section
#define RELEASE_ASSERT(pred)
LaneType
Can be used as flags.
bool IsStraight() const
Checks whether the geometry is straight or not.
static std::pair< double, double > ComputeTotalLaneWidth(const T container, const double s, const LaneId lane_id)
Returns a pair containing first = width, second = tangent, for an specific Lane given an s and a iter...
geom::Transform ComputeTransform(const double s) const
static constexpr T ToDegrees(T rad)
static auto MakeListView(Iterator begin, Iterator end)
void ApplyLateralOffset(float lateral_offset)
std::pair< geom::Vector3D, geom::Vector3D > GetCornerPositions(const double s, const float extra_width=0.f) const
Computes the location of the edges given a s.
geom::Transform Transform
element::DirectedPoint GetDirectedPointIn(const double s) const
Returns a directed point on the center of the road (lane 0), with the corresponding laneOffset and el...
const LaneSection * GetLaneSection() const