QgsPolygon class

Polygon geometry type.

Base classes

class QgsCurvePolygon
Curve polygon geometry type.

Derived classes

class QgsTriangle
Triangle geometry type.

Public functions

void addInteriorRing(QgsCurve* ring) override
Adds an interior ring to the geometry (takes ownership)
auto asWkb() const -> QByteArray override
Returns a WKB representation of the geometry.
auto boundary() const -> QgsAbstractGeometry* override
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the geometry).
auto cast(const QgsAbstractGeometry* geom) const -> const QgsPolygon*
Cast the geom to a QgsPolygonV2.
void clear() override
Clears the geometry, ie reset it to a null geometry.
auto clone() const -> QgsPolygon* override
Clones the geometry by performing a deep copy.
auto createEmptyWithSameType() const -> QgsPolygon* override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
auto fromWkb(QgsConstWkbPtr& wkb) -> bool override
Sets the geometry from a WKB string.
auto geometryType() const -> QString override
Returns a unique string representing the geometry type.
auto pointDistanceToBoundary(double x, double y) const -> double
Returns the distance from a point to the boundary of the polygon (either the exterior ring or any closer interior rings).
void setExteriorRing(QgsCurve* ring) override
Sets the exterior ring of the polygon.
auto surfaceToPolygon() const -> QgsPolygon* override
Gets a polygon representation of this surface.
auto toCurveType() const -> QgsCurvePolygon* override
Returns the geometry converted to the more generic curve type QgsCurvePolygon.

Function documentation

QByteArray QgsPolygon::asWkb() const override

Returns a WKB representation of the geometry.

QgsAbstractGeometry* QgsPolygon::boundary() const override

Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the geometry).

Returns boundary for geometry. May be null for some geometry types.

For instance, a polygon geometry will have a boundary consisting of the linestrings for each ring in the polygon.

const QgsPolygon* QgsPolygon::cast(const QgsAbstractGeometry* geom) const

Cast the geom to a QgsPolygonV2.

Should be used by qgsgeometry_cast<QgsPolygon *>( geometry ).

QgsPolygon* QgsPolygon::createEmptyWithSameType() const override

Creates a new geometry with the same class and same WKB type as the original and transfers ownership.

To create it, the geometry is default constructed and then the WKB is changed.

bool QgsPolygon::fromWkb(QgsConstWkbPtr& wkb) override

Sets the geometry from a WKB string.

After successful read the wkb argument will be at the position where the reading has stopped.

QString QgsPolygon::geometryType() const override

Returns a unique string representing the geometry type.

double QgsPolygon::pointDistanceToBoundary(double x, double y) const

Returns the distance from a point to the boundary of the polygon (either the exterior ring or any closer interior rings).

The returned distance will be negative if the point lies outside the polygon.

void QgsPolygon::setExteriorRing(QgsCurve* ring) override

Sets the exterior ring of the polygon.

Parameters
ring new exterior ring. Ownership is transferred to the CurvePolygon.

The CurvePolygon type will be updated to match the dimensionality of the exterior ring. For instance, setting a 2D exterior ring on a 3D CurvePolygon will drop the z dimension from the CurvePolygon and all interior rings.

QgsPolygon* QgsPolygon::surfaceToPolygon() const override

Gets a polygon representation of this surface.

Ownership is transferred to the caller.

QgsCurvePolygon* QgsPolygon::toCurveType() const override

Returns the geometry converted to the more generic curve type QgsCurvePolygon.

Returns the converted geometry. Caller takes ownership