ad_map_access
CoreIntersection.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 <map>
15 #include <memory>
16 #include <sstream>
17 #include <string>
18 #include <vector>
19 #include "ad/map/lane/Types.hpp"
20 #include "ad/map/match/Types.hpp"
21 #include "ad/map/point/Types.hpp"
23 
25 namespace ad {
27 namespace map {
29 namespace intersection {
30 
35 
39 typedef std::shared_ptr<CoreIntersection> CoreIntersectionPtr;
40 
44 typedef std::shared_ptr<CoreIntersection const> CoreIntersectionConstPtr;
45 
59 {
60 public:
64  static bool isLanePartOfAnIntersection(lane::LaneId const laneId);
65 
73  static bool isRoutePartOfAnIntersection(route::FullRoute const &route);
74 
82  static bool isIntersectionOnRoute(route::FullRoute const &route);
83 
93  static bool isRoadSegmentEnteringIntersection(route::RouteIterator const &routeIterator,
94  route::RoadSegmentList::const_iterator &routePreviousSegmentIter);
95 
102  bool objectRouteCrossesIntersection(route::FullRoute const &objectRoute) const;
103 
105  physics::Distance objectDistanceToIntersection(match::Object const &object) const;
106 
109 
111  lane::LaneIdSet const &internalLanes() const;
112 
114  lane::LaneIdSet const &entryLanes() const;
115 
117  point::ParaPointList const &entryParaPoints() const;
118 
120  lane::LaneIdSet const &exitLanes() const;
121 
123  point::ParaPointList const &exitParaPoints() const;
124 
127  {
128  return mInternalLanesBoundingSphere;
129  }
130 
139 
153  static std::vector<CoreIntersectionPtr> getCoreIntersectionsFor(lane::LaneIdSet const &laneIds);
154 
168  static std::vector<CoreIntersectionPtr> getCoreIntersectionsFor(lane::LaneIdList const &laneIds);
169 
175  static std::vector<CoreIntersectionPtr> getCoreIntersectionsForMap();
176 
182  static CoreIntersectionPtr getCoreIntersectionFor(match::MapMatchedPosition const &mapMatchedPosition);
183 
190  static std::vector<CoreIntersectionPtr> getCoreIntersectionsForInLaneMatches(point::ENUPoint const &position);
191 
202  static std::vector<CoreIntersectionPtr>
203  getCoreIntersectionsForInLaneMatches(match::MapMatchedPositionConfidenceList const &mapMatchedPositionConfidenceList);
204 
215  static std::vector<CoreIntersectionPtr>
217 
218 protected:
219  CoreIntersection() = default;
220 
222  bool isLanePartOfCoreIntersection(lane::LaneId const laneId) const;
223 
224  void extractLanesOfCoreIntersection(lane::LaneId const laneId);
225 
226  enum SuccessorMode
227  {
228  OwnIntersection,
229  AnyIntersection
230  };
231 
232  bool isLanePartOfIntersection(lane::LaneId const laneId, SuccessorMode const successorMode) const;
233 
240  std::pair<lane::LaneIdSet, lane::LaneIdSet>
241  getDirectSuccessorsInLaneDirection(lane::LaneId const laneId, SuccessorMode const successorMode) const;
242 
250  SuccessorMode const successorMode) const;
251 
260  SuccessorMode const successorMode) const;
261 
270  SuccessorMode const successorMode) const;
271 
278  lane::LaneIdSet getAllReachableOutgoingLanes(lane::LaneId const laneId, SuccessorMode const successorMode) const;
279 
287  std::pair<lane::LaneIdSet, lane::LaneIdSet>
288  getAllReachableInternalAndOutgoingLanes(lane::LaneId const laneId, SuccessorMode const successorMode) const;
289 
290  point::ParaPoint getEntryParaPointOfExternalLane(lane::LaneId const &laneId) const;
291  point::ParaPoint getExitParaPointOfExternalLane(lane::LaneId const &laneId) const;
292  point::ParaPoint getEntryParaPointOfInternalLane(lane::LaneId const &laneId) const;
293  point::ParaPoint getExitParaPointOfInternalLane(lane::LaneId const &laneId) const;
294 
296  lane::LaneIdSet mInternalLanes{};
297 
299  lane::LaneIdSet mEntryLanes{};
300 
303 
305  lane::LaneIdSet mExitLanes{};
306 
309 
315  std::map<lane::LaneId, lane::LaneIdSet> mOverlapping;
316  std::map<lane::LaneId, lane::LaneIdSet> mSuccessor;
317  std::map<lane::LaneId, lane::LaneIdSet> mPredecessor;
318 
319  point::BoundingSphere mInternalLanesBoundingSphere;
320 
321 private:
322  explicit CoreIntersection(lane::LaneId const &laneId);
323 
324  void checkAndInsertEntryLane(lane::LaneId const laneId);
325  void checkAndInsertExitLane(lane::LaneId const laneId);
326  void processContactsForLane(lane::Lane const &lane, lane::ContactLane const &contact);
327 
328  template <typename CONTAINER>
329  static std::vector<CoreIntersectionPtr> getCoreIntersectionsForLaneIds(CONTAINER const &laneIds);
330 };
331 
332 } // namespace intersection
333 } // namespace map
334 } // namespace ad
335 
336 namespace std {
337 
347 std::ostream &operator<<(std::ostream &os, ::ad::map::intersection::CoreIntersection const &intersection);
348 
352 static inline std::string to_string(::ad::map::intersection::CoreIntersection const &intersection)
353 {
354  stringstream sstream;
355  sstream << intersection;
356  return sstream.str();
357 }
358 } // namespace std
ad::map::intersection::CoreIntersection::getDirectSuccessorsInLaneDirectionWithinIntersection
lane::LaneIdSet getDirectSuccessorsInLaneDirectionWithinIntersection(lane::LaneId const laneId, SuccessorMode const successorMode) const
Provide the direct successor lane segments in lane direction within the intersection.
ad
namespace ad
Definition: GeometryStoreItem.hpp:28
ad::map::intersection::CoreIntersection::isLanePartOfAnIntersection
static bool isLanePartOfAnIntersection(lane::LaneId const laneId)
check if a lane is part of any intersection
ad::map::route::RouteIterator
struct defining iterator information on a route
Definition: RouteOperation.hpp:41
ad::map::intersection::CoreIntersection::mExitLanes
lane::LaneIdSet mExitLanes
lanes going out of the intersection
Definition: CoreIntersection.hpp:305
Types.hpp
ad::map::intersection::CoreIntersection::exitParaPoints
const point::ParaPointList & exitParaPoints() const
ad::map::intersection::CoreIntersection::isRoadSegmentEnteringIntersection
static bool isRoadSegmentEnteringIntersection(route::RouteIterator const &routeIterator, route::RoadSegmentList::const_iterator &routePreviousSegmentIter)
check if the road segment enters an intersection
ad::map::intersection::CoreIntersection::getCoreIntersectionsForMap
static std::vector< CoreIntersectionPtr > getCoreIntersectionsForMap()
retrieve all CoreIntersection objects of the map
ad::map::intersection::CoreIntersection::mExitParaPoints
point::ParaPointList mExitParaPoints
lanes going out of the intersection represented as ParaPoint
Definition: CoreIntersection.hpp:308
ad::map::intersection::CoreIntersection::entryLanes
const lane::LaneIdSet & entryLanes() const
ad::map::match::Object
DataType Object.
Definition: Object.hpp:43
ad::map::intersection::CoreIntersection::entryParaPoints
const point::ParaPointList & entryParaPoints() const
ad::map::intersection::CoreIntersectionPtr
std::shared_ptr< CoreIntersection > CoreIntersectionPtr
typedef for shared_ptr of CoreIntersection class
Definition: CoreIntersection.hpp:34
ad::map::point::ParaPoint
DataType ParaPoint.
Definition: ParaPoint.hpp:48
ad::map::intersection::CoreIntersectionConstPtr
std::shared_ptr< CoreIntersection const > CoreIntersectionConstPtr
typedef for shared_ptr of const CoreIntersection class
Definition: CoreIntersection.hpp:44
ad::map::intersection::CoreIntersection::getCoreIntersectionFor
static CoreIntersectionPtr getCoreIntersectionFor(lane::LaneId const &laneId)
retrieve the core intersection for the given laneId
ad::map::intersection::CoreIntersection::objectWithinIntersection
bool objectWithinIntersection(match::MapMatchedObjectBoundingBox const &object) const
ad::map::intersection::CoreIntersection::getDirectSuccessorsInLaneDirection
std::pair< lane::LaneIdSet, lane::LaneIdSet > getDirectSuccessorsInLaneDirection(lane::LaneId const laneId, SuccessorMode const successorMode) const
Provide the direct successor lane segments in lane direction within and outside of the intersection.
ad::map::lane::LaneIdList
std::vector<::ad::map::lane::LaneId > LaneIdList
DataType LaneIdList.
Definition: LaneIdList.hpp:44
ad::map::intersection::CoreIntersection::exitLanes
const lane::LaneIdSet & exitLanes() const
std::to_string
std::string to_string(::ad::map::access::GeometryStoreItem const &value)
overload of the std::to_string for GeometryStoreItem
Definition: GeometryStoreItem.hpp:183
ad::map::intersection::CoreIntersection::getLaneAndAllSuccessorsInLaneDirectionWithinIntersection
lane::LaneIdSet getLaneAndAllSuccessorsInLaneDirectionWithinIntersection(lane::LaneId const laneId, SuccessorMode const successorMode) const
Provide the successor lane segments in lane direction within the intersection recursively until the i...
ad::map::intersection::CoreIntersection::isRoutePartOfAnIntersection
static bool isRoutePartOfAnIntersection(route::FullRoute const &route)
check if any lane in the route is part of any intersection
ad::map::point::ENUPoint
DataType ENUPoint.
Definition: ENUPoint.hpp:51
ad::map::intersection::CoreIntersection::isIntersectionOnRoute
static bool isIntersectionOnRoute(route::FullRoute const &route)
check if there is an intersection for the given route
ad::map::intersection::CoreIntersection::isLanePartOfCoreIntersection
bool isLanePartOfCoreIntersection(lane::LaneId const laneId) const
check if given lane is inside the intersection
ad::map::lane::LaneId
DataType LaneId.
Definition: LaneId.hpp:66
ad::map::point::ParaPointList
std::vector<::ad::map::point::ParaPoint > ParaPointList
DataType ParaPointList.
Definition: ParaPointList.hpp:42
ad::map::match::MapMatchedPositionConfidenceList
std::vector<::ad::map::match::MapMatchedPosition > MapMatchedPositionConfidenceList
DataType MapMatchedPositionConfidenceList.
Definition: MapMatchedPositionConfidenceList.hpp:44
ad::map::intersection::CoreIntersection::mInternalLanes
lane::LaneIdSet mInternalLanes
all lanes inside the intersection
Definition: CoreIntersection.hpp:296
ad::map::point::BoundingSphere
DataType BoundingSphere.
Definition: BoundingSphere.hpp:46
ad::map::intersection::CoreIntersection::getCoreIntersectionsFor
static std::vector< CoreIntersectionPtr > getCoreIntersectionsFor(lane::LaneIdSet const &laneIds)
retrieve all CoreIntersection objects for the given lane Ids
ad::map::match::MapMatchedObjectBoundingBox
DataType MapMatchedObjectBoundingBox.
Definition: MapMatchedObjectBoundingBox.hpp:45
Types.hpp
ad::map::intersection::CoreIntersection::getCoreIntersectionsForInLaneMatches
static std::vector< CoreIntersectionPtr > getCoreIntersectionsForInLaneMatches(point::ENUPoint const &position)
retrieve the core intersection for the given ENU position
ad::map::intersection::CoreIntersection::internalLanes
const lane::LaneIdSet & internalLanes() const
ad::map::intersection::CoreIntersection::getAllReachableInternalAndOutgoingLanes
std::pair< lane::LaneIdSet, lane::LaneIdSet > getAllReachableInternalAndOutgoingLanes(lane::LaneId const laneId, SuccessorMode const successorMode) const
Provide the outgoing lane segments that are reachable in lane direction as well as the intersection i...
ad::map::intersection::CoreIntersection::objectDistanceToIntersection
physics::Distance objectDistanceToIntersection(match::Object const &object) const
calculate and return the physics::Distance of the object to the intersection
ad::map::intersection::CoreIntersection::objectRouteCrossesIntersection
bool objectRouteCrossesIntersection(route::FullRoute const &objectRoute) const
Types.hpp
ad::map::lane::ContactLane
DataType ContactLane.
Definition: ContactLane.hpp:47
ad::map::intersection::CoreIntersection::getBoundingSphere
const point::BoundingSphere & getBoundingSphere() const
Definition: CoreIntersection.hpp:126
RouteOperation.hpp
ad::map::intersection::CoreIntersection::mOverlapping
std::map< lane::LaneId, lane::LaneIdSet > mOverlapping
Definition: CoreIntersection.hpp:315
ad::map::intersection::CoreIntersection::getAllReachableOutgoingLanes
lane::LaneIdSet getAllReachableOutgoingLanes(lane::LaneId const laneId, SuccessorMode const successorMode) const
Provide the outgoing lane segments that are reachable in lane direction.
ad::map::route::FullRoute
DataType FullRoute.
Definition: FullRoute.hpp:59
ad::map::intersection::CoreIntersection::getAllSuccessorsInLaneDirectionWithinIntersection
lane::LaneIdSet getAllSuccessorsInLaneDirectionWithinIntersection(lane::LaneId const laneId, SuccessorMode const successorMode) const
Provide the successor lane segments in lane direction within the intersection recursively until the i...
ad::map::match::MapMatchedPosition
DataType MapMatchedPosition.
Definition: MapMatchedPosition.hpp:49
ad::map::intersection::CoreIntersection::mEntryParaPoints
point::ParaPointList mEntryParaPoints
lanes going into the intersection represented as ParaPoint
Definition: CoreIntersection.hpp:302
ad::map::lane::Lane
DataType Lane.
Definition: Lane.hpp:56
ad::map::intersection::CoreIntersection
Definition: CoreIntersection.hpp:58
ad::map::intersection::CoreIntersection::mEntryLanes
lane::LaneIdSet mEntryLanes
lanes going into the intersection
Definition: CoreIntersection.hpp:299