SFCGAL 2.3.0
SFCGAL::LineString Class Reference

A LineString in SFA. More...

#include <LineString.h>

Classes

class  Point_2_const_iterator
 Const iterator to 2D points TODO: replace by boost::tranform_iterator ? More...
class  Point_3_const_iterator
 Const iterator to 3D points TODO: replace by boost::tranform_iterator ? More...

Public Types

using iterator
 Iterator type for linestring points.
using const_iterator
 Const iterator type for linestring points.

Public Member Functions

 LineString ()
 Empty LineString constructor.
 LineString (const std::vector< Point > &points)
 Constructor with a point vector.
 LineString (const Point &startPoint, const Point &endPoint)
 LineString constructor.
 LineString (LineString const &other)
 Copy constructor.
auto operator= (LineString other) -> LineString &
 assign operator
 ~LineString () override
 destructor
auto geometryType () const -> std::string override
 Get the geometry type as string.
auto geometryTypeId () const -> GeometryType override
 Get the geometry type identifier.
auto dimension () const -> int override
 Get the dimension of the linestring.
auto coordinateDimension () const -> int override
 Get the coordinate dimension.
auto isEmpty () const -> bool override
 Check if the linestring is empty.
auto is3D () const -> bool override
 Check if the linestring has 3D coordinates.
auto isMeasured () const -> bool override
 Check if the linestring has measured coordinates.
auto dropZ () -> bool override
 Drop Z coordinate from all points.
auto dropM () -> bool override
 Drop M coordinate from all points.
auto swapXY () -> void override
 Swap X and Y coordinates of all points.
void clear ()
 remove all points from the LineString
void reverse ()
 reverse LineString orientation
auto numPoints () const -> size_t
 [SFA/OGC]Returns the number of points
auto numSegments () const -> size_t
 Returns the number of segments.
auto pointN (size_t const &n) const -> const Point &
 [SFA/OGC]Returns the n-th point
auto pointN (size_t const &n) -> Point &
 [SFA/OGC]Returns the n-th point
auto startPoint () const -> const Point &
 [SFA/OGC]Returns the first point
auto startPoint () -> Point &
 [SFA/OGC]Returns the first point
auto endPoint () const -> const Point &
 [SFA/OGC]Returns the last point
auto endPoint () -> Point &
 [SFA/OGC]Returns the last point
void addPoint (const Point &point)
 Appends a Point to the LineString.
void addPoint (Point *point)
 Appends a Point to the LineString and takes ownership.
void addPoint (std::unique_ptr< Point > point)
 Appends a Point to the LineString.
auto isClosed () const -> bool
 test if the LineString is closed
void closes ()
 closes the LineString If the linestring is already closed, it remains unchanged
auto begin () -> iterator
 Get iterator to beginning of points.
auto begin () const -> const_iterator
 Get const iterator to beginning of points.
auto end () -> iterator
 Get iterator to end of points.
auto end () const -> const_iterator
 Get const iterator to end of points.
void reserve (const size_t &n)
 Reserve space for points.
auto points_2_begin () const -> Point_2_const_iterator
 Get iterator to beginning of 2D points.
auto points_2_end () const -> Point_2_const_iterator
 Get iterator to end of 2D points.
auto points_2 () const -> std::pair< Point_2_const_iterator, Point_2_const_iterator >
 Get pair of iterators for 2D points.
auto points_3_begin () const -> Point_3_const_iterator
 Get iterator to beginning of 3D points.
auto points_3_end () const -> Point_3_const_iterator
 Get iterator to end of 3D points.
auto points_3 () const -> std::pair< Point_3_const_iterator, Point_3_const_iterator >
 Get pair of iterators for 3D points.
auto toPolygon_2 (bool fixOrientation=true) const -> CGAL::Polygon_2< Kernel >
 Convert to CGAL::Polygon_2.
void accept (GeometryVisitor &visitor) override
 Accept a geometry visitor.
void accept (ConstGeometryVisitor &visitor) const override
 Accept a const geometry visitor.
template<class Archive>
void serialize (Archive &ar, const unsigned int)
 Serializer.

Detailed Description

A LineString in SFA.

Member Typedef Documentation

◆ const_iterator

Initial value:
Iterator adapter that dereferences unique_ptr elements automatically.
Definition DereferenceIterator.h:22
DereferenceIterator< std::vector< std::unique_ptr< Geometry > >::const_iterator > const_iterator
Const iterator type for geometry collection.
Definition GeometryCollection.h:30

Const iterator type for linestring points.

◆ iterator

Initial value:
DereferenceIterator< std::vector< std::unique_ptr< Geometry > >::iterator > iterator
Iterator type for geometry collection.
Definition GeometryCollection.h:27

Iterator type for linestring points.

Constructor & Destructor Documentation

◆ LineString() [1/4]

SFCGAL::LineString::LineString ( )
default

Empty LineString constructor.

◆ LineString() [2/4]

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

Constructor with a point vector.

Parameters
pointsVector of points to initialize the linestring

◆ LineString() [3/4]

SFCGAL::LineString::LineString ( const Point & startPoint,
const Point & endPoint )

LineString constructor.

Parameters
startPointThe starting point of the linestring
endPointThe ending point of the linestring

◆ LineString() [4/4]

SFCGAL::LineString::LineString ( LineString const & other)

Copy constructor.

Parameters
otherThe linestring to copy from

◆ ~LineString()

SFCGAL::LineString::~LineString ( )
overridedefault

destructor

Member Function Documentation

◆ accept() [1/2]

void SFCGAL::LineString::accept ( ConstGeometryVisitor & visitor) const
override

Accept a const geometry visitor.

Parameters
visitorConst visitor to accept

◆ accept() [2/2]

void SFCGAL::LineString::accept ( GeometryVisitor & visitor)
override

Accept a geometry visitor.

Parameters
visitorVisitor to accept

◆ addPoint() [1/3]

void SFCGAL::LineString::addPoint ( const Point & point)
inline

Appends a Point to the LineString.

Parameters
pointThe Point object to append.

◆ addPoint() [2/3]

void SFCGAL::LineString::addPoint ( Point * point)
inline

Appends a Point to the LineString and takes ownership.

Parameters
pointA raw pointer to the Point object to append. Ownership of this point is moved into the LineString.
Deprecated
The unique_ptr version should be used instead

◆ addPoint() [3/3]

void SFCGAL::LineString::addPoint ( std::unique_ptr< Point > point)
inline

Appends a Point to the LineString.

Parameters
pointA unique pointer to the Point object to append. Ownership of this point is moved into the LineString.

◆ begin() [1/2]

auto SFCGAL::LineString::begin ( ) -> iterator
inline

Get iterator to beginning of points.

Returns
Iterator to first point

◆ begin() [2/2]

auto SFCGAL::LineString::begin ( ) const -> const_iterator
inlinenodiscard

Get const iterator to beginning of points.

Returns
Const iterator to first point

◆ clear()

void SFCGAL::LineString::clear ( )

remove all points from the LineString

◆ closes()

void SFCGAL::LineString::closes ( )
inline

closes the LineString If the linestring is already closed, it remains unchanged

◆ coordinateDimension()

auto SFCGAL::LineString::coordinateDimension ( ) const -> int
nodiscardoverride

Get the coordinate dimension.

Returns
Number of coordinates per point

◆ dimension()

auto SFCGAL::LineString::dimension ( ) const -> int
nodiscardoverride

Get the dimension of the linestring.

Returns
1 (linestrings are 1-dimensional)

◆ dropM()

auto SFCGAL::LineString::dropM ( ) -> bool
override

Drop M coordinate from all points.

Returns
true if M was dropped, false otherwise

◆ dropZ()

auto SFCGAL::LineString::dropZ ( ) -> bool
override

Drop Z coordinate from all points.

Returns
true if Z was dropped, false otherwise

◆ end() [1/2]

auto SFCGAL::LineString::end ( ) -> iterator
inline

Get iterator to end of points.

Returns
Iterator to past-the-end

◆ end() [2/2]

auto SFCGAL::LineString::end ( ) const -> const_iterator
inlinenodiscard

Get const iterator to end of points.

Returns
Const iterator to past-the-end

◆ endPoint() [1/2]

auto SFCGAL::LineString::endPoint ( ) -> Point &
inline

[SFA/OGC]Returns the last point

Returns
Reference to the last point

◆ endPoint() [2/2]

auto SFCGAL::LineString::endPoint ( ) const -> const Point &
inlinenodiscard

[SFA/OGC]Returns the last point

Returns
Const reference to the last point

◆ geometryType()

auto SFCGAL::LineString::geometryType ( ) const -> std::string
nodiscardoverride

Get the geometry type as string.

Returns
"LineString"

◆ geometryTypeId()

auto SFCGAL::LineString::geometryTypeId ( ) const -> GeometryType
nodiscardoverride

Get the geometry type identifier.

Returns
TYPE_LINESTRING

◆ is3D()

auto SFCGAL::LineString::is3D ( ) const -> bool
nodiscardoverride

Check if the linestring has 3D coordinates.

Returns
true if 3D, false otherwise

◆ isClosed()

auto SFCGAL::LineString::isClosed ( ) const -> bool
nodiscard

test if the LineString is closed

Returns
true if linestring is closed, false otherwise

◆ isEmpty()

auto SFCGAL::LineString::isEmpty ( ) const -> bool
nodiscardoverride

Check if the linestring is empty.

Returns
true if empty, false otherwise

◆ isMeasured()

auto SFCGAL::LineString::isMeasured ( ) const -> bool
nodiscardoverride

Check if the linestring has measured coordinates.

Returns
true if measured, false otherwise

◆ numPoints()

auto SFCGAL::LineString::numPoints ( ) const -> size_t
inlinenodiscard

[SFA/OGC]Returns the number of points

Returns
Number of points in the linestring

◆ numSegments()

auto SFCGAL::LineString::numSegments ( ) const -> size_t
nodiscard

Returns the number of segments.

Returns
Number of segments in the linestring
Warning
not standard, returns zero if LineString contains only one point

◆ operator=()

auto SFCGAL::LineString::operator= ( LineString other) -> LineString &

assign operator

Parameters
otherThe linestring to assign from
Returns
Reference to this linestring

◆ pointN() [1/2]

auto SFCGAL::LineString::pointN ( size_t const & n) -> Point &
inline

[SFA/OGC]Returns the n-th point

Parameters
nThe index of the point to get
Returns
Reference to the nth point

◆ pointN() [2/2]

auto SFCGAL::LineString::pointN ( size_t const & n) const -> const Point &
inlinenodiscard

[SFA/OGC]Returns the n-th point

Parameters
nThe index of the point to get
Returns
Const reference to the nth point

◆ points_2()

auto SFCGAL::LineString::points_2 ( ) const -> std::pair< Point_2_const_iterator, Point_2_const_iterator >
inlinenodiscard

Get pair of iterators for 2D points.

Returns
Pair of begin and end iterators for 2D points

◆ points_2_begin()

auto SFCGAL::LineString::points_2_begin ( ) const -> Point_2_const_iterator
inlinenodiscard

Get iterator to beginning of 2D points.

Returns
Iterator to first 2D point

◆ points_2_end()

auto SFCGAL::LineString::points_2_end ( ) const -> Point_2_const_iterator
inlinenodiscard

Get iterator to end of 2D points.

Returns
Iterator to past-the-end of 2D points

◆ points_3()

auto SFCGAL::LineString::points_3 ( ) const -> std::pair< Point_3_const_iterator, Point_3_const_iterator >
inlinenodiscard

Get pair of iterators for 3D points.

Returns
Pair of begin and end iterators for 3D points

◆ points_3_begin()

auto SFCGAL::LineString::points_3_begin ( ) const -> Point_3_const_iterator
inlinenodiscard

Get iterator to beginning of 3D points.

Returns
Iterator to first 3D point

◆ points_3_end()

auto SFCGAL::LineString::points_3_end ( ) const -> Point_3_const_iterator
inlinenodiscard

Get iterator to end of 3D points.

Returns
Iterator to past-the-end of 3D points

◆ reserve()

void SFCGAL::LineString::reserve ( const size_t & n)

Reserve space for points.

Parameters
nNumber of points to reserve space for

◆ reverse()

void SFCGAL::LineString::reverse ( )

reverse LineString orientation

◆ serialize()

template<class Archive>
void SFCGAL::LineString::serialize ( Archive & ar,
const unsigned int  )
inline

Serializer.

Parameters
arArchive for serialization

◆ startPoint() [1/2]

auto SFCGAL::LineString::startPoint ( ) -> Point &
inline

[SFA/OGC]Returns the first point

Returns
Reference to the first point

◆ startPoint() [2/2]

auto SFCGAL::LineString::startPoint ( ) const -> const Point &
inlinenodiscard

[SFA/OGC]Returns the first point

Returns
Const reference to the first point

◆ swapXY()

auto SFCGAL::LineString::swapXY ( ) -> void
override

Swap X and Y coordinates of all points.

◆ toPolygon_2()

auto SFCGAL::LineString::toPolygon_2 ( bool fixOrientation = true) const -> CGAL::Polygon_2< Kernel >
nodiscard

Convert to CGAL::Polygon_2.

Parameters
fixOrientationForce exterior ring orientation (counter clockwise)
Returns
CGAL 2D polygon representation