Skip to content
Permalink
Browse files

[Geometry checker] Update for QgsGeometryEngine API changes

  • Loading branch information
manisandro committed Sep 19, 2017
1 parent c71d421 commit e4de3a8c33cf5d439369eef57a3063f2ff6e3890
@@ -180,7 +180,7 @@ bool QgsGeometryAreaCheck::mergeWithNeighbor( const QString &layerId, QgsFeature
QgsGeometry mergeFeatureGeom = mergeFeature.geometry();
QgsAbstractGeometry *mergeGeom = mergeFeatureGeom.geometry();
QSharedPointer<QgsGeometryEngine> geomEngine = QgsGeometryCheckerUtils::createGeomEngine( QgsGeometryCheckerUtils::getGeomPart( mergeGeom, mergePartIdx ), mContext->tolerance );
QgsAbstractGeometry *combinedGeom = geomEngine->combine( *QgsGeometryCheckerUtils::getGeomPart( geom, partIdx ), &errMsg );
QgsAbstractGeometry *combinedGeom = geomEngine->combine( QgsGeometryCheckerUtils::getGeomPart( geom, partIdx ), &errMsg );
if ( !combinedGeom || combinedGeom->isEmpty() )
{
return false;
@@ -46,7 +46,7 @@ void QgsGeometryContainedCheck::collectErrors( QList<QgsGeometryCheckError *> &e
continue;
}
QString errMsg;
if ( geomEngineA->within( *layerFeatureB.geometry(), &errMsg ) )
if ( geomEngineA->within( layerFeatureB.geometry(), &errMsg ) )
{
errors.append( new QgsGeometryContainedCheckError( this, layerFeatureA, layerFeatureA.geometry()->centroid(), layerFeatureB ) );
}
@@ -79,7 +79,7 @@ void QgsGeometryContainedCheck::fixError( QgsGeometryCheckError *error, int meth

QSharedPointer<QgsGeometryEngine> geomEngineA = QgsGeometryCheckerUtils::createGeomEngine( layerFeatureA.geometry(), mContext->tolerance );

if ( !geomEngineA->within( *layerFeatureB.geometry() ) )
if ( !geomEngineA->within( layerFeatureB.geometry() ) )
{
error->setObsolete();
return;
@@ -88,7 +88,7 @@ void QgsGeometryDuplicateCheck::collectErrors( QList<QgsGeometryCheckError *> &e
else if ( geomType == QgsWkbTypes::PolygonGeometry )
{
QString errMsg;
QgsAbstractGeometry *diffGeom = geomEngineA->symDifference( *layerFeatureB.geometry(), &errMsg );
QgsAbstractGeometry *diffGeom = geomEngineA->symDifference( layerFeatureB.geometry(), &errMsg );
if ( diffGeom && diffGeom->area() < mContext->tolerance )
{
duplicates[layerFeatureB.layer().id()].append( layerFeatureB.feature().id() );
@@ -152,7 +152,7 @@ void QgsGeometryDuplicateCheck::fixError( QgsGeometryCheckError *error, int meth
}
else if ( geomType == QgsWkbTypes::PolygonGeometry )
{
QgsAbstractGeometry *diffGeom = geomEngineA->symDifference( *layerFeatureB.geometry() );
QgsAbstractGeometry *diffGeom = geomEngineA->symDifference( layerFeatureB.geometry() );
if ( diffGeom && diffGeom->area() < mContext->tolerance )
{
featurePoolB->deleteFeature( featureB );
@@ -84,13 +84,13 @@ void QgsGeometryGapCheck::collectErrors( QList<QgsGeometryCheckError *> &errors,

// Buffer envelope
geomEngine = QgsGeometryCheckerUtils::createGeomEngine( envelope, mContext->tolerance );
QgsAbstractGeometry *bufEnvelope = geomEngine->buffer( 2, 0, GEOSBUF_CAP_SQUARE, GEOSBUF_JOIN_MITRE, 4. );
QgsAbstractGeometry *bufEnvelope = geomEngine->buffer( 2, 0, GEOSBUF_CAP_SQUARE, GEOSBUF_JOIN_MITRE, 4. ); //#spellok //#spellok
delete envelope;
envelope = bufEnvelope;

// Compute difference between envelope and union to obtain gap polygons
geomEngine = QgsGeometryCheckerUtils::createGeomEngine( envelope, mContext->tolerance );
QgsAbstractGeometry *diffGeom = geomEngine->difference( *unionGeom, &errMsg );
QgsAbstractGeometry *diffGeom = geomEngine->difference( unionGeom, &errMsg );
if ( !diffGeom )
{
messages.append( tr( "Gap check: %1" ).arg( errMsg ) );
@@ -220,7 +220,7 @@ bool QgsGeometryGapCheck::mergeWithNeighbor( QgsGeometryGapCheckError *err, Chan
QgsGeometry mergeFeatureGeom = mergeFeature.geometry();
QgsAbstractGeometry *mergeGeom = mergeFeatureGeom.geometry();
QSharedPointer<QgsGeometryEngine> geomEngine = QgsGeometryCheckerUtils::createGeomEngine( errLayerGeom, mContext->tolerance );
QgsAbstractGeometry *combinedGeom = geomEngine->combine( *QgsGeometryCheckerUtils::getGeomPart( mergeGeom, mergePartIdx ), &errMsg );
QgsAbstractGeometry *combinedGeom = geomEngine->combine( QgsGeometryCheckerUtils::getGeomPart( mergeGeom, mergePartIdx ), &errMsg );
delete errLayerGeom;
if ( !combinedGeom || combinedGeom->isEmpty() )
{
@@ -53,9 +53,9 @@ void QgsGeometryOverlapCheck::collectErrors( QList<QgsGeometryCheckError *> &err
continue;
}
QString errMsg;
if ( geomEngineA->overlaps( *layerFeatureB.geometry(), &errMsg ) )
if ( geomEngineA->overlaps( layerFeatureB.geometry(), &errMsg ) )
{
QgsAbstractGeometry *interGeom = geomEngineA->intersection( *layerFeatureB.geometry() );
QgsAbstractGeometry *interGeom = geomEngineA->intersection( layerFeatureB.geometry() );
if ( interGeom && !interGeom->isEmpty() )
{
QgsGeometryCheckerUtils::filter1DTypes( interGeom );
@@ -99,12 +99,12 @@ void QgsGeometryOverlapCheck::fixError( QgsGeometryCheckError *error, int method
QgsGeometryCheckerUtils::LayerFeature layerFeatureB( featurePoolB, featureB, true );
QSharedPointer<QgsGeometryEngine> geomEngineA = QgsGeometryCheckerUtils::createGeomEngine( layerFeatureA.geometry(), mContext->reducedTolerance );

if ( !geomEngineA->overlaps( *layerFeatureB.geometry() ) )
if ( !geomEngineA->overlaps( layerFeatureB.geometry() ) )
{
error->setObsolete();
return;
}
QgsAbstractGeometry *interGeom = geomEngineA->intersection( *layerFeatureB.geometry(), &errMsg );
QgsAbstractGeometry *interGeom = geomEngineA->intersection( layerFeatureB.geometry(), &errMsg );
if ( !interGeom )
{
error->setFixFailed( tr( "Failed to compute intersection between overlapping features: %1" ).arg( errMsg ) );
@@ -137,7 +137,7 @@ void QgsGeometryOverlapCheck::fixError( QgsGeometryCheckError *error, int method
}
else if ( method == Subtract )
{
QgsAbstractGeometry *diff1 = geomEngineA->difference( *interPart, &errMsg );
QgsAbstractGeometry *diff1 = geomEngineA->difference( interPart, &errMsg );
if ( !diff1 || diff1->isEmpty() )
{
delete diff1;
@@ -148,7 +148,7 @@ void QgsGeometryOverlapCheck::fixError( QgsGeometryCheckError *error, int method
QgsGeometryCheckerUtils::filter1DTypes( diff1 );
}
QSharedPointer<QgsGeometryEngine> geomEngineB = QgsGeometryCheckerUtils::createGeomEngine( layerFeatureB.geometry(), mContext->reducedTolerance );
QgsAbstractGeometry *diff2 = geomEngineB->difference( *interPart, &errMsg );
QgsAbstractGeometry *diff2 = geomEngineB->difference( interPart, &errMsg );
if ( !diff2 || diff2->isEmpty() )
{
delete diff2;
@@ -49,7 +49,7 @@ void QgsGeometryPointInPolygonCheck::collectErrors( QList<QgsGeometryCheckError
continue;
}
QSharedPointer<QgsGeometryEngine> testGeomEngine = QgsGeometryCheckerUtils::createGeomEngine( testPoly, mContext->tolerance );
if ( testGeomEngine->contains( *point ) )
if ( testGeomEngine->contains( point ) )
{
// Check whether point does not lie on a ring boundary
bool touchesBoundary = false;

0 comments on commit e4de3a8

Please sign in to comment.
You can’t perform that action at this time.