maliput_sparse
LineString< CoordinateT, DistanceFunction > Class Template Referencefinal

Detailed Description

template<typename CoordinateT, typename DistanceFunction = details::EuclideanDistance<CoordinateT>>
class maliput_sparse::geometry::LineString< CoordinateT, DistanceFunction >

Defines a polyline in the CoordinateT domain composed of at least 2 points.

Template Parameters
CoordinateTThe coordinate point type to be used.
DistanceFunctionThe function to compute the distance with. By default, the Euclidean distance is used.

#include <include/maliput_sparse/geometry/line_string.h>

Classes

class  Point
 Extends the CoordinateT class with information about the index of the coordinate in the LineString and the \( p \) value up-to the coordinate in the parametrized LineString. More...
 
struct  Segment
 A segment of a LineString. More...
 

Public Types

using iterator = typename std::vector< CoordinateT >::iterator
 
using const_iterator = typename std::vector< CoordinateT >::const_iterator
 
using Segments = std::map< typename Segment::Interval, Segment >
 
using KDTree = maliput::math::KDTree< Point, CoordinateT::kDimension >
 

Public Member Functions

 LineString (const std::vector< CoordinateT > &coordinates)
 Constructs a LineString from a std::vector. More...
 
 LineString (std::initializer_list< CoordinateT > coordinates)
 Constructs a LineString form an initializer list. More...
 
template<typename Iterator >
 LineString (Iterator begin, Iterator end)
 Constructs a LineString form the begin and end iterators. More...
 
const CoordinateT & first () const
 
const CoordinateT & last () const
 
const CoordinateT & at (size_t i) const
 
size_t size () const
 
double length () const
 
const Segmentssegments () const
 Return the segments of this LineString. More...
 
const std::vector< Point > & points () const
 Return the points of this LineString. More...
 
const KDTreekd_tree () const
 Get KD Tree of the LineString. More...
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
const CoordinateT & operator[] (std::size_t index) const
 
CoordinateT & operator[] (std::size_t index)
 
bool operator== (const LineString< CoordinateT, DistanceFunction > &other) const
 Equality operator. More...
 

Member Typedef Documentation

◆ const_iterator

using const_iterator = typename std::vector<CoordinateT>::const_iterator

◆ iterator

using iterator = typename std::vector<CoordinateT>::iterator

◆ KDTree

using KDTree = maliput::math::KDTree<Point, CoordinateT::kDimension>

◆ Segments

using Segments = std::map<typename Segment::Interval, Segment>

Constructor & Destructor Documentation

◆ LineString() [1/3]

LineString ( const std::vector< CoordinateT > &  coordinates)
explicit

Constructs a LineString from a std::vector.

This function calls LineString(coordinates.begin, coordinates.end)

Parameters
coordinatesA vector of CoordinateT to define this LineString.

◆ LineString() [2/3]

LineString ( std::initializer_list< CoordinateT >  coordinates)
explicit

Constructs a LineString form an initializer list.

This function calls LineString(coordinates.begin, coordinates.end)

Parameters
coordinatesAn initializer list to define this LineString.

◆ LineString() [3/3]

LineString ( Iterator  begin,
Iterator  end 
)

Constructs a LineString form the begin and end iterators.

After loading the coordinates, this iterates through the list of points and computes the total length. This operation is O(n) in the list size.

Parameters
beginThe initial iterator.
endThe final iterator.
Template Parameters
Iteratorthe iterator type.
Exceptions
maliput::common::assertion_errorWhen there are less than two points.

Member Function Documentation

◆ at()

const CoordinateT& at ( size_t  i) const
Returns
The point at i index in the LineString.
Exceptions
std::out_of_rangeWhen i is not in [0, size()) bounds.

◆ begin() [1/2]

iterator begin ( )
Returns
begin iterator of the underlying collection.

◆ begin() [2/2]

const_iterator begin ( ) const
Returns
begin const iterator of the underlying collection.

◆ end() [1/2]

iterator end ( )
Returns
end iterator of the underlying collection.

◆ end() [2/2]

const_iterator end ( ) const
Returns
end const iterator of the underlying collection.

◆ first()

const CoordinateT& first ( ) const
Returns
The first point in the LineString.

◆ kd_tree()

const KDTree* kd_tree ( ) const

Get KD Tree of the LineString.

◆ last()

const CoordinateT& last ( ) const
Returns
The last point in the LineString.

◆ length()

double length ( ) const
Returns
The accumulated length between consecutive points in this LineString by means of DistanceFunction.

◆ operator==()

bool operator== ( const LineString< CoordinateT, DistanceFunction > &  other) const

Equality operator.

◆ operator[]() [1/2]

CoordinateT& operator[] ( std::size_t  index)

◆ operator[]() [2/2]

const CoordinateT& operator[] ( std::size_t  index) const

◆ points()

const std::vector<Point>& points ( ) const

Return the points of this LineString.

◆ segments()

const Segments& segments ( ) const

Return the segments of this LineString.

Returns
A vector of segments.

◆ size()

size_t size ( ) const
Returns
The number of points this LineString has.

The documentation for this class was generated from the following file: