78 auto info = GetInfo<element::RoadInfoElevation>(s);
79 if (info ==
nullptr) {
82 return info->GetPolynomial();
88 auto *lane = section.GetLane(lane_id);
89 if (lane !=
nullptr) {
103 std::vector<Lane*> result;
105 for (
auto &lane_section : lane_sections) {
106 for (
auto & lane_pair : lane_section.GetLanes()) {
107 result.emplace_back(&lane_pair.second);
115 std::vector<const Lane*> result;
117 for (
const auto &lane_section : lane_sections) {
118 for (
const auto & lane_pair : lane_section.GetLanes()) {
119 result.emplace_back(&lane_pair.second);
141 Lane *ptr = upper->second.GetLane(lane_id);
154 auto rlower = std::make_reverse_iterator(lower);
157 Lane *ptr = rlower->second.GetLane(lane_id);
158 if (ptr !=
nullptr) {
171 Lane *ptr = it->second.GetLane(
id);
172 if (ptr !=
nullptr) {
173 return &(it->second);
184 Lane *ptr = it->second.GetLane(
id);
185 if (ptr !=
nullptr) {
186 return &(it->second);
196 const auto geometry =
_info.
GetInfo<element::RoadInfoGeometry>(clamped_s);
198 const auto lane_offset =
_info.
GetInfo<element::RoadInfoLaneOffset>(clamped_s);
201 offset =
static_cast<float>(lane_offset->GetPolynomial().Evaluate(clamped_s));
204 element::DirectedPoint p = geometry->GetGeometry().PosFromDist(clamped_s - geometry->GetDistance());
206 p.ApplyLateralOffset(-offset);
210 p.location.z =
static_cast<float>(elevation_info.Evaluate(s));
211 p.pitch = elevation_info.Tangent(s);
219 const auto geometry =
_info.
GetInfo<element::RoadInfoGeometry>(clamped_s);
221 element::DirectedPoint p = geometry->GetGeometry().PosFromDist(clamped_s - geometry->GetDistance());
225 p.location.z =
static_cast<float>(elevation_info.Evaluate(s));
226 p.pitch = elevation_info.Tangent(s);
233 std::pair<double, double> last = { 0.0, std::numeric_limits<double>::max() };
235 auto geom_info_list =
_info.
GetInfos<element::RoadInfoGeometry>();
236 decltype(geom_info_list)::iterator nearest_geom = geom_info_list.end();
238 for (
auto g = geom_info_list.begin(); g != geom_info_list.end(); ++g) {
240 auto dist = (*g)->GetGeometry().DistanceTo(loc);
241 if (dist.second < last.second) {
247 for (
auto g = geom_info_list.begin();
248 g != geom_info_list.end() && g != nearest_geom;
251 last.first += (*g)->GetGeometry().GetLength();
258 const geom::Location &loc,
259 uint32_t lane_type)
const {
261 std::map<LaneId, const Lane *> lanes(
GetLanesAt(s));
265 std::make_reverse_iterator(lanes.lower_bound(0)), lanes.rend());
268 lanes.lower_bound(1), lanes.end());
271 std::pair<const Lane *, double> result =
272 std::make_pair(
nullptr, std::numeric_limits<double>::max());
275 for (
const auto &lane : right_lanes) {
277 const auto half_width =
static_cast<float>(lane_width_info->GetPolynomial().Evaluate(s)) * 0.5f;
283 if (current_dist <= result.second) {
285 if ((
static_cast<uint32_t
>(lane.second->GetType()) & lane_type) > 0) {
286 result.first = &(*lane.second);
287 result.second = current_dist;
296 current_dp = dp_lane_zero;
297 for (
const auto &lane : left_lanes) {
299 const auto half_width = -
static_cast<float>(lane_width_info->GetPolynomial().Evaluate(s)) * 0.5f;
305 if (current_dist <= result.second) {
307 if ((
static_cast<uint32_t
>(lane.second->GetType()) & lane_type) > 0) {
308 result.first = &(*lane.second);
309 result.second = current_dist;
322 std::map<LaneId, const Lane *> map;
324 for (
auto &&lane : lane_section.GetLanes()) {
325 map[lane.first] = &(lane.second);
#define DEBUG_ASSERT(predicate)
static T Clamp(T a, T min=T(0), T max=T(1))
static auto Distance(const Vector3D &a, const Vector3D &b)
std::map< LaneId, Lane > & GetLanes()
RoadId GetPredecessor() const
const std::pair< double, double > GetNearestPoint(const geom::Location &loc) const
返回一个包含以下内容的对:
std::vector< Road * > GetPrevs() const
Lane * GetPrevLane(const double s, const LaneId lane_id)
Lane & GetLaneById(SectionId section_id, LaneId lane_id)
LaneSectionMap _lane_sections
RoadId GetSuccessor() const
std::vector< Road * > _nexts
std::vector< Road * > _prevs
std::map< LaneId, const Lane * > GetLanesAt(const double s) const
获取在给定 s 位置的所有车道
std::vector< Road * > GetNexts() const
LaneSection * GetStartSection(LaneId id)
获取给定车道 ID 的起始车道段
Lane * GetNextLane(const double s, const LaneId lane_id)
const geom::CubicPolynomial & GetElevationOn(const double s) const
Lane & GetLaneByDistance(double s, LaneId lane_id)
auto GetLaneSectionsAt(const double s)
const std::pair< const Lane *, double > GetNearestLane(const double s, const geom::Location &loc, uint32_t type=static_cast< uint32_t >(Lane::LaneType::Any)) const
返回最近的车道指针,给定相对于路段的 s 值和位置
element::DirectedPoint GetDirectedPointIn(const double s) const
返回指定距离的中心点(车道 0)的导向点
std::vector< Lane * > GetLanesByDistance(double s)
在特定的 s 值获取所有车道
element::DirectedPoint GetDirectedPointInNoLaneOffset(const double s) const
返回指定距离的中心点(车道 0)的导向点,不考虑车道偏移
JuncId GetJunctionId() const
LaneSection * GetEndSection(LaneId id)
获取给定车道 ID 的结束车道段
std::string GetName() const
const MapData * GetMap() const
LaneSection & GetLaneSectionById(SectionId id)
车道宽度记录:道路上每个交叉部分的车道可以提供多个宽度条目。 每个车道至少必须定义一个条目,除了按照惯例中心车道宽度为零。 每个条目在定义新条目之前都是有效的。如果为一个车道定义了多个条目, 它们必须按...
void throw_exception(const std::exception &e)
static auto MakeListView(Iterator begin, Iterator end)
void ApplyLateralOffset(float lateral_offset)