LuciadCPillar 2025.0.02
luciad::Polygon Class Referencefinal

Represents a polygon. More...

#include <luciad/geometries/Polygon.h>

Inheritance diagram for luciad::Polygon:
luciad::CompositePatch luciad::Surface luciad::Geometry

Public Member Functions

std::shared_ptr< PolygonappendInteriorRing (std::shared_ptr< PolylineRing > interiorRing) const
 Creates a new Polygon instance based on this instance, but with a new interior ring appended to the list of interior rings. More...
 
double getArea () const
 Returns the 2D area of this polygon. More...
 
std::shared_ptr< PolygonremoveInteriorRing (size_t index) const
 Creates a new Polygon instance based on this instance, but with the interior ring at location 'index' removed. More...
 
std::shared_ptr< PolygonreplaceExteriorRing (std::shared_ptr< PolylineRing > exteriorRing) const
 Creates a new Polygon instance using the interior rings from this instance, but with a new exterior ring. More...
 
std::shared_ptr< PolygonreplaceInteriorRing (size_t index, std::shared_ptr< PolylineRing > interiorRing) const
 Creates a new Polygon instance with the exterior and interior rings from this instance, but with a new interior ring at location 'index'. More...
 
- Public Member Functions inherited from luciad::CompositePatch
 ~CompositePatch () override
 
Bounds getBounds () const override
 Returns the bounds for the geometry object. More...
 
const std::shared_ptr< Patch > & getExteriorPatch () const
 Returns the exterior patch of this composite patch. More...
 
const std::vector< std::shared_ptr< Patch > > & getInteriorPatches () const
 Returns the interior patches of this composite patch. More...
 
std::shared_ptr< luciad::CoordinateReferencegetReference () const override
 Returns the coordinate reference of the geometry. More...
 
- Public Member Functions inherited from luciad::Geometry
virtual ~Geometry ()=default
 
virtual Bounds getBounds () const =0
 Returns the bounds for the geometry object. More...
 
virtual std::shared_ptr< CoordinateReferencegetReference () const =0
 Returns the coordinate reference of the geometry. More...
 

Protected Member Functions

size_t getHash () const override
 Returns the hash value for this geometry. More...
 
size_t getHash () const override
 Returns the hash value for this geometry. More...
 
virtual size_t getHash () const =0
 Returns the hash value for this geometry. More...
 

Detailed Description

Represents a polygon.

See also
GeometryFactory::createPolygon

Member Function Documentation

◆ appendInteriorRing()

std::shared_ptr< Polygon > luciad::Polygon::appendInteriorRing ( std::shared_ptr< PolylineRing interiorRing) const

Creates a new Polygon instance based on this instance, but with a new interior ring appended to the list of interior rings.

Parameters
interiorRingthe new interior ring.
Returns
a new Polyline instance, with a new interior ring.
Exceptions
luciad::NullArgumentExceptionwhen passing nullptr.
Since
2024.1

◆ getArea()

double luciad::Polygon::getArea ( ) const

Returns the 2D area of this polygon.

The calculations are performed in the coordinate reference of this geometry. This means that

  • for geodetic references, the curvature of the line segments are taken into account
  • for other references, the calculations are cartesian.

The returned value is expressed in the unit of measure of the reference of this geometry.

  • for geodetic references, this is always meters.
  • or other references this is typically meters, but depending on the reference the unit of measure can also be something else like millimeters or feet.

Limitations:

  • The area calculation is performed in 2D. For 3D polygons, the z value will be ignored and considered as 0.
  • For this reason, geometries with a geocentric reference are not supported at all. In this case, an exception is thrown.
  • Geometries with a rhumb line interpolation type are not supported. In this case, an exception is thrown.
  • The calculations assume non-degenerare polygons. This means that the exterior and interior rings are not self intersecting, and that none of the (exterior or interior) rings overlap with other (exterior or interior) rings. The calculations will still produce a result, though it will not be well-defined (since the input is also no well-defined).
Returns
the 2D area of this polygon.
Exceptions
luciad::InvalidArgumentExceptionwhen using this method on a geometry with a geocentric reference, or with a rhumb interpolation type.
Since
2025.0

◆ getHash()

size_t luciad::Polygon::getHash ( ) const
overrideprotectedvirtual

Returns the hash value for this geometry.

Returns
the hash value for this geometry.

Reimplemented from luciad::CompositePatch.

◆ removeInteriorRing()

std::shared_ptr< Polygon > luciad::Polygon::removeInteriorRing ( size_t  index) const

Creates a new Polygon instance based on this instance, but with the interior ring at location 'index' removed.

Parameters
indexthe index of the interior ring to remove
Returns
a new Polyline instance, with the interior ring at location 'index' removed.
Exceptions
luciad::InvalidArgumentExceptionfor an invalid index
Since
2024.1

◆ replaceExteriorRing()

std::shared_ptr< Polygon > luciad::Polygon::replaceExteriorRing ( std::shared_ptr< PolylineRing exteriorRing) const

Creates a new Polygon instance using the interior rings from this instance, but with a new exterior ring.

Parameters
exteriorRingthe new exterior ring.
Returns
a new Polyline instance.
Exceptions
luciad::NullArgumentExceptionwhen passing nullptr.
Since
2024.1

◆ replaceInteriorRing()

std::shared_ptr< Polygon > luciad::Polygon::replaceInteriorRing ( size_t  index,
std::shared_ptr< PolylineRing interiorRing 
) const

Creates a new Polygon instance with the exterior and interior rings from this instance, but with a new interior ring at location 'index'.

Parameters
indexthe index of the interior ring to replace
interiorRingthe new interior ring.
Returns
a new Polyline instance
Exceptions
luciad::NullArgumentExceptionwhen passing nullptr.
luciad::InvalidArgumentExceptionfor an invalid index
Since
2024.1