ad_map_access
LaneIntervalOperation.hpp
Go to the documentation of this file.
1 // ----------------- BEGIN LICENSE BLOCK ---------------------------------
2 //
3 // Copyright (C) 2018-2021 Intel Corporation
4 //
5 // SPDX-License-Identifier: MIT
6 //
7 // ----------------- END LICENSE BLOCK -----------------------------------
12 #pragma once
13 
14 #include "ad/map/access/Types.hpp"
15 #include "ad/map/lane/Types.hpp"
16 #include "ad/map/route/Types.hpp"
17 
19 namespace ad {
21 namespace map {
23 namespace route {
24 
40 inline point::ParaPoint getIntervalStart(LaneInterval const &laneInterval)
41 {
42  point::ParaPoint result;
43  result.laneId = laneInterval.laneId;
44  result.parametricOffset = laneInterval.start;
45  return result;
46 }
47 
53 point::ParaPoint getIntervalStart(FullRoute const &route, lane::LaneId const &laneId);
54 
58 inline point::ParaPoint getIntervalEnd(LaneInterval const &laneInterval)
59 {
60  point::ParaPoint result;
61  result.laneId = laneInterval.laneId;
62  result.parametricOffset = laneInterval.end;
63  return result;
64 }
65 
69 inline physics::ParametricRange toParametricRange(route::LaneInterval const &laneInterval)
70 {
71  physics::ParametricRange range;
72  if (laneInterval.start <= laneInterval.end)
73  {
74  range.minimum = laneInterval.start;
75  range.maximum = laneInterval.end;
76  }
77  else
78  {
79  range.minimum = laneInterval.end;
80  range.maximum = laneInterval.start;
81  }
82  return range;
83 }
84 
95 physics::ParametricValue
96 getSignedDistance(LaneInterval const &laneInterval, point::ParaPoint const &first, point::ParaPoint const &second);
97 
104 physics::ParametricValue
105 getUnsignedDistance(LaneInterval const &laneInterval, point::ParaPoint const &first, point::ParaPoint const &second);
106 
114 inline bool isStartOfInterval(LaneInterval const &laneInterval, point::ParaPoint const &point)
115 {
116  return (point.laneId == laneInterval.laneId) && (point.parametricOffset == laneInterval.start);
117 }
118 
126 inline bool isEndOfInterval(LaneInterval const &laneInterval, point::ParaPoint const &point)
127 {
128  return (point.laneId == laneInterval.laneId) && (point.parametricOffset == laneInterval.end);
129 }
130 
139 bool isRouteDirectionPositive(LaneInterval const &laneInterval);
140 
146 inline bool isRouteDirectionNegative(LaneInterval const &laneInterval)
147 {
148  return !isRouteDirectionPositive(laneInterval);
149 }
150 
154 bool isRouteDirectionAlignedWithDrivingDirection(LaneInterval const &laneInterval);
155 
163 inline bool isWithinInterval(LaneInterval const &laneInterval, physics::ParametricValue const &parametricOffset)
164 {
165  if (isRouteDirectionPositive(laneInterval))
166  {
167  return (laneInterval.start <= parametricOffset) && (parametricOffset <= laneInterval.end);
168  }
169  else
170  {
171  return (laneInterval.end <= parametricOffset) && (parametricOffset <= laneInterval.start);
172  }
173 }
174 
182 inline bool isWithinInterval(LaneInterval const &laneInterval, point::ParaPoint const &point)
183 {
184  return (point.laneId == laneInterval.laneId) && isWithinInterval(laneInterval, point.parametricOffset);
185 }
186 
195 inline bool isDegenerated(LaneInterval const &laneInterval)
196 {
197  return (laneInterval.start == laneInterval.end);
198 }
199 
208 inline bool isAfterInterval(LaneInterval const &laneInterval, physics::ParametricValue const parametricOffset)
209 {
210  if (isRouteDirectionPositive(laneInterval))
211  {
212  return (parametricOffset > laneInterval.end);
213  }
214  else
215  {
216  return (parametricOffset < laneInterval.end);
217  }
218 }
219 
229 inline bool isAfterInterval(LaneInterval const &laneInterval, point::ParaPoint const &point)
230 {
231  if (point.laneId == laneInterval.laneId)
232  {
233  return isAfterInterval(laneInterval, point.parametricOffset);
234  }
235  return false;
236 }
237 
246 inline bool isBeforeInterval(LaneInterval const &laneInterval, physics::ParametricValue const parametricOffset)
247 {
248  if (isRouteDirectionPositive(laneInterval))
249  {
250  return (parametricOffset < laneInterval.start);
251  }
252  else
253  {
254  return (parametricOffset > laneInterval.start);
255  }
256 }
257 
267 inline bool isBeforeInterval(LaneInterval const &laneInterval, point::ParaPoint const &point)
268 {
269  if (point.laneId == laneInterval.laneId)
270  {
271  return isBeforeInterval(laneInterval, point.parametricOffset);
272  }
273  return false;
274 }
275 
283 inline bool overlapsInterval(LaneInterval const &laneInterval, physics::ParametricRange const &range)
284 {
285  bool rangeIsOutside = (isBeforeInterval(laneInterval, range.minimum) && isBeforeInterval(laneInterval, range.maximum))
286  || (isAfterInterval(laneInterval, range.minimum) && isAfterInterval(laneInterval, range.maximum));
287  return !rangeIsOutside;
288 }
289 
302 physics::ParametricValue getProjectedParametricOffsetOnNeighborLane(LaneInterval const &currentInterval,
303  LaneInterval const &neighborInterval,
304  physics::ParametricValue const &parametricOffset);
305 
309 inline physics::ParametricValue calcParametricLength(LaneInterval const &laneInterval)
310 {
311  return std::fabs(laneInterval.start - laneInterval.end);
312 }
313 
319 physics::Distance calcLength(LaneInterval const &laneInterval);
320 
325 physics::Duration calcDuration(LaneInterval const &laneInterval);
326 
335 void getRightEdge(LaneInterval const &laneInterval, point::ENUEdge &enuEdge);
336 
345 void getRightEdge(LaneInterval const &laneInterval, point::ECEFEdge &ecefEdge);
346 
355 void getRightEdge(LaneInterval const &laneInterval, point::GeoEdge &geoEdge);
356 
365 point::ENUEdge getRightENUEdge(LaneInterval const &laneInterval);
366 
375 point::ECEFEdge getRightECEFEdge(LaneInterval const &laneInterval);
376 
385 point::GeoEdge getRightGeoEdge(LaneInterval const &laneInterval);
386 
395 void getRightProjectedEdge(LaneInterval const &laneInterval, point::ENUEdge &enuEdge);
396 
405 void getRightProjectedEdge(LaneInterval const &laneInterval, point::ECEFEdge &ecefEdge);
406 
415 void getRightProjectedEdge(LaneInterval const &laneInterval, point::GeoEdge &geoEdge);
416 
425 point::ENUEdge getRightProjectedENUEdge(LaneInterval const &laneInterval);
426 
435 point::ECEFEdge getRightProjectedECEFEdge(LaneInterval const &laneInterval);
436 
445 point::GeoEdge getRightProjectedGeoEdge(LaneInterval const &laneInterval);
446 
455 void getLeftEdge(LaneInterval const &laneInterval, point::ENUEdge &enuEdge);
456 
465 void getLeftEdge(LaneInterval const &laneInterval, point::ECEFEdge &ecefEdge);
466 
475 void getLeftEdge(LaneInterval const &laneInterval, point::GeoEdge &geoEdge);
476 
485 point::ENUEdge getLeftENUEdge(LaneInterval const &laneInterval);
486 
495 point::ECEFEdge getLeftECEFEdge(LaneInterval const &laneInterval);
496 
505 point::GeoEdge getLeftGeoEdge(LaneInterval const &laneInterval);
506 
515 void getLeftProjectedEdge(LaneInterval const &laneInterval, point::ENUEdge &enuEdge);
516 
525 void getLeftProjectedEdge(LaneInterval const &laneInterval, point::ECEFEdge &ecefEdge);
526 
535 void getLeftProjectedEdge(LaneInterval const &laneInterval, point::GeoEdge &geoEdge);
536 
545 point::ENUEdge getLeftProjectedENUEdge(LaneInterval const &laneInterval);
546 
555 point::ECEFEdge getLeftProjectedECEFEdge(LaneInterval const &laneInterval);
556 
565 point::GeoEdge getLeftProjectedGeoEdge(LaneInterval const &laneInterval);
566 
570 lane::GeoBorder getGeoBorder(LaneInterval const &laneInterval);
571 
575 lane::ECEFBorder getECEFBorder(LaneInterval const &laneInterval);
576 
583 lane::ENUBorder getENUBorder(LaneInterval const &laneInterval);
584 
593 lane::ENUBorder getENUProjectedBorder(LaneInterval const &laneInterval);
594 
607 LaneInterval shortenIntervalFromBegin(LaneInterval const &laneInterval, physics::Distance const &distance);
608 
621 LaneInterval shortenIntervalFromEnd(LaneInterval const &laneInterval, physics::Distance const &distance);
622 
633 LaneInterval restrictIntervalFromBegin(LaneInterval const &laneInterval, physics::Distance const &distance);
634 
645 LaneInterval extendIntervalUntilEnd(LaneInterval const &laneInterval);
646 
658 LaneInterval cutIntervalAtStart(LaneInterval const &laneInterval, physics::ParametricValue const &newIntervalStart);
659 
670 LaneInterval extendIntervalUntilStart(LaneInterval const &laneInterval);
671 
682 LaneInterval extendIntervalFromStart(LaneInterval const &laneInterval, physics::Distance const &distance);
683 
694 LaneInterval extendIntervalFromEnd(LaneInterval const &laneInterval, physics::Distance const &distance);
695 
707 LaneInterval cutIntervalAtEnd(LaneInterval const &laneInterval, physics::ParametricValue const &newIntervalEnd);
708 
712 restriction::SpeedLimitList getSpeedLimits(LaneInterval const &laneInterval);
713 
717 void getMetricRanges(LaneInterval const &laneInterval,
718  physics::MetricRange &lengthRange,
719  physics::MetricRange &widthRange);
720 
721 } // namespace route
722 } // namespace map
723 } // namespace ad
ad
namespace ad
Definition: GeometryStoreItem.hpp:28
ad::map::route::getRightProjectedENUEdge
point::ENUEdge getRightProjectedENUEdge(LaneInterval const &laneInterval)
get right edge of the lane interval as ENUEdge using projection to find the start of the edge
ad::map::route::getLeftProjectedEdge
void getLeftProjectedEdge(LaneInterval const &laneInterval, point::ENUEdge &enuEdge)
get Left edge of the lane interval as ENUEdge using projection to find the start of the edge
ad::map::route::getRightProjectedEdge
void getRightProjectedEdge(LaneInterval const &laneInterval, point::ENUEdge &enuEdge)
get right edge of the lane interval as ENUEdge using projection to find the start of the edge
ad::map::route::shortenIntervalFromBegin
LaneInterval shortenIntervalFromBegin(LaneInterval const &laneInterval, physics::Distance const &distance)
shorten the LaneInterval about a given physics::Distance. Will remove at the begin of the LaneInterva...
ad::map::route::getRightECEFEdge
point::ECEFEdge getRightECEFEdge(LaneInterval const &laneInterval)
get right edge of the lane interval as ECEFEdge
ad::map::route::overlapsInterval
bool overlapsInterval(LaneInterval const &laneInterval, physics::ParametricRange const &range)
checks if the range overlaps with the interval
Definition: LaneIntervalOperation.hpp:283
ad::map::route::isRouteDirectionNegative
bool isRouteDirectionNegative(LaneInterval const &laneInterval)
checks if the direction of this route interval is negative in respect to the lane geometry
Definition: LaneIntervalOperation.hpp:146
ad::map::route::toParametricRange
physics::ParametricRange toParametricRange(route::LaneInterval const &laneInterval)
convert lane interval to ParametricRange
Definition: LaneIntervalOperation.hpp:69
ad::map::route::extendIntervalFromEnd
LaneInterval extendIntervalFromEnd(LaneInterval const &laneInterval, physics::Distance const &distance)
extend the lane interval by moving its end position by physics::Distance
ad::map::lane::ECEFBorder
DataType ECEFBorder.
Definition: ECEFBorder.hpp:44
ad::map::route::getLeftENUEdge
point::ENUEdge getLeftENUEdge(LaneInterval const &laneInterval)
get left edge of the lane interval as ENUEdge
ad::map::route::getMetricRanges
void getMetricRanges(LaneInterval const &laneInterval, physics::MetricRange &lengthRange, physics::MetricRange &widthRange)
get the metric ranges of the lane interval
ad::map::route::getENUProjectedBorder
lane::ENUBorder getENUProjectedBorder(LaneInterval const &laneInterval)
get the enu borders of this lane
ad::map::route::getSpeedLimits
restriction::SpeedLimitList getSpeedLimits(LaneInterval const &laneInterval)
get the speed limits of the lane interval
ad::map::route::calcDuration
physics::Duration calcDuration(LaneInterval const &laneInterval)
calculate the Duration of the provided lane interval as duration value
ad::map::point::ParaPoint
DataType ParaPoint.
Definition: ParaPoint.hpp:48
ad::map::route::getLeftProjectedGeoEdge
point::GeoEdge getLeftProjectedGeoEdge(LaneInterval const &laneInterval)
get left edge of the lane interval as GeoEdge using projection to find the start of the edge
ad::map::route::calcLength
physics::Distance calcLength(LaneInterval const &laneInterval)
calculate the length of the provided lane interval as physics::Distance value
ad::map::route::shortenIntervalFromEnd
LaneInterval shortenIntervalFromEnd(LaneInterval const &laneInterval, physics::Distance const &distance)
shorten the LaneInterval about a given physics::Distance. Will remove at the end of the LaneInterval
ad::map::route::getRightEdge
void getRightEdge(LaneInterval const &laneInterval, point::ENUEdge &enuEdge)
get right edge of the lane interval as ENUEdge
ad::map::route::extendIntervalFromStart
LaneInterval extendIntervalFromStart(LaneInterval const &laneInterval, physics::Distance const &distance)
extend the lane interval by moving its start position by physics::Distance
ad::map::route::isAfterInterval
bool isAfterInterval(LaneInterval const &laneInterval, physics::ParametricValue const parametricOffset)
checks if the parametric offset is after the interval
Definition: LaneIntervalOperation.hpp:208
ad::map::route::getLeftGeoEdge
point::GeoEdge getLeftGeoEdge(LaneInterval const &laneInterval)
get left edge of the lane interval as GeoEdge
ad::map::route::cutIntervalAtEnd
LaneInterval cutIntervalAtEnd(LaneInterval const &laneInterval, physics::ParametricValue const &newIntervalEnd)
cut the LaneInterval at a given parametric point. Will remove at the end of the LaneInterval
ad::map::route::isEndOfInterval
bool isEndOfInterval(LaneInterval const &laneInterval, point::ParaPoint const &point)
checks if the point marks the end of the interval
Definition: LaneIntervalOperation.hpp:126
ad::map::point::distance
physics::Distance distance(BoundingSphere const &left, BoundingSphere const &right)
Computes distance between BoundingSpheres.
Definition: BoundingSphereOperation.hpp:29
ad::map::route::isStartOfInterval
bool isStartOfInterval(LaneInterval const &laneInterval, point::ParaPoint const &point)
checks if the point marks the start of the interval
Definition: LaneIntervalOperation.hpp:114
ad::map::lane::LaneId
DataType LaneId.
Definition: LaneId.hpp:66
ad::map::route::getLeftProjectedENUEdge
point::ENUEdge getLeftProjectedENUEdge(LaneInterval const &laneInterval)
get left edge of the lane interval as ENUEdge using projection to find the start of the edge
ad::map::route::isRouteDirectionPositive
bool isRouteDirectionPositive(LaneInterval const &laneInterval)
checks if the direction of this route interval is positive in respect to the lane geometry
ad::map::route::getLeftEdge
void getLeftEdge(LaneInterval const &laneInterval, point::ENUEdge &enuEdge)
get Left edge of the lane interval as ENUEdge
ad::map::route::getRightGeoEdge
point::GeoEdge getRightGeoEdge(LaneInterval const &laneInterval)
get right edge of the lane interval as GeoEdge
ad::map::route::getLeftProjectedECEFEdge
point::ECEFEdge getLeftProjectedECEFEdge(LaneInterval const &laneInterval)
get left edge of the lane interval as ECEFEdge using projection to find the start of the edge
ad::map::route::getECEFBorder
lane::ECEFBorder getECEFBorder(LaneInterval const &laneInterval)
get the ecef borders of this lane
Types.hpp
ad::map::route::getSignedDistance
physics::ParametricValue getSignedDistance(LaneInterval const &laneInterval, point::ParaPoint const &first, point::ParaPoint const &second)
get the signed parametric physics::Distance between two parametric points respecting the laneInterval...
ad::map::route::getENUBorder
lane::ENUBorder getENUBorder(LaneInterval const &laneInterval)
get the enu borders of this lane
ad::map::route::isRouteDirectionAlignedWithDrivingDirection
bool isRouteDirectionAlignedWithDrivingDirection(LaneInterval const &laneInterval)
checks if the route direction is aligned with the nominal driving direction of the lane
ad::map::point::GeoEdge
std::vector<::ad::map::point::GeoPoint > GeoEdge
DataType GeoEdge.
Definition: GeoEdge.hpp:42
ad::map::route::getRightProjectedGeoEdge
point::GeoEdge getRightProjectedGeoEdge(LaneInterval const &laneInterval)
get right edge of the lane interval as GeoEdge using projection to find the start of the edge
ad::map::route::isBeforeInterval
bool isBeforeInterval(LaneInterval const &laneInterval, physics::ParametricValue const parametricOffset)
checks if the parametric offset is before the interval
Definition: LaneIntervalOperation.hpp:246
Types.hpp
ad::map::route::cutIntervalAtStart
LaneInterval cutIntervalAtStart(LaneInterval const &laneInterval, physics::ParametricValue const &newIntervalStart)
cut the LaneInterval at a given parametric point. Will remove at the start of the LaneInterval
ad::map::restriction::SpeedLimitList
std::vector<::ad::map::restriction::SpeedLimit > SpeedLimitList
DataType SpeedLimitList.
Definition: SpeedLimitList.hpp:42
ad::map::route::getUnsignedDistance
physics::ParametricValue getUnsignedDistance(LaneInterval const &laneInterval, point::ParaPoint const &first, point::ParaPoint const &second)
get the unsigned parametric physics::Distance between two parametric points
ad::map::route::getRightENUEdge
point::ENUEdge getRightENUEdge(LaneInterval const &laneInterval)
get right edge of the lane interval as ENUEdge
ad::map::lane::GeoBorder
DataType GeoBorder.
Definition: GeoBorder.hpp:44
ad::map::route::getGeoBorder
lane::GeoBorder getGeoBorder(LaneInterval const &laneInterval)
get the geo borders of this lane
ad::map::point::ECEFEdge
std::vector<::ad::map::point::ECEFPoint > ECEFEdge
DataType ECEFEdge.
Definition: ECEFEdge.hpp:42
ad::map::route::getProjectedParametricOffsetOnNeighborLane
physics::ParametricValue getProjectedParametricOffsetOnNeighborLane(LaneInterval const &currentInterval, LaneInterval const &neighborInterval, physics::ParametricValue const &parametricOffset)
project a given parametric position (offset) to the center line of the given neighbor lane
ad::map::route::LaneInterval
DataType LaneInterval.
Definition: LaneInterval.hpp:51
Types.hpp
ad::map::route::extendIntervalUntilStart
LaneInterval extendIntervalUntilStart(LaneInterval const &laneInterval)
extend the lane interval until the start of the lane reached
ad::map::point::ParaPoint::parametricOffset
::ad::physics::ParametricValue parametricOffset
Definition: ParaPoint.hpp:136
ad::map::route::isWithinInterval
bool isWithinInterval(LaneInterval const &laneInterval, physics::ParametricValue const &parametricOffset)
checks if the parametric offset is within the interval
Definition: LaneIntervalOperation.hpp:163
ad::map::route::getIntervalEnd
point::ParaPoint getIntervalEnd(LaneInterval const &laneInterval)
get interval end as ParaPoint
Definition: LaneIntervalOperation.hpp:58
ad::map::route::getRightProjectedECEFEdge
point::ECEFEdge getRightProjectedECEFEdge(LaneInterval const &laneInterval)
get right edge of the lane interval as ECEFEdge using projection to find the start of the edge
ad::map::route::getLeftECEFEdge
point::ECEFEdge getLeftECEFEdge(LaneInterval const &laneInterval)
get left edge of the lane interval as ECEFEdge
ad::map::route::restrictIntervalFromBegin
LaneInterval restrictIntervalFromBegin(LaneInterval const &laneInterval, physics::Distance const &distance)
Restrict length of the LaneInterval to a given physics::Distance from start.
ad::map::route::calcParametricLength
physics::ParametricValue calcParametricLength(LaneInterval const &laneInterval)
calculate the length of the provided lane interval as parametric value
Definition: LaneIntervalOperation.hpp:309
ad::map::lane::ENUBorder
DataType ENUBorder.
Definition: ENUBorder.hpp:44
ad::map::route::isDegenerated
bool isDegenerated(LaneInterval const &laneInterval)
checks if the interval is degenerated
Definition: LaneIntervalOperation.hpp:195
ad::map::point::ENUEdge
std::vector<::ad::map::point::ENUPoint > ENUEdge
DataType ENUEdge.
Definition: ENUEdge.hpp:42
ad::map::route::getIntervalStart
point::ParaPoint getIntervalStart(LaneInterval const &laneInterval)
class defining a route interval with one lane
Definition: LaneIntervalOperation.hpp:40
ad::map::point::ParaPoint::laneId
::ad::map::lane::LaneId laneId
Definition: ParaPoint.hpp:125
ad::map::route::extendIntervalUntilEnd
LaneInterval extendIntervalUntilEnd(LaneInterval const &laneInterval)
extend the lane interval until the end of the lane reached