Skip to content

Class SFCGAL::Geometry#

ClassList > Geometry

OGC/SFA based Geometry abstract class.

Inherited by the following classes: SFCGAL::GeometryCollection, SFCGAL::LineString, SFCGAL::Point, SFCGAL::Solid, SFCGAL::Surface

Public Functions#

Type Name
Geometry ()
Default constructor.
Geometry (const Geometry &) = default
Copy constructor.
virtual void accept (GeometryVisitor & visitor) = 0
[visitor]dispatch visitor
virtual void accept (ConstGeometryVisitor & visitor) const = 0
[visitor]dispatch visitor
auto almostEqual (const Geometry & other, const double tolerance) const
const Derived & as () const
Downcast to a "Derived" class.
Derived & as ()
Downcast to a "Derived" class.
std::string asText (const int & numDecimals=-1) const
std::string asWkb (boost::endian::order wkbOrder=boost::endian::order::native, bool asHex=false) const
virtual std::unique_ptr< Geometry > boundary () const
[OGC/SFA]Returns the boundary of the geometry
Point centroid () const
Computes centroid of this geometry.
Point centroid3D () const
Computes 3D centroid of this geometry.
virtual Geometry * clone () const = 0
Get a deep copy of the geometry.
virtual int coordinateDimension () const = 0
virtual int dimension () const = 0
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.
virtual auto dropM () = 0
Drops the m coordinate of the geometry.
virtual auto dropZ () = 0
Drops the z coordinate of the geometry.
Envelope envelope () const
void forceValidityFlag (bool validity)
virtual const Geometry & geometryN (size_t const & n) const
[OGC/SFA]Returns the n-th geometry
virtual Geometry & geometryN (size_t const & n)
[OGC/SFA]Returns the n-th 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.
auto getCoordinateType () const
Determines the coordinate dimension of a geometry.
bool hasValidityFlag () const
bool is () const
Tests if geometry is of "Derived" type given as template parameter.
virtual bool is3D () const = 0
virtual bool isEmpty () const = 0
virtual bool isMeasured () const = 0
virtual size_t numGeometries () const
[OGC/SFA]Gets the number of geometries in a collection of geometries
Geometry & operator= (const Geometry & other) = default
Copy assignemnt operator.
void round (const long & scale=1)
round the geometry with a corresponding scale factor
void serialize (Archive &, const unsigned int)
virtual void setGeometryN (const Geometry & geometry, size_t const & n)
[OGC/SFA]Sets the n-th geometry, starting at zero
virtual void setGeometryN (Geometry * geometry, size_t const & n)
[OGC/SFA]Sets the n-th geometry, starting at zero The ownership of the geometry is taken. The caller is not responsible anymore of its deallocation.
virtual auto swapXY () = 0
Swaps the x and y coordinates of the geometry.
virtual ~Geometry () = default
Destructor.

Protected Attributes#

Type Name
bool validityFlag_ = false

Public Functions Documentation#

function Geometry [1/2]#

Default constructor.

Geometry::Geometry () 

function Geometry [2/2]#

Copy constructor.

Geometry::Geometry (
    const Geometry &
) = default

function accept [1/2]#

[visitor]dispatch visitor

virtual void Geometry::accept (
    GeometryVisitor & visitor
) = 0

function accept [2/2]#

[visitor]dispatch visitor

virtual void Geometry::accept (
    ConstGeometryVisitor & visitor
) const = 0

function almostEqual#

auto Geometry::almostEqual (
    const Geometry & other,
    const double tolerance
) const

Equality operator

Todo

only compare coordinate points

Precondition:

the two geometries must be valid


function as [1/2]#

Downcast to a "Derived" class.

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

Warning:

performs check if boost assertions are enabled

Precondition:

The cast must be doable


function as [2/2]#

Downcast to a "Derived" class.

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

Warning:

performs check if boost assertions are enabled

Precondition:

The cast must be doable


function asText#

std::string Geometry::asText (
    const int & numDecimals=-1
) const

[OGC/SFA]returns the WKT string

Parameters:

  • numDecimals extension specify fix precision output

function asWkb#

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

[OGC/SFA]returns the WKB string


function boundary#

[OGC/SFA]Returns the boundary of the geometry

virtual std::unique_ptr< Geometry > Geometry::boundary () const

function centroid#

Computes centroid of this geometry.

Point Geometry::centroid () const

function centroid3D#

Computes 3D centroid of this geometry.

Point Geometry::centroid3D () const

function clone#

Get a deep copy of the geometry.

virtual Geometry * Geometry::clone () const = 0

function coordinateDimension#

virtual int Geometry::coordinateDimension () const = 0

[OGC/SFA]returns the dimension of the coordinates

Precondition:

suppose no mix of 2D/3D coordinates


function dimension#

virtual int Geometry::dimension () const = 0

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

Warning:

empty geometries provide the dimension corresponding to the object


function distance#

Computes the distance to an other geometry.

double Geometry::distance (
    const Geometry & other
) const

function distance3D#

Computes the 3D distance to an other geometry.

double Geometry::distance3D (
    const Geometry & other
) const

function dropM#

Drops the m coordinate of the geometry.

virtual auto Geometry::dropM () = 0

Returns:

TRUE if a M value was present and has been removed

Precondition:

suppose no mix of M/!M points


function dropZ#

Drops the z coordinate of the geometry.

virtual auto Geometry::dropZ () = 0

Returns:

TRUE if a Z value was present and has been removed

Precondition:

suppose no mix of 2D/3D coordinates


function envelope#

Envelope 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


function forceValidityFlag#

void 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


function geometryN [1/2]#

[OGC/SFA]Returns the n-th geometry

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

Warning:

*this for Point, LineString, Polygon, PolyhedralSurface, Triangle, TriangulatedSurface


function geometryN [2/2]#

[OGC/SFA]Returns the n-th geometry

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

Warning:

*this for Point, LineString, Polygon, PolyhedralSurface, Triangle, TriangulatedSurface


function geometryType#

[OGC/SFA]returns the geometry type

virtual std::string Geometry::geometryType () const = 0

Warning:

use CamelCase (LineString, not LINESTRING)


function geometryTypeId#

Returns a code corresponding to the type.

virtual GeometryType Geometry::geometryTypeId () const = 0

Warning:

not standard


function getCoordinateType#

Determines the coordinate dimension of a geometry.

inline auto Geometry::getCoordinateType () const

Returns:

CoordinateType The coordinate dimension (XY, XYZ, XYM, XYZM)


function hasValidityFlag#

bool Geometry::hasValidityFlag () const

Returns the validity flag


function is#

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

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

Warning:

not optimized (slow with dynamic_cast)


function is3D#

virtual bool Geometry::is3D () const = 0

[OGC/SFA]test if geometry is 3d

Precondition:

suppose no mix of 2D/3D coordinates


function isEmpty#

virtual bool Geometry::isEmpty () const = 0

[OGC/SFA]test if geometry is empty


function isMeasured#

virtual bool Geometry::isMeasured () const = 0

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

Precondition:

suppose no mix of M/!M points


function numGeometries#

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

virtual size_t Geometry::numGeometries () const

Warning:

1 for Point, LineString, Polygon, PolyhedralSurface, Triangle, TriangulatedSurface


function operator=#

Copy assignemnt operator.

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

function round#

round the geometry with a corresponding scale factor

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

Parameters:

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

function serialize#

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

Serializer


function setGeometryN [1/2]#

[OGC/SFA]Sets the n-th geometry, starting at zero

virtual void Geometry::setGeometryN (
    const Geometry & geometry,
    size_t const & n
) 

Warning:

Does nothing for Point, LineString, Polygon, Triangle TriangulatedSurface


function setGeometryN [2/2]#

[OGC/SFA]Sets the n-th geometry, starting at zero The ownership of the geometry is taken. The caller is not responsible anymore of its deallocation.

virtual void Geometry::setGeometryN (
    Geometry * geometry,
    size_t const & n
) 

Warning:

*this for GeometryCollection, PolyhedralSurface, TriangulatedSurface


function swapXY#

Swaps the x and y coordinates of the geometry.

virtual auto Geometry::swapXY () = 0

function ~Geometry#

Destructor.

virtual Geometry::~Geometry () = default

Protected Attributes Documentation#

variable validityFlag_#

bool SFCGAL::Geometry::validityFlag_;


The documentation for this class was generated from the following file /builds/sfcgal/SFCGAL/src/Geometry.h