Skip to content

Class SFCGAL::Geometry

ClassList > SFCGAL > Geometry

OGC/SFA based Geometry abstract class.

  • #include <Geometry.h>

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
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.
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.
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 ~Geometry () = default
Destructor.

Protected Attributes

Type Name
bool validityFlag_ = = false

Public Functions Documentation

function Geometry [1/2]

SFCGAL::Geometry::Geometry () 

function Geometry [2/2]

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

function accept [1/2]

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

function accept [2/2]

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

function almostEqual

auto SFCGAL::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 & SFCGAL::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 & SFCGAL::Geometry::as () 

Warning:

performs check if boost assertions are enabled

Precondition:

The cast must be doable


function asText

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

[OGC/SFA]returns the WKT string

Parameters:

  • numDecimals extension specify fix precision output

function asWkb

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

[OGC/SFA]returns the WKB string


function boundary

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

function clone

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

function coordinateDimension

virtual int SFCGAL::Geometry::coordinateDimension () const = 0

[OGC/SFA]returns the dimension of the coordinates

Precondition:

suppose no mix of 2D/3D coordinates


function dimension

virtual int SFCGAL::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

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

function distance3D

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

function envelope

Envelope 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


function 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


function geometryN [1/2]

[OGC/SFA]Returns the n-th geometry

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

Warning:

*this for Point, LineString, Polygon, Triangle


function geometryN [2/2]

[OGC/SFA]Returns the n-th geometry

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

Warning:

*this for Point, LineString, Polygon, Triangle


function geometryType

[OGC/SFA]returns the geometry type

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

Warning:

use CamelCase (LineString, not LINESTRING)


function geometryTypeId

Returns a code corresponding to the type.

virtual GeometryType SFCGAL::Geometry::geometryTypeId () const = 0

Warning:

not standard


function hasValidityFlag

bool SFCGAL::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 SFCGAL::Geometry::is () const

Warning:

not optimized (slow with dynamic_cast)


function is3D

virtual bool SFCGAL::Geometry::is3D () const = 0

[OGC/SFA]test if geometry is 3d

Precondition:

suppose no mix of 2D/3D coordinates


function isEmpty

virtual bool SFCGAL::Geometry::isEmpty () const = 0

[OGC/SFA]test if geometry is empty


function isMeasured

virtual bool SFCGAL::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 SFCGAL::Geometry::numGeometries () const

Warning:

1 for Point, LineString, Polygon, Triangle


function operator=

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

function round

round the geometry with a corresponding scale factor

void SFCGAL::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 SFCGAL::Geometry::serialize (
    Archive &,
    const unsigned int
) 

Serializer


function ~Geometry

virtual SFCGAL::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