Class: QgsGeometryEngine¶
-
class
qgis.core.
QgsGeometryEngine
¶ Bases:
sip.wrapper
Contains geometry relation and modification algorithms.
Methods
- param errorMsg
buffer(self, distance: float, segments: int, endCapStyle: int, joinStyle: int, miterLimit: float, errorMsg: str = ‘’) -> QgsAbstractGeometry
Calculates the centroid of this.
Calculate the combination of this and
geom
.Checks if
geom
contains this.Calculate the convex hull of this.
Checks if
geom
crosses this.Calculate the difference of this and
geom
.Checks if
geom
is disjoint from this.Calculates the distance between this and
geom
.- param errorMsg
Should be called whenever the geometry associated with the engine has been modified and the engine must be updated to suit.
- param distance
Calculate the intersection of this and
geom
.Checks if
geom
intersects this.- param errorMsg
Checks if this is equal to
geom
.Determines whether the geometry is simple (according to OGC definition).
Returns true if the geometry is valid.
- param errorMsg
- param distance
Checks if
geom
overlaps this.Calculate a point that is guaranteed to be on the surface of this.
Prepares the geometry, so that subsequent calls to spatial relation methods are much faster.
Returns the Dimensional Extended 9 Intersection Model (DE-9IM) representation of the relationship between the geometries.
Tests whether two geometries are related by a specified Dimensional Extended 9 Intersection Model (DE-9IM) pattern.
- param tolerance
Splits this geometry according to a given line.
Calculate the symmetric difference of this and
geom
.Checks if
geom
touches this.Checks if
geom
is within this.Attributes
-
EngineError
= 1002¶
-
class
EngineOperationResult
¶ Bases:
int
-
InvalidBaseGeometry
= 1004¶
-
InvalidInput
= 1005¶
-
MethodNotImplemented
= 1001¶
-
NodedGeometryError
= 1003¶
-
NothingHappened
= 1000¶
-
SplitCannotSplitPoint
= 1006¶
-
Success
= 0¶
-
area
(self, errorMsg: str = '') → float¶ - Parameters
errorMsg (str = '') –
- Return type
float
-
buffer
(self, distance: float, segments: int, errorMsg: str = '') → QgsAbstractGeometry¶ buffer(self, distance: float, segments: int, endCapStyle: int, joinStyle: int, miterLimit: float, errorMsg: str = ‘’) -> QgsAbstractGeometry
- Parameters
distance (float) –
segments (int) –
errorMsg (str = '') –
- Return type
-
centroid
(self, errorMsg: str = '') → QgsPoint¶ Calculates the centroid of this. May return a
`None`
.New in version 3.0.
- Parameters
errorMsg (str = '') –
- Return type
-
combine
(self, geom: QgsAbstractGeometry, errorMsg: str = '') → QgsAbstractGeometry¶ Calculate the combination of this and
geom
.New in version 3.0.
combine(self, geomList: object, errorMsg: str) -> QgsAbstractGeometry Calculate the combination of this and
geometries
.New in version 3.0.
combine(self, geometries: Iterable[QgsGeometry], errorMsg: str = ‘’) -> QgsAbstractGeometry Calculate the combination of this and
geometries
.New in version 3.0.
- Parameters
geom (QgsAbstractGeometry) –
errorMsg (str = '') –
- Return type
-
contains
(self, geom: QgsAbstractGeometry, errorMsg: str = '') → bool¶ Checks if
geom
contains this.New in version 3.0.
- Parameters
geom (QgsAbstractGeometry) –
errorMsg (str = '') –
- Return type
bool
-
convexHull
(self, errorMsg: str = '') → QgsAbstractGeometry¶ Calculate the convex hull of this.
- Parameters
errorMsg (str = '') –
- Return type
-
crosses
(self, geom: QgsAbstractGeometry, errorMsg: str = '') → bool¶ Checks if
geom
crosses this.New in version 3.0.
- Parameters
geom (QgsAbstractGeometry) –
errorMsg (str = '') –
- Return type
bool
-
difference
(self, geom: QgsAbstractGeometry, errorMsg: str = '') → QgsAbstractGeometry¶ Calculate the difference of this and
geom
.New in version 3.0.
- Parameters
geom (QgsAbstractGeometry) –
errorMsg (str = '') –
- Return type
-
disjoint
(self, geom: QgsAbstractGeometry, errorMsg: str = '') → bool¶ Checks if
geom
is disjoint from this.New in version 3.0.
- Parameters
geom (QgsAbstractGeometry) –
errorMsg (str = '') –
- Return type
bool
-
distance
(self, geom: QgsAbstractGeometry, errorMsg: str = '') → float¶ Calculates the distance between this and
geom
.New in version 3.0.
- Parameters
geom (QgsAbstractGeometry) –
errorMsg (str = '') –
- Return type
float
-
envelope
(self, errorMsg: str = '') → QgsAbstractGeometry¶ - Parameters
errorMsg (str = '') –
- Return type
-
geometryChanged
(self)¶ Should be called whenever the geometry associated with the engine has been modified and the engine must be updated to suit.
-
interpolate
(self, distance: float, errorMsg: str = '') → QgsAbstractGeometry¶ - Parameters
distance (float) –
errorMsg (str = '') –
- Return type
-
intersection
(self, geom: QgsAbstractGeometry, errorMsg: str = '') → QgsAbstractGeometry¶ Calculate the intersection of this and
geom
.New in version 3.0.
- Parameters
geom (QgsAbstractGeometry) –
errorMsg (str = '') –
- Return type
-
intersects
(self, geom: QgsAbstractGeometry, errorMsg: str = '') → bool¶ Checks if
geom
intersects this.New in version 3.0.
- Parameters
geom (QgsAbstractGeometry) –
errorMsg (str = '') –
- Return type
bool
-
isEmpty
(self, errorMsg: str) → bool¶ - Parameters
errorMsg (str) –
- Return type
bool
-
isEqual
(self, geom: QgsAbstractGeometry, errorMsg: str = '') → bool¶ Checks if this is equal to
geom
. If both are Null geometries,`False`
is returned.New in version 3.0.
- Parameters
geom (QgsAbstractGeometry) –
errorMsg (str = '') –
- Return type
bool
-
isSimple
(self, errorMsg: str = '') → bool¶ Determines whether the geometry is simple (according to OGC definition).
New in version 3.0.
- Parameters
errorMsg (str = '') –
- Return type
bool
-
isValid
(self, errorMsg: str = '', allowSelfTouchingHoles: bool = False, errorLoc: QgsGeometry = None) → bool¶ 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.- Parameters
errorMsg (str = '') –
allowSelfTouchingHoles (bool = False) –
errorLoc (
QgsGeometry
= None) –
- Return type
bool
-
length
(self, errorMsg: str = '') → float¶ - Parameters
errorMsg (str = '') –
- Return type
float
-
offsetCurve
(self, distance: float, segments: int, joinStyle: int, miterLimit: float, errorMsg: str = '') → QgsAbstractGeometry¶ - Parameters
distance (float) –
segments (int) –
joinStyle (int) –
miterLimit (float) –
errorMsg (str = '') –
- Return type
-
overlaps
(self, geom: QgsAbstractGeometry, errorMsg: str = '') → bool¶ Checks if
geom
overlaps this.New in version 3.0.
- Parameters
geom (QgsAbstractGeometry) –
errorMsg (str = '') –
- Return type
bool
-
pointOnSurface
(self, errorMsg: str = '') → QgsPoint¶ Calculate a point that is guaranteed to be on the surface of this. May return a
`None`
.New in version 3.0.
- Parameters
errorMsg (str = '') –
- Return type
-
prepareGeometry
(self)¶ 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
-
relate
(self, geom: QgsAbstractGeometry, errorMsg: str = '') → str¶ Returns the Dimensional Extended 9 Intersection Model (DE-9IM) representation of the relationship between the geometries.
- Parameters
geom (QgsAbstractGeometry) – geometry to relate to
errorMsg (str = '') – destination storage for any error message
- Return type
str
- Returns
DE-9IM string for relationship, or an empty string if an error occurred
New in version 2.12.
-
relatePattern
(self, geom: QgsAbstractGeometry, pattern: str, errorMsg: str = '') → bool¶ Tests whether two geometries are related by a specified Dimensional Extended 9 Intersection Model (DE-9IM) pattern.
- Parameters
geom (QgsAbstractGeometry) – geometry to relate to
pattern (str) – DE-9IM pattern for match
errorMsg (str = '') – destination storage for any error message
- Return type
bool
- Returns
True
if geometry relationship matches with pattern
New in version 2.14.
-
simplify
(self, tolerance: float, errorMsg: str = '') → QgsAbstractGeometry¶ - Parameters
tolerance (float) –
errorMsg (str = '') –
- Return type
-
splitGeometry
(self, splitLine: QgsLineString, topological: bool, topologyTestPoints: Iterable[QgsPoint], errorMsg: str = '') → Tuple[QgsGeometryEngine.EngineOperationResult, List[QgsGeometry]]¶ Splits this geometry according to a given line.
- Parameters
splitLine (QgsLineString) – the line that splits the geometry
param[out] newGeometries list of new geometries that have been created with the split :type topological: bool :param topological:
True
if topological editing is enabled param[out] topologyTestPoints points that need to be tested for topological completeness in the dataset param[out] errorMsg error messages emitted, if any- Return type
Tuple[QgsGeometryEngine.EngineOperationResult, List[QgsGeometry]]
- Returns
0 in case of success, 1 if geometry has not been split, error else
- Parameters
topologyTestPoints (Iterable[QgsPoint]) –
errorMsg (str = '') –
-
symDifference
(self, geom: QgsAbstractGeometry, errorMsg: str = '') → QgsAbstractGeometry¶ Calculate the symmetric difference of this and
geom
.New in version 3.0.
- Parameters
geom (QgsAbstractGeometry) –
errorMsg (str = '') –
- Return type
-
touches
(self, geom: QgsAbstractGeometry, errorMsg: str = '') → bool¶ Checks if
geom
touches this.New in version 3.0.
- Parameters
geom (QgsAbstractGeometry) –
errorMsg (str = '') –
- Return type
bool
-
within
(self, geom: QgsAbstractGeometry, errorMsg: str = '') → bool¶ Checks if
geom
is within this.New in version 3.0.
- Parameters
geom (QgsAbstractGeometry) –
errorMsg (str = '') –
- Return type
bool