|
1 | 1 | /***************************************************************************
|
2 |
| - qgsgeometryfixes.cpp |
| 2 | + qgsgeometryoptions.cpp |
3 | 3 | -------------------
|
4 | 4 | begin : Aug 23, 2018
|
5 | 5 | copyright : (C) 2018 by Matthias Kuhn
|
|
15 | 15 | * *
|
16 | 16 | ***************************************************************************/
|
17 | 17 |
|
18 |
| -#include "qgsgeometryfixes.h" |
| 18 | +#include "qgsgeometryoptions.h" |
19 | 19 |
|
20 |
| -bool QgsGeometryFixes::removeDuplicateNodes() const |
| 20 | +#include "qgsxmlutils.h" |
| 21 | + |
| 22 | +bool QgsGeometryOptions::removeDuplicateNodes() const |
21 | 23 | {
|
22 | 24 | return mRemoveDuplicateNodes;
|
23 | 25 | }
|
24 | 26 |
|
25 |
| -void QgsGeometryFixes::setRemoveDuplicateNodes( bool value ) |
| 27 | +void QgsGeometryOptions::setRemoveDuplicateNodes( bool value ) |
26 | 28 | {
|
27 | 29 | mRemoveDuplicateNodes = value;
|
28 | 30 | }
|
29 | 31 |
|
30 |
| -double QgsGeometryFixes::geometryPrecision() const |
| 32 | +double QgsGeometryOptions::geometryPrecision() const |
31 | 33 | {
|
32 | 34 | return mGeometryPrecision;
|
33 | 35 | }
|
34 | 36 |
|
35 |
| -void QgsGeometryFixes::setGeometryPrecision( double value ) |
| 37 | +void QgsGeometryOptions::setGeometryPrecision( double value ) |
36 | 38 | {
|
37 | 39 | mGeometryPrecision = value;
|
38 | 40 | }
|
39 | 41 |
|
40 |
| -bool QgsGeometryFixes::isActive() const |
| 42 | +bool QgsGeometryOptions::isActive() const |
41 | 43 | {
|
42 | 44 | return mGeometryPrecision != 0.0 || mRemoveDuplicateNodes;
|
43 | 45 | }
|
44 | 46 |
|
45 |
| -void QgsGeometryFixes::apply( QgsGeometry &geometry ) const |
| 47 | +void QgsGeometryOptions::apply( QgsGeometry &geometry ) const |
46 | 48 | {
|
47 | 49 | if ( mGeometryPrecision != 0.0 )
|
48 | 50 | geometry = geometry.snappedToGrid( mGeometryPrecision, mGeometryPrecision );
|
49 | 51 |
|
50 | 52 | if ( mRemoveDuplicateNodes )
|
51 | 53 | geometry.removeDuplicateNodes();
|
52 | 54 | }
|
| 55 | + |
| 56 | +void QgsGeometryOptions::writeXml( QDomNode &node ) const |
| 57 | +{ |
| 58 | + QDomElement geometryOptionsElement = node.ownerDocument().createElement( QStringLiteral( "geometryOptions" ) ); |
| 59 | + node.appendChild( geometryOptionsElement ); |
| 60 | + |
| 61 | + geometryOptionsElement.setAttribute( QStringLiteral( "removeDuplicateNodes" ), mRemoveDuplicateNodes ? 1 : 0 ); |
| 62 | + geometryOptionsElement.setAttribute( QStringLiteral( "geometryPrecision" ), mGeometryPrecision ); |
| 63 | +} |
| 64 | + |
| 65 | +void QgsGeometryOptions::readXml( const QDomNode &node ) |
| 66 | +{ |
| 67 | + QDomElement geometryOptionsElement = node.toElement(); |
| 68 | + setGeometryPrecision( geometryOptionsElement.attribute( QStringLiteral( "geometryPrecision" ), QStringLiteral( "0.0" ) ).toDouble() ); |
| 69 | + setRemoveDuplicateNodes( geometryOptionsElement.attribute( QStringLiteral( "removeDuplicateNodes" ), QStringLiteral( "0" ) ).toInt() == 1 ); |
| 70 | +} |
0 commit comments