primitives/LineString.h
Go to the documentation of this file.
1 #pragma once
2 #include <utility>
3 
11 
12 namespace lanelet {
13 
16 
17 template <typename PointT>
18 using Segment = std::pair<PointT, PointT>;
19 
26 
27 namespace traits {
28 template <>
35 };
36 template <>
37 struct LineStringTraits<BasicLineString2d> : public PrimitiveTraits<BasicLineString2d> {
40 };
41 template <>
48 };
49 template <>
50 struct LineStringTraits<BasicLineString3d> : public PrimitiveTraits<BasicLineString3d> {
53 };
54 template <typename PointT>
55 struct PrimitiveTraits<Segment<PointT>> {
61 };
62 template <typename PointT>
63 struct LineStringTraits<Segment<PointT>> : public PrimitiveTraits<Segment<PointT>> {
64  using PointType = PointT;
66 };
67 template <>
69  BasicLineString2d ls2d(primitive.size());
70  std::transform(primitive.begin(), primitive.end(), ls2d.begin(), utils::to2D<BasicPoint3d>);
71  return ls2d;
72 }
73 
74 template <typename PointT>
76  return std::make_pair(toBasicPoint(s.first), toBasicPoint(s.second));
77 }
78 
79 } // namespace traits
80 
81 namespace utils {
83 }
84 
85 namespace internal {
86 template <typename PointT>
89 };
90 template <typename PointT>
91 struct SelectLsIterator<const PointT> {
92  using Iterator =
94 };
95 template <>
98 };
99 template <>
100 struct SelectLsIterator<const Point3d> {
102 };
103 
104 template <typename T>
106 
107 template <typename PointT>
109 
110 template <>
113 };
114 
115 template <>
118 };
119 
120 template <typename T>
122 
124  return Points3d::iterator(it);
125 }
126 template <typename T>
129 };
130 template <>
131 struct SelectInsertIterator<typename SelectLsIterator<Point2d>::Iterator> {
133 };
134 
135 } // namespace internal
136 
140  public:
141  explicit LineStringData(Id id) : PrimitiveData(id) {}
142  LineStringData(Id id, Points3d points, AttributeMap attributes)
143  : PrimitiveData(id, std::move(attributes)), points_(std::move(points)) {}
144  // NOLINTNEXTLINE
146  // NOLINTNEXTLINE
148 
154  Points3d& points() { return points_; }
155 
156  template <typename IteratorT = const_iterator>
157  IteratorT begin(bool inverted) const noexcept {
158  return inverted ? IteratorT(const_iterator(points_.rbegin())) : IteratorT(const_iterator(points_.begin()));
159  }
160 
161  template <typename IteratorT = iterator>
162  IteratorT begin(bool inverted) noexcept {
163  return inverted ? IteratorT(iterator(points_.rbegin())) : IteratorT(iterator(points_.begin()));
164  }
165 
166  template <typename IteratorT = const_iterator>
167  IteratorT end(bool inverted) const noexcept {
168  return inverted ? IteratorT(const_iterator(points_.rend())) : IteratorT(const_iterator(points_.end()));
169  }
170  template <typename IteratorT = iterator>
171  IteratorT end(bool inverted) noexcept {
172  return inverted ? IteratorT(iterator(points_.rend())) : IteratorT(iterator(points_.end()));
173  }
174  auto size() const noexcept { return points_.size(); }
175  auto empty() const noexcept { return points_.empty(); }
176  const ConstPoint3d& at(bool inverted, size_t idx) const noexcept {
177  return inverted ? points_[points_.size() - 1 - idx] : points_[idx];
178  }
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(); }
181 
182  private:
184 }; // class LineStringData
185 
217 
219 template <typename PointT>
220 class ConstLineStringImpl : public ConstPrimitive<LineStringData> {
221  public:
222  // using declarations
228 
229  // NOLINTNEXTLINE
231  using iterator = const_iterator; // NOLINT
232  using value_type = ConstPointType; // NOLINT
233  using size_type = size_t; // NOLINT
234  using difference_type = typename iterator::difference_type; // NOLINT
235 
241 
243  explicit ConstLineStringImpl(Id id = InvalId, Points3d points = Points3d(),
244  const AttributeMap& attributes = AttributeMap())
245  : ConstPrimitive{std::make_shared<LineStringData>(id, std::move(points), attributes)} {}
246 
248  explicit ConstLineStringImpl(const std::shared_ptr<const LineStringData>& data, bool inverted = false)
249  : ConstPrimitive(data), inverted_{inverted} {}
250 
252  template <typename OtherT>
254  : ConstPrimitive(other.constData()), inverted_{other.inverted()} {}
255 
257  bool inverted() const noexcept { return inverted_; }
258 
260  size_t size() const noexcept { return constData()->size(); }
261 
263  bool empty() const noexcept { return constData()->empty(); }
264 
266 
271  const_iterator begin() const noexcept { return constData()->template begin<const_iterator>(inverted()); }
273 
278  const_iterator end() const noexcept { return constData()->template end<const_iterator>(inverted()); }
279 
281 
286  const ConstPointType& front() const noexcept { return constData()->front(inverted()); }
287 
295  const ConstPointType& back() const noexcept { return constData()->back(inverted()); }
296 
304  const ConstPointType& operator[](size_t idx) const noexcept {
305  assert(idx < size());
306  return constData()->at(inverted(), idx);
307  }
308 
313  BasicIterator basicBegin() const noexcept { return constData()->template begin<BasicIterator>(inverted_); }
314 
319  BasicIterator basicEnd() const noexcept { return constData()->template end<BasicIterator>(inverted_); }
320 
325  ConstSegmentType segment(size_t idx) const noexcept {
326  assert(idx < size());
327  auto first = begin() + idx;
328  auto second = idx + 1 == size() ? begin() : first + 1;
329  return ConstSegmentType(*first, *second);
330  }
331 
333  size_t numSegments() const noexcept { return size() <= 1 ? 0 : size() - 1; }
334 
345  BasicLineString basicLineString() const noexcept { return {basicBegin(), basicEnd()}; }
346 
347  template <typename LineStringT>
349 
350  protected:
351  // This class is only an implementation class and should never be instanciated
352  ConstLineStringImpl(ConstLineStringImpl&& rhs) noexcept = default;
353  ConstLineStringImpl& operator=(ConstLineStringImpl&& rhs) noexcept = default;
354  ConstLineStringImpl(const ConstLineStringImpl& rhs) = default;
355  ConstLineStringImpl& operator=(const ConstLineStringImpl& rhs) = default;
356  ~ConstLineStringImpl() noexcept = default;
357 
358  private:
359  bool inverted_{false};
360 }; // class ConstLineStringImpl
361 
363 template <typename ConstLineStringT>
364 class LineStringImpl : public Primitive<ConstLineStringT> {
365  protected:
367  using Base::data;
368 
369  public:
372  using Base::Base;
373  using Base::inverted;
374  using Base::size;
375  using SegmentType = typename Base::SegmentType;
376  LineStringImpl() = default; // Not inherited from base class
377 
379  template <typename OtherT>
380  explicit LineStringImpl(const LineStringImpl<OtherT>& other) : Base(other) {}
381 
382  explicit LineStringImpl(const std::shared_ptr<const LineStringData>&, bool inverted) = delete;
383 
385  explicit LineStringImpl(const std::shared_ptr<LineStringData>& data, bool inverted) : Base(data, inverted) {}
386 
388  LineStringImpl& operator=(std::vector<PointType> rhs) {
389  if (inverted()) {
390  points() = utils::transform(rhs.rbegin(), rhs.rend(), [](const auto& v) { return Point3d(v); });
391  } else {
392  points() = utils::transform(rhs.begin(), rhs.end(), [](const auto& v) { return Point3d(v); });
393  }
394  return *this;
395  }
396 
398  LineStringImpl& operator=(std::vector<Point3d>&& rhs) {
399  if (inverted()) {
400  utils::invert(rhs);
401  }
402  points() = std::move(rhs);
403  return *this;
404  }
405 
413  iterator insert(iterator position, const PointType& point) {
414  using Iter = LineStringData::iterator;
415  auto fwIter = points().insert(internal::pointIter(position), Point3d(point));
416  return inverted() ? Iter::reversed(fwIter + 1) : Iter(fwIter);
417  }
418 
420  template <typename InIter>
421  iterator insert(iterator position, InIter start, InIter end) {
422  using Viter = typename internal::SelectInsertIterator<InIter>::Type;
423  using RIter = LineStringData::iterator;
424  if (inverted()) {
425  using RViter = std::reverse_iterator<Viter>;
426  auto fwIter = points().insert(internal::pointIter(position), RViter(end), RViter(start));
427  return RIter(Points3d::reverse_iterator(fwIter + 1));
428  }
429  auto fwIter = points().insert(internal::pointIter(position), Viter(start), Viter(end));
430  return RIter(fwIter);
431  }
432 
434  void push_back(const PointType& point) { // NOLINT
435  inverted() ? void(points().insert(points().begin(), Point3d(point))) : points().push_back(Point3d(point));
436  }
437 
439  iterator erase(iterator position) { // NOLINT
440  if (inverted()) {
441  position += 1;
442  }
443  using Iter = LineStringData::iterator;
444  auto it = points().erase(internal::pointIter(position));
445  return inverted() ? Iter::reversed(it) : Iter(it);
446  }
447 
449  void pop_back() { // NOLINT
450  inverted() ? void(points().erase(points().begin())) : points().pop_back();
451  }
452 
454  void reserve(size_t num) { points().reserve(num); }
455 
458  void resize(size_t num) {
459  if (inverted()) {
460  std::reverse(begin(), end());
461  }
462  points().resize(num);
463  if (inverted()) {
464  std::reverse(begin(), end());
465  }
466  }
467 
470  void clear() { points().clear(); }
471 
472  // inherit the const versions
473  using Base::back;
474  using Base::begin;
475  using Base::end;
476  using Base::front;
477  using Base::operator[];
478  using Base::segment;
479 
481  iterator begin() { return inverted() ? iterator(points().rbegin()) : iterator(points().begin()); }
482 
484  iterator end() { return inverted() ? iterator(points().rend()) : iterator(points().end()); }
485 
487  PointType& front() { return inverted() ? points().back() : points().front(); }
488 
490  PointType& back() { return inverted() ? points().front() : points().back(); }
491 
493  PointType& operator[](size_t idx) {
494  assert(idx < size());
495  return points()[inverted() ? points().size() - 1 - idx : idx];
496  }
497 
502  SegmentType segment(size_t idx) noexcept {
503  assert(idx < size());
504  const auto snd = idx + 1;
505  return SegmentType(operator[](idx), operator[](snd == size() ? 0 : snd));
506  }
507 
508  protected:
509  // This class is only an implementation class and should never be instanciated
510  LineStringImpl(LineStringImpl&& rhs) noexcept = default;
511  LineStringImpl& operator=(LineStringImpl&& rhs) noexcept = default;
512  LineStringImpl(const LineStringImpl& rhs) = default;
513  LineStringImpl& operator=(const LineStringImpl& rhs) = default;
514  ~LineStringImpl() noexcept = default;
515  Points3d& points() { return data()->points(); }
516 }; // class LineStringImpl
517 
521 class ConstLineString3d : public ConstLineStringImpl<Point3d> {
522  public:
529  ConstLineString3d() = default; // Not inherited from base class
530 
532  ConstLineString3d invert() const noexcept { return ConstLineString3d{constData(), !inverted()}; }
533 };
534 
538 class LineString3d : public LineStringImpl<ConstLineString3d> {
539  public:
543  LineString3d() = default; // Not inherited from base class
544 
546  LineString3d invert() const noexcept { return LineString3d{data(), !inverted()}; }
547 };
548 
552 class ConstLineString2d : public ConstLineStringImpl<Point2d> {
553  public:
560  ConstLineString2d() = default; // Not inherited from base class
561 
563  ConstLineString2d invert() const noexcept { return ConstLineString2d{constData(), !inverted()}; }
564 };
565 
569 class LineString2d : public LineStringImpl<ConstLineString2d> {
570  public:
574  LineString2d() = default; // Not inherited from base class
575 
577  LineString2d invert() const noexcept { return LineString2d{data(), !inverted()}; }
578 };
579 
586  public:
588  using const_iterator = BasicIterator; // NOLINT
589  using iterator = BasicIterator; // NOLINT
594 
596  ConstHybridLineString3d() = default; // Not inherited from base class
599 
601  ConstHybridLineString3d invert() const noexcept { return ConstHybridLineString3d{constData(), !inverted()}; }
602 
604  BasicIterator begin() const noexcept { return basicBegin(); }
605 
607  BasicIterator end() const noexcept { return basicEnd(); }
608 
610  const BasicPointType& front() const noexcept { return ConstLineString3d::front().basicPoint(); }
611 
613  const BasicPointType& back() const noexcept { return ConstLineString3d::back().basicPoint(); }
614 
616  const BasicPointType& operator[](size_t idx) const noexcept {
617  return ConstLineString3d::operator[](idx).basicPoint();
618  }
619 
624  SegmentType segment(size_t idx) const noexcept {
625  assert(idx < size());
626  const auto snd = idx + 1;
627  return {operator[](idx), operator[](snd == size() ? 0 : snd)};
628  }
629 };
630 
637  public:
639  using const_iterator = BasicIterator; // NOLINT
640  using iterator = BasicIterator; // NOLINT
645 
647  ConstHybridLineString2d() = default; // Not inherited from base class
650 
652  ConstHybridLineString2d invert() const noexcept { return ConstHybridLineString2d{constData(), !inverted()}; }
653 
655  BasicIterator begin() const noexcept { return basicBegin(); }
656 
658  BasicIterator end() const noexcept { return basicEnd(); }
659 
661  const BasicPointType& front() const noexcept { return ConstLineString2d::front().basicPoint(); }
662 
664  const BasicPointType& back() const noexcept { return ConstLineString2d::back().basicPoint(); }
665 
667  const BasicPointType& operator[](size_t idx) const noexcept {
668  return ConstLineString2d::operator[](idx).basicPoint();
669  }
670 
675  SegmentType segment(size_t idx) const noexcept {
676  assert(idx < size());
677  const auto snd = idx + 1;
678  return {operator[](idx), operator[](snd == size() ? 0 : snd)};
679  }
680 };
681 
682 inline std::ostream& operator<<(std::ostream& stream, const ConstLineString2d& obj) {
683  stream << "[id: " << obj.id();
684  if (obj.inverted()) {
685  stream << ", inverted";
686  }
687  stream << " point ids: ";
688  for (auto it = obj.begin(); it != obj.end(); ++it) {
689  stream << it->id();
690  if (std::next(it) != obj.end()) {
691  stream << ", ";
692  }
693  }
694  return stream << "]";
695 }
696 
697 inline std::ostream& operator<<(std::ostream& stream, const ConstLineString3d& obj) {
698  stream << "[id: " << obj.id();
699  if (obj.inverted()) {
700  stream << ", inverted";
701  }
702  stream << " point ids: ";
703  for (auto it = obj.begin(); it != obj.end(); ++it) {
704  stream << it->id();
705  if (std::next(it) != obj.end()) {
706  stream << ", ";
707  }
708  }
709  return stream << "]";
710 }
711 
712 // comparison
713 template <typename LhsPointT, typename RhsPointT>
715  return lhs.constData() == rhs.constData() && lhs.inverted() == rhs.inverted();
716 }
717 template <typename LhsPointT, typename RhsPointT>
719  return !(lhs == rhs);
720 }
721 
722 template <typename PointT>
723 bool operator==(const ConstLineStringImpl<PointT>& lhs, const std::vector<PointT>& rhs) {
724  return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin());
725 }
726 
727 template <typename PointT>
728 bool operator==(const std::vector<PointT>& lhs, const ConstLineStringImpl<PointT>& rhs) {
729  return rhs == lhs;
730 }
731 
732 template <typename PointT>
733 bool operator!=(const ConstLineStringImpl<PointT>& lhs, const std::vector<PointT>& rhs) {
734  return !(lhs == rhs);
735 }
736 
737 template <typename PointT>
738 bool operator!=(const std::vector<PointT>& lhs, const ConstLineStringImpl<PointT>& rhs) {
739  return !(lhs == rhs);
740 }
741 
742 namespace traits {
743 template <typename T>
744 constexpr bool isLinestringT() {
745  return isCategory<T, traits::LineStringTag>();
746 }
747 
748 namespace detail {
749 template <typename T, typename Enable = void>
750 struct HybridType {};
751 
752 template <typename T>
753 struct HybridType<T, std::enable_if_t<traits::isLinestringT<T>(), void>> {
755 };
756 template <typename T>
757 struct HybridType<T, std::enable_if_t<!traits::isLinestringT<T>(), void>> {
759 };
760 } // namespace detail
761 template <typename LineStringT>
763 
764 template <typename LineStringT>
765 constexpr auto toHybrid(const LineStringT ls) {
766  return HybridT<LineStringT>(ls);
767 }
768 } // namespace traits
769 
770 template <typename T, typename RetT>
771 using IfLS = std::enable_if_t<traits::isLinestringT<T>(), RetT>;
772 
773 template <typename T1, typename T2, typename RetT>
774 using IfLS2 = std::enable_if_t<traits::isLinestringT<T1>() && traits::isLinestringT<T2>(), RetT>;
775 
776 namespace utils {
777 using traits::toHybrid;
778 
789 template <typename PointT>
790 bool has(const ConstLineStringImpl<PointT>& ls, Id id) {
791  return std::any_of(ls.begin(), ls.end(), [&id](const auto& elem) { return elem.id() == id; });
792 }
793 } // namespace utils
794 
795 } // namespace lanelet
796 
797 // Hash function for usage in containers
798 namespace std {
799 template <>
800 struct hash<lanelet::LineString3d> : public lanelet::HashBase<lanelet::LineString3d> {};
801 template <>
802 struct hash<lanelet::ConstLineString3d> : public lanelet::HashBase<lanelet::ConstLineString3d> {};
803 template <>
804 struct hash<lanelet::LineString2d> : public lanelet::HashBase<lanelet::LineString2d> {};
805 template <>
806 struct hash<lanelet::ConstLineString2d> : public lanelet::HashBase<lanelet::ConstLineString2d> {};
807 template <>
808 struct hash<lanelet::ConstHybridLineString2d> : public lanelet::HashBase<lanelet::ConstHybridLineString2d> {};
809 template <>
810 struct hash<lanelet::ConstHybridLineString3d> : public lanelet::HashBase<lanelet::ConstHybridLineString3d> {};
811 } // namespace std
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
Definition: Primitive.h:96
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)
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...
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
Definition: Traits.h:156
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
int64_t Id
Definition: Forward.h:198
auto transform(Iterator begin, Iterator end, const Func f)
Definition: Utilities.h:176
Eigen::Vector3d BasicPoint3d
a simple 3d-point
Specialization of traits for linestrings.
Definition: Traits.h:143
std::ostream & operator<<(std::ostream &stream, const Attribute &obj)
Definition: Attribute.h:369
const ConstPoint3d & back(bool inverted) const noexcept
std::pair< PointT, PointT > Segment
HybridMap< Attribute, decltype(AttributeNamesString::Map)&, AttributeNamesString::Map > AttributeMap
Definition: Attribute.h:371
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
Definition: Traits.h:159
traits::BasicPointT< Point3d > BasicPointType
std::enable_if_t< traits::isLinestringT< T >(), RetT > IfLS
bool operator==(const Attribute &lhs, const Attribute &rhs)
Definition: Attribute.h:179
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)
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.
Definition: Traits.h:8
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.
Definition: Traits.h:20
std::vector< Point3d > Points3d
Definition: Forward.h:34
bool has(const ConstLineStringImpl< PointT > &ls, Id id)
returns true if element of a lanelet primitive has a matching Id
Segment< MutablePrimitiveType< PointT > > MutableType
LineStringImpl & operator=(std::vector< PointType > rhs)
Copy assign from a normal vector. The Id of this object is unchanged.
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.
A mutable 3d point.
const std::shared_ptr< const LineStringData > & constData() const
get the internal data of this primitive
Definition: Primitive.h:178
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)
Definition: Attribute.h:180
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.
Definition: Traits.h:80
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.
Definition: Primitive.h:70
Base class for all mutable Primitives of lanelet2.
Definition: Primitive.h:243
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
auto transform(Container &&c, Func f)
Definition: Utilities.h:120
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 ...
Definition: Primitive.h:31
ConstHybridLineString2d(const ConstLineString2d &ls)
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > BasicPoint2d
a simple 2d-point
auto toBasicSegment(const Segment< PointT > &s)
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.
Id id
Definition: LaneletMap.cpp:63
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 >>
Definition: Traits.h:165
BasicLineString2d to2D< BasicLineString3d >(const BasicLineString3d &primitive)
An immutable 3d point.
PointType & operator[](size_t idx)
access element at specific position
IteratorT end(bool inverted) const noexcept
LineString3d invert() const noexcept
create a new, inverted linestring from this one
typename PointTraits< PointT >::MutablePoint MutablePointT
Definition: Traits.h:162
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)
Definition: Utilities.h:169
A normal 2d linestring with immutable data.
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.
A mutable 2d point.
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.
Definition: Traits.h:133
typename LineStringT::HybridType HybridType
Definition: Traits.h:145
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
Definition: Forward.h:199
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


lanelet2_core
Author(s): Fabian Poggenhans
autogenerated on Tue Jun 6 2023 02:23:32