17 template <
typename Po
intT>
18 using Segment = std::pair<PointT, PointT>;
54 template <
typename Po
intT>
62 template <
typename Po
intT>
70 std::transform(primitive.begin(), primitive.end(), ls2d.begin(), utils::to2D<BasicPoint3d>);
74 template <
typename Po
intT>
86 template <
typename Po
intT>
90 template <
typename Po
intT>
104 template <
typename T>
107 template <
typename Po
intT>
120 template <
typename T>
124 return Points3d::iterator(it);
126 template <
typename T>
156 template <
typename IteratorT = const_iterator>
157 IteratorT
begin(
bool inverted)
const noexcept {
161 template <
typename IteratorT = iterator>
162 IteratorT
begin(
bool inverted) noexcept {
163 return inverted ? IteratorT(
iterator(points_.rbegin())) : IteratorT(
iterator(points_.begin()));
166 template <
typename IteratorT = const_iterator>
167 IteratorT
end(
bool inverted)
const noexcept {
170 template <
typename IteratorT = iterator>
171 IteratorT
end(
bool inverted) noexcept {
172 return inverted ? IteratorT(
iterator(points_.rend())) : IteratorT(
iterator(points_.end()));
174 auto size() const noexcept {
return points_.size(); }
175 auto empty() const noexcept {
return points_.empty(); }
177 return inverted ? points_[points_.size() - 1 - idx] : points_[idx];
179 const ConstPoint3d&
front(
bool inverted)
const noexcept {
return inverted ? points_.back() : points_.front(); }
180 const ConstPoint3d&
back(
bool inverted)
const noexcept {
return inverted ? points_.front() : points_.back(); }
219 template <
typename Po
intT>
245 :
ConstPrimitive{std::make_shared<LineStringData>(
id, std::move(points), attributes)} {}
252 template <
typename OtherT>
257 bool inverted() const noexcept {
return inverted_; }
260 size_t size() const noexcept {
return constData()->size(); }
263 bool empty() const noexcept {
return constData()->empty(); }
278 const_iterator end() const noexcept {
return constData()->template end<const_iterator>(inverted()); }
305 assert(idx < size());
306 return constData()->at(inverted(), idx);
326 assert(idx < size());
327 auto first = begin() + idx;
328 auto second = idx + 1 == size() ? begin() : first + 1;
333 size_t numSegments() const noexcept {
return size() <= 1 ? 0 : size() - 1; }
347 template <
typename LineStringT>
359 bool inverted_{
false};
363 template <
typename ConstLineStringT>
373 using Base::inverted;
379 template <
typename OtherT>
382 explicit LineStringImpl(
const std::shared_ptr<const LineStringData>&,
bool inverted) =
delete;
385 explicit LineStringImpl(
const std::shared_ptr<LineStringData>& data,
bool inverted) :
Base(data, inverted) {}
402 points() = std::move(rhs);
416 return inverted() ? Iter::reversed(fwIter + 1) : Iter(fwIter);
420 template <
typename InIter>
425 using RViter = std::reverse_iterator<Viter>;
427 return RIter(Points3d::reverse_iterator(fwIter + 1));
430 return RIter(fwIter);
435 inverted() ? void(points().insert(points().begin(),
Point3d(point))) : points().push_back(
Point3d(point));
445 return inverted() ? Iter::reversed(it) : Iter(it);
450 inverted() ? void(points().erase(points().begin())) : points().pop_back();
454 void reserve(
size_t num) { points().reserve(num); }
460 std::reverse(begin(), end());
462 points().resize(num);
464 std::reverse(begin(), end());
477 using Base::operator[];
490 PointType&
back() {
return inverted() ? points().front() : points().back(); }
494 assert(idx < size());
495 return points()[inverted() ? points().size() - 1 - idx : idx];
503 assert(idx < size());
504 const auto snd = idx + 1;
505 return SegmentType(
operator[](idx),
operator[](snd == size() ? 0 : snd));
625 assert(idx < size());
626 const auto snd = idx + 1;
627 return {operator[](idx), operator[](snd == size() ? 0 : snd)};
676 assert(idx < size());
677 const auto snd = idx + 1;
678 return {operator[](idx), operator[](snd == size() ? 0 : snd)};
683 stream <<
"[id: " << obj.
id();
685 stream <<
", inverted";
687 stream <<
" point ids: ";
688 for (
auto it = obj.
begin(); it != obj.
end(); ++it) {
690 if (std::next(it) != obj.
end()) {
694 return stream <<
"]";
698 stream <<
"[id: " << obj.
id();
700 stream <<
", inverted";
702 stream <<
" point ids: ";
703 for (
auto it = obj.
begin(); it != obj.
end(); ++it) {
705 if (std::next(it) != obj.
end()) {
709 return stream <<
"]";
713 template <
typename LhsPo
intT,
typename RhsPo
intT>
717 template <
typename LhsPo
intT,
typename RhsPo
intT>
719 return !(lhs == rhs);
722 template <
typename Po
intT>
724 return lhs.
size() == rhs.size() && std::equal(lhs.
begin(), lhs.
end(), rhs.begin());
727 template <
typename Po
intT>
732 template <
typename Po
intT>
734 return !(lhs == rhs);
737 template <
typename Po
intT>
739 return !(lhs == rhs);
743 template <
typename T>
745 return isCategory<T, traits::LineStringTag>();
749 template <
typename T,
typename Enable =
void>
752 template <
typename T>
756 template <
typename T>
761 template <
typename LineStringT>
764 template <
typename LineStringT>
770 template <
typename T,
typename RetT>
771 using IfLS = std::enable_if_t<traits::isLinestringT<T>(), RetT>;
773 template <
typename T1,
typename T2,
typename RetT>
774 using IfLS2 = std::enable_if_t<traits::isLinestringT<T1>() && traits::isLinestringT<T2>(), RetT>;
789 template <
typename Po
intT>
791 return std::any_of(ls.
begin(), ls.
end(), [&
id](
const auto& elem) {
return elem.id() ==
id; });
802 struct hash<lanelet::ConstLineString3d> :
public lanelet::HashBase<lanelet::ConstLineString3d> {};
806 struct hash<lanelet::ConstLineString2d> :
public lanelet::HashBase<lanelet::ConstLineString2d> {};
808 struct hash<lanelet::ConstHybridLineString2d> :
public lanelet::HashBase<lanelet::ConstHybridLineString2d> {};
810 struct hash<lanelet::ConstHybridLineString3d> :
public lanelet::HashBase<lanelet::ConstHybridLineString3d> {};
iterator insert(iterator position, const PointType &point)
Inserts an element at a specific position.
std::vector< BasicPoint3d > BasicPoints3d
multiple simple 3d-points
BasicIterator begin() const noexcept
BasicPoint3d Iterator to begin.
std::vector< Eigen::Vector2d, Eigen::aligned_allocator< Eigen::Vector2d > > BasicPoints2d
multiple simple 2d-points
Segment< ConstPrimitiveType< PointT > > ConstType
std::enable_if_t< traits::isLinestringT< T1 >() &&traits::isLinestringT< T2 >(), RetT > IfLS2
Id id() const noexcept
get the unique id of this primitive
iterator end()
mutable iterator to the end of the elements of this vector.
BasicIterator begin() const noexcept
BasicPoint2d Iterator to begin.
Segment< ConstPoint3d > ConstSegment3d
LineStringData(Id id, Points3d points, AttributeMap attributes)
BasicLineString2d HybridType
Implementation template class that is common to all non-const types.
BasicPoints3d BasicLineString3d
SegmentType segment(size_t idx) noexcept
returns the n-th segment. If n equals size() -1, the segment from back() to front() is returned...
BasicLineString3d ThreeDType
internal::SelectLsIteratorT< const ConstPointType > const_iterator
const ConstPoint3d & front(bool inverted) const noexcept
Implementation template class that is common to all LineStrings.
SegmentType segment(size_t idx) const noexcept
returns the n-th segment. If n equals size() -1, the segment from back() to front() is returned...
A Linestring that returns BasicPoint2d instead of Point2d.
typename PointTraits< PointT >::BasicPoint BasicPointT
IteratorT begin(bool inverted) const noexcept
Segment< traits::BasicPointT< PointT > > HybridType
typename SelectLsIterator< T >::Iterator SelectLsIteratorT
ConstHybridLineString2d(const LineString2d &ls)
void pop_back()
removes element from the end
iterator erase(iterator position)
Removes point, returns iterator to the next point.
traits::MutablePointT< Point3d > MutablePointType
linestring will return this point type
ConstLineString3d invert() const noexcept
create a new, inverted linestring from this one
auto transform(Iterator begin, Iterator end, const Func f)
Eigen::Vector3d BasicPoint3d
a simple 3d-point
Specialization of traits for linestrings.
std::ostream & operator<<(std::ostream &stream, const Attribute &obj)
const ConstPoint3d & back(bool inverted) const noexcept
BasicLineString3d MutableType
std::pair< PointT, PointT > Segment
HybridMap< Attribute, decltype(AttributeNamesString::Map)&, AttributeNamesString::Map > AttributeMap
iterator insert(iterator position, InIter start, InIter end)
Inserts an range of elements at a specific position.
LineStringImpl(const std::shared_ptr< LineStringData > &data, bool inverted)
Construct from linestring data.
typename PointTraits< PointT >::ConstPoint ConstPointT
traits::BasicPointT< Point3d > BasicPointType
std::enable_if_t< traits::isLinestringT< T >(), RetT > IfLS
bool operator==(const Attribute &lhs, const Attribute &rhs)
Segment< BasicPoint3d > BasicSegment3d
const ConstPointType & back() const noexcept
returns the last point (if it exist)
const ConstPointType & front() const noexcept
returns the first point (if it exist)
ConstLineString3d()=default
const_iterator end() const noexcept
Returns an iterator to end of the points.
typename iterator::difference_type difference_type
Segment< ConstPoint2d > ConstSegment2d
Segment< Point3d > Segment3d
ConstHybridLineString3d(const ConstLineString3d &ls)
PointType & front()
get a refernce to the first element (make sure it exists)
ConstSegmentType segment(size_t idx) const noexcept
returns the n-th segment. If n equals size() -1, the segment from back() to front() is returned...
IteratorT begin(bool inverted) noexcept
Identifies bounding boxes.
A normal 3d linestring with immutable data.
Segment< BasicPointType > SegmentType
const BasicPointType & front() const noexcept
Get first BasicPoint2d.
const BasicPointType & operator[](size_t idx) const noexcept
access BasicPoint3d at specific position
ConstLineString2d invert() const noexcept
create a new, inverted linestring from this one
typename detail::HybridType< LineStringT >::Type HybridT
size_t size() const noexcept
Return the number of points in this linestring.
Identifies RegulatoryElementPrimitives.
std::vector< Point3d > Points3d
bool has(const ConstLineStringImpl< PointT > &ls, Id id)
returns true if element of a lanelet primitive has a matching Id
Segment< TwoD< PointT > > TwoDType
typename LineStringTraits< T >::HybridType Type
Segment< MutablePrimitiveType< PointT > > MutableType
LineStringImpl & operator=(std::vector< PointType > rhs)
Copy assign from a normal vector. The Id of this object is unchanged.
ConstLineString2d()=default
traits::ConstPrimitiveType< SegmentType > ConstSegmentType
LineString2d invert() const noexcept
create a new, inverted linestring from this one
SegmentType segment(size_t idx) const noexcept
returns the n-th segment. If n equals size() -1, the segment from back() to front() is returned...
ConstLineStringImpl(const ConstLineStringImpl< OtherT > &other)
construct from other ConstLineStrings
A normal 3d linestring with mutable data.
const std::shared_ptr< const LineStringData > & constData() const
get the internal data of this primitive
ConstLineStringImpl(const std::shared_ptr< const LineStringData > &data, bool inverted=false)
Constructs a linestring from the data object of another linestring.
PointType & back()
get a reference to the last element if it exists
auto size() const noexcept
void reserve(size_t num)
request a change in capacity
internal::ReverseAndForwardIterator< Points3d::iterator > iterator
bool operator!=(const Attribute &lhs, const Attribute &rhs)
auto empty() const noexcept
internal::SelectBasicLineStringT< BasicPointType > BasicLineString
BasicIterator end() const noexcept
BasicPoint3d Iterator to past-the-end.
LineStringImpl & operator=(std::vector< Point3d > &&rhs)
Move assign from a normal vector. Id and attributes stay unchanged.
BasicLineString basicLineString() const noexcept
Create a basic linestring (ie a vector of Eigen Points)
BasicPoints2d BasicLineString2d
bool empty() const noexcept
return if there are any points in this object
typename PrimitiveTraits< PrimitiveT >::ConstType ConstPrimitiveType
Utility for determinig the matching const type for a primitive.
const BasicPointType & operator[](size_t idx) const noexcept
access element at specific position
const BasicPointType & back() const noexcept
Get last BasicPoint2d.
typename SelectBasicLineString< T >::Type SelectBasicLineStringT
Basic Primitive class for all primitives of lanelet2.
Base class for all mutable Primitives of lanelet2.
A Linestring that returns BasicPoint3d instead of Point3d.
const BasicPointType & back() const noexcept
Get last BasicPoint3d.
const ConstPointType & operator[](size_t idx) const noexcept
returns the point at this position
IteratorT end(bool inverted) noexcept
BasicLineString3d ThreeDType
auto transform(Container &&c, Func f)
Segment< Point3d > SegmentType
ConstHybridLineString2d invert() const noexcept
Returns an inverted linestring, O(0)
Segment< BasicPointType > SegmentType
Common data class for all lanelet primitivesThis class provides the data that all lanelet primitives ...
ConstHybridLineString2d(const ConstLineString2d &ls)
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > BasicPoint2d
a simple 2d-point
auto toBasicSegment(const Segment< PointT > &s)
BasicLineString2d TwoDType
BasicLineString2d TwoDType
const BasicPointType & front() const noexcept
Get first BasicPoint3d.
Points3d::const_iterator pointIter(internal::ReverseAndForwardIterator< Points3d::iterator > it)
BasicIterator basicEnd() const noexcept
returns a normal iterator for the internal point type at end
LineStringImpl(const LineStringImpl< OtherT > &other)
Construct from other (mutable!) LineStrings.
BasicIterator end() const noexcept
BasicPoint2d Iterator to past-the-end.
bool inverted() const noexcept
Returns whether this is an inverted linestring.
auto toBasicPoint(const PointT &point) -> std::enable_if_t< PointTraits< PointT >::IsPrimitive, BasicPointT< PointT >>
BasicLineString2d to2D< BasicLineString3d >(const BasicLineString3d &primitive)
typename LineStringTraits< T >::HybridType Type
PointType & operator[](size_t idx)
access element at specific position
IteratorT end(bool inverted) const noexcept
BasicLineString3d ConstType
LineString3d invert() const noexcept
create a new, inverted linestring from this one
BasicLineString2d MutableType
BasicLineString3d HybridType
typename PointTraits< PointT >::MutablePoint MutablePointT
const_iterator begin() const noexcept
Returns an iterator to the start of the points.
BasicIterator basicBegin() const noexcept
returns a normal iterator to the internal point type at begin
Container invert(const Container &cont)
A normal 2d linestring with immutable data.
Segment< ThreeD< PointT > > ThreeDType
BasicLineString2d ConstType
void push_back(const PointType &point)
inserts a new element at the end
ConstHybridLineString3d invert() const noexcept
Returns an inverted linestring, O(0)
A normal 2d linestring with mutable data.
ConstLineStringImpl(Id id=InvalId, Points3d points=Points3d(), const AttributeMap &attributes=AttributeMap())
Constructs a LineString or similar from an Id and a list of points.
Segment< BasicPoint2d > BasicSegment2d
Specialization of traits for points.
typename LineStringT::HybridType HybridType
ConstPointType value_type
size_t numSegments() const noexcept
Returns the number of (geometrically valid) segments.
traits::ConstPointT< Point3d > ConstPointType
constexpr bool isLinestringT()
const ConstPoint3d & at(bool inverted, size_t idx) const noexcept
constexpr auto toHybrid(const LineStringT ls)
constexpr Id InvalId
indicates a primitive that is not part of a map
Points3d & points()
returns a reference to the points
ConstHybridLineString3d(const LineString3d &ls)
iterator begin()
mutable iterator for the elements of this vector.
Segment< Point2d > Segment2d