QGIS API Documentation
3.6.0-Noosa (5873452)
|
Does vector analysis using the geos library and handles import, export, exception handling*. More...
#include <qgsgeos.h>
Public Member Functions | |
QgsGeos (const QgsAbstractGeometry *geometry, double precision=0) | |
GEOS geometry engine constructor. More... | |
double | area (QString *errorMsg=nullptr) const override |
QgsAbstractGeometry * | buffer (double distance, int segments, QString *errorMsg=nullptr) const override |
QgsAbstractGeometry * | buffer (double distance, int segments, int endCapStyle, int joinStyle, double miterLimit, QString *errorMsg=nullptr) const override |
QgsPoint * | centroid (QString *errorMsg=nullptr) const override |
Calculates the centroid of this. More... | |
std::unique_ptr< QgsAbstractGeometry > | clip (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... | |
QgsAbstractGeometry * | combine (const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const override |
Calculate the combination of this and geom. More... | |
QgsAbstractGeometry * | combine (const QVector< QgsAbstractGeometry *> &geomList, QString *errorMsg) const override |
Calculate the combination of this and geometries. More... | |
QgsAbstractGeometry * | combine (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... | |
QgsAbstractGeometry * | convexHull (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... | |
QgsAbstractGeometry * | difference (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... | |
QgsAbstractGeometry * | envelope (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... | |
QgsAbstractGeometry * | interpolate (double distance, QString *errorMsg=nullptr) const override |
QgsAbstractGeometry * | intersection (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) const override |
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... | |
QgsAbstractGeometry * | offsetCurve (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... | |
QgsPoint * | pointOnSurface (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< QgsAbstractGeometry > | reshapeGeometry (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... | |
QgsAbstractGeometry * | simplify (double tolerance, QString *errorMsg=nullptr) const override |
std::unique_ptr< QgsAbstractGeometry > | singleSidedBuffer (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< QgsAbstractGeometry > | subdivide (int maxNodes, QString *errorMsg=nullptr) const |
Subdivides the geometry. More... | |
QgsAbstractGeometry * | symDifference (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< QgsAbstractGeometry > | fromGeos (const GEOSGeometry *geos) |
Create a geometry from a GEOSGeometry. More... | |
static std::unique_ptr< QgsPolygon > | fromGeosPolygon (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 QgsAbstractGeometry * | mGeometry = nullptr |
Does vector analysis using the geos library and handles import, export, exception handling*.
QgsGeos::QgsGeos | ( | const QgsAbstractGeometry * | geometry, |
double | precision = 0 |
||
) |
GEOS geometry engine constructor.
geometry | The geometry |
precision | The 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.
|
static |
Adds a new island polygon to a multipolygon feature.
geometry | geometry to add part to |
newPart | part to add. Ownership is NOT transferred. |
Definition at line 176 of file qgsgeos.cpp.
|
overridevirtual |
Implements QgsGeometryEngine.
Definition at line 586 of file qgsgeos.cpp.
|
static |
Returns a geos geometry - caller takes ownership of the object (should be deleted with GEOSGeom_destroy_r)
geometry | geometry to convert to GEOS representation |
precision | The 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.
|
static |
Returns a geos geometry - caller takes ownership of the object (should be deleted with GEOSGeom_destroy_r)
geometry | geometry to convert to GEOS representation |
precision | The 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.
|
overridevirtual |
Implements QgsGeometryEngine.
Definition at line 1514 of file qgsgeos.cpp.
|
overridevirtual |
Implements QgsGeometryEngine.
Definition at line 1530 of file qgsgeos.cpp.
|
overridevirtual |
Calculates the centroid of this.
May return a nullptr
.
Implements QgsGeometryEngine.
Definition at line 1576 of file qgsgeos.cpp.
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.
QgsGeometry QgsGeos::closestPoint | ( | const QgsGeometry & | other, |
QString * | errorMsg = nullptr |
||
) | const |
Returns the closest point on the geometry to the other geometry.
Definition at line 2114 of file qgsgeos.cpp.
|
overridevirtual |
Calculate the combination of this and geom.
Implements QgsGeometryEngine.
Definition at line 361 of file qgsgeos.cpp.
|
overridevirtual |
Calculate the combination of this and geometries.
Implements QgsGeometryEngine.
Definition at line 366 of file qgsgeos.cpp.
|
overridevirtual |
Calculate the combination of this and geometries.
Implements QgsGeometryEngine.
Definition at line 390 of file qgsgeos.cpp.
|
overridevirtual |
Checks if geom contains this.
Implements QgsGeometryEngine.
Definition at line 513 of file qgsgeos.cpp.
|
overridevirtual |
Calculate the convex hull of this.
Implements QgsGeometryEngine.
Definition at line 1645 of file qgsgeos.cpp.
|
static |
Definition at line 1253 of file qgsgeos.cpp.
|
overridevirtual |
Checks if geom crosses this.
Implements QgsGeometryEngine.
Definition at line 498 of file qgsgeos.cpp.
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.
Definition at line 2290 of file qgsgeos.cpp.
|
overridevirtual |
Calculate the difference of this and geom.
Implements QgsGeometryEngine.
Definition at line 222 of file qgsgeos.cpp.
|
overridevirtual |
Checks if geom is disjoint from this.
Implements QgsGeometryEngine.
Definition at line 518 of file qgsgeos.cpp.
|
overridevirtual |
Calculates the distance between this and geom.
Implements QgsGeometryEngine.
Definition at line 419 of file qgsgeos.cpp.
|
overridevirtual |
Implements QgsGeometryEngine.
Definition at line 1602 of file qgsgeos.cpp.
|
static |
Create a geometry from a GEOSGeometry.
geos | GEOSGeometry. Ownership is NOT transferred. |
Definition at line 1081 of file qgsgeos.cpp.
|
static |
Definition at line 1169 of file qgsgeos.cpp.
|
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.
|
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.
|
static |
Creates a new QgsGeometry object, feeding in a geometry in GEOS format.
Definition at line 160 of file qgsgeos.cpp.
|
static |
Definition at line 2777 of file qgsgeos.cpp.
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:
If the default approximate provided by this method is insufficient, use hausdorffDistanceDensify() instead.
Definition at line 442 of file qgsgeos.cpp.
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.
Definition at line 465 of file qgsgeos.cpp.
|
overridevirtual |
Implements QgsGeometryEngine.
Definition at line 1561 of file qgsgeos.cpp.
|
overridevirtual |
Calculate the intersection of this and geom.
Implements QgsGeometryEngine.
Definition at line 217 of file qgsgeos.cpp.
|
overridevirtual |
Checks if geom intersects this.
Implements QgsGeometryEngine.
Definition at line 488 of file qgsgeos.cpp.
|
overridevirtual |
Implements QgsGeometryEngine.
Definition at line 1695 of file qgsgeos.cpp.
|
overridevirtual |
Checks if this is equal to geom.
If both are Null geometries, false
is returned.
Implements QgsGeometryEngine.
Definition at line 1675 of file qgsgeos.cpp.
|
overridevirtual |
Determines whether the geometry is simple (according to OGC definition).
Implements QgsGeometryEngine.
Definition at line 1709 of file qgsgeos.cpp.
|
overridevirtual |
Implements QgsGeometryEngine.
Definition at line 1661 of file qgsgeos.cpp.
|
overridevirtual |
Implements QgsGeometryEngine.
Definition at line 603 of file qgsgeos.cpp.
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.
point | point to seek proximity to |
errorMsg | error messages emitted, if any |
Definition at line 2189 of file qgsgeos.cpp.
QgsGeometry QgsGeos::mergeLines | ( | QString * | errorMsg = nullptr | ) | const |
Merges any connected lines in a LineString/MultiLineString geometry and converts them to single line strings.
errorMsg | if specified, will be set to any reported GEOS errors |
Definition at line 2095 of file qgsgeos.cpp.
|
overridevirtual |
Implements QgsGeometryEngine.
Definition at line 1938 of file qgsgeos.cpp.
|
overridevirtual |
Checks if geom overlaps this.
Implements QgsGeometryEngine.
Definition at line 508 of file qgsgeos.cpp.
|
overridevirtual |
Calculate a point that is guaranteed to be on the surface of this.
May return a nullptr
.
Implements QgsGeometryEngine.
Definition at line 1617 of file qgsgeos.cpp.
|
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.
Definition at line 2219 of file qgsgeos.cpp.
|
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.
Implements QgsGeometryEngine.
Definition at line 198 of file qgsgeos.cpp.
|
overridevirtual |
Returns the Dimensional Extended 9 Intersection Model (DE-9IM) representation of the relationship between the geometries.
geom | geometry to relate to |
errorMsg | destination storage for any error message |
Implements QgsGeometryEngine.
Definition at line 523 of file qgsgeos.cpp.
|
overridevirtual |
Tests whether two geometries are related by a specified Dimensional Extended 9 Intersection Model (DE-9IM) pattern.
geom | geometry to relate to |
pattern | DE-9IM pattern for match |
errorMsg | destination storage for any error message |
Implements QgsGeometryEngine.
Definition at line 557 of file qgsgeos.cpp.
std::unique_ptr< QgsAbstractGeometry > QgsGeos::reshapeGeometry | ( | const QgsLineString & | reshapeWithLine, |
EngineOperationResult * | errorCode, | ||
QString * | errorMsg = nullptr |
||
) | const |
Reshapes the geometry using a line.
reshapeWithLine | the line used to reshape lines or polygons |
errorCode | if specified, provides result of operation (success or reason of failure) |
errorMsg | if specified, provides more details about failure |
Definition at line 1979 of file qgsgeos.cpp.
QgsGeometry QgsGeos::shortestLine | ( | const QgsGeometry & | other, |
QString * | errorMsg = nullptr |
||
) | const |
Returns the shortest line joining this geometry to the other geometry.
Definition at line 2148 of file qgsgeos.cpp.
|
overridevirtual |
Implements QgsGeometryEngine.
Definition at line 1546 of file qgsgeos.cpp.
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.
distance | buffer distance |
segments | for round joins, number of segments to approximate quarter-circle |
side | side of geometry to buffer (0 = left, 1 = right) |
joinStyle | join style for corners ( Round (1) / Miter (2) / Bevel (3) ) |
miterLimit | limit on the miter ratio used for very sharp corners |
errorMsg | error messages emitted, if any |
Definition at line 1953 of file qgsgeos.cpp.
|
overridevirtual |
Splits this geometry according to a given line.
splitLine | the line that splits the geometry | |
[out] | newGeometries | list of new geometries that have been created with the split |
topological | true if topological editing is enabled | |
[out] | topologyTestPoints | points that need to be tested for topological completeness in the dataset |
[out] | errorMsg | error messages emitted, if any |
Reimplemented from QgsGeometryEngine.
Definition at line 619 of file qgsgeos.cpp.
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.
Definition at line 341 of file qgsgeos.cpp.
|
overridevirtual |
Calculate the symmetric difference of this and geom.
Implements QgsGeometryEngine.
Definition at line 414 of file qgsgeos.cpp.
|
overridevirtual |
Checks if geom touches this.
Implements QgsGeometryEngine.
Definition at line 493 of file qgsgeos.cpp.
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.
Definition at line 2258 of file qgsgeos.cpp.
|
overridevirtual |
Checks if geom is within this.
Implements QgsGeometryEngine.
Definition at line 503 of file qgsgeos.cpp.