SFCGAL
SFCGAL::Polygon Class Reference

A Polygon in SFA with holes. More...

#include <Polygon.h>

Inheritance diagram for SFCGAL::Polygon:
SFCGAL::Surface SFCGAL::Geometry

Public Types

typedef boost::ptr_vector< LineString >::iterator iterator
 
typedef boost::ptr_vector< LineString >::const_iterator const_iterator
 

Public Member Functions

 Polygon ()
 Empty Polygon constructor.
 
 Polygon (const std::vector< LineString > &rings)
 Constructor with an exterior ring.
 
 Polygon (const LineString &exteriorRing)
 Constructor with an exterior ring.
 
 Polygon (LineString *exteriorRing)
 Constructor with an exterior ring (takes ownership)
 
 Polygon (const Triangle &triangle)
 Constructor with a Triangle.
 
 Polygon (const Polygon &other)
 Copy constructor.
 
 Polygon (const CGAL::Polygon_2< Kernel > &other)
 Constructor from CGAL::Polygon_with_holes_2<K>
 
 Polygon (const CGAL::Polygon_with_holes_2< Kernel > &other)
 Constructor from CGAL::Polygon_with_holes_2<K>
 
Polygonoperator= (Polygon other)
 assign operator
 
 ~Polygon ()
 destructor
 
virtual Polygonclone () const
 Get a deep copy of the geometry.
 
virtual std::string geometryType () const
 [OGC/SFA]returns the geometry type
 
virtual GeometryType geometryTypeId () const
 Returns a code corresponding to the type.
 
virtual int coordinateDimension () const
 [OGC/SFA]returns the dimension of the coordinates
 
virtual bool isEmpty () const
 [OGC/SFA]test if geometry is empty
 
virtual bool is3D () const
 [OGC/SFA]test if geometry is 3d
 
virtual bool isMeasured () const
 [OGC/SFA]test if geometry is measured (has an m)
 
bool isCounterClockWiseOriented () const
 Check whether the 2D polygon is pointing up.
 
void reverse ()
 reverse Polygon orientation
 
const LineStringexteriorRing () const
 [OGC/SFA]returns the exterior ring
 
LineStringexteriorRing ()
 [OGC/SFA]returns the exterior ring
 
void setExteriorRing (const LineString &ring)
 Sets the exterior ring.
 
void setExteriorRing (LineString *ring)
 Sets the exterior ring (takes ownership)
 
bool hasInteriorRings () const
 Test if the polygon has interior rings.
 
size_t numInteriorRings () const
 [OGC/SFA]returns the exterior ring
 
const LineStringinteriorRingN (const size_t &n) const
 [OGC/SFA]returns the exterior ring
 
LineStringinteriorRingN (const size_t &n)
 [OGC/SFA]returns the exterior ring
 
size_t numRings () const
 Returns the number of rings.
 
const LineStringringN (const size_t &n) const
 Returns the n-th ring, 0 is exteriorRing.
 
LineStringringN (const size_t &n)
 Returns the n-th ring, 0 is exteriorRing.
 
void addInteriorRing (const LineString &ls)
 append a ring to the Polygon
 
void addInteriorRing (LineString *ls)
 append a ring to the Polygon (take ownership)
 
void addRing (const LineString &ls)
 append a ring to the Polygon
 
void addRing (LineString *ls)
 append a ring to the Polygon (take ownership)
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
CGAL::Polygon_2< KerneltoPolygon_2 (bool fixOrientation=true) const
 
CGAL::Polygon_with_holes_2< KerneltoPolygon_with_holes_2 (bool fixOrientation=true) const
 
virtual void accept (GeometryVisitor &visitor)
 [visitor]dispatch visitor
 
virtual void accept (ConstGeometryVisitor &visitor) const
 [visitor]dispatch visitor
 
template<class Archive >
void serialize (Archive &ar, const unsigned int)
 Serializer.
 
- Public Member Functions inherited from SFCGAL::Surface
virtual ~Surface ()
 destructor
 
virtual int dimension () const
 [OGC/SFA]Dimension of the Geometry ( 0 : punctual, 1 : curve, ...)
 
- Public Member Functions inherited from SFCGAL::Geometry
 Geometry ()
 Default constructor.
 
 Geometry (const Geometry &)=default
 Copy constructor.
 
Geometryoperator= (const Geometry &other)=default
 Copy assignemnt operator.
 
virtual ~Geometry ()=default
 Destructor.
 
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.
 
template<class Archive >
void serialize (Archive &, const unsigned int)
 Serializer.
 

Additional Inherited Members

- Protected Member Functions inherited from SFCGAL::Surface
 Surface ()
 [OGC/SFS]"The area of this Surface, as measured in the spatial reference system of this Surface"
 
 Surface (Surface const &other)
 no copy constructor
 
- Protected Attributes inherited from SFCGAL::Geometry
bool validityFlag_
 

Detailed Description

A Polygon in SFA with holes.

Member Typedef Documentation

◆ const_iterator

typedef boost::ptr_vector<LineString>::const_iterator SFCGAL::Polygon::const_iterator

◆ iterator

typedef boost::ptr_vector<LineString>::iterator SFCGAL::Polygon::iterator

Constructor & Destructor Documentation

◆ Polygon() [1/8]

SFCGAL::Polygon::Polygon ( )

Empty Polygon constructor.

◆ Polygon() [2/8]

SFCGAL::Polygon::Polygon ( const std::vector< LineString > & rings)

Constructor with an exterior ring.

◆ Polygon() [3/8]

SFCGAL::Polygon::Polygon ( const LineString & exteriorRing)

Constructor with an exterior ring.

◆ Polygon() [4/8]

SFCGAL::Polygon::Polygon ( LineString * exteriorRing)

Constructor with an exterior ring (takes ownership)

◆ Polygon() [5/8]

SFCGAL::Polygon::Polygon ( const Triangle & triangle)

Constructor with a Triangle.

◆ Polygon() [6/8]

SFCGAL::Polygon::Polygon ( const Polygon & other)

Copy constructor.

◆ Polygon() [7/8]

SFCGAL::Polygon::Polygon ( const CGAL::Polygon_2< Kernel > & other)

Constructor from CGAL::Polygon_with_holes_2<K>

◆ Polygon() [8/8]

SFCGAL::Polygon::Polygon ( const CGAL::Polygon_with_holes_2< Kernel > & other)

Constructor from CGAL::Polygon_with_holes_2<K>

◆ ~Polygon()

SFCGAL::Polygon::~Polygon ( )
default

destructor

Member Function Documentation

◆ accept() [1/2]

void SFCGAL::Polygon::accept ( ConstGeometryVisitor & visitor) const
virtual

[visitor]dispatch visitor

Implements SFCGAL::Geometry.

◆ accept() [2/2]

void SFCGAL::Polygon::accept ( GeometryVisitor & visitor)
virtual

[visitor]dispatch visitor

Implements SFCGAL::Geometry.

◆ addInteriorRing() [1/2]

void SFCGAL::Polygon::addInteriorRing ( const LineString & ls)
inline

append a ring to the Polygon

◆ addInteriorRing() [2/2]

void SFCGAL::Polygon::addInteriorRing ( LineString * ls)
inline

append a ring to the Polygon (take ownership)

◆ addRing() [1/2]

void SFCGAL::Polygon::addRing ( const LineString & ls)
inline

append a ring to the Polygon

Deprecated
addInteriorRing

◆ addRing() [2/2]

void SFCGAL::Polygon::addRing ( LineString * ls)
inline

append a ring to the Polygon (take ownership)

Deprecated
addInteriorRing

◆ begin() [1/2]

iterator SFCGAL::Polygon::begin ( )
inline

◆ begin() [2/2]

const_iterator SFCGAL::Polygon::begin ( ) const
inline

◆ clone()

auto SFCGAL::Polygon::clone ( ) const
virtual

Get a deep copy of the geometry.

Implements SFCGAL::Geometry.

◆ coordinateDimension()

auto SFCGAL::Polygon::coordinateDimension ( ) const
virtual

[OGC/SFA]returns the dimension of the coordinates

Precondition
suppose no mix of 2D/3D coordinates

Implements SFCGAL::Geometry.

◆ end() [1/2]

iterator SFCGAL::Polygon::end ( )
inline

◆ end() [2/2]

const_iterator SFCGAL::Polygon::end ( ) const
inline

◆ exteriorRing() [1/2]

LineString & SFCGAL::Polygon::exteriorRing ( )
inline

[OGC/SFA]returns the exterior ring

◆ exteriorRing() [2/2]

const LineString & SFCGAL::Polygon::exteriorRing ( ) const
inline

[OGC/SFA]returns the exterior ring

◆ geometryType()

auto SFCGAL::Polygon::geometryType ( ) const
virtual

[OGC/SFA]returns the geometry type

Warning
use CamelCase (LineString, not LINESTRING)

Implements SFCGAL::Geometry.

◆ geometryTypeId()

auto SFCGAL::Polygon::geometryTypeId ( ) const
virtual

Returns a code corresponding to the type.

Warning
not standard

Implements SFCGAL::Geometry.

◆ hasInteriorRings()

bool SFCGAL::Polygon::hasInteriorRings ( ) const
inline

Test if the polygon has interior rings.

◆ interiorRingN() [1/2]

LineString & SFCGAL::Polygon::interiorRingN ( const size_t & n)
inline

[OGC/SFA]returns the exterior ring

◆ interiorRingN() [2/2]

const LineString & SFCGAL::Polygon::interiorRingN ( const size_t & n) const
inline

[OGC/SFA]returns the exterior ring

◆ is3D()

auto SFCGAL::Polygon::is3D ( ) const
virtual

[OGC/SFA]test if geometry is 3d

Precondition
suppose no mix of 2D/3D coordinates

Implements SFCGAL::Geometry.

◆ isCounterClockWiseOriented()

auto SFCGAL::Polygon::isCounterClockWiseOriented ( ) const

Check whether the 2D polygon is pointing up.

◆ isEmpty()

auto SFCGAL::Polygon::isEmpty ( ) const
virtual

[OGC/SFA]test if geometry is empty

Implements SFCGAL::Geometry.

◆ isMeasured()

auto SFCGAL::Polygon::isMeasured ( ) const
virtual

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

Precondition
suppose no mix of M/!M points

Implements SFCGAL::Geometry.

◆ numInteriorRings()

size_t SFCGAL::Polygon::numInteriorRings ( ) const
inline

[OGC/SFA]returns the exterior ring

◆ numRings()

size_t SFCGAL::Polygon::numRings ( ) const
inline

Returns the number of rings.

◆ operator=()

auto SFCGAL::Polygon::operator= ( Polygon other)

assign operator

◆ reverse()

void SFCGAL::Polygon::reverse ( )

reverse Polygon orientation

◆ ringN() [1/2]

LineString & SFCGAL::Polygon::ringN ( const size_t & n)
inline

Returns the n-th ring, 0 is exteriorRing.

Warning
not standard, avoid conditionnal to access rings

◆ ringN() [2/2]

const LineString & SFCGAL::Polygon::ringN ( const size_t & n) const
inline

Returns the n-th ring, 0 is exteriorRing.

Warning
not standard, avoid conditionnal to access rings

◆ serialize()

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

Serializer.

◆ setExteriorRing() [1/2]

void SFCGAL::Polygon::setExteriorRing ( const LineString & ring)
inline

Sets the exterior ring.

◆ setExteriorRing() [2/2]

void SFCGAL::Polygon::setExteriorRing ( LineString * ring)
inline

Sets the exterior ring (takes ownership)

◆ toPolygon_2()

auto SFCGAL::Polygon::toPolygon_2 ( bool fixOrientation = true) const

◆ toPolygon_with_holes_2()

auto SFCGAL::Polygon::toPolygon_with_holes_2 ( bool fixOrientation = true) const