Skip to content

Commit d0f33d6

Browse files
committedAug 13, 2017
Expose makeValid() errors to QgsGeometry::error()
1 parent feffa04 commit d0f33d6

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed
 

‎python/core/geometry/qgsgeometry.sip

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,15 +1109,21 @@ Ring 0 is outer ring and can't be deleted.
11091109
%Docstring
11101110
Attempts to make an invalid geometry valid without losing vertices.
11111111

1112-
.. note::
1113-
1114-
Ported from PostGIS ST_MakeValid() and it should return equivalent results.
11151112
Already-valid geometries are returned without further intervention.
11161113
In case of full or partial dimensional collapses, the output geometry may be a collection
11171114
of lower-to-equal dimension geometries or a geometry of lower dimension.
11181115
Single polygons may become multi-geometries in case of self-intersections.
11191116
It preserves Z values, but M values will be dropped.
1117+
1118+
If an error was encountered during the process, more information can be retrieved
1119+
by calling `error()` on the returned geometry.
1120+
11201121
:return: new valid QgsGeometry or null geometry on error
1122+
1123+
.. note::
1124+
1125+
Ported from PostGIS ST_MakeValid() and it should return equivalent results.
1126+
11211127
.. versionadded:: 3.0
11221128
:rtype: QgsGeometry
11231129
%End

‎src/core/geometry/qgsgeometry.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,8 +2012,7 @@ QgsGeometry QgsGeometry::makeValid()
20122012
if ( !d->geometry )
20132013
return QgsGeometry();
20142014

2015-
QString errorMsg;
2016-
QgsAbstractGeometry *g = _qgis_lwgeom_make_valid( d->geometry, errorMsg );
2015+
QgsAbstractGeometry *g = _qgis_lwgeom_make_valid( d->geometry, d->error );
20172016

20182017
return QgsGeometry( g );
20192018
}

‎src/core/geometry/qgsgeometry.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,13 +993,19 @@ class CORE_EXPORT QgsGeometry
993993
/**
994994
* Attempts to make an invalid geometry valid without losing vertices.
995995
*
996-
* \note Ported from PostGIS ST_MakeValid() and it should return equivalent results.
997996
* Already-valid geometries are returned without further intervention.
998997
* In case of full or partial dimensional collapses, the output geometry may be a collection
999998
* of lower-to-equal dimension geometries or a geometry of lower dimension.
1000999
* Single polygons may become multi-geometries in case of self-intersections.
10011000
* It preserves Z values, but M values will be dropped.
1001+
*
1002+
* If an error was encountered during the process, more information can be retrieved
1003+
* by calling `error()` on the returned geometry.
1004+
*
10021005
* \returns new valid QgsGeometry or null geometry on error
1006+
*
1007+
* \note Ported from PostGIS ST_MakeValid() and it should return equivalent results.
1008+
*
10031009
* \since QGIS 3.0
10041010
*/
10051011
QgsGeometry makeValid();

0 commit comments

Comments
 (0)
Please sign in to comment.