@@ -72,28 +72,42 @@ void QgsGeometryMissingVertexCheck::fixError( const QMap<QString, QgsFeaturePool
72
72
{
73
73
Q_UNUSED ( featurePools )
74
74
Q_UNUSED ( changes )
75
- if ( method == NoChange )
75
+
76
+ QMetaEnum metaEnum = QMetaEnum::fromType<QgsGeometryMissingVertexCheck::ResolutionMethod>();
77
+ if ( !metaEnum.isValid () || !metaEnum.valueToKey ( method ) )
76
78
{
77
- error->setFixed ( method );
79
+ error->setFixFailed ( tr ( " Unknown method" ) );
78
80
}
79
- if ( method == AddMissingVertex )
81
+ else
80
82
{
81
- QgsFeaturePool *featurePool = featurePools[ error->layerId () ];
83
+ ResolutionMethod methodValue = static_cast <ResolutionMethod>( method );
84
+ switch ( methodValue )
85
+ {
86
+ case NoChange:
87
+ error->setFixed ( method );
88
+ break ;
89
+
90
+ case AddMissingVertex:
91
+ {
92
+ QgsFeaturePool *featurePool = featurePools[ error->layerId () ];
82
93
83
- QgsFeature feature;
84
- featurePool->getFeature ( error->featureId (), feature );
94
+ QgsFeature feature;
95
+ featurePool->getFeature ( error->featureId (), feature );
85
96
86
- QgsPointXY pointOnSegment; // Should be equal to location
87
- int vertexIndex;
88
- QgsGeometry geometry = feature.geometry ();
89
- geometry.closestSegmentWithContext ( error->location (), pointOnSegment, vertexIndex );
90
- geometry.insertVertex ( QgsPoint ( error->location () ), vertexIndex );
91
- feature.setGeometry ( geometry );
97
+ QgsPointXY pointOnSegment; // Should be equal to location
98
+ int vertexIndex;
99
+ QgsGeometry geometry = feature.geometry ();
100
+ geometry.closestSegmentWithContext ( error->location (), pointOnSegment, vertexIndex );
101
+ geometry.insertVertex ( QgsPoint ( error->location () ), vertexIndex );
102
+ feature.setGeometry ( geometry );
92
103
93
- featurePool->updateFeature ( feature );
94
- // TODO update "changes" structure
104
+ featurePool->updateFeature ( feature );
105
+ // TODO update "changes" structure
95
106
96
- error->setFixed ( method );
107
+ error->setFixed ( method );
108
+ }
109
+ break ;
110
+ }
97
111
}
98
112
}
99
113
0 commit comments