mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-30 00:04:11 -04:00
[Geometry checker] Make checks report affected are in selected crs
This commit is contained in:
parent
2a92bfb2c9
commit
e7efde2c31
@ -13,6 +13,7 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "qgscrscache.h"
|
||||||
#include "qgsgeometrycollection.h"
|
#include "qgsgeometrycollection.h"
|
||||||
#include "qgscurvepolygon.h"
|
#include "qgscurvepolygon.h"
|
||||||
#include "qgsgeometrycheck.h"
|
#include "qgsgeometrycheck.h"
|
||||||
@ -41,7 +42,7 @@ QgsGeometryCheckError::QgsGeometryCheckError( const QgsGeometryCheck *check, con
|
|||||||
, mStatus( StatusPending )
|
, mStatus( StatusPending )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QgsAbstractGeometry *QgsGeometryCheckError::geometry()
|
QgsAbstractGeometry *QgsGeometryCheckError::geometry() const
|
||||||
{
|
{
|
||||||
QgsFeature f;
|
QgsFeature f;
|
||||||
if ( mCheck->getContext()->featurePools[ layerId() ]->get( featureId(), f ) && f.hasGeometry() )
|
if ( mCheck->getContext()->featurePools[ layerId() ]->get( featureId(), f ) && f.hasGeometry() )
|
||||||
@ -53,6 +54,20 @@ QgsAbstractGeometry *QgsGeometryCheckError::geometry()
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QgsRectangle QgsGeometryCheckError::affectedAreaBBox() const
|
||||||
|
{
|
||||||
|
QgsAbstractGeometry *geom = geometry();
|
||||||
|
if ( !geom )
|
||||||
|
{
|
||||||
|
return QgsRectangle();
|
||||||
|
}
|
||||||
|
QString srcCrs = mCheck->getContext()->featurePools[ layerId() ]->getLayer()->crs().authid();
|
||||||
|
QgsCoordinateTransform t = QgsCoordinateTransformCache::instance()->transform( srcCrs, mCheck->getContext()->crs );
|
||||||
|
QgsRectangle rect = t.transformBoundingBox( geom->boundingBox() );
|
||||||
|
delete geom;
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
|
||||||
bool QgsGeometryCheckError::handleChanges( const QgsGeometryCheck::Changes &changes )
|
bool QgsGeometryCheckError::handleChanges( const QgsGeometryCheck::Changes &changes )
|
||||||
{
|
{
|
||||||
if ( status() == StatusObsolete )
|
if ( status() == StatusObsolete )
|
||||||
|
@ -105,15 +105,15 @@ class QgsGeometryCheckError
|
|||||||
QgsVertexId vidx = QgsVertexId(),
|
QgsVertexId vidx = QgsVertexId(),
|
||||||
const QVariant &value = QVariant(),
|
const QVariant &value = QVariant(),
|
||||||
ValueType valueType = ValueOther );
|
ValueType valueType = ValueOther );
|
||||||
virtual ~QgsGeometryCheckError() = default;
|
virtual ~QgsGeometryCheckError() {}
|
||||||
|
|
||||||
const QgsGeometryCheckError &operator=( const QgsGeometryCheckError & ) = delete;
|
const QgsGeometryCheckError &operator=( const QgsGeometryCheckError & ) = delete;
|
||||||
|
|
||||||
const QgsGeometryCheck *check() const { return mCheck; }
|
const QgsGeometryCheck *check() const { return mCheck; }
|
||||||
const QString &layerId() const { return mLayerId; }
|
const QString &layerId() const { return mLayerId; }
|
||||||
QgsFeatureId featureId() const { return mFeatureId; }
|
QgsFeatureId featureId() const { return mFeatureId; }
|
||||||
virtual QgsAbstractGeometry *geometry();
|
virtual QgsAbstractGeometry *geometry() const;
|
||||||
virtual QgsRectangle affectedAreaBBox() { return geometry() ? geometry()->boundingBox() : QgsRectangle(); }
|
virtual QgsRectangle affectedAreaBBox() const;
|
||||||
virtual QString description() const { return mCheck->errorDescription(); }
|
virtual QString description() const { return mCheck->errorDescription(); }
|
||||||
const QgsPoint &location() const { return mErrorLocation; }
|
const QgsPoint &location() const { return mErrorLocation; }
|
||||||
QVariant value() const { return mValue; }
|
QVariant value() const { return mValue; }
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "qgscrscache.h"
|
||||||
#include "qgsgeometryengine.h"
|
#include "qgsgeometryengine.h"
|
||||||
#include "qgsgeometrygapcheck.h"
|
#include "qgsgeometrygapcheck.h"
|
||||||
#include "qgsgeometrycollection.h"
|
#include "qgsgeometrycollection.h"
|
||||||
@ -28,6 +29,7 @@ void QgsGeometryGapCheck::collectErrors( QList<QgsGeometryCheckError *> &errors,
|
|||||||
for ( const QString &layerId : featureIds.keys() )
|
for ( const QString &layerId : featureIds.keys() )
|
||||||
{
|
{
|
||||||
QgsFeaturePool *featurePool = mContext->featurePools[ layerId ];
|
QgsFeaturePool *featurePool = mContext->featurePools[ layerId ];
|
||||||
|
QgsCoordinateTransform t = QgsCoordinateTransformCache::instance()->transform( featurePool->getLayer()->crs().authid(), mContext->crs );
|
||||||
if ( !getCompatibility( featurePool->getLayer()->geometryType() ) )
|
if ( !getCompatibility( featurePool->getLayer()->geometryType() ) )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@ -110,7 +112,7 @@ void QgsGeometryGapCheck::collectErrors( QList<QgsGeometryCheckError *> &errors,
|
|||||||
|
|
||||||
// Get neighboring polygons
|
// Get neighboring polygons
|
||||||
QgsFeatureIds neighboringIds;
|
QgsFeatureIds neighboringIds;
|
||||||
QgsRectangle gapAreaBBox = geom->boundingBox();
|
QgsRectangle gapAreaBBox = t.transform( geom->boundingBox() );
|
||||||
QgsFeatureIds intersectIds = featurePool->getIntersects( geom->boundingBox() );
|
QgsFeatureIds intersectIds = featurePool->getIntersects( geom->boundingBox() );
|
||||||
|
|
||||||
for ( QgsFeatureId id : intersectIds )
|
for ( QgsFeatureId id : intersectIds )
|
||||||
@ -125,7 +127,7 @@ void QgsGeometryGapCheck::collectErrors( QList<QgsGeometryCheckError *> &errors,
|
|||||||
if ( QgsGeometryCheckerUtils::sharedEdgeLength( geom, geom2, mContext->reducedTolerance ) > 0 )
|
if ( QgsGeometryCheckerUtils::sharedEdgeLength( geom, geom2, mContext->reducedTolerance ) > 0 )
|
||||||
{
|
{
|
||||||
neighboringIds.insert( feature.id() );
|
neighboringIds.insert( feature.id() );
|
||||||
gapAreaBBox.unionRect( geom2->boundingBox() );
|
gapAreaBBox.unionRect( t.transform( geom2->boundingBox() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( neighboringIds.isEmpty() )
|
if ( neighboringIds.isEmpty() )
|
||||||
|
@ -39,7 +39,7 @@ class QgsGeometryGapCheckError : public QgsGeometryCheckError
|
|||||||
delete mGeometry;
|
delete mGeometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsAbstractGeometry *geometry() override { return mGeometry->clone(); }
|
QgsAbstractGeometry *geometry() const override { return mGeometry->clone(); }
|
||||||
const QgsFeatureIds &neighbors() const { return mNeighbors; }
|
const QgsFeatureIds &neighbors() const { return mNeighbors; }
|
||||||
|
|
||||||
bool isEqual( QgsGeometryCheckError *other ) const override
|
bool isEqual( QgsGeometryCheckError *other ) const override
|
||||||
@ -70,7 +70,7 @@ class QgsGeometryGapCheckError : public QgsGeometryCheckError
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsRectangle affectedAreaBBox() override
|
QgsRectangle affectedAreaBBox() const override
|
||||||
{
|
{
|
||||||
return mGapAreaBBox;
|
return mGapAreaBBox;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "qgscrscache.h"
|
||||||
#include "qgsgeometrychecker.h"
|
#include "qgsgeometrychecker.h"
|
||||||
#include "checks/qgsgeometrycheck.h"
|
#include "checks/qgsgeometrycheck.h"
|
||||||
#include "utils/qgsfeaturepool.h"
|
#include "utils/qgsfeaturepool.h"
|
||||||
@ -111,6 +112,8 @@ bool QgsGeometryChecker::fixError( QgsGeometryCheckError *error, int method, boo
|
|||||||
for ( const QString &layerId : changes.keys() )
|
for ( const QString &layerId : changes.keys() )
|
||||||
{
|
{
|
||||||
const QMap<QgsFeatureId, QList<QgsGeometryCheck::Change>> &layerChanges = changes[layerId];
|
const QMap<QgsFeatureId, QList<QgsGeometryCheck::Change>> &layerChanges = changes[layerId];
|
||||||
|
QgsFeaturePool *featurePool = mContext->featurePools[layerId];
|
||||||
|
QgsCoordinateTransform t = QgsCoordinateTransformCache::instance()->transform( featurePool->getLayer()->crs().authid(), mContext->crs );
|
||||||
for ( QgsFeatureId id : layerChanges.keys() )
|
for ( QgsFeatureId id : layerChanges.keys() )
|
||||||
{
|
{
|
||||||
bool removed = false;
|
bool removed = false;
|
||||||
@ -125,10 +128,10 @@ bool QgsGeometryChecker::fixError( QgsGeometryCheckError *error, int method, boo
|
|||||||
if ( !removed )
|
if ( !removed )
|
||||||
{
|
{
|
||||||
QgsFeature f;
|
QgsFeature f;
|
||||||
if ( mContext->featurePools[layerId]->get( id, f ) )
|
if ( featurePool->get( id, f ) )
|
||||||
{
|
{
|
||||||
recheckFeatures[layerId].insert( id );
|
recheckFeatures[layerId].insert( id );
|
||||||
recheckArea.combineExtentWith( f.geometry().boundingBox() );
|
recheckArea.combineExtentWith( t.transformBoundingBox( f.geometry().boundingBox() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -149,7 +152,8 @@ bool QgsGeometryChecker::fixError( QgsGeometryCheckError *error, int method, boo
|
|||||||
for ( const QString &layerId : mContext->featurePools.keys() )
|
for ( const QString &layerId : mContext->featurePools.keys() )
|
||||||
{
|
{
|
||||||
QgsFeaturePool *featurePool = mContext->featurePools[layerId];
|
QgsFeaturePool *featurePool = mContext->featurePools[layerId];
|
||||||
recheckAreaFeatures[layerId] = featurePool->getIntersects( recheckArea );
|
QgsCoordinateTransform t = QgsCoordinateTransformCache::instance()->transform( mContext->crs, featurePool->getLayer()->crs().authid() );
|
||||||
|
recheckAreaFeatures[layerId] = featurePool->getIntersects( t.transform( recheckArea ) );
|
||||||
// If only selected features were checked, confine the recheck areas to the selected features
|
// If only selected features were checked, confine the recheck areas to the selected features
|
||||||
if ( featurePool->getSelectedOnly() )
|
if ( featurePool->getSelectedOnly() )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user