31 leftBound_{std::move(leftBound)},
32 rightBound_{std::move(rightBound)},
33 regulatoryElements_{std::move(regulatoryElements)} {}
46 template <
typename RegElemT>
48 return utils::transformSharedPtr<const RegElemT>(regulatoryElements_);
50 template <
typename RegElemT>
52 return utils::transformSharedPtr<RegElemT>(regulatoryElements_);
65 bool hasCustomCenterline()
const;
68 void resetCache()
const;
147 :
ConstPrimitive{std::make_shared<LaneletData>(
id, leftBound, rightBound, attributes, regulatoryElements)} {}
150 explicit ConstLanelet(
const std::shared_ptr<const LaneletData>& data,
bool inverted =
false)
165 return inverted() ? constData()->rightBound().
invert() : constData()->leftBound();
174 return inverted() ? constData()->leftBound().
invert() : constData()->rightBound();
181 template <
typename RegElemT>
183 return constData()->regulatoryElementsAs<RegElemT>();
194 return inverted() ? constData()->centerline().
invert() : constData()->centerline();
215 bool inverted_{
false};
228 Lanelet(
const std::shared_ptr<const LaneletData>&,
bool inverted) =
delete;
234 using Primitive::leftBound;
235 using Primitive::leftBound2d;
236 using Primitive::leftBound3d;
246 using Primitive::rightBound;
247 using Primitive::rightBound2d;
248 using Primitive::rightBound3d;
263 inverted() ? data()->setRightBound(bound.
invert()) : data()->setLeftBound(bound);
268 inverted() ? data()->setLeftBound(bound.
invert()) : data()->setRightBound(bound);
279 inverted() ? data()->setCenterline(centerline.
invert()) : data()->setCenterline(centerline);
287 if (regElem ==
nullptr) {
290 data()->regulatoryElements().push_back(std::move(regElem));
295 auto& regElems = data()->regulatoryElements();
296 auto remove =
std::find(regElems.begin(), regElems.end(), regElem);
297 if (
remove != regElems.end()) {
298 regElems.erase(
remove);
304 using Primitive::regulatoryElements;
305 using Primitive::regulatoryElementsAs;
308 template <
typename RegElemT>
310 return data()->regulatoryElementsAs<RegElemT>();
324 : laneletData_{llet.
constData()}, inverted_{llet.inverted()} {}
333 bool expired() const noexcept {
return laneletData_.expired(); }
337 bool inverted_{
false};
351 Lanelet lock()
const {
return Lanelet(std::const_pointer_cast<LaneletData>(laneletData_.lock()), inverted_); }
380 template <
typename T>
382 return isCategory<T, traits::LaneletTag>();
386 template <
typename T,
typename RetT>
387 using IfLL = std::enable_if_t<traits::isLaneletT<T>(), RetT>;
398 template <
typename T,
typename U>
399 struct hash<
std::pair<U, T>> {
401 return std::hash<U>()(x.first) ^ std::hash<T>()(x.second);
std::shared_ptr< ConstLineString3d > centerline_
const RegulatoryElementPtrs & regulatoryElements()
Return regulatoryElements that affect this lanelet.
ConstLineString2d centerline2d() const
get the (cached) centerline of this lanelet in 2d. To be used in context of geometric calculations...
std::shared_ptr< RegulatoryElement > RegulatoryElementPtr
ConstLanelet(Id id=InvalId)
Constructs an empty or invalid lanelet.
std::enable_if_t< traits::isLaneletT< T >(), RetT > IfLL
auto find(ContainerT &&c, const ValueT &val)
size_t operator()(const std::pair< U, T > x) const noexcept
std::vector< RegulatoryElementPtr > RegulatoryElementPtrs
bool has(const ConstLanelet &ll, Id id)
returns true if element of a regulatory element has a matching Id
LineString3d rightBound_
represents the right bound
ConstLineString3d rightBound3d() const
get the right bound in 3d. To be used over rightBound where geometric calculations are required...
void addRegulatoryElement(RegulatoryElementPtr regElem)
Add a new regulatory element.
bool removeRegulatoryElement(const RegulatoryElementPtr ®Elem)
Removes a regulatory element, returns true on success.
RegulatoryElementConstPtrs regulatoryElements() const
get a list of regulatory elements that affect this lanelet
ConstLineString2d rightBound2d() const
get the right bound in 2d. To be used over rightBound where geometric calculations are required...
ConstLineString3d invert() const noexcept
create a new, inverted linestring from this one
auto transform(Iterator begin, Iterator end, const Func f)
std::ostream & operator<<(std::ostream &stream, const Attribute &obj)
Lanelet(const LaneletDataPtr &data, bool inverted)
std::vector< std::shared_ptr< RegElemT > > regulatoryElementsAs()
Get the regulatoryElements that could be converted to RegElemT.
HybridMap< Attribute, decltype(AttributeNamesString::Map)&, AttributeNamesString::Map > AttributeMap
The famous (mutable) lanelet class.
bool operator==(const Attribute &lhs, const Attribute &rhs)
Common data management class for all Lanelet-Typed objects.
std::weak_ptr< const LaneletData > laneletData_
void resetCache() const
resets the internal cache of the centerline
void setCenterline(const LineString3d ¢erline)
Identifies PolygonPrimitives.
std::vector< std::shared_ptr< const RegElemT > > regulatoryElementsAs() const
get the regulatoryElements that could be converted to RegElemT
LineString2d rightBound2d()
get the right bound in 2d. To be used over rightBound where geometric calculations are required...
A normal 3d linestring with immutable data.
ConstLineString3d centerline3d() const
get the (cached) centerline of this lanelet in 3d. To be used in context of geometric calculations...
LaneletData(Id id, LineString3d leftBound, LineString3d rightBound, const AttributeMap &attributes=AttributeMap(), RegulatoryElementPtrs regulatoryElements=RegulatoryElementPtrs())
Constructs a new, valid LaneletData object.
bool expired() const noexcept
tests whether the WeakLanelet is still valid
ConstLanelet(const std::shared_ptr< const LaneletData > &data, bool inverted=false)
Construct from the data of a different Lanelet.
Combines multiple linestrings to one polygon in 3d.
ConstWeakLanelet(const ConstLanelet &llet)
ConstLineString2d leftBound2d() const
get the left bound in 2d. To be used over leftBound where geometric calculations are required...
bool inverted() const
returns if this is an inverted lanelet
RegulatoryElementPtrs & regulatoryElements()
WeakLanelet(const Lanelet &llet)
void setRightBound(const LineString3d &bound)
Sets a new right bound and resets the cached centerline.
void setLeftBound(const LineString3d &bound)
Sets a new left bound and resets the cached centerline.
A normal 3d linestring with mutable data.
const std::shared_ptr< const Data > & constData() const
get the internal data of this primitive
const ConstLineString3d & rightBound() const
ConstLineString3d centerline() const
get the (cached) centerline of this lanelet.
bool operator!=(const Attribute &lhs, const Attribute &rhs)
const LineString3d & leftBound()
ConstLanelet(Id id, const LineString3d &leftBound, const LineString3d &rightBound, const AttributeMap &attributes=AttributeMap(), const RegulatoryElementPtrs ®ulatoryElements=RegulatoryElementPtrs())
Constructs a lanelet from id, attributes, regulatoryElements and bounds.
LineString2d leftBound2d()
get the left bound in 2d. To be used over leftBound where geometric calculations are required...
LineString3d leftBound_
represents the left bound
ConstLineString3d leftBound() const
get the left bound.
SharedPtrs in lanelet2 must never point to null. If this is violated, this exception is thrown (usual...
std::shared_ptr< const RegulatoryElement > RegulatoryElementConstPtr
Basic Primitive class for all primitives of lanelet2.
std::vector< std::shared_ptr< const RegElemT > > regulatoryElementsAs() const
Base class for all mutable Primitives of lanelet2.
LineString3d leftBound()
Get the left bound.
RegulatoryElementPtrs regulatoryElements_
regulatory elements
LineString3d rightBound()
Get the right bound.
ConstLineString3d rightBound() const
get the right bound.
Common data class for all lanelet primitivesThis class provides the data that all lanelet primitives ...
bool hasCustomCenterline() const
Returns whether the centerline has been overridden by setCenterline.
const ConstLineString3d & leftBound() const
std::shared_ptr< LaneletData > LaneletDataPtr
std::vector< RegulatoryElementConstPtr > RegulatoryElementConstPtrs
ConstLanelet invert() const
returns the inverted lanelet
LineString3d invert() const noexcept
create a new, inverted linestring from this one
Lanelet invert() const
non-const version to invert a lanelet
Lanelet lock() const
Obtains the original Lanelet.
BoundingBox2d to2D(const BoundingBox3d &primitive)
LineString3d leftBound3d()
get the left bound in 3d. To be used over leftBound where geometric calculations are required...
RegulatoryElementConstPtrs regulatoryElements() const
Combines multiple linestrings to one polygon in 2d.
constexpr bool isLaneletT()
A normal 2d linestring with immutable data.
std::vector< std::shared_ptr< RegElemT > > regulatoryElementsAs()
A normal 2d linestring with mutable data.
ConstLineString3d rightBound() const
get the right bound.
ConstLineString3d leftBound3d() const
get the left bound in 3d. To be used over leftBound where geometric calculations are required...
ConstLanelet lock() const
Obtains the original ConstLanelet.
const LineString3d & rightBound()
constexpr Id InvalId
indicates a primitive that is not part of a map
LineString3d rightBound3d()
get the right bound in 3d. To be used over rightBound where geometric calculations are required...