void QgsGeometryGapCheck::fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> & /*mergeAttributeIndices*/, Changes &changes ) const { QMetaEnum metaEnum = QMetaEnum::fromType<QgsGeometryGapCheck::ResolutionMethod>(); if ( !metaEnum.isValid() || !metaEnum.valueToKey( method ) ) { error->setFixFailed( tr( "Unknown method" ) ); } else { ResolutionMethod methodValue = static_cast<ResolutionMethod>( method ); switch ( methodValue ) { case NoChange: error->setFixed( method ); break; case MergeLongestEdge: QString errMsg; if ( mergeWithNeighbor( featurePools, static_cast<QgsGeometryGapCheckError *>( error ), changes, errMsg ) ) { error->setFixed( method ); } else { error->setFixFailed( tr( "Failed to merge with neighbor: %1" ).arg( errMsg ) ); } break; } } }
void QgsGeometryAreaCheck::fixError( QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const { QgsFeaturePool *featurePool = mContext->featurePools[ error->layerId() ]; QgsFeature feature; if ( !featurePool->get( error->featureId(), feature ) ) { error->setObsolete(); return; } double layerToMapUnits = featurePool->getLayerToMapUnits(); QgsGeometry g = feature.geometry(); const QgsAbstractGeometry *geom = g.constGet(); QgsVertexId vidx = error->vidx(); // Check if polygon still exists if ( !vidx.isValid( geom ) ) { error->setObsolete(); return; } // Check if error still applies double value; if ( !checkThreshold( layerToMapUnits, QgsGeometryCheckerUtils::getGeomPart( geom, vidx.part ), value ) ) { error->setObsolete(); return; } // Fix with selected method if ( method == NoChange ) { error->setFixed( method ); } else if ( method == Delete ) { deleteFeatureGeometryPart( error->layerId(), feature, vidx.part, changes ); error->setFixed( method ); } else if ( method == MergeLongestEdge || method == MergeLargestArea || method == MergeIdenticalAttribute ) { QString errMsg; if ( mergeWithNeighbor( error->layerId(), feature, vidx.part, method, mergeAttributeIndices[error->layerId()], changes, errMsg ) ) { error->setFixed( method ); } else { error->setFixFailed( tr( "Failed to merge with neighbor: %1" ).arg( errMsg ) ); } } else { error->setFixFailed( tr( "Unknown method" ) ); } }
void QgsGeometryGapCheck::fixError( QgsGeometryCheckError *error, int method, const QMap<QString, int> & /*mergeAttributeIndices*/, Changes &changes ) const { if ( method == NoChange ) { error->setFixed( method ); } else if ( method == MergeLongestEdge ) { QString errMsg; if ( mergeWithNeighbor( static_cast<QgsGeometryGapCheckError *>( error ), changes, errMsg ) ) { error->setFixed( method ); } else { error->setFixFailed( tr( "Failed to merge with neighbor: %1" ).arg( errMsg ) ); } } else { error->setFixFailed( tr( "Unknown method" ) ); } }
void QgsGeometryAreaCheck::fixError( QgsGeometryCheckError* error, int method, int mergeAttributeIndex, Changes &changes ) const { QgsFeature feature; if ( !mFeaturePool->get( error->featureId(), feature ) ) { error->setObsolete(); return; } QgsAbstractGeometryV2* geom = feature.geometry()->geometry(); const QgsVertexId& vidx = error->vidx(); // Check if polygon still exists if ( !vidx.isValid( geom ) ) { error->setObsolete(); return; } // Check if error still applies if ( dynamic_cast<QgsGeometryCollectionV2*>( geom ) ) { double value; if ( !checkThreshold( static_cast<QgsGeometryCollectionV2*>( geom )->geometryN( vidx.part ), value ) ) { error->setObsolete(); return; } } else { double value; if ( !checkThreshold( geom, value ) ) { error->setObsolete(); return; } } // Fix with selected method if ( method == NoChange ) { error->setFixed( method ); } else if ( method == Delete ) { deleteFeatureGeometryPart( feature, vidx.part, changes ); error->setFixed( method ); } else if ( method == MergeLongestEdge || method == MergeLargestArea || method == MergeIdenticalAttribute ) { QString errMsg; if ( mergeWithNeighbor( feature, vidx.part, method, mergeAttributeIndex, changes, errMsg ) ) { error->setFixed( method ); } else { error->setFixFailed( tr( "Failed to merge with neighbor: %1" ).arg( errMsg ) ); } } else { error->setFixFailed( tr( "Unknown method" ) ); } }