Skip to content

Commit

Permalink
[Geometry checker] Update for QgsGeometryEngine API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Oct 23, 2017
1 parent c71d421 commit e4de3a8
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
}
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand Down Expand Up @@ -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 );
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/geometry_checker/checks/qgsgeometrygapcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down Expand Up @@ -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() )
{
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 ) );
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e4de3a8

Please sign in to comment.