Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7672 from m-kuhn/geomCheckerAutoFixes
Add automatical fixes for geometries
- Loading branch information
Showing
12 changed files
with
774 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsgeometryfixes.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsGeometryFixes | ||
{ | ||
%Docstring | ||
|
||
The QgsGeometryFixes class contains options to automatically adjust geometries to | ||
constraints on a layer. | ||
|
||
.. versionadded:: 3.4 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsgeometryfixes.h" | ||
%End | ||
public: | ||
|
||
QgsGeometryFixes(); | ||
%Docstring | ||
Create a new QgsGeometryFixes object. | ||
%End | ||
|
||
bool removeDuplicateNodes() const; | ||
%Docstring | ||
Automatically remove duplicate nodes on all geometries which are edited on this layer. | ||
|
||
.. versionadded:: 3.4 | ||
%End | ||
|
||
void setRemoveDuplicateNodes( bool value ); | ||
%Docstring | ||
Automatically remove duplicate nodes on all geometries which are edited on this layer. | ||
|
||
.. versionadded:: 3.4 | ||
%End | ||
|
||
double geometryPrecision() const; | ||
%Docstring | ||
The precision in which geometries on this layer should be saved. | ||
Geometries which are edited on this layer will be rounded to multiples of this value (snap to grid). | ||
Set to 0.0 to disable. | ||
|
||
.. versionadded:: 3.4 | ||
%End | ||
|
||
void setGeometryPrecision( double value ); | ||
%Docstring | ||
The precision in which geometries on this layer should be saved. | ||
Geometries which are edited on this layer will be rounded to multiples of this value (snap to grid). | ||
Set to 0.0 to disable. | ||
|
||
.. versionadded:: 3.4 | ||
%End | ||
|
||
bool isActive() const; | ||
%Docstring | ||
Determines if at least one fix is enabled. | ||
|
||
.. versionadded:: 3.4 | ||
%End | ||
|
||
void apply( QgsGeometry &geometry ) const; | ||
%Docstring | ||
Apply any fixes configured on this class to ``geometry``. | ||
|
||
.. versionadded:: 3.4 | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsgeometryfixes.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/*************************************************************************** | ||
qgsgeometryfixes.cpp | ||
------------------- | ||
begin : Aug 23, 2018 | ||
copyright : (C) 2018 by Matthias Kuhn | ||
email : matthias@opengis.ch | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsgeometryfixes.h" | ||
|
||
bool QgsGeometryFixes::removeDuplicateNodes() const | ||
{ | ||
return mRemoveDuplicateNodes; | ||
} | ||
|
||
void QgsGeometryFixes::setRemoveDuplicateNodes( bool value ) | ||
{ | ||
mRemoveDuplicateNodes = value; | ||
} | ||
|
||
double QgsGeometryFixes::geometryPrecision() const | ||
{ | ||
return mGeometryPrecision; | ||
} | ||
|
||
void QgsGeometryFixes::setGeometryPrecision( double value ) | ||
{ | ||
mGeometryPrecision = value; | ||
} | ||
|
||
bool QgsGeometryFixes::isActive() const | ||
{ | ||
return mGeometryPrecision != 0.0 || mRemoveDuplicateNodes; | ||
} | ||
|
||
void QgsGeometryFixes::apply( QgsGeometry &geometry ) const | ||
{ | ||
if ( mGeometryPrecision != 0.0 ) | ||
geometry = geometry.snappedToGrid( mGeometryPrecision, mGeometryPrecision ); | ||
|
||
if ( mRemoveDuplicateNodes ) | ||
geometry.removeDuplicateNodes(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/*************************************************************************** | ||
qgsgeometryfixes.h | ||
------------------- | ||
begin : Aug 23, 2018 | ||
copyright : (C) 2018 by Matthias Kuhn | ||
email : matthias@opengis.ch | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSGEOMETRYFIXES_H | ||
#define QGSGEOMETRYFIXES_H | ||
|
||
#include "qgsgeometry.h" | ||
|
||
/** | ||
* \ingroup core | ||
* | ||
* The QgsGeometryFixes class contains options to automatically adjust geometries to | ||
* constraints on a layer. | ||
* | ||
* \since QGIS 3.4 | ||
*/ | ||
class CORE_EXPORT QgsGeometryFixes | ||
{ | ||
public: | ||
|
||
/** | ||
* Create a new QgsGeometryFixes object. | ||
*/ | ||
QgsGeometryFixes() = default; | ||
|
||
/** | ||
* Automatically remove duplicate nodes on all geometries which are edited on this layer. | ||
* | ||
* \since QGIS 3.4 | ||
*/ | ||
bool removeDuplicateNodes() const; | ||
|
||
/** | ||
* Automatically remove duplicate nodes on all geometries which are edited on this layer. | ||
* | ||
* \since QGIS 3.4 | ||
*/ | ||
void setRemoveDuplicateNodes( bool value ); | ||
|
||
/** | ||
* The precision in which geometries on this layer should be saved. | ||
* Geometries which are edited on this layer will be rounded to multiples of this value (snap to grid). | ||
* Set to 0.0 to disable. | ||
* | ||
* \since QGIS 3.4 | ||
*/ | ||
double geometryPrecision() const; | ||
|
||
/** | ||
* The precision in which geometries on this layer should be saved. | ||
* Geometries which are edited on this layer will be rounded to multiples of this value (snap to grid). | ||
* Set to 0.0 to disable. | ||
* | ||
* \since QGIS 3.4 | ||
*/ | ||
void setGeometryPrecision( double value ); | ||
|
||
/** | ||
* Determines if at least one fix is enabled. | ||
* | ||
* \since QGIS 3.4 | ||
*/ | ||
bool isActive() const; | ||
|
||
/** | ||
* Apply any fixes configured on this class to \a geometry. | ||
* | ||
* \since QGIS 3.4 | ||
*/ | ||
void apply( QgsGeometry &geometry ) const; | ||
|
||
private: | ||
|
||
/** | ||
* Automatically remove duplicate nodes on all geometries which are edited on this layer. | ||
* | ||
* \since QGIS 3.4 | ||
*/ | ||
bool mRemoveDuplicateNodes = false; | ||
|
||
/** | ||
* The precision in which geometries on this layer should be saved. | ||
* Geometries which are edited on this layer will be rounded to multiples of this value (snap to grid). | ||
* Set to 0.0 to disable. | ||
* | ||
* \since QGIS 3.4 | ||
*/ | ||
double mGeometryPrecision = 0.0; | ||
}; | ||
|
||
#endif // QGSGEOMETRYFIXES_H |
Oops, something went wrong.