Skip to content

Commit ec21166

Browse files
committedSep 10, 2018
Use pointer instead of reference to QgsVectorLayer
1 parent 41184bf commit ec21166

11 files changed

+27
-22
lines changed
 

‎src/analysis/vector/geometry_checker/qgsgeometrycheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ QgsGeometryCheckError::QgsGeometryCheckError( const QgsGeometryCheck *check,
5050
const QgsPointXY &errorLocation, QgsVertexId vidx,
5151
const QVariant &value, ValueType valueType )
5252
: mCheck( check )
53-
, mLayerId( layerFeature.layer().id() )
53+
, mLayerId( layerFeature.layer()->id() )
5454
, mFeatureId( layerFeature.feature().id() )
5555
, mErrorLocation( errorLocation )
5656
, mVidx( vidx )

‎src/analysis/vector/geometry_checker/qgsgeometrycheckerutils.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,28 @@ namespace QgsGeometryCheckerUtils
4343
{
4444
delete mGeometry;
4545
}
46-
const QgsVectorLayer &LayerFeature::layer() const { return *mFeaturePool->layer(); }
46+
47+
QgsVectorLayer *LayerFeature::layer() const
48+
{
49+
return mFeaturePool->layer();
50+
}
51+
4752
double LayerFeature::layerToMapUnits() const { return mFeaturePool->getLayerToMapUnits(); }
4853
const QgsCoordinateTransform &LayerFeature::layerToMapTransform() const { return mFeaturePool->getLayerToMapTransform(); }
4954

5055
QString LayerFeature::id() const
5156
{
52-
return QString( "%1:%2" ).arg( layer().name() ).arg( mFeature.id() );
57+
return QString( "%1:%2" ).arg( layer()->name() ).arg( mFeature.id() );
5358
}
5459

5560
bool LayerFeature::operator==( const LayerFeature &other ) const
5661
{
57-
return layer().id() == other.layer().id() && feature().id() == other.feature().id();
62+
return layer()->id() == other.layer()->id() && feature().id() == other.feature().id();
5863
}
5964

6065
bool LayerFeature::operator!=( const LayerFeature &other ) const
6166
{
62-
return layer().id() != other.layer().id() || feature().id() != other.feature().id();
67+
return layer()->id() != other.layer()->id() || feature().id() != other.feature().id();
6368
}
6469

6570
/////////////////////////////////////////////////////////////////////////////

‎src/analysis/vector/geometry_checker/qgsgeometrycheckerutils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace QgsGeometryCheckerUtils
3535
LayerFeature( const QgsFeaturePool *pool, const QgsFeature &feature, bool useMapCrs );
3636
~LayerFeature();
3737
const QgsFeature &feature() const { return mFeature; }
38-
const QgsVectorLayer &layer() const;
38+
QgsVectorLayer *layer() const;
3939
double layerToMapUnits() const;
4040
const QgsCoordinateTransform &layerToMapTransform() const;
4141
const QgsAbstractGeometry *geometry() const { return mGeometry; }

‎src/analysis/vector/geometry_checker/qgsgeometrycontainedcheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ANALYSIS_EXPORT QgsGeometryContainedCheckError : public QgsGeometryCheckEr
3030
const QgsGeometryCheckerUtils::LayerFeature &containingFeature
3131
)
3232
: QgsGeometryCheckError( check, layerFeature, errorLocation, QgsVertexId(), containingFeature.id(), ValueOther )
33-
, mContainingFeature( qMakePair( containingFeature.layer().id(), containingFeature.feature().id() ) )
33+
, mContainingFeature( qMakePair( containingFeature.layer()->id(), containingFeature.feature().id() ) )
3434
{ }
3535
const QPair<QString, QgsFeatureId> &containingFeature() const { return mContainingFeature; }
3636

‎src/analysis/vector/geometry_checker/qgsgeometrydanglecheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void QgsGeometryDangleCheck::collectErrors( QList<QgsGeometryCheckError *> &erro
4747
}
4848

4949
// Check whether endpoints line on another line in the layer
50-
QgsGeometryCheckerUtils::LayerFeatures checkFeatures( mContext->featurePools, QList<QString>() << layerFeature.layer().id(), line->boundingBox(), {QgsWkbTypes::LineGeometry} );
50+
QgsGeometryCheckerUtils::LayerFeatures checkFeatures( mContext->featurePools, QList<QString>() << layerFeature.layer()->id(), line->boundingBox(), {QgsWkbTypes::LineGeometry} );
5151
for ( const QgsGeometryCheckerUtils::LayerFeature &checkFeature : checkFeatures )
5252
{
5353
const QgsAbstractGeometry *testGeom = checkFeature.geometry();

‎src/analysis/vector/geometry_checker/qgsgeometryduplicatecheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void QgsGeometryDuplicateCheck::collectErrors( QList<QgsGeometryCheckError *> &e
4545
for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeatureA : layerFeaturesA )
4646
{
4747
// Ensure each pair of layers only gets compared once: remove the current layer from the layerIds, but add it to the layerList for layerFeaturesB
48-
layerIds.removeOne( layerFeatureA.layer().id() );
48+
layerIds.removeOne( layerFeatureA.layer()->id() );
4949

5050
QgsRectangle bboxA = layerFeatureA.geometry()->boundingBox();
5151
std::unique_ptr< QgsGeometryEngine > geomEngineA = QgsGeometryCheckerUtils::createGeomEngine( layerFeatureA.geometry(), mContext->tolerance );
@@ -57,19 +57,19 @@ void QgsGeometryDuplicateCheck::collectErrors( QList<QgsGeometryCheckError *> &e
5757
QMap<QString, QList<QgsFeatureId>> duplicates;
5858

5959
QgsWkbTypes::GeometryType geomType = layerFeatureA.feature().geometry().type();
60-
QgsGeometryCheckerUtils::LayerFeatures layerFeaturesB( mContext->featurePools, QList<QString>() << layerFeatureA.layer().id() << layerIds, bboxA, {geomType} );
60+
QgsGeometryCheckerUtils::LayerFeatures layerFeaturesB( mContext->featurePools, QList<QString>() << layerFeatureA.layer()->id() << layerIds, bboxA, {geomType} );
6161
for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeatureB : layerFeaturesB )
6262
{
6363
// > : only report overlaps within same layer once
64-
if ( layerFeatureA.layer().id() == layerFeatureB.layer().id() && layerFeatureB.feature().id() >= layerFeatureA.feature().id() )
64+
if ( layerFeatureA.layer()->id() == layerFeatureB.layer()->id() && layerFeatureB.feature().id() >= layerFeatureA.feature().id() )
6565
{
6666
continue;
6767
}
6868
QString errMsg;
6969
QgsAbstractGeometry *diffGeom = geomEngineA->symDifference( layerFeatureB.geometry(), &errMsg );
7070
if ( errMsg.isEmpty() && diffGeom && diffGeom->isEmpty() )
7171
{
72-
duplicates[layerFeatureB.layer().id()].append( layerFeatureB.feature().id() );
72+
duplicates[layerFeatureB.layer()->id()].append( layerFeatureB.feature().id() );
7373
}
7474
else if ( !errMsg.isEmpty() )
7575
{

‎src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void QgsGeometryFollowBoundariesCheck::collectErrors( QList<QgsGeometryCheckErro
4949
const QgsAbstractGeometry *geom = layerFeature.geometry();
5050

5151
// The geometry to crs of the check layer
52-
QgsCoordinateTransform crst( layerFeature.layer().crs(), mCheckLayer->crs(), QgsProject::instance() );
52+
QgsCoordinateTransform crst( layerFeature.layer()->crs(), mCheckLayer->crs(), QgsProject::instance() );
5353
QgsGeometry geomt( geom->clone() );
5454
geomt.transform( crst );
5555

‎src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void QgsGeometryGapCheck::collectErrors( QList<QgsGeometryCheckError *> &errors,
100100
{
101101
if ( QgsGeometryCheckerUtils::sharedEdgeLength( gapGeom.get(), layerFeature.geometry(), mContext->reducedTolerance ) > 0 )
102102
{
103-
neighboringIds[layerFeature.layer().id()].insert( layerFeature.feature().id() );
103+
neighboringIds[layerFeature.layer()->id()].insert( layerFeature.feature().id() );
104104
gapAreaBBox.combineExtentWith( layerFeature.geometry()->boundingBox() );
105105
}
106106
}

‎src/analysis/vector/geometry_checker/qgsgeometrylineintersectioncheck.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void QgsGeometryLineIntersectionCheck::collectErrors( QList<QgsGeometryCheckErro
2525
for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeatureA : layerFeaturesA )
2626
{
2727
// Ensure each pair of layers only gets compared once: remove the current layer from the layerIds, but add it to the layerList for layerFeaturesB
28-
layerIds.removeOne( layerFeatureA.layer().id() );
28+
layerIds.removeOne( layerFeatureA.layer()->id() );
2929

3030
const QgsAbstractGeometry *geom = layerFeatureA.geometry();
3131
for ( int iPart = 0, nParts = geom->partCount(); iPart < nParts; ++iPart )
@@ -38,11 +38,11 @@ void QgsGeometryLineIntersectionCheck::collectErrors( QList<QgsGeometryCheckErro
3838
}
3939

4040
// Check whether the line intersects with any other lines
41-
QgsGeometryCheckerUtils::LayerFeatures layerFeaturesB( mContext->featurePools, QList<QString>() << layerFeatureA.layer().id() << layerIds, line->boundingBox(), {QgsWkbTypes::LineGeometry} );
41+
QgsGeometryCheckerUtils::LayerFeatures layerFeaturesB( mContext->featurePools, QList<QString>() << layerFeatureA.layer()->id() << layerIds, line->boundingBox(), {QgsWkbTypes::LineGeometry} );
4242
for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeatureB : layerFeaturesB )
4343
{
4444
// > : only report intersections within same layer once
45-
if ( layerFeatureA.layer().id() == layerFeatureB.layer().id() && layerFeatureB.feature().id() > layerFeatureA.feature().id() )
45+
if ( layerFeatureA.layer()->id() == layerFeatureB.layer()->id() && layerFeatureB.feature().id() > layerFeatureA.feature().id() )
4646
{
4747
continue;
4848
}

‎src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void QgsGeometryOverlapCheck::collectErrors( QList<QgsGeometryCheckError *> &err
2727
for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeatureA : layerFeaturesA )
2828
{
2929
// Ensure each pair of layers only gets compared once: remove the current layer from the layerIds, but add it to the layerList for layerFeaturesB
30-
layerIds.removeOne( layerFeatureA.layer().id() );
30+
layerIds.removeOne( layerFeatureA.layer()->id() );
3131

3232
QgsRectangle bboxA = layerFeatureA.geometry()->boundingBox();
3333
std::unique_ptr< QgsGeometryEngine > geomEngineA = QgsGeometryCheckerUtils::createGeomEngine( layerFeatureA.geometry(), mContext->tolerance );
@@ -37,11 +37,11 @@ void QgsGeometryOverlapCheck::collectErrors( QList<QgsGeometryCheckError *> &err
3737
continue;
3838
}
3939

40-
const QgsGeometryCheckerUtils::LayerFeatures layerFeaturesB( mContext->featurePools, QList<QString>() << layerFeatureA.layer().id() << layerIds, bboxA, mCompatibleGeometryTypes );
40+
const QgsGeometryCheckerUtils::LayerFeatures layerFeaturesB( mContext->featurePools, QList<QString>() << layerFeatureA.layer()->id() << layerIds, bboxA, mCompatibleGeometryTypes );
4141
for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeatureB : layerFeaturesB )
4242
{
4343
// > : only report overlaps within same layer once
44-
if ( layerFeatureA.layer().id() == layerFeatureB.layer().id() && layerFeatureB.feature().id() >= layerFeatureA.feature().id() )
44+
if ( layerFeatureA.layer()->id() == layerFeatureB.layer()->id() && layerFeatureB.feature().id() >= layerFeatureA.feature().id() )
4545
{
4646
continue;
4747
}

‎src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class ANALYSIS_EXPORT QgsGeometryOverlapCheckError : public QgsGeometryCheckErro
3030
const QgsPointXY &errorLocation,
3131
const QVariant &value,
3232
const QgsGeometryCheckerUtils::LayerFeature &overlappedFeature )
33-
: QgsGeometryCheckError( check, layerFeature.layer().id(), layerFeature.feature().id(), geometry, errorLocation, QgsVertexId(), value, ValueArea )
34-
, mOverlappedFeature( qMakePair( overlappedFeature.layer().id(), overlappedFeature.feature().id() ) )
33+
: QgsGeometryCheckError( check, layerFeature.layer()->id(), layerFeature.feature().id(), geometry, errorLocation, QgsVertexId(), value, ValueArea )
34+
, mOverlappedFeature( qMakePair( overlappedFeature.layer()->id(), overlappedFeature.feature().id() ) )
3535
{ }
3636
const QPair<QString, QgsFeatureId> &overlappedFeature() const { return mOverlappedFeature; }
3737

0 commit comments

Comments
 (0)