SFCGAL 2.3.0
SFCGAL::GeometryCollection Class Reference

A GeometryCollection in SFA. More...

#include <GeometryCollection.h>

Public Types

using iterator
 Iterator type for geometry collection.
using const_iterator
 Const iterator type for geometry collection.

Public Member Functions

 GeometryCollection ()
 Empty GeometryCollection constructor.
 GeometryCollection (const GeometryCollection &other)
 Copy constructor.
auto operator= (GeometryCollection other) -> GeometryCollection &
 assign operator
 ~GeometryCollection () 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 collection.
auto coordinateDimension () const -> int override
 Get the coordinate dimension.
auto isEmpty () const -> bool override
 Check if the collection is empty.
auto is3D () const -> bool override
 Check if the collection has 3D coordinates.
auto isMeasured () const -> bool override
 Check if the collection has measured coordinates.
auto dropZ () -> bool override
 Drop Z coordinate from all geometries.
auto dropM () -> bool override
 Drop M coordinate from all geometries.
auto swapXY () -> void override
 Swap X and Y coordinates of all geometries in collection.
auto numGeometries () const -> size_t override
 Get the number of geometries in the collection.
auto geometryN (size_t const &n) const -> const Geometry &override
 Get the n-th geometry in the collection (const version).
auto geometryN (size_t const &n) -> Geometry &override
 Get the n-th geometry in the collection (non-const version).
void setGeometryN (const Geometry &geometry, size_t const &idx) override
 Set the geometry at the given index (copy version).
void setGeometryN (Geometry *geometry, size_t const &idx) override
 Set the geometry at the given index (pointer version).
void setGeometryN (std::unique_ptr< Geometry > geometry, size_t const &idx) override
 [SFA/OGC] Sets the n-th geometry using unique_ptr
void addGeometry (std::unique_ptr< Geometry > geometry)
 [SFA/OGC] Add a geometry to the collection.
void addGeometry (Geometry *geometry)
 [SFA/OGC]add a geometry to the collection (takes ownership)
void addGeometry (Geometry const &geometry)
 [SFA/OGC]add a geometry to the collection (clone instance)
auto begin () -> iterator
 Get iterator to beginning of geometries.
auto begin () const -> const_iterator
 Get const iterator to beginning of geometries.
auto end () -> iterator
 Get iterator to end of geometries.
auto end () const -> const_iterator
 Get const iterator to end of geometries.
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.

Protected Member Functions

virtual auto isAllowed (Geometry const &geometry) -> bool
 Test if a geometry is allowed in the collection.
void swap (GeometryCollection &other)
 Swap the contents of two geometry collections.

Detailed Description

Member Typedef Documentation

◆ const_iterator

Initial value:
std::vector<std::unique_ptr<Geometry>>::const_iterator>
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 geometry collection.

◆ iterator

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

Iterator type for geometry collection.

Constructor & Destructor Documentation

◆ GeometryCollection() [1/2]

SFCGAL::GeometryCollection::GeometryCollection ( )
default

Empty GeometryCollection constructor.

◆ GeometryCollection() [2/2]

SFCGAL::GeometryCollection::GeometryCollection ( const GeometryCollection & other)

Copy constructor.

Parameters
otherThe geometry collection to copy from

◆ ~GeometryCollection()

SFCGAL::GeometryCollection::~GeometryCollection ( )
overridedefault

destructor

Member Function Documentation

◆ accept() [1/2]

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

Accept a const geometry visitor.

Parameters
visitorConst visitor to accept

◆ accept() [2/2]

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

Accept a geometry visitor.

Parameters
visitorVisitor to accept

◆ addGeometry() [1/3]

void SFCGAL::GeometryCollection::addGeometry ( Geometry * geometry)

[SFA/OGC]add a geometry to the collection (takes ownership)

Parameters
geometryPointer to geometry to add
Deprecated
The unique_ptr version should be used instead

◆ addGeometry() [2/3]

void SFCGAL::GeometryCollection::addGeometry ( Geometry const & geometry)

[SFA/OGC]add a geometry to the collection (clone instance)

Parameters
geometryConst reference to geometry to clone and add

◆ addGeometry() [3/3]

void SFCGAL::GeometryCollection::addGeometry ( std::unique_ptr< Geometry > geometry)

[SFA/OGC] Add a geometry to the collection.

Parameters
geometryA unique pointer to the Geometry object to add. Ownership of this geometry is moved into the GeometryCollection.

◆ begin() [1/2]

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

Get iterator to beginning of geometries.

Returns
Iterator to first geometry

◆ begin() [2/2]

auto SFCGAL::GeometryCollection::begin ( ) const -> const_iterator
inline

Get const iterator to beginning of geometries.

Returns
Const iterator to first geometry

◆ coordinateDimension()

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

Get the coordinate dimension.

Returns
Number of coordinates per point

◆ dimension()

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

Get the dimension of the collection.

Returns
Maximum dimension of contained geometries

◆ dropM()

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

Drop M coordinate from all geometries.

Returns
true if M was dropped, false otherwise

◆ dropZ()

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

Drop Z coordinate from all geometries.

Returns
true if Z was dropped, false otherwise

◆ end() [1/2]

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

Get iterator to end of geometries.

Returns
Iterator to past-the-end

◆ end() [2/2]

auto SFCGAL::GeometryCollection::end ( ) const -> const_iterator
inline

Get const iterator to end of geometries.

Returns
Const iterator to past-the-end

◆ geometryN() [1/2]

auto SFCGAL::GeometryCollection::geometryN ( size_t const & n) -> Geometry &
override

Get the n-th geometry in the collection (non-const version).

Parameters
nIndex of the geometry to retrieve
Returns
Reference to the geometry

◆ geometryN() [2/2]

auto SFCGAL::GeometryCollection::geometryN ( size_t const & n) const -> const Geometry &
override

Get the n-th geometry in the collection (const version).

Parameters
nIndex of the geometry to retrieve
Returns
Const reference to the geometry

◆ geometryType()

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

Get the geometry type as string.

Returns
"GeometryCollection"

◆ geometryTypeId()

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

Get the geometry type identifier.

Returns
TYPE_GEOMETRYCOLLECTION

◆ is3D()

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

Check if the collection has 3D coordinates.

Returns
true if any geometry is 3D, false otherwise

◆ isAllowed()

auto SFCGAL::GeometryCollection::isAllowed ( Geometry const & geometry) -> bool
protectedvirtual

Test if a geometry is allowed in the collection.

Parameters
geometryGeometry to test
Returns
true if geometry is allowed in this collection

◆ isEmpty()

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

Check if the collection is empty.

Returns
true if empty, false otherwise

◆ isMeasured()

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

Check if the collection has measured coordinates.

Returns
true if any geometry is measured, false otherwise

◆ numGeometries()

auto SFCGAL::GeometryCollection::numGeometries ( ) const -> size_t
nodiscardoverride

Get the number of geometries in the collection.

Returns
Number of geometries

◆ operator=()

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

assign operator

Parameters
otherThe geometry collection to assign from
Returns
Reference to this geometry collection

◆ serialize()

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

Serializer.

Parameters
arArchive for serialization

◆ setGeometryN() [1/3]

void SFCGAL::GeometryCollection::setGeometryN ( const Geometry & geometry,
size_t const & idx )
override

Set the geometry at the given index (copy version).

Parameters
geometryGeometry to copy and set
idxIndex where to set the geometry

◆ setGeometryN() [2/3]

void SFCGAL::GeometryCollection::setGeometryN ( Geometry * geometry,
size_t const & idx )
override

Set the geometry at the given index (pointer version).

Parameters
geometryPointer to geometry to set
idxIndex where to set the geometry
Deprecated
The unique_ptr version should be used instead

◆ setGeometryN() [3/3]

void SFCGAL::GeometryCollection::setGeometryN ( std::unique_ptr< Geometry > geometry,
size_t const & idx )
override

[SFA/OGC] Sets the n-th geometry using unique_ptr

Parameters
geometryUnique pointer to geometry to set
idxIndex where to set the geometry

◆ swap()

void SFCGAL::GeometryCollection::swap ( GeometryCollection & other)
inlineprotected

Swap the contents of two geometry collections.

Parameters
otherGeometryCollection to swap with

◆ swapXY()

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

Swap X and Y coordinates of all geometries in collection.