QGIS API Documentation  3.8.0-Zanzibar (11aff65)
Public Member Functions | Static Public Member Functions | List of all members
QgsGeos Class Reference

Does vector analysis using the geos library and handles import, export, exception handling*. More...

#include <qgsgeos.h>

Inheritance diagram for QgsGeos:
Inheritance graph
[legend]

Public Member Functions

 QgsGeos (const QgsAbstractGeometry *geometry, double precision=0)
 GEOS geometry engine constructor. More...
 
double area (QString *errorMsg=nullptr) const override
 
QgsAbstractGeometrybuffer (double distance, int segments, QString *errorMsg=nullptr) const override
 
QgsAbstractGeometrybuffer (double distance, int segments, int endCapStyle, int joinStyle, double miterLimit, QString *errorMsg=nullptr) const override
 
QgsPointcentroid (QString *errorMsg=nullptr) const override
 Calculates the centroid of this. More...
 
std::unique_ptr< QgsAbstractGeometryclip (const QgsRectangle &rectangle, QString *errorMsg=nullptr) const
 Performs a fast, non-robust intersection between the geometry and a rectangle. More...
 
QgsGeometry closestPoint (const QgsGeometry &other, QString *errorMsg=nullptr) const
 Returns the closest point on the geometry to the other geometry. More...
 
QgsAbstractGeometrycombine (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const override
 Calculate the combination of this and geom. More...
 
QgsAbstractGeometrycombine (const QVector< QgsAbstractGeometry *> &geomList, QString *errorMsg) const override
 Calculate the combination of this and geometries. More...
 
QgsAbstractGeometrycombine (const QVector< QgsGeometry > &, QString *errorMsg=nullptr) const override
 Calculate the combination of this and geometries. More...
 
bool contains (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const override
 Checks if geom contains this. More...
 
QgsAbstractGeometryconvexHull (QString *errorMsg=nullptr) const override
 Calculate the convex hull of this. More...
 
bool crosses (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const override
 Checks if geom crosses this. More...
 
QgsGeometry delaunayTriangulation (double tolerance=0.0, bool edgesOnly=false, QString *errorMsg=nullptr) const
 Returns the Delaunay triangulation for the vertices of the geometry. More...
 
QgsAbstractGeometrydifference (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const override
 Calculate the difference of this and geom. More...
 
bool disjoint (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const override
 Checks if geom is disjoint from this. More...
 
double distance (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const override
 Calculates the distance between this and geom. More...
 
QgsAbstractGeometryenvelope (QString *errorMsg=nullptr) const override
 
void geometryChanged () override
 Should be called whenever the geometry associated with the engine has been modified and the engine must be updated to suit. More...
 
double hausdorffDistance (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const
 Returns the Hausdorff distance between this geometry and geom. More...
 
double hausdorffDistanceDensify (const QgsAbstractGeometry *geom, double densifyFraction, QString *errorMsg=nullptr) const
 Returns the Hausdorff distance between this geometry and geom. More...
 
QgsAbstractGeometryinterpolate (double distance, QString *errorMsg=nullptr) const override
 
QgsAbstractGeometryintersection (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const override
 Calculate the intersection of this and geom. More...
 
bool intersects (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const override
 Checks if geom intersects this. More...
 
bool isEmpty (QString *errorMsg=nullptr) const override
 
bool isEqual (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const override
 Checks if this is equal to geom. More...
 
bool isSimple (QString *errorMsg=nullptr) const override
 Determines whether the geometry is simple (according to OGC definition). More...
 
bool isValid (QString *errorMsg=nullptr, bool allowSelfTouchingHoles=false, QgsGeometry *errorLoc=nullptr) const override
 Returns true if the geometry is valid. More...
 
double length (QString *errorMsg=nullptr) const override
 
double lineLocatePoint (const QgsPoint &point, QString *errorMsg=nullptr) const
 Returns a distance representing the location along this linestring of the closest point on this linestring geometry to the specified point. More...
 
QgsGeometry mergeLines (QString *errorMsg=nullptr) const
 Merges any connected lines in a LineString/MultiLineString geometry and converts them to single line strings. More...
 
QgsAbstractGeometryoffsetCurve (double distance, int segments, int joinStyle, double miterLimit, QString *errorMsg=nullptr) const override
 
bool overlaps (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const override
 Checks if geom overlaps this. More...
 
QgsPointpointOnSurface (QString *errorMsg=nullptr) const override
 Calculate a point that is guaranteed to be on the surface of this. More...
 
void prepareGeometry () override
 Prepares the geometry, so that subsequent calls to spatial relation methods are much faster. More...
 
QString relate (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const override
 Returns the Dimensional Extended 9 Intersection Model (DE-9IM) representation of the relationship between the geometries. More...
 
bool relatePattern (const QgsAbstractGeometry *geom, const QString &pattern, QString *errorMsg=nullptr) const override
 Tests whether two geometries are related by a specified Dimensional Extended 9 Intersection Model (DE-9IM) pattern. More...
 
std::unique_ptr< QgsAbstractGeometryreshapeGeometry (const QgsLineString &reshapeWithLine, EngineOperationResult *errorCode, QString *errorMsg=nullptr) const
 Reshapes the geometry using a line. More...
 
QgsGeometry shortestLine (const QgsGeometry &other, QString *errorMsg=nullptr) const
 Returns the shortest line joining this geometry to the other geometry. More...
 
QgsAbstractGeometrysimplify (double tolerance, QString *errorMsg=nullptr) const override
 
std::unique_ptr< QgsAbstractGeometrysingleSidedBuffer (double distance, int segments, int side, int joinStyle, double miterLimit, QString *errorMsg=nullptr) const
 Returns a single sided buffer for a geometry. More...
 
EngineOperationResult splitGeometry (const QgsLineString &splitLine, QVector< QgsGeometry > &newGeometries, bool topological, QgsPointSequence &topologyTestPoints, QString *errorMsg=nullptr) const override
 Splits this geometry according to a given line. More...
 
std::unique_ptr< QgsAbstractGeometrysubdivide (int maxNodes, QString *errorMsg=nullptr) const
 Subdivides the geometry. More...
 
QgsAbstractGeometrysymDifference (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const override
 Calculate the symmetric difference of this and geom. More...
 
bool touches (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const override
 Checks if geom touches this. More...
 
QgsGeometry voronoiDiagram (const QgsAbstractGeometry *extent=nullptr, double tolerance=0.0, bool edgesOnly=false, QString *errorMsg=nullptr) const
 Creates a Voronoi diagram for the nodes contained within the geometry. More...
 
bool within (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const override
 Checks if geom is within this. More...
 
- Public Member Functions inherited from QgsGeometryEngine
virtual ~QgsGeometryEngine ()=default
 

Static Public Member Functions

static QgsGeometry::OperationResult addPart (QgsGeometry &geometry, GEOSGeometry *newPart)
 Adds a new island polygon to a multipolygon feature. More...
 
static geos::unique_ptr asGeos (const QgsGeometry &geometry, double precision=0)
 Returns a geos geometry - caller takes ownership of the object (should be deleted with GEOSGeom_destroy_r) More...
 
static geos::unique_ptr asGeos (const QgsAbstractGeometry *geometry, double precision=0)
 Returns a geos geometry - caller takes ownership of the object (should be deleted with GEOSGeom_destroy_r) More...
 
static QgsPoint coordSeqPoint (const GEOSCoordSequence *cs, int i, bool hasZ, bool hasM)
 
static std::unique_ptr< QgsAbstractGeometryfromGeos (const GEOSGeometry *geos)
 Create a geometry from a GEOSGeometry. More...
 
static std::unique_ptr< QgsPolygonfromGeosPolygon (const GEOSGeometry *geos)
 
static QgsGeometry geometryFromGeos (GEOSGeometry *geos)
 Creates a new QgsGeometry object, feeding in a geometry in GEOS format. More...
 
static QgsGeometry geometryFromGeos (const geos::unique_ptr &geos)
 Creates a new QgsGeometry object, feeding in a geometry in GEOS format. More...
 
static GEOSContextHandle_t getGEOSHandler ()
 
static QgsGeometry polygonize (const QVector< const QgsAbstractGeometry *> &geometries, QString *errorMsg=nullptr)
 Creates a GeometryCollection geometry containing possible polygons formed from the constituent linework of a set of geometries. More...
 

Additional Inherited Members

- Public Types inherited from QgsGeometryEngine
enum  EngineOperationResult {
  Success = 0, NothingHappened = 1000, MethodNotImplemented, EngineError,
  NodedGeometryError, InvalidBaseGeometry, InvalidInput, SplitCannotSplitPoint
}
 Success or failure of a geometry operation. More...
 
- Protected Member Functions inherited from QgsGeometryEngine
 QgsGeometryEngine (const QgsAbstractGeometry *geometry)
 
- Protected Attributes inherited from QgsGeometryEngine
const QgsAbstractGeometrymGeometry = nullptr
 

Detailed Description

Does vector analysis using the geos library and handles import, export, exception handling*.

Note
not available in Python bindings

Definition at line 103 of file qgsgeos.h.

Constructor & Destructor Documentation

◆ QgsGeos()

QgsGeos::QgsGeos ( const QgsAbstractGeometry geometry,
double  precision = 0 
)

GEOS geometry engine constructor.

Parameters
geometryThe geometry
precisionThe precision of the grid to which to snap the geometry vertices. If 0, no snapping is performed.

Definition at line 145 of file qgsgeos.cpp.

Member Function Documentation

◆ addPart()

QgsGeometry::OperationResult QgsGeos::addPart ( QgsGeometry geometry,
GEOSGeometry *  newPart 
)
static

Adds a new island polygon to a multipolygon feature.

Parameters
geometrygeometry to add part to
newPartpart to add. Ownership is NOT transferred.
Returns
OperationResult a result code: success or reason of failure

Definition at line 176 of file qgsgeos.cpp.

◆ area()

double QgsGeos::area ( QString *  errorMsg = nullptr) const
overridevirtual

Implements QgsGeometryEngine.

Definition at line 586 of file qgsgeos.cpp.

◆ asGeos() [1/2]

geos::unique_ptr QgsGeos::asGeos ( const QgsGeometry geometry,
double  precision = 0 
)
static

Returns a geos geometry - caller takes ownership of the object (should be deleted with GEOSGeom_destroy_r)

Parameters
geometrygeometry to convert to GEOS representation
precisionThe precision of the grid to which to snap the geometry vertices. If 0, no snapping is performed.

Definition at line 166 of file qgsgeos.cpp.

◆ asGeos() [2/2]

geos::unique_ptr QgsGeos::asGeos ( const QgsAbstractGeometry geometry,
double  precision = 0 
)
static

Returns a geos geometry - caller takes ownership of the object (should be deleted with GEOSGeom_destroy_r)

Parameters
geometrygeometry to convert to GEOS representation
precisionThe precision of the grid to which to snap the geometry vertices. If 0, no snapping is performed.

Definition at line 1290 of file qgsgeos.cpp.

◆ buffer() [1/2]

QgsAbstractGeometry * QgsGeos::buffer ( double  distance,
int  segments,
QString *  errorMsg = nullptr 
) const
overridevirtual

Implements QgsGeometryEngine.

Definition at line 1514 of file qgsgeos.cpp.

◆ buffer() [2/2]

QgsAbstractGeometry * QgsGeos::buffer ( double  distance,
int  segments,
int  endCapStyle,
int  joinStyle,
double  miterLimit,
QString *  errorMsg = nullptr 
) const
overridevirtual

Implements QgsGeometryEngine.

Definition at line 1530 of file qgsgeos.cpp.

◆ centroid()

QgsPoint * QgsGeos::centroid ( QString *  errorMsg = nullptr) const
overridevirtual

Calculates the centroid of this.

May return a \c nullptr.

Since
QGIS 3.0 the centroid is returned

Implements QgsGeometryEngine.

Definition at line 1576 of file qgsgeos.cpp.

◆ clip()

std::unique_ptr< QgsAbstractGeometry > QgsGeos::clip ( const QgsRectangle rectangle,
QString *  errorMsg = nullptr 
) const

Performs a fast, non-robust intersection between the geometry and a rectangle.

The returned geometry may be invalid.

Definition at line 227 of file qgsgeos.cpp.

◆ closestPoint()

QgsGeometry QgsGeos::closestPoint ( const QgsGeometry other,
QString *  errorMsg = nullptr 
) const

Returns the closest point on the geometry to the other geometry.

See also
shortestLine()
Since
QGIS 2.14

Definition at line 2152 of file qgsgeos.cpp.

◆ combine() [1/3]

QgsAbstractGeometry * QgsGeos::combine ( const QgsAbstractGeometry geom,
QString *  errorMsg = nullptr 
) const
overridevirtual

Calculate the combination of this and geom.

Since
QGIS 3.0 geom is a pointer

Implements QgsGeometryEngine.

Definition at line 361 of file qgsgeos.cpp.

◆ combine() [2/3]

QgsAbstractGeometry * QgsGeos::combine ( const QVector< QgsAbstractGeometry *> &  geomList,
QString *  errorMsg 
) const
overridevirtual

Calculate the combination of this and geometries.

Since
QGIS 3.0 geom is a pointer

Implements QgsGeometryEngine.

Definition at line 366 of file qgsgeos.cpp.

◆ combine() [3/3]

QgsAbstractGeometry * QgsGeos::combine ( const QVector< QgsGeometry > &  geometries,
QString *  errorMsg = nullptr 
) const
overridevirtual

Calculate the combination of this and geometries.

Since
QGIS 3.0 geom is a pointer

Implements QgsGeometryEngine.

Definition at line 390 of file qgsgeos.cpp.

◆ contains()

bool QgsGeos::contains ( const QgsAbstractGeometry geom,
QString *  errorMsg = nullptr 
) const
overridevirtual

Checks if geom contains this.

Since
QGIS 3.0 geom is a pointer

Implements QgsGeometryEngine.

Definition at line 513 of file qgsgeos.cpp.

◆ convexHull()

QgsAbstractGeometry * QgsGeos::convexHull ( QString *  errorMsg = nullptr) const
overridevirtual

Calculate the convex hull of this.

Implements QgsGeometryEngine.

Definition at line 1645 of file qgsgeos.cpp.

◆ coordSeqPoint()

QgsPoint QgsGeos::coordSeqPoint ( const GEOSCoordSequence *  cs,
int  i,
bool  hasZ,
bool  hasM 
)
static

Definition at line 1253 of file qgsgeos.cpp.

◆ crosses()

bool QgsGeos::crosses ( const QgsAbstractGeometry geom,
QString *  errorMsg = nullptr 
) const
overridevirtual

Checks if geom crosses this.

Since
QGIS 3.0 geom is a pointer

Implements QgsGeometryEngine.

Definition at line 498 of file qgsgeos.cpp.

◆ delaunayTriangulation()

QgsGeometry QgsGeos::delaunayTriangulation ( double  tolerance = 0.0,
bool  edgesOnly = false,
QString *  errorMsg = nullptr 
) const

Returns the Delaunay triangulation for the vertices of the geometry.

The tolerance parameter specifies an optional snapping tolerance which can be used to improve the robustness of the triangulation. If edgesOnly is true than line string boundary geometries will be returned instead of polygons. An empty geometry will be returned if the diagram could not be calculated.

Since
QGIS 3.0

Definition at line 2328 of file qgsgeos.cpp.

◆ difference()

QgsAbstractGeometry * QgsGeos::difference ( const QgsAbstractGeometry geom,
QString *  errorMsg = nullptr 
) const
overridevirtual

Calculate the difference of this and geom.

Since
QGIS 3.0 geom is a pointer

Implements QgsGeometryEngine.

Definition at line 222 of file qgsgeos.cpp.

◆ disjoint()

bool QgsGeos::disjoint ( const QgsAbstractGeometry geom,
QString *  errorMsg = nullptr 
) const
overridevirtual

Checks if geom is disjoint from this.

Since
QGIS 3.0 geom is a pointer

Implements QgsGeometryEngine.

Definition at line 518 of file qgsgeos.cpp.

◆ distance()

double QgsGeos::distance ( const QgsAbstractGeometry geom,
QString *  errorMsg = nullptr 
) const
overridevirtual

Calculates the distance between this and geom.

Since
QGIS 3.0 geom is a pointer

Implements QgsGeometryEngine.

Definition at line 419 of file qgsgeos.cpp.

◆ envelope()

QgsAbstractGeometry * QgsGeos::envelope ( QString *  errorMsg = nullptr) const
overridevirtual

Implements QgsGeometryEngine.

Definition at line 1602 of file qgsgeos.cpp.

◆ fromGeos()

std::unique_ptr< QgsAbstractGeometry > QgsGeos::fromGeos ( const GEOSGeometry *  geos)
static

Create a geometry from a GEOSGeometry.

Parameters
geosGEOSGeometry. Ownership is NOT transferred.

Definition at line 1081 of file qgsgeos.cpp.

◆ fromGeosPolygon()

std::unique_ptr< QgsPolygon > QgsGeos::fromGeosPolygon ( const GEOSGeometry *  geos)
static

Definition at line 1169 of file qgsgeos.cpp.

◆ geometryChanged()

void QgsGeos::geometryChanged ( )
overridevirtual

Should be called whenever the geometry associated with the engine has been modified and the engine must be updated to suit.

Implements QgsGeometryEngine.

Definition at line 191 of file qgsgeos.cpp.

◆ geometryFromGeos() [1/2]

QgsGeometry QgsGeos::geometryFromGeos ( GEOSGeometry *  geos)
static

Creates a new QgsGeometry object, feeding in a geometry in GEOS format.

This class will take ownership of the buffer.

Definition at line 153 of file qgsgeos.cpp.

◆ geometryFromGeos() [2/2]

QgsGeometry QgsGeos::geometryFromGeos ( const geos::unique_ptr geos)
static

Creates a new QgsGeometry object, feeding in a geometry in GEOS format.

Definition at line 160 of file qgsgeos.cpp.

◆ getGEOSHandler()

GEOSContextHandle_t QgsGeos::getGEOSHandler ( )
static

Definition at line 2815 of file qgsgeos.cpp.

◆ hausdorffDistance()

double QgsGeos::hausdorffDistance ( const QgsAbstractGeometry geom,
QString *  errorMsg = nullptr 
) const

Returns the Hausdorff distance between this geometry and geom.

This is basically a measure of how similar or dissimilar 2 geometries are.

This algorithm is an approximation to the standard Hausdorff distance. This approximation is exact or close enough for a large subset of useful cases. Examples of these are:

  • computing distance between Linestrings that are roughly parallel to each other, and roughly equal in length. This occurs in matching linear networks.
  • Testing similarity of geometries.

If the default approximate provided by this method is insufficient, use hausdorffDistanceDensify() instead.

See also
hausdorffDistanceDensify()
Since
QGIS 3.0

Definition at line 442 of file qgsgeos.cpp.

◆ hausdorffDistanceDensify()

double QgsGeos::hausdorffDistanceDensify ( const QgsAbstractGeometry geom,
double  densifyFraction,
QString *  errorMsg = nullptr 
) const

Returns the Hausdorff distance between this geometry and geom.

This is basically a measure of how similar or dissimilar 2 geometries are.

This function accepts a densifyFraction argument. The function performs a segment densification before computing the discrete Hausdorff distance. The densifyFraction parameter sets the fraction by which to densify each segment. Each segment will be split into a number of equal-length subsegments, whose fraction of the total length is closest to the given fraction.

This method can be used when the default approximation provided by hausdorffDistance() is not sufficient. Decreasing the densifyFraction parameter will make the distance returned approach the true Hausdorff distance for the geometries.

See also
hausdorffDistance()
Since
QGIS 3.0

Definition at line 465 of file qgsgeos.cpp.

◆ interpolate()

QgsAbstractGeometry * QgsGeos::interpolate ( double  distance,
QString *  errorMsg = nullptr 
) const
overridevirtual

Implements QgsGeometryEngine.

Definition at line 1561 of file qgsgeos.cpp.

◆ intersection()

QgsAbstractGeometry * QgsGeos::intersection ( const QgsAbstractGeometry geom,
QString *  errorMsg = nullptr 
) const
overridevirtual

Calculate the intersection of this and geom.

Since
QGIS 3.0 geom is a pointer

Implements QgsGeometryEngine.

Definition at line 217 of file qgsgeos.cpp.

◆ intersects()

bool QgsGeos::intersects ( const QgsAbstractGeometry geom,
QString *  errorMsg = nullptr 
) const
overridevirtual

Checks if geom intersects this.

Since
QGIS 3.0 geom is a pointer

Implements QgsGeometryEngine.

Definition at line 488 of file qgsgeos.cpp.

◆ isEmpty()

bool QgsGeos::isEmpty ( QString *  errorMsg = nullptr) const
overridevirtual

Implements QgsGeometryEngine.

Definition at line 1733 of file qgsgeos.cpp.

◆ isEqual()

bool QgsGeos::isEqual ( const QgsAbstractGeometry geom,
QString *  errorMsg = nullptr 
) const
overridevirtual

Checks if this is equal to geom.

If both are Null geometries, \c false is returned.

Since
QGIS 3.0 geom is a pointer

Implements QgsGeometryEngine.

Definition at line 1713 of file qgsgeos.cpp.

◆ isSimple()

bool QgsGeos::isSimple ( QString *  errorMsg = nullptr) const
overridevirtual

Determines whether the geometry is simple (according to OGC definition).

Since
QGIS 3.0

Implements QgsGeometryEngine.

Definition at line 1747 of file qgsgeos.cpp.

◆ isValid()

bool QgsGeos::isValid ( QString *  errorMsg = nullptr,
bool  allowSelfTouchingHoles = false,
QgsGeometry errorLoc = nullptr 
) const
overridevirtual

Returns true if the geometry is valid.

If the geometry is invalid, errorMsg will be filled with the reported geometry error.

The allowSelfTouchingHoles argument specifies whether self-touching holes are permitted. OGC validity states that self-touching holes are NOT permitted, whilst other vendor validity checks (e.g. ESRI) permit self-touching holes.

If errorLoc is specified, it will be set to the geometry of the error location.

Implements QgsGeometryEngine.

Definition at line 1661 of file qgsgeos.cpp.

◆ length()

double QgsGeos::length ( QString *  errorMsg = nullptr) const
overridevirtual

Implements QgsGeometryEngine.

Definition at line 603 of file qgsgeos.cpp.

◆ lineLocatePoint()

double QgsGeos::lineLocatePoint ( const QgsPoint point,
QString *  errorMsg = nullptr 
) const

Returns a distance representing the location along this linestring of the closest point on this linestring geometry to the specified point.

Ie, the returned value indicates how far along this linestring you need to traverse to get to the closest location where this linestring comes to the specified point.

Parameters
pointpoint to seek proximity to
errorMsgerror messages emitted, if any
Returns
distance along line, or -1 on error
Note
only valid for linestring geometries

Definition at line 2227 of file qgsgeos.cpp.

◆ mergeLines()

QgsGeometry QgsGeos::mergeLines ( QString *  errorMsg = nullptr) const

Merges any connected lines in a LineString/MultiLineString geometry and converts them to single line strings.

Parameters
errorMsgif specified, will be set to any reported GEOS errors
Returns
a LineString or MultiLineString geometry, with any connected lines joined. An empty geometry will be returned if the input geometry was not a LineString/MultiLineString geometry.
Since
QGIS 3.0

Definition at line 2133 of file qgsgeos.cpp.

◆ offsetCurve()

QgsAbstractGeometry * QgsGeos::offsetCurve ( double  distance,
int  segments,
int  joinStyle,
double  miterLimit,
QString *  errorMsg = nullptr 
) const
overridevirtual

Implements QgsGeometryEngine.

Definition at line 1976 of file qgsgeos.cpp.

◆ overlaps()

bool QgsGeos::overlaps ( const QgsAbstractGeometry geom,
QString *  errorMsg = nullptr 
) const
overridevirtual

Checks if geom overlaps this.

Since
QGIS 3.0 geom is a pointer

Implements QgsGeometryEngine.

Definition at line 508 of file qgsgeos.cpp.

◆ pointOnSurface()

QgsPoint * QgsGeos::pointOnSurface ( QString *  errorMsg = nullptr) const
overridevirtual

Calculate a point that is guaranteed to be on the surface of this.

May return a \c nullptr.

Since
QGIS 3.0 the centroid is returned

Implements QgsGeometryEngine.

Definition at line 1617 of file qgsgeos.cpp.

◆ polygonize()

QgsGeometry QgsGeos::polygonize ( const QVector< const QgsAbstractGeometry *> &  geometries,
QString *  errorMsg = nullptr 
)
static

Creates a GeometryCollection geometry containing possible polygons formed from the constituent linework of a set of geometries.

The input geometries must be fully noded (i.e. nodes exist at every common intersection of the geometries). The easiest way to ensure this is to first unary union these geometries by calling combine() on the set of input geometries and then pass the result to polygonize(). An empty geometry will be returned in the case of errors.

Since
QGIS 3.0

Definition at line 2257 of file qgsgeos.cpp.

◆ prepareGeometry()

void QgsGeos::prepareGeometry ( )
overridevirtual

Prepares the geometry, so that subsequent calls to spatial relation methods are much faster.

This should be called for any geometry which is used for multiple relation tests against other geometries.

See also
geometryChanged()

Implements QgsGeometryEngine.

Definition at line 198 of file qgsgeos.cpp.

◆ relate()

QString QgsGeos::relate ( const QgsAbstractGeometry geom,
QString *  errorMsg = nullptr 
) const
overridevirtual

Returns the Dimensional Extended 9 Intersection Model (DE-9IM) representation of the relationship between the geometries.

Parameters
geomgeometry to relate to
errorMsgdestination storage for any error message
Returns
DE-9IM string for relationship, or an empty string if an error occurred
Since
QGIS 2.12

Implements QgsGeometryEngine.

Definition at line 523 of file qgsgeos.cpp.

◆ relatePattern()

bool QgsGeos::relatePattern ( const QgsAbstractGeometry geom,
const QString &  pattern,
QString *  errorMsg = nullptr 
) const
overridevirtual

Tests whether two geometries are related by a specified Dimensional Extended 9 Intersection Model (DE-9IM) pattern.

Parameters
geomgeometry to relate to
patternDE-9IM pattern for match
errorMsgdestination storage for any error message
Returns
true if geometry relationship matches with pattern
Since
QGIS 2.14

Implements QgsGeometryEngine.

Definition at line 557 of file qgsgeos.cpp.

◆ reshapeGeometry()

std::unique_ptr< QgsAbstractGeometry > QgsGeos::reshapeGeometry ( const QgsLineString reshapeWithLine,
EngineOperationResult errorCode,
QString *  errorMsg = nullptr 
) const

Reshapes the geometry using a line.

Parameters
reshapeWithLinethe line used to reshape lines or polygons
errorCodeif specified, provides result of operation (success or reason of failure)
errorMsgif specified, provides more details about failure
Returns
the reshaped geometry

Definition at line 2017 of file qgsgeos.cpp.

◆ shortestLine()

QgsGeometry QgsGeos::shortestLine ( const QgsGeometry other,
QString *  errorMsg = nullptr 
) const

Returns the shortest line joining this geometry to the other geometry.

See also
closestPoint()
Since
QGIS 2.14

Definition at line 2186 of file qgsgeos.cpp.

◆ simplify()

QgsAbstractGeometry * QgsGeos::simplify ( double  tolerance,
QString *  errorMsg = nullptr 
) const
overridevirtual

Implements QgsGeometryEngine.

Definition at line 1546 of file qgsgeos.cpp.

◆ singleSidedBuffer()

std::unique_ptr< QgsAbstractGeometry > QgsGeos::singleSidedBuffer ( double  distance,
int  segments,
int  side,
int  joinStyle,
double  miterLimit,
QString *  errorMsg = nullptr 
) const

Returns a single sided buffer for a geometry.

The buffer is only applied to one side of the geometry.

Parameters
distancebuffer distance
segmentsfor round joins, number of segments to approximate quarter-circle
sideside of geometry to buffer (0 = left, 1 = right)
joinStylejoin style for corners ( Round (1) / Miter (2) / Bevel (3) )
miterLimitlimit on the miter ratio used for very sharp corners
errorMsgerror messages emitted, if any
Returns
buffered geometry, or an nullptr if buffer could not be calculated
Since
QGIS 3.0

Definition at line 1991 of file qgsgeos.cpp.

◆ splitGeometry()

QgsGeometryEngine::EngineOperationResult QgsGeos::splitGeometry ( const QgsLineString splitLine,
QVector< QgsGeometry > &  newGeometries,
bool  topological,
QgsPointSequence topologyTestPoints,
QString *  errorMsg = nullptr 
) const
overridevirtual

Splits this geometry according to a given line.

Parameters
splitLinethe line that splits the geometry
[out]newGeometrieslist of new geometries that have been created with the split
topologicaltrue if topological editing is enabled
[out]topologyTestPointspoints that need to be tested for topological completeness in the dataset
[out]errorMsgerror messages emitted, if any
Returns
0 in case of success, 1 if geometry has not been split, error else

Reimplemented from QgsGeometryEngine.

Definition at line 619 of file qgsgeos.cpp.

◆ subdivide()

std::unique_ptr< QgsAbstractGeometry > QgsGeos::subdivide ( int  maxNodes,
QString *  errorMsg = nullptr 
) const

Subdivides the geometry.

The returned geometry will be a collection containing subdivided parts from the original geometry, where no part has more then the specified maximum number of nodes (maxNodes).

This is useful for dividing a complex geometry into less complex parts, which are better able to be spatially indexed and faster to perform further operations such as intersects on. The returned geometry parts may not be valid and may contain self-intersections.

The minimum allowed value for maxNodes is 8.

Curved geometries are not supported.

Since
QGIS 3.0

Definition at line 341 of file qgsgeos.cpp.

◆ symDifference()

QgsAbstractGeometry * QgsGeos::symDifference ( const QgsAbstractGeometry geom,
QString *  errorMsg = nullptr 
) const
overridevirtual

Calculate the symmetric difference of this and geom.

Since
QGIS 3.0 geom is a pointer

Implements QgsGeometryEngine.

Definition at line 414 of file qgsgeos.cpp.

◆ touches()

bool QgsGeos::touches ( const QgsAbstractGeometry geom,
QString *  errorMsg = nullptr 
) const
overridevirtual

Checks if geom touches this.

Since
QGIS 3.0 geom is a pointer

Implements QgsGeometryEngine.

Definition at line 493 of file qgsgeos.cpp.

◆ voronoiDiagram()

QgsGeometry QgsGeos::voronoiDiagram ( const QgsAbstractGeometry extent = nullptr,
double  tolerance = 0.0,
bool  edgesOnly = false,
QString *  errorMsg = nullptr 
) const

Creates a Voronoi diagram for the nodes contained within the geometry.

Returns the Voronoi polygons for the nodes contained within the geometry. If extent is specified then it will be used as a clipping envelope for the diagram. If no extent is set then the clipping envelope will be automatically calculated. In either case the diagram will be clipped to the larger of the provided envelope OR the envelope surrounding all input nodes. The tolerance parameter specifies an optional snapping tolerance which can be used to improve the robustness of the diagram calculation. If edgesOnly is true than line string boundary geometries will be returned instead of polygons. An empty geometry will be returned if the diagram could not be calculated.

Since
QGIS 3.0

Definition at line 2296 of file qgsgeos.cpp.

◆ within()

bool QgsGeos::within ( const QgsAbstractGeometry geom,
QString *  errorMsg = nullptr 
) const
overridevirtual

Checks if geom is within this.

Since
QGIS 3.0 geom is a pointer

Implements QgsGeometryEngine.

Definition at line 503 of file qgsgeos.cpp.


The documentation for this class was generated from the following files: