Each primitive in lanelet2 has its own layer in the map. More...
#include <LaneletMap.h>
Classes | |
struct | Tree |
Public Types | |
using | const_iterator = internal::TransformIterator< typename Map::const_iterator, const ConstPrimitiveT, internal::PairConverter< const ConstPrimitiveT > > |
iterator that gives a const primitive, not a std::pair More... | |
using | ConstPrimitiveT = traits::ConstPrimitiveType< T > |
using | ConstPrimitiveVec = std::vector< ConstPrimitiveT > |
using | ConstSearchFunction = std::function< bool(const internal::SearchBoxT< T > &box, const ConstPrimitiveT &prim)> |
using | iterator = internal::TransformIterator< typename Map::iterator, PrimitiveT, internal::PairConverter< PrimitiveT > > |
iterator that gives the primitive when dereferencing, not a std:pair More... | |
using | Map = std::unordered_map< Id, T > |
using | OptConstPrimitiveT = Optional< ConstPrimitiveT > |
using | OptPrimitiveT = Optional< PrimitiveT > |
using | PrimitiveT = T |
using | PrimitiveVec = std::vector< PrimitiveT > |
using | SearchFunction = std::function< bool(const internal::SearchBoxT< T > &box, const PrimitiveT &prim)> |
Public Member Functions | |
iterator | begin () |
iterator to beginning More... | |
const_iterator | begin () const |
iterator to beginning of the elements (not ordered by id!) More... | |
bool | empty () const |
returns whether this layer contains something More... | |
iterator | end () |
iterator to end More... | |
const_iterator | end () const |
iterator to end of the elements More... | |
bool | exists (Id id) const |
checks whether an element exists in this layer More... | |
iterator | find (Id id) |
non-const version of finding an element More... | |
const_iterator | find (Id id) const |
find returns an iterator to an element if it exists More... | |
std::vector< PrimitiveT > | findUsages (const traits::ConstPrimitiveType< traits::OwnedT< PrimitiveT >> &primitive) |
finds usages of an owned type within this layer More... | |
std::vector< ConstPrimitiveT > | findUsages (const traits::ConstPrimitiveType< traits::OwnedT< PrimitiveT >> &primitive) const |
finds usages of an owned type within this layer More... | |
PrimitiveT | get (Id id) |
returns an element for this id if it exists More... | |
ConstPrimitiveT | get (Id id) const |
returns an element for this id if it exists More... | |
PrimitiveVec | nearest (const BasicPoint2d &point, unsigned n) |
ConstPrimitiveVec | nearest (const BasicPoint2d &point, unsigned n) const |
search for the n nearest elements to a point More... | |
PrimitiveVec | nearest (const Point2d &point, unsigned n) |
ConstPrimitiveVec | nearest (const Point2d &point, unsigned n) const |
OptConstPrimitiveT | nearestUntil (const BasicPoint2d &point, const ConstSearchFunction &func) const |
repeatedly calls a user-defined predicate until it returns true. More... | |
OptPrimitiveT | nearestUntil (const BasicPoint2d &point, const SearchFunction &func) |
OptConstPrimitiveT | nearestUntil (const ConstPoint2d &point, const ConstSearchFunction &func) const |
OptPrimitiveT | nearestUntil (const Point2d &point, const SearchFunction &func) |
PrimitiveLayer & | operator= (const PrimitiveLayer &rhs)=delete |
PrimitiveLayer (const PrimitiveLayer &rhs)=delete | |
PrimitiveLayer (const PrimitiveLayer::Map &primitives) | |
PrimitiveLayer (const PrimitiveLayer::Map &primitives) | |
PrimitiveVec | search (const BoundingBox2d &area) |
ConstPrimitiveVec | search (const BoundingBox2d &area) const |
searches for elements within a search area More... | |
OptConstPrimitiveT | searchUntil (const BoundingBox2d &area, const ConstSearchFunction &func) const |
searches within search area until a search function returns true. More... | |
OptPrimitiveT | searchUntil (const BoundingBox2d &area, const SearchFunction &func) |
size_t | size () const |
returns number of elements in this layer More... | |
Id | uniqueId () const |
returns a unique id. it is guaranteed that the id is not used within this layer More... | |
Protected Member Functions | |
void | add (const Area &area) |
void | add (const Lanelet &ll) |
void | add (const Point3d &p) |
void | add (const PrimitiveLayer< RegulatoryElementPtr >::PrimitiveT &element) |
void | add (const PrimitiveT &element) |
PrimitiveLayer & | operator= (PrimitiveLayer &&rhs) noexcept |
PrimitiveLayer (const Map &primitives=Map()) | |
PrimitiveLayer (PrimitiveLayer &&rhs) noexcept | |
void | remove (Id element) |
~PrimitiveLayer () noexcept | |
Protected Attributes | |
Map | elements_ |
the list of elements in this layer More... | |
std::unique_ptr< Tree > | tree_ |
Hides boost trees from you/the compiler. More... | |
Friends | |
class | LaneletMap |
class | LaneletMapLayers |
class | LaneletSubmap |
Each primitive in lanelet2 has its own layer in the map.
This template class defines the common interface for these layers. It is only implemented for lanelet primitives and should not be instanciated with any other type.
Layers are an integral part of LaneletMap, they can not be created or modified without a LaneletMap object.
Internally, the elements are identified by their id, therefore it is absolutely important that an id is unique within one layer.
Definition at line 39 of file LaneletMap.h.
using lanelet::PrimitiveLayer< T >::const_iterator = internal::TransformIterator<typename Map::const_iterator, const ConstPrimitiveT, internal::PairConverter<const ConstPrimitiveT> > |
iterator that gives a const primitive, not a std::pair
Definition at line 56 of file LaneletMap.h.
using lanelet::PrimitiveLayer< T >::ConstPrimitiveT = traits::ConstPrimitiveType<T> |
Definition at line 42 of file LaneletMap.h.
using lanelet::PrimitiveLayer< T >::ConstPrimitiveVec = std::vector<ConstPrimitiveT> |
Definition at line 44 of file LaneletMap.h.
using lanelet::PrimitiveLayer< T >::ConstSearchFunction = std::function<bool(const internal::SearchBoxT<T>& box, const ConstPrimitiveT& prim)> |
Definition at line 155 of file LaneletMap.h.
using lanelet::PrimitiveLayer< T >::iterator = internal::TransformIterator<typename Map::iterator, PrimitiveT, internal::PairConverter<PrimitiveT> > |
iterator that gives the primitive when dereferencing, not a std:pair
Definition at line 51 of file LaneletMap.h.
using lanelet::PrimitiveLayer< T >::Map = std::unordered_map<Id, T> |
Definition at line 43 of file LaneletMap.h.
using lanelet::PrimitiveLayer< T >::OptConstPrimitiveT = Optional<ConstPrimitiveT> |
Definition at line 46 of file LaneletMap.h.
using lanelet::PrimitiveLayer< T >::OptPrimitiveT = Optional<PrimitiveT> |
Definition at line 47 of file LaneletMap.h.
using lanelet::PrimitiveLayer< T >::PrimitiveT = T |
Definition at line 41 of file LaneletMap.h.
using lanelet::PrimitiveLayer< T >::PrimitiveVec = std::vector<PrimitiveT> |
Definition at line 45 of file LaneletMap.h.
using lanelet::PrimitiveLayer< T >::SearchFunction = std::function<bool(const internal::SearchBoxT<T>& box, const PrimitiveT& prim)> |
Definition at line 156 of file LaneletMap.h.
|
delete |
|
explicitprotected |
Definition at line 329 of file LaneletMap.cpp.
|
protecteddefaultnoexcept |
|
protecteddefaultnoexcept |
lanelet::PrimitiveLayer< Lanelet >::PrimitiveLayer | ( | const PrimitiveLayer< T >::Map & | primitives | ) |
Definition at line 337 of file LaneletMap.cpp.
lanelet::PrimitiveLayer< Area >::PrimitiveLayer | ( | const PrimitiveLayer< T >::Map & | primitives | ) |
Definition at line 345 of file LaneletMap.cpp.
|
protected |
Definition at line 392 of file LaneletMap.cpp.
|
protected |
Definition at line 399 of file LaneletMap.cpp.
|
protected |
Definition at line 406 of file LaneletMap.cpp.
|
protected |
Definition at line 413 of file LaneletMap.cpp.
|
protected |
Definition at line 383 of file LaneletMap.cpp.
iterator lanelet::PrimitiveLayer< T >::begin | ( | ) |
iterator to beginning
PrimitiveLayer< T >::iterator lanelet::PrimitiveLayer< T >::begin |
iterator to beginning of the elements (not ordered by id!)
Definition at line 476 of file LaneletMap.cpp.
|
inline |
returns whether this layer contains something
Definition at line 147 of file LaneletMap.h.
iterator lanelet::PrimitiveLayer< T >::end | ( | ) |
iterator to end
PrimitiveLayer< T >::iterator lanelet::PrimitiveLayer< T >::end |
bool lanelet::PrimitiveLayer< T >::exists | ( | Id | id | ) | const |
checks whether an element exists in this layer
id | the id identifying the element |
Definition at line 354 of file LaneletMap.cpp.
PrimitiveLayer< T >::iterator lanelet::PrimitiveLayer< T >::find | ( | Id | id | ) |
non-const version of finding an element
id | the id to look for |
Definition at line 486 of file LaneletMap.cpp.
PrimitiveLayer< T >::const_iterator lanelet::PrimitiveLayer< T >::find | ( | Id | id | ) | const |
find returns an iterator to an element if it exists
id | id to look for |
Note that dereferencing the iterator will give you only the primitive, not a std::pair as usual with normal std::maps!
Definition at line 471 of file LaneletMap.cpp.
std::vector< typename PrimitiveLayer< T >::PrimitiveT > lanelet::PrimitiveLayer< T >::findUsages | ( | const traits::ConstPrimitiveType< traits::OwnedT< PrimitiveT >> & | primitive | ) |
finds usages of an owned type within this layer
This is the non-const version to find usages of a primitive in a layer.
Definition at line 427 of file LaneletMap.cpp.
std::vector<ConstPrimitiveT> lanelet::PrimitiveLayer< T >::findUsages | ( | const traits::ConstPrimitiveType< traits::OwnedT< PrimitiveT >> & | primitive | ) | const |
finds usages of an owned type within this layer
Finds e.g. points owned by linestrings in the lanelet layer.
The relations are stored by a map internally, so this is just a fast map lookup.
PrimitiveLayer< T >::PrimitiveT lanelet::PrimitiveLayer< T >::get | ( | Id | id | ) |
returns an element for this id if it exists
id | the id identifying the element |
NoSuchPrimitiveError | if the element does not exist |
Definition at line 359 of file LaneletMap.cpp.
PrimitiveLayer< T >::ConstPrimitiveT lanelet::PrimitiveLayer< T >::get | ( | Id | id | ) | const |
returns an element for this id if it exists
id | the id identifying the element |
NoSuchPrimitiveError | if the element does not exist |
Definition at line 371 of file LaneletMap.cpp.
PrimitiveLayer< T >::PrimitiveVec lanelet::PrimitiveLayer< T >::nearest | ( | const BasicPoint2d & | point, |
unsigned | n | ||
) |
Definition at line 533 of file LaneletMap.cpp.
PrimitiveLayer< T >::ConstPrimitiveVec lanelet::PrimitiveLayer< T >::nearest | ( | const BasicPoint2d & | point, |
unsigned | n | ||
) | const |
search for the n nearest elements to a point
point | the point for the query |
n | number of elements returned |
Note that this function does not yield accurate results for all primitives except points. For all other primitives, "nearest" is determined by the bounding box of the object. For regulatory elements, this will be the bounding box of all parameters of the regulatory element. For Lanelets, it will be the bounding box alround the polygon.
If you are not happy with this, have a look at nearestUntil, or one of the free functions, like geometry::findNearest.
Definition at line 526 of file LaneletMap.cpp.
|
inline |
Definition at line 206 of file LaneletMap.h.
|
inline |
Definition at line 205 of file LaneletMap.h.
PrimitiveLayer< T >::OptConstPrimitiveT lanelet::PrimitiveLayer< T >::nearestUntil | ( | const BasicPoint2d & | point, |
const ConstSearchFunction & | func | ||
) | const |
repeatedly calls a user-defined predicate until it returns true.
Starting at the primitive with the closest bounding-box distance to the query point iteratively calls func until true is returned. This can be used for iterative queries.
Definition at line 541 of file LaneletMap.cpp.
PrimitiveLayer< T >::OptPrimitiveT lanelet::PrimitiveLayer< T >::nearestUntil | ( | const BasicPoint2d & | point, |
const SearchFunction & | func | ||
) |
Definition at line 547 of file LaneletMap.cpp.
|
inline |
Definition at line 219 of file LaneletMap.h.
|
inline |
Definition at line 222 of file LaneletMap.h.
|
delete |
|
protecteddefaultnoexcept |
|
protected |
PrimitiveLayer< T >::PrimitiveVec lanelet::PrimitiveLayer< T >::search | ( | const BoundingBox2d & | area | ) |
Definition at line 507 of file LaneletMap.cpp.
PrimitiveLayer< T >::ConstPrimitiveVec lanelet::PrimitiveLayer< T >::search | ( | const BoundingBox2d & | area | ) | const |
searches for elements within a search area
area | the search area in the map |
The search is done by comparing bounding boxes, therefore this function might return false positives because the elements do not intersect with the area, but their bounding boxes do. To sort these out use lanelet::geometry::intersects or lanelet::geometry::overlaps.
Note that this function is also implemented for the point layer for consistency, even if it does not make sense for this type. It will always return an empty vector.
Definition at line 500 of file LaneletMap.cpp.
PrimitiveLayer< T >::OptConstPrimitiveT lanelet::PrimitiveLayer< T >::searchUntil | ( | const BoundingBox2d & | area, |
const ConstSearchFunction & | func | ||
) | const |
searches within search area until a search function returns true.
Starting by the object with the closest bounding box, searchUntil will pass primitives to func until the result is true. This is the returned object. If no such object exists, the Optional will be empty.
Definition at line 514 of file LaneletMap.cpp.
PrimitiveLayer< T >::OptPrimitiveT lanelet::PrimitiveLayer< T >::searchUntil | ( | const BoundingBox2d & | area, |
const SearchFunction & | func | ||
) |
Definition at line 520 of file LaneletMap.cpp.
|
inline |
returns number of elements in this layer
Definition at line 153 of file LaneletMap.h.
Id lanelet::PrimitiveLayer< T >::uniqueId |
returns a unique id. it is guaranteed that the id is not used within this layer
Several calls to uniqueId might or might not produce the same Id, as long as no element with this Id was added to the layer
Definition at line 553 of file LaneletMap.cpp.
|
friend |
Definition at line 237 of file LaneletMap.h.
|
friend |
Definition at line 238 of file LaneletMap.h.
|
friend |
Definition at line 239 of file LaneletMap.h.
|
protected |
the list of elements in this layer
Definition at line 249 of file LaneletMap.h.
|
protected |
Hides boost trees from you/the compiler.
Definition at line 250 of file LaneletMap.h.