Skip to content

Commit

Permalink
Topology check integration in validation service
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Oct 15, 2018
1 parent 88ef921 commit ea87815
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/app/qgsgeometryvalidationservice.cpp
Expand Up @@ -52,6 +52,10 @@ void QgsGeometryValidationService::onLayersAdded( const QList<QgsMapLayer *> &la
{
onFeatureDeleted( vectorLayer, fid );
} );
connect( vectorLayer, &QgsVectorLayer::beforeCommitChanges, this, [this, vectorLayer]()
{
onBeforeCommitChanges( vectorLayer );
} );

enableLayerChecks( vectorLayer );
}
Expand All @@ -76,6 +80,14 @@ void QgsGeometryValidationService::onFeatureDeleted( QgsVectorLayer *layer, QgsF
cancelChecks( layer, fid );
}

void QgsGeometryValidationService::onBeforeCommitChanges( QgsVectorLayer *layer )
{
if ( !mTopologyChecksOk.value( layer ) )
{
triggerTopologyChecks( layer );
}
}

void QgsGeometryValidationService::enableLayerChecks( QgsVectorLayer *layer )
{
// TODO: finish all ongoing checks
Expand Down Expand Up @@ -145,7 +157,9 @@ void QgsGeometryValidationService::processFeature( QgsVectorLayer *layer, QgsFea
}

emit geometryCheckCompleted( layer, fid, allErrors );
// TODO: this is a bit hardcore
// const auto errors = mIsValidGeometryCheck->processGeometry( feature.geometry() );
// emit geometryCheckCompleted( layer, fid, errors );
}

void QgsGeometryValidationService::triggerTopologyChecks( QgsVectorLayer *layer )
{

}
4 changes: 4 additions & 0 deletions src/app/qgsgeometryvalidationservice.h
Expand Up @@ -71,6 +71,7 @@ class QgsGeometryValidationService : public QObject
void onFeatureAdded( QgsVectorLayer *layer, QgsFeatureId fid );
void onGeometryChanged( QgsVectorLayer *layer, QgsFeatureId fid, const QgsGeometry &geometry );
void onFeatureDeleted( QgsVectorLayer *layer, QgsFeatureId fid );
void onBeforeCommitChanges( QgsVectorLayer *layer );

private:
void enableLayerChecks( QgsVectorLayer *layer );
Expand All @@ -79,9 +80,12 @@ class QgsGeometryValidationService : public QObject

void processFeature( QgsVectorLayer *layer, QgsFeatureId fid );

void triggerTopologyChecks( QgsVectorLayer *layer );

QgsProject *mProject = nullptr;

QHash<QgsVectorLayer *, QList< QgsSingleGeometryCheck * > > mSingleFeatureChecks;
QHash<QgsVectorLayer *, bool > mTopologyChecksOk;
};

#endif // QGSGEOMETRYVALIDATIONSERVICE_H

0 comments on commit ea87815

Please sign in to comment.