SFCGAL  2.3.0
Classes | Public Types | Public Member Functions | List of all members
SFCGAL::LineString Class Reference

A LineString in SFA. More...

#include <LineString.h>

Inherits SFCGAL::GeometryImpl< Derived, Base >.

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 = DereferenceIterator< std::vector< std::unique_ptr< Point >>::iterator >
 Iterator type for linestring points. More...
 
using const_iterator = DereferenceIterator< std::vector< std::unique_ptr< Point >>::const_iterator >
 Const iterator type for linestring points. More...
 

Public Member Functions

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

Detailed Description

A LineString in SFA.

Member Typedef Documentation

Const iterator type for linestring points.

using SFCGAL::LineString::iterator = DereferenceIterator<std::vector<std::unique_ptr<Point>>::iterator>

Iterator type for linestring points.

Constructor & Destructor Documentation

SFCGAL::LineString::LineString ( )
default

Empty LineString constructor.

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

Constructor with a point vector.

Parameters
pointsVector of points to initialize the linestring
SFCGAL::LineString::LineString ( const Point &  startPoint,
const Point &  endPoint 
)

LineString constructor.

Parameters
startPointThe starting point of the linestring
endPointThe ending point of the linestring
SFCGAL::LineString::LineString ( LineString const &  other)

Copy constructor.

Parameters
otherThe linestring to copy from
SFCGAL::LineString::~LineString ( )
overridedefault

destructor

Member Function Documentation

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

Accept a geometry visitor.

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

Accept a const geometry visitor.

Parameters
visitorConst visitor to accept
void SFCGAL::LineString::addPoint ( const Point &  point)
inline

Appends a Point to the LineString.

Parameters
pointThe Point object to append.
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
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.
auto SFCGAL::LineString::begin ( ) -> iterator
inline

Get iterator to beginning of points.

Returns
Iterator to first point
auto SFCGAL::LineString::begin ( ) const -> const_iterator
inline

Get const iterator to beginning of points.

Returns
Const iterator to first point
void SFCGAL::LineString::clear ( )

remove all points from the LineString

void SFCGAL::LineString::closes ( )
inline

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

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

Get the coordinate dimension.

Returns
Number of coordinates per point
auto SFCGAL::LineString::dimension ( ) const -> int
override

Get the dimension of the linestring.

Returns
1 (linestrings are 1-dimensional)
auto SFCGAL::LineString::dropM ( ) -> bool
override

Drop M coordinate from all points.

Returns
true if M was dropped, false otherwise
auto SFCGAL::LineString::dropZ ( ) -> bool
override

Drop Z coordinate from all points.

Returns
true if Z was dropped, false otherwise
auto SFCGAL::LineString::end ( ) -> iterator
inline

Get iterator to end of points.

Returns
Iterator to past-the-end
auto SFCGAL::LineString::end ( ) const -> const_iterator
inline

Get const iterator to end of points.

Returns
Const iterator to past-the-end
auto SFCGAL::LineString::endPoint ( ) const -> const Point &
inline

[SFA/OGC]Returns the last point

Returns
Const reference to the last point
auto SFCGAL::LineString::endPoint ( ) -> Point &
inline

[SFA/OGC]Returns the last point

Returns
Reference to the last point
auto SFCGAL::LineString::geometryType ( ) const -> std::string
override

Get the geometry type as string.

Returns
"LineString"
auto SFCGAL::LineString::geometryTypeId ( ) const -> GeometryType
override

Get the geometry type identifier.

Returns
TYPE_LINESTRING
auto SFCGAL::LineString::is3D ( ) const -> bool
override

Check if the linestring has 3D coordinates.

Returns
true if 3D, false otherwise
auto SFCGAL::LineString::isClosed ( ) const -> bool

test if the LineString is closed

Returns
true if linestring is closed, false otherwise
auto SFCGAL::LineString::isEmpty ( ) const -> bool
override

Check if the linestring is empty.

Returns
true if empty, false otherwise
auto SFCGAL::LineString::isMeasured ( ) const -> bool
override

Check if the linestring has measured coordinates.

Returns
true if measured, false otherwise
auto SFCGAL::LineString::numPoints ( ) const -> size_t
inline

[SFA/OGC]Returns the number of points

Returns
Number of points in the linestring
auto SFCGAL::LineString::numSegments ( ) const -> size_t

Returns the number of segments.

Returns
Number of segments in the linestring
Warning
not standard, returns zero if LineString contains only one point
auto SFCGAL::LineString::operator= ( LineString  other) -> LineString &

assign operator

Parameters
otherThe linestring to assign from
Returns
Reference to this linestring
auto SFCGAL::LineString::pointN ( size_t const &  n) const -> const Point &
inline

[SFA/OGC]Returns the n-th point

Parameters
nThe index of the point to get
Returns
Const reference to the nth point
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
auto SFCGAL::LineString::points_2 ( ) const -> std::pair<Point_2_const_iterator, Point_2_const_iterator>
inline

Get pair of iterators for 2D points.

Returns
Pair of begin and end iterators for 2D points
auto SFCGAL::LineString::points_2_begin ( ) const -> Point_2_const_iterator
inline

Get iterator to beginning of 2D points.

Returns
Iterator to first 2D point
auto SFCGAL::LineString::points_2_end ( ) const -> Point_2_const_iterator
inline

Get iterator to end of 2D points.

Returns
Iterator to past-the-end of 2D points
auto SFCGAL::LineString::points_3 ( ) const -> std::pair<Point_3_const_iterator, Point_3_const_iterator>
inline

Get pair of iterators for 3D points.

Returns
Pair of begin and end iterators for 3D points
auto SFCGAL::LineString::points_3_begin ( ) const -> Point_3_const_iterator
inline

Get iterator to beginning of 3D points.

Returns
Iterator to first 3D point
auto SFCGAL::LineString::points_3_end ( ) const -> Point_3_const_iterator
inline

Get iterator to end of 3D points.

Returns
Iterator to past-the-end of 3D points
void SFCGAL::LineString::reserve ( const size_t &  n)

Reserve space for points.

Parameters
nNumber of points to reserve space for
void SFCGAL::LineString::reverse ( )

reverse LineString orientation

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

Serializer.

Parameters
arArchive for serialization
auto SFCGAL::LineString::startPoint ( ) const -> const Point &
inline

[SFA/OGC]Returns the first point

Returns
Const reference to the first point
auto SFCGAL::LineString::startPoint ( ) -> Point &
inline

[SFA/OGC]Returns the first point

Returns
Reference to the first point
auto SFCGAL::LineString::swapXY ( ) -> void
override

Swap X and Y coordinates of all points.

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

Convert to CGAL::Polygon_2.

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