Skip to content

Commit

Permalink
Expose makeValid() errors to QgsGeometry::error()
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Aug 13, 2017
1 parent feffa04 commit d0f33d6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
12 changes: 9 additions & 3 deletions python/core/geometry/qgsgeometry.sip
Original file line number Diff line number Diff line change
Expand Up @@ -1109,15 +1109,21 @@ Ring 0 is outer ring and can't be deleted.
%Docstring
Attempts to make an invalid geometry valid without losing vertices.

.. note::

Ported from PostGIS ST_MakeValid() and it should return equivalent results.
Already-valid geometries are returned without further intervention.
In case of full or partial dimensional collapses, the output geometry may be a collection
of lower-to-equal dimension geometries or a geometry of lower dimension.
Single polygons may become multi-geometries in case of self-intersections.
It preserves Z values, but M values will be dropped.

If an error was encountered during the process, more information can be retrieved
by calling `error()` on the returned geometry.

:return: new valid QgsGeometry or null geometry on error

.. note::

Ported from PostGIS ST_MakeValid() and it should return equivalent results.

.. versionadded:: 3.0
:rtype: QgsGeometry
%End
Expand Down
3 changes: 1 addition & 2 deletions src/core/geometry/qgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2012,8 +2012,7 @@ QgsGeometry QgsGeometry::makeValid()
if ( !d->geometry )
return QgsGeometry();

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

return QgsGeometry( g );
}
Expand Down
8 changes: 7 additions & 1 deletion src/core/geometry/qgsgeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -993,13 +993,19 @@ class CORE_EXPORT QgsGeometry
/**
* Attempts to make an invalid geometry valid without losing vertices.
*
* \note Ported from PostGIS ST_MakeValid() and it should return equivalent results.
* Already-valid geometries are returned without further intervention.
* In case of full or partial dimensional collapses, the output geometry may be a collection
* of lower-to-equal dimension geometries or a geometry of lower dimension.
* Single polygons may become multi-geometries in case of self-intersections.
* It preserves Z values, but M values will be dropped.
*
* If an error was encountered during the process, more information can be retrieved
* by calling `error()` on the returned geometry.
*
* \returns new valid QgsGeometry or null geometry on error
*
* \note Ported from PostGIS ST_MakeValid() and it should return equivalent results.
*
* \since QGIS 3.0
*/
QgsGeometry makeValid();
Expand Down

0 comments on commit d0f33d6

Please sign in to comment.