62 return road->UpperBound(s) - s;
68 const auto width_info = GetInfo<element::RoadInfoLaneWidth>(s);
69 if(width_info !=
nullptr){
70 return width_info->GetPolynomial().Evaluate(s);
79 auto *geometry = road->GetInfo<element::RoadInfoGeometry>(
GetDistance());
81 auto geometry_type = geometry->GetGeometry().GetType();
90 geometry->GetDistance() + geometry->GetGeometry().GetLength()) {
96 auto lane_offsets = GetInfos<element::RoadInfoLaneOffset>();
97 for (
auto *lane_offset : lane_offsets) {
98 if (std::abs(lane_offset->GetPolynomial().GetC()) > 0 ||
99 std::abs(lane_offset->GetPolynomial().GetD()) > 0) {
106 auto elevations = road->GetInfos<element::RoadInfoElevation>();
107 for (
auto *elevation : elevations) {
108 if (std::abs(elevation->GetPolynomial().GetC()) > 0 ||
109 std::abs(elevation->GetPolynomial().GetD()) > 0) {
119 template <
typename T>
120 static std::pair<double, double> ComputeTotalLaneWidth(
128const bool negative_lane_id = lane_id < 0;
132for (
const auto &lane : container) {
133 auto info = lane.second.template GetInfo<element::RoadInfoLaneWidth>(s);
135 const auto current_polynomial = info->GetPolynomial();
136 auto current_dist = current_polynomial.Evaluate(s);
137 auto current_tang = current_polynomial.Tangent(s);
139 if (lane.first != lane_id) {
140 dist += negative_lane_id ? current_dist : -current_dist;
141 tangent += negative_lane_id ? current_tang : -current_tang;
144 dist += negative_lane_id ? current_dist : -current_dist;
145 tangent += (negative_lane_id ? current_tang : -current_tang) * 0.5;
149return std::make_pair(dist, tangent);
161 const std::map<LaneId, Lane>& lanes = lane_section->GetLanes();
169 float lane_t_offset = 0.0f;
170 float lane_tangent = 0.0f;
174 std::make_reverse_iterator(lanes.lower_bound(0)), lanes.rend());
175 const auto computed_width =
176 ComputeTotalLaneWidth(side_lanes, s,
GetId());
177 lane_t_offset =
static_cast<float>(computed_width.first);
178 lane_tangent =
static_cast<float>(computed_width.second);
180 else if (
GetId() > 0) {
181 const auto side_lanes =
MakeListView(lanes.lower_bound(1), lanes.end());
182 const auto computed_width =
183 ComputeTotalLaneWidth(side_lanes, s,
GetId());
184 lane_t_offset =
static_cast<float>(computed_width.first);
185 lane_tangent =
static_cast<float>(computed_width.second);
189 const auto lane_offset_info = road->GetInfo<element::RoadInfoLaneOffset>(s);
190 const auto lane_offset_tangent =
191 static_cast<float>(lane_offset_info->GetPolynomial().Tangent(s));
194 lane_tangent -= lane_offset_tangent;
197 element::DirectedPoint dp = road->GetDirectedPointIn(s);
200 dp.ApplyLateralOffset(lane_t_offset);
203 dp.tangent -= lane_tangent;
215 rot.pitch = 360.0f - rot.pitch;
218 return geom::Transform(dp.location, rot);
222 const double s,
const float extra_width)
const {
228 const std::map<LaneId, Lane> &lanes = lane_section->GetLanes();
235 float lane_t_offset = 0.0f;
240 std::make_reverse_iterator(lanes.lower_bound(0)), lanes.rend());
241 const auto computed_width =
242 ComputeTotalLaneWidth(side_lanes, s,
GetId());
243 lane_t_offset =
static_cast<float>(computed_width.first);
244 }
else if (
GetId() > 0) {
246 const auto side_lanes =
MakeListView(lanes.lower_bound(1), lanes.end());
247 const auto computed_width =
248 ComputeTotalLaneWidth(side_lanes, s,
GetId());
249 lane_t_offset =
static_cast<float>(computed_width.first);
252 float lane_width =
static_cast<float>(
GetWidth(s)) / 2.0f;
254 lane_width += extra_width;
258 element::DirectedPoint dp_r, dp_l;
259 dp_r = dp_l = road->GetDirectedPointIn(s);
262 dp_r.ApplyLateralOffset(lane_t_offset + lane_width);
263 dp_l.ApplyLateralOffset(lane_t_offset - lane_width);
266 dp_r.location.y *= -1;
267 dp_l.location.y *= -1;
272 dp_r.location.z += 0.1524f;
273 dp_l.location.z += 0.1524f;
277 return std::make_pair(dp_r.location, dp_l.location);
#define DEBUG_ASSERT(predicate)
#define RELEASE_ASSERT(pred)
static constexpr T ToDegrees(T rad)
double GetDistance() const
bool IsStraight() const
检查几何形状是否是直线
double GetWidth(const double s) const
返回给定位置s的车道总宽度
geom::Transform ComputeTransform(const double s) const
const LaneSection * GetLaneSection() const
LaneSection * _lane_section
double GetDistance() const
std::pair< geom::Vector3D, geom::Vector3D > GetCornerPositions(const double s, const float extra_width=0.f) const
计算给定位置s的车道边缘位置
static auto MakeListView(Iterator begin, Iterator end)