SFCGAL 2.0.0
SFCGAL::Geometry Class Referenceabstract

OGC/SFA based Geometry abstract class. More...

#include <Geometry.h>

Inheritance diagram for SFCGAL::Geometry:
SFCGAL::GeometryCollection SFCGAL::LineString SFCGAL::Point SFCGAL::Solid SFCGAL::Surface SFCGAL::MultiLineString SFCGAL::MultiPoint SFCGAL::MultiPolygon SFCGAL::MultiSolid SFCGAL::Polygon SFCGAL::PolyhedralSurface SFCGAL::Triangle SFCGAL::TriangulatedSurface

Public Member Functions

 Geometry ()
 Default constructor.
 Geometry (const Geometry &)=default
 Copy constructor.
Geometryoperator= (const Geometry &other)=default
 Copy assignemnt operator.
virtual ~Geometry ()=default
 Destructor.
virtual Geometryclone () const =0
 Get a deep copy of the geometry.
virtual std::string geometryType () const =0
 [OGC/SFA]returns the geometry type
virtual GeometryType geometryTypeId () const =0
 Returns a code corresponding to the type.
virtual int dimension () const =0
 [OGC/SFA]Dimension of the Geometry ( 0 : punctual, 1 : curve, ...)
virtual int coordinateDimension () const =0
 [OGC/SFA]returns the dimension of the coordinates
virtual bool isEmpty () const =0
 [OGC/SFA]test if geometry is empty
virtual bool is3D () const =0
 [OGC/SFA]test if geometry is 3d
virtual bool isMeasured () const =0
 [OGC/SFA]test if geometry is measured (has an m)
void forceValidityFlag (bool validity)
 Force the state of the validity flag.
bool hasValidityFlag () const
 Returns the validity flag.
std::string asText (const int &numDecimals=-1) const
 [OGC/SFA]returns the WKT string
std::string asWkb (boost::endian::order wkbOrder=boost::endian::order::native, bool asHex=false) const
 [OGC/SFA]returns the WKB string
Envelope envelope () const
 [OGC/SFA]Returns a polygon representing the BBOX of the geometry
virtual std::unique_ptr< Geometryboundary () const
 [OGC/SFA]Returns the boundary of the geometry
double distance (const Geometry &other) const
 Computes the distance to an other geometry.
double distance3D (const Geometry &other) const
 Computes the 3D distance to an other geometry.
void round (const long &scale=1)
 round the geometry with a corresponding scale factor
auto almostEqual (const Geometry &, const double tolerance) const -> bool
 Equality operator.
virtual size_t numGeometries () const
 [OGC/SFA]Gets the number of geometries in a collection of geometries
virtual const GeometrygeometryN (size_t const &n) const
 [OGC/SFA]Returns the n-th geometry
virtual GeometrygeometryN (size_t const &n)
 [OGC/SFA]Returns the n-th geometry
template<typename Derived>
bool is () const
 Tests if geometry is of "Derived" type given as template parameter.
template<typename Derived>
const Derived & as () const
 Downcast to a "Derived" class.
template<typename Derived>
Derived & as ()
 Downcast to a "Derived" class.
virtual void accept (GeometryVisitor &visitor)=0
 [visitor]dispatch visitor
virtual void accept (ConstGeometryVisitor &visitor) const =0
 [visitor]dispatch visitor
template<class Archive>
void serialize (Archive &, const unsigned int)
 Serializer.

Protected Attributes

bool validityFlag_ = false

Detailed Description

OGC/SFA based Geometry abstract class.

Constructor & Destructor Documentation

◆ Geometry() [1/2]

SFCGAL::Geometry::Geometry ( )
default

Default constructor.

◆ Geometry() [2/2]

SFCGAL::Geometry::Geometry ( const Geometry & )
default

Copy constructor.

◆ ~Geometry()

virtual SFCGAL::Geometry::~Geometry ( )
virtualdefault

Destructor.

Member Function Documentation

◆ almostEqual()

auto SFCGAL::Geometry::almostEqual ( const Geometry & other,
const double tolerance ) const -> bool

Equality operator.

Todo
only compare coordinate points
Precondition
the two geometries must be valid

◆ as() [1/2]

template<typename Derived>
Derived & SFCGAL::Geometry::as ( )
inline

Downcast to a "Derived" class.

Warning
performs check if boost assertions are enabled
Precondition
The cast must be doable

◆ as() [2/2]

template<typename Derived>
const Derived & SFCGAL::Geometry::as ( ) const
inline

Downcast to a "Derived" class.

Warning
performs check if boost assertions are enabled
Precondition
The cast must be doable

◆ asText()

auto SFCGAL::Geometry::asText ( const int & numDecimals = -1) const

[OGC/SFA]returns the WKT string

Parameters
numDecimalsextension specify fix precision output

◆ asWkb()

auto SFCGAL::Geometry::asWkb ( boost::endian::order wkbOrder = boost::endian::order::native,
bool asHex = false ) const

[OGC/SFA]returns the WKB string

◆ boundary()

auto SFCGAL::Geometry::boundary ( ) const
virtual

[OGC/SFA]Returns the boundary of the geometry

◆ clone()

◆ coordinateDimension()

virtual int SFCGAL::Geometry::coordinateDimension ( ) const
pure virtual

[OGC/SFA]returns the dimension of the coordinates

Precondition
suppose no mix of 2D/3D coordinates

Implemented in SFCGAL::GeometryCollection, SFCGAL::LineString, SFCGAL::Point, SFCGAL::Polygon, SFCGAL::PolyhedralSurface, SFCGAL::Solid, SFCGAL::Triangle, and SFCGAL::TriangulatedSurface.

◆ dimension()

virtual int SFCGAL::Geometry::dimension ( ) const
pure virtual

[OGC/SFA]Dimension of the Geometry ( 0 : punctual, 1 : curve, ...)

Warning
empty geometries provide the dimension corresponding to the object

Implemented in SFCGAL::GeometryCollection, SFCGAL::LineString, SFCGAL::Point, SFCGAL::PolyhedralSurface, SFCGAL::Solid, SFCGAL::Surface, and SFCGAL::TriangulatedSurface.

◆ distance()

auto SFCGAL::Geometry::distance ( const Geometry & other) const

Computes the distance to an other geometry.

◆ distance3D()

auto SFCGAL::Geometry::distance3D ( const Geometry & other) const

Computes the 3D distance to an other geometry.

◆ envelope()

auto SFCGAL::Geometry::envelope ( ) const

[OGC/SFA]Returns a polygon representing the BBOX of the geometry

Todo
In order to adapt to 3D, would be better to define an "Envelope type", otherway would lead to Polygon and PolyhedralSurface

◆ forceValidityFlag()

void SFCGAL::Geometry::forceValidityFlag ( bool validity)

Force the state of the validity flag.

The validity flag allows to bypass validity checks If the flag is true, it means the geometry is considered valid If the flag is false, it means the validity state of the geometry is unknown The flag is only changed for this geometry and not the internal geometries.

See also
propagateValidityFlag

◆ geometryN() [1/2]

auto SFCGAL::Geometry::geometryN ( size_t const & n)
virtual

[OGC/SFA]Returns the n-th geometry

Warning
*this for Point, LineString, Polygon, Triangle

Reimplemented in SFCGAL::GeometryCollection, SFCGAL::PolyhedralSurface, and SFCGAL::TriangulatedSurface.

◆ geometryN() [2/2]

auto SFCGAL::Geometry::geometryN ( size_t const & n) const
virtual

[OGC/SFA]Returns the n-th geometry

Warning
*this for Point, LineString, Polygon, Triangle

Reimplemented in SFCGAL::GeometryCollection, SFCGAL::PolyhedralSurface, and SFCGAL::TriangulatedSurface.

◆ geometryType()

virtual std::string SFCGAL::Geometry::geometryType ( ) const
pure virtual

◆ geometryTypeId()

virtual GeometryType SFCGAL::Geometry::geometryTypeId ( ) const
pure virtual

◆ hasValidityFlag()

auto SFCGAL::Geometry::hasValidityFlag ( ) const

Returns the validity flag.

◆ is()

template<typename Derived>
bool SFCGAL::Geometry::is ( ) const
inline

Tests if geometry is of "Derived" type given as template parameter.

Warning
not optimized (slow with dynamic_cast)

◆ is3D()

virtual bool SFCGAL::Geometry::is3D ( ) const
pure virtual

[OGC/SFA]test if geometry is 3d

Precondition
suppose no mix of 2D/3D coordinates

Implemented in SFCGAL::GeometryCollection, SFCGAL::LineString, SFCGAL::Point, SFCGAL::Polygon, SFCGAL::PolyhedralSurface, SFCGAL::Solid, SFCGAL::Triangle, and SFCGAL::TriangulatedSurface.

◆ isEmpty()

virtual bool SFCGAL::Geometry::isEmpty ( ) const
pure virtual

◆ isMeasured()

virtual bool SFCGAL::Geometry::isMeasured ( ) const
pure virtual

[OGC/SFA]test if geometry is measured (has an m)

Precondition
suppose no mix of M/!M points

Implemented in SFCGAL::GeometryCollection, SFCGAL::LineString, SFCGAL::Point, SFCGAL::Polygon, SFCGAL::PolyhedralSurface, SFCGAL::Solid, SFCGAL::Triangle, and SFCGAL::TriangulatedSurface.

◆ numGeometries()

auto SFCGAL::Geometry::numGeometries ( ) const
virtual

[OGC/SFA]Gets the number of geometries in a collection of geometries

Warning
1 for Point, LineString, Polygon, Triangle

Reimplemented in SFCGAL::GeometryCollection, SFCGAL::PolyhedralSurface, and SFCGAL::TriangulatedSurface.

◆ operator=()

Geometry & SFCGAL::Geometry::operator= ( const Geometry & other)
default

Copy assignemnt operator.

◆ round()

void SFCGAL::Geometry::round ( const long & scale = 1)

round the geometry with a corresponding scale factor

Parameters
scalethe scale factor (1 corresponds to the nearest integer, 1000 to a 0.001 tolerance)

Member Data Documentation

◆ validityFlag_

bool SFCGAL::Geometry::validityFlag_ = false
protected