Skip to content
Permalink
Browse files

[Geometry checker] QgsGeomUtils -> QgsGeometryCheckerUtils

  • Loading branch information
manisandro committed Jul 14, 2016
1 parent 97861cd commit 54e424faf73fcaa2323762ec07377e25ad133579
Showing with 66 additions and 66 deletions.
  1. +2 −2 src/plugins/geometry_checker/CMakeLists.txt
  2. +2 −2 src/plugins/geometry_checker/checks/qgsgeometryanglecheck.cpp
  3. +3 −3 src/plugins/geometry_checker/checks/qgsgeometryareacheck.cpp
  4. +2 −2 src/plugins/geometry_checker/checks/qgsgeometrycheck.cpp
  5. +1 −1 src/plugins/geometry_checker/checks/qgsgeometrycheck.h
  6. +2 −2 src/plugins/geometry_checker/checks/qgsgeometrycontainedcheck.cpp
  7. +2 −2 src/plugins/geometry_checker/checks/qgsgeometrydegeneratepolygoncheck.cpp
  8. +2 −2 src/plugins/geometry_checker/checks/qgsgeometryduplicatecheck.cpp
  9. +3 −3 src/plugins/geometry_checker/checks/qgsgeometryduplicatenodescheck.cpp
  10. +10 −10 src/plugins/geometry_checker/checks/qgsgeometrygapcheck.cpp
  11. +1 −1 src/plugins/geometry_checker/checks/qgsgeometrygapcheck.h
  12. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryholecheck.cpp
  13. +1 −1 src/plugins/geometry_checker/checks/qgsgeometrymultipartcheck.cpp
  14. +13 −13 src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.cpp
  15. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.h
  16. +2 −2 src/plugins/geometry_checker/checks/qgsgeometrysegmentlengthcheck.cpp
  17. +4 −4 src/plugins/geometry_checker/checks/qgsgeometryselfintersectioncheck.cpp
  18. +2 −2 src/plugins/geometry_checker/checks/qgsgeometrytypecheck.cpp
  19. +1 −1 src/plugins/geometry_checker/utils/qgsfeaturepool.cpp
  20. +1 −1 src/plugins/geometry_checker/utils/qgsfeaturepool.h
  21. +4 −4 src/plugins/geometry_checker/utils/{qgsgeomutils.cpp → qgsgeometrycheckerutils.cpp}
  22. +6 −6 src/plugins/geometry_checker/utils/{qgsgeomutils.h → qgsgeometrycheckerutils.h}
@@ -26,15 +26,15 @@ SET (geometrychecker_SRCS
ui/qgsgeometrycheckfixdialog.cpp
ui/qgsgeometrycheckerfixsummarydialog.cpp
utils/qgsfeaturepool.cpp
utils/qgsgeomutils.cpp
utils/qgsgeometrycheckerutils.cpp
)

SET (geometrychecker_HDRS
checks/qgsgeometrycheck.h
qgsgeometrycheckerplugin.h
qgsgeometrycheckfactory.h
utils/qgsfeaturepool.h
utils/qgsgeomutils.h
utils/qgsgeometrycheckerutils.h
)

SET (geometrychecker_MOC_HDRS
@@ -32,7 +32,7 @@ void QgsGeometryAngleCheck::collectErrors( QList<QgsGeometryCheckError*>& errors
{
for ( int iRing = 0, nRings = geom->ringCount( iPart ); iRing < nRings; ++iRing )
{
int nVerts = QgsGeomUtils::polyLineSize( geom, iPart, iRing );
int nVerts = QgsGeometryCheckerUtils::polyLineSize( geom, iPart, iRing );
// Less than three points, no angles to check
if ( nVerts < 3 )
{
@@ -85,7 +85,7 @@ void QgsGeometryAngleCheck::fixError( QgsGeometryCheckError* error, int method,
}

// Check if error still applies
int n = QgsGeomUtils::polyLineSize( geometry, vidx.part, vidx.ring );
int n = QgsGeometryCheckerUtils::polyLineSize( geometry, vidx.part, vidx.ring );
const QgsPointV2& p1 = geometry->vertexAt( QgsVertexId( vidx.part, vidx.ring, ( vidx.vertex - 1 + n ) % n ) );
const QgsPointV2& p2 = geometry->vertexAt( vidx );
const QgsPointV2& p3 = geometry->vertexAt( QgsVertexId( vidx.part, vidx.ring, ( vidx.vertex + 1 ) % n ) );
@@ -143,7 +143,7 @@ bool QgsGeometryAreaCheck::mergeWithNeighbor( QgsFeature& feature, int partIdx,
{
continue;
}
double len = QgsGeomUtils::sharedEdgeLength( QgsGeomUtils::getGeomPart( geom, partIdx ), QgsGeomUtils::getGeomPart( testGeom, testPartIdx ), QgsGeometryCheckPrecision::reducedTolerance() );
double len = QgsGeometryCheckerUtils::sharedEdgeLength( QgsGeometryCheckerUtils::getGeomPart( geom, partIdx ), QgsGeometryCheckerUtils::getGeomPart( testGeom, testPartIdx ), QgsGeometryCheckPrecision::reducedTolerance() );
if ( len > 0. )
{
if ( method == MergeLongestEdge || method == MergeLargestArea )
@@ -192,8 +192,8 @@ bool QgsGeometryAreaCheck::mergeWithNeighbor( QgsFeature& feature, int partIdx,

// Merge geometries
QgsAbstractGeometryV2* mergeGeom = mergeFeature.geometry()->geometry();
QgsGeometryEngine* geomEngine = QgsGeomUtils::createGeomEngine( QgsGeomUtils::getGeomPart( mergeGeom, mergePartIdx ), QgsGeometryCheckPrecision::tolerance() );
QgsAbstractGeometryV2* combinedGeom = geomEngine->combine( *QgsGeomUtils::getGeomPart( geom, partIdx ), &errMsg );
QgsGeometryEngine* geomEngine = QgsGeometryCheckerUtils::createGeomEngine( QgsGeometryCheckerUtils::getGeomPart( mergeGeom, mergePartIdx ), QgsGeometryCheckPrecision::tolerance() );
QgsAbstractGeometryV2* combinedGeom = geomEngine->combine( *QgsGeometryCheckerUtils::getGeomPart( geom, partIdx ), &errMsg );
delete geomEngine;
if ( !combinedGeom || combinedGeom->isEmpty() )
{
@@ -80,7 +80,7 @@ QgsAbstractGeometryV2 *QgsGeometryCheckError::geometry()
if ( mCheck->getFeaturePool()->get( featureId(), f ) && f.geometry() )
{
QgsAbstractGeometryV2* geom = f.geometry()->geometry();
return mVidx.part >= 0 ? QgsGeomUtils::getGeomPart( geom, mVidx.part )->clone() : geom->clone();
return mVidx.part >= 0 ? QgsGeometryCheckerUtils::getGeomPart( geom, mVidx.part )->clone() : geom->clone();
}
return nullptr;
}
@@ -196,7 +196,7 @@ void QgsGeometryCheck::deleteFeatureGeometryPart( QgsFeature &feature, int partI

void QgsGeometryCheck::deleteFeatureGeometryRing( QgsFeature &feature, int partIdx, int ringIdx, Changes &changes ) const
{
QgsAbstractGeometryV2* partGeom = QgsGeomUtils::getGeomPart( feature.geometry()->geometry(), partIdx );
QgsAbstractGeometryV2* partGeom = QgsGeometryCheckerUtils::getGeomPart( feature.geometry()->geometry(), partIdx );
if ( dynamic_cast<QgsCurvePolygonV2*>( partGeom ) )
{
// If we delete the exterior ring of a polygon, it makes no sense to keep the interiors
@@ -21,7 +21,7 @@
#include "qgsfeature.h"
#include "qgsvectorlayer.h"
#include "geometry/qgsgeometry.h"
#include "../utils/qgsgeomutils.h"
#include "../utils/qgsgeometrycheckerutils.h"
#include "geos_c.h"
#include <QApplication>

@@ -29,7 +29,7 @@ void QgsGeometryContainedCheck::collectErrors( QList<QgsGeometryCheckError*>& er
continue;
}

QgsGeometryEngine* geomEngine = QgsGeomUtils::createGeomEngine( feature.geometry()->geometry(), QgsGeometryCheckPrecision::tolerance() );
QgsGeometryEngine* geomEngine = QgsGeometryCheckerUtils::createGeomEngine( feature.geometry()->geometry(), QgsGeometryCheckPrecision::tolerance() );

QgsFeatureIds ids = mFeaturePool->getIntersects( feature.geometry()->geometry()->boundingBox() );
Q_FOREACH ( QgsFeatureId otherid, ids )
@@ -72,7 +72,7 @@ void QgsGeometryContainedCheck::fixError( QgsGeometryCheckError* error, int meth
}

// Check if error still applies
QgsGeometryEngine* geomEngine = QgsGeomUtils::createGeomEngine( feature.geometry()->geometry(), QgsGeometryCheckPrecision::tolerance() );
QgsGeometryEngine* geomEngine = QgsGeometryCheckerUtils::createGeomEngine( feature.geometry()->geometry(), QgsGeometryCheckPrecision::tolerance() );

if ( !geomEngine->within( *otherFeature.geometry()->geometry() ) )
{
@@ -32,7 +32,7 @@ void QgsGeometryDegeneratePolygonCheck::collectErrors( QList<QgsGeometryCheckErr
{
for ( int iRing = 0, nRings = geom->ringCount( iPart ); iRing < nRings; ++iRing )
{
if ( QgsGeomUtils::polyLineSize( geom, iPart, iRing ) < 3 )
if ( QgsGeometryCheckerUtils::polyLineSize( geom, iPart, iRing ) < 3 )
{
errors.append( new QgsGeometryCheckError( this, featureid, geom->vertexAt( QgsVertexId( iPart, iRing, 0 ) ), QgsVertexId( iPart, iRing ) ) );
}
@@ -60,7 +60,7 @@ void QgsGeometryDegeneratePolygonCheck::fixError( QgsGeometryCheckError* error,
}

// Check if error still applies
if ( QgsGeomUtils::polyLineSize( geom, vidx.part, vidx.ring ) >= 3 )
if ( QgsGeometryCheckerUtils::polyLineSize( geom, vidx.part, vidx.ring ) >= 3 )
{
error->setObsolete();
return;
@@ -30,7 +30,7 @@ void QgsGeometryDuplicateCheck::collectErrors( QList<QgsGeometryCheckError*>& er
{
continue;
}
QgsGeometryEngine* geomEngine = QgsGeomUtils::createGeomEngine( feature.geometry()->geometry(), QgsGeometryCheckPrecision::tolerance() );
QgsGeometryEngine* geomEngine = QgsGeometryCheckerUtils::createGeomEngine( feature.geometry()->geometry(), QgsGeometryCheckPrecision::tolerance() );

QList<QgsFeatureId> duplicates;
QgsFeatureIds ids = mFeaturePool->getIntersects( feature.geometry()->geometry()->boundingBox() );
@@ -82,7 +82,7 @@ void QgsGeometryDuplicateCheck::fixError( QgsGeometryCheckError* error, int meth
}
else if ( method == RemoveDuplicates )
{
QgsGeometryEngine* geomEngine = QgsGeomUtils::createGeomEngine( feature.geometry()->geometry(), QgsGeometryCheckPrecision::tolerance() );
QgsGeometryEngine* geomEngine = QgsGeometryCheckerUtils::createGeomEngine( feature.geometry()->geometry(), QgsGeometryCheckPrecision::tolerance() );

QgsGeometryDuplicateCheckError* duplicateError = static_cast<QgsGeometryDuplicateCheckError*>( error );
Q_FOREACH ( QgsFeatureId id, duplicateError->duplicates() )
@@ -34,7 +34,7 @@ void QgsGeometryDuplicateNodesCheck::collectErrors( QList<QgsGeometryCheckError*
{
for ( int iRing = 0, nRings = geom->ringCount( iPart ); iRing < nRings; ++iRing )
{
int nVerts = QgsGeomUtils::polyLineSize( geom, iPart, iRing );
int nVerts = QgsGeometryCheckerUtils::polyLineSize( geom, iPart, iRing );
if ( nVerts < 2 )
continue;
for ( int iVert = nVerts - 1, jVert = 0; jVert < nVerts; iVert = jVert++ )
@@ -70,7 +70,7 @@ void QgsGeometryDuplicateNodesCheck::fixError( QgsGeometryCheckError* error, int
}

// Check if error still applies
int nVerts = QgsGeomUtils::polyLineSize( geom, vidx.part, vidx.ring );
int nVerts = QgsGeometryCheckerUtils::polyLineSize( geom, vidx.part, vidx.ring );
QgsPointV2 pi = geom->vertexAt( QgsVertexId( vidx.part, vidx.ring, ( vidx.vertex + nVerts - 1 ) % nVerts ) );
QgsPointV2 pj = geom->vertexAt( error->vidx() );
if ( QgsGeometryUtils::sqrDistance2D( pi, pj ) >= QgsGeometryCheckPrecision::tolerance() * QgsGeometryCheckPrecision::tolerance() )
@@ -87,7 +87,7 @@ void QgsGeometryDuplicateNodesCheck::fixError( QgsGeometryCheckError* error, int
else if ( method == RemoveDuplicates )
{
geom->deleteVertex( error->vidx() );
if ( QgsGeomUtils::polyLineSize( geom, vidx.part, vidx.ring ) < 3 )
if ( QgsGeometryCheckerUtils::polyLineSize( geom, vidx.part, vidx.ring ) < 3 )
{
error->setFixFailed( tr( "Resulting geometry is degenerate" ) );
}
@@ -41,7 +41,7 @@ void QgsGeometryGapCheck::collectErrors( QList<QgsGeometryCheckError*>& errors,
return;
}

QgsGeometryEngine* geomEngine = QgsGeomUtils::createGeomEngine( nullptr, QgsGeometryCheckPrecision::tolerance() );
QgsGeometryEngine* geomEngine = QgsGeometryCheckerUtils::createGeomEngine( nullptr, QgsGeometryCheckPrecision::tolerance() );

// Create union of geometry
QString errMsg;
@@ -55,7 +55,7 @@ void QgsGeometryGapCheck::collectErrors( QList<QgsGeometryCheckError*>& errors,
}

// Get envelope of union
geomEngine = QgsGeomUtils::createGeomEngine( unionGeom, QgsGeometryCheckPrecision::tolerance() );
geomEngine = QgsGeometryCheckerUtils::createGeomEngine( unionGeom, QgsGeometryCheckPrecision::tolerance() );
QgsAbstractGeometryV2* envelope = geomEngine->envelope( &errMsg );
delete geomEngine;
if ( !envelope )
@@ -66,14 +66,14 @@ void QgsGeometryGapCheck::collectErrors( QList<QgsGeometryCheckError*>& errors,
}

// Buffer envelope
geomEngine = QgsGeomUtils::createGeomEngine( envelope, QgsGeometryCheckPrecision::tolerance() );
geomEngine = QgsGeometryCheckerUtils::createGeomEngine( envelope, QgsGeometryCheckPrecision::tolerance() );
QgsAbstractGeometryV2* bufEnvelope = geomEngine->buffer( 2, 0, GEOSBUF_CAP_SQUARE, GEOSBUF_JOIN_MITRE, 4. );
delete geomEngine;
delete envelope;
envelope = bufEnvelope;

// Compute difference between envelope and union to obtain gap polygons
geomEngine = QgsGeomUtils::createGeomEngine( envelope, QgsGeometryCheckPrecision::tolerance() );
geomEngine = QgsGeometryCheckerUtils::createGeomEngine( envelope, QgsGeometryCheckPrecision::tolerance() );
QgsAbstractGeometryV2* diffGeom = geomEngine->difference( *unionGeom, &errMsg );
delete geomEngine;
if ( !diffGeom )
@@ -87,7 +87,7 @@ void QgsGeometryGapCheck::collectErrors( QList<QgsGeometryCheckError*>& errors,
// For each gap polygon which does not lie on the boundary, get neighboring polygons and add error
for ( int iPart = 0, nParts = diffGeom->partCount(); iPart < nParts; ++iPart )
{
QgsAbstractGeometryV2* geom = QgsGeomUtils::getGeomPart( diffGeom, iPart );
QgsAbstractGeometryV2* geom = QgsGeometryCheckerUtils::getGeomPart( diffGeom, iPart );
// Skip the gap between features and boundingbox
if ( geom->boundingBox() == envelope->boundingBox() )
{
@@ -113,7 +113,7 @@ void QgsGeometryGapCheck::collectErrors( QList<QgsGeometryCheckError*>& errors,
continue;
}
QgsAbstractGeometryV2* geom2 = feature.geometry()->geometry();
if ( QgsGeomUtils::sharedEdgeLength( geom, geom2, QgsGeometryCheckPrecision::reducedTolerance() ) > 0 )
if ( QgsGeometryCheckerUtils::sharedEdgeLength( geom, geom2, QgsGeometryCheckPrecision::reducedTolerance() ) > 0 )
{
neighboringIds.insert( feature.id() );
gapAreaBBox.unionRect( geom2->boundingBox() );
@@ -164,7 +164,7 @@ bool QgsGeometryGapCheck::mergeWithNeighbor( QgsGeometryGapCheckError* err, Chan
QgsFeature mergeFeature;
int mergePartIdx = -1;

QgsAbstractGeometryV2* errGeometry = QgsGeomUtils::getGeomPart( err->geometry(), 0 );
QgsAbstractGeometryV2* errGeometry = QgsGeometryCheckerUtils::getGeomPart( err->geometry(), 0 );

// Search for touching neighboring geometries
Q_FOREACH ( QgsFeatureId testId, err->neighbors() )
@@ -177,7 +177,7 @@ bool QgsGeometryGapCheck::mergeWithNeighbor( QgsGeometryGapCheckError* err, Chan
QgsAbstractGeometryV2* testGeom = testFeature.geometry()->geometry();
for ( int iPart = 0, nParts = testGeom->partCount(); iPart < nParts; ++iPart )
{
double len = QgsGeomUtils::sharedEdgeLength( errGeometry, QgsGeomUtils::getGeomPart( testGeom, iPart ), QgsGeometryCheckPrecision::reducedTolerance() );
double len = QgsGeometryCheckerUtils::sharedEdgeLength( errGeometry, QgsGeometryCheckerUtils::getGeomPart( testGeom, iPart ), QgsGeometryCheckPrecision::reducedTolerance() );
if ( len > maxVal )
{
maxVal = len;
@@ -194,8 +194,8 @@ bool QgsGeometryGapCheck::mergeWithNeighbor( QgsGeometryGapCheckError* err, Chan

// Merge geometries
QgsAbstractGeometryV2* mergeGeom = mergeFeature.geometry()->geometry();
QgsGeometryEngine* geomEngine = QgsGeomUtils::createGeomEngine( errGeometry, QgsGeometryCheckPrecision::tolerance() );
QgsAbstractGeometryV2* combinedGeom = geomEngine->combine( *QgsGeomUtils::getGeomPart( mergeGeom, mergePartIdx ), &errMsg );
QgsGeometryEngine* geomEngine = QgsGeometryCheckerUtils::createGeomEngine( errGeometry, QgsGeometryCheckPrecision::tolerance() );
QgsAbstractGeometryV2* combinedGeom = geomEngine->combine( *QgsGeometryCheckerUtils::getGeomPart( mergeGeom, mergePartIdx ), &errMsg );
delete geomEngine;
if ( !combinedGeom || combinedGeom->isEmpty() )
{
@@ -44,7 +44,7 @@ class QgsGeometryGapCheckError : public QgsGeometryCheckError
bool isEqual( QgsGeometryCheckError* other ) const override
{
QgsGeometryGapCheckError* err = dynamic_cast<QgsGeometryGapCheckError*>( other );
return err && QgsGeomUtils::pointsFuzzyEqual( err->location(), location(), QgsGeometryCheckPrecision::reducedTolerance() ) && err->neighbors() == neighbors();
return err && QgsGeometryCheckerUtils::pointsFuzzyEqual( err->location(), location(), QgsGeometryCheckPrecision::reducedTolerance() ) && err->neighbors() == neighbors();
}

bool closeMatch( QgsGeometryCheckError *other ) const override
@@ -34,7 +34,7 @@ void QgsGeometryHoleCheck::collectErrors( QList<QgsGeometryCheckError*>& errors,
// Rings after the first one are interiors
for ( int iRing = 1, nRings = geom->ringCount( iPart ); iRing < nRings; ++iRing )
{
errors.append( new QgsGeometryCheckError( this, featureid, QgsGeomUtils::getGeomPart( geom, iPart )->centroid(), QgsVertexId( iPart, iRing ) ) );
errors.append( new QgsGeometryCheckError( this, featureid, QgsGeometryCheckerUtils::getGeomPart( geom, iPart )->centroid(), QgsVertexId( iPart, iRing ) ) );
}
}
}
@@ -61,7 +61,7 @@ void QgsGeometryMultipartCheck::fixError( QgsGeometryCheckError* error, int meth
}
else if ( method == ConvertToSingle )
{
feature.setGeometry( new QgsGeometry( QgsGeomUtils::getGeomPart( geom, 0 )->clone() ) );
feature.setGeometry( new QgsGeometry( QgsGeometryCheckerUtils::getGeomPart( geom, 0 )->clone() ) );
mFeaturePool->updateFeature( feature );
error->setFixed( method );
changes[feature.id()].append( Change( ChangeFeature, ChangeChanged ) );

0 comments on commit 54e424f

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