Always pass QgsFeatureId by value, not reference

Since it's just a int64, it's faster to pass by value
This commit is contained in:
Nyall Dawson 2015-12-30 22:51:32 +11:00
parent 34c9daab48
commit 566dd4bd43
39 changed files with 62 additions and 62 deletions

View File

@ -1444,7 +1444,7 @@ class QgsVectorLayer : QgsMapLayer
* *
* @see select(QgsFeatureIds) * @see select(QgsFeatureIds)
*/ */
void select( const QgsFeatureId &featureId ); void select( QgsFeatureId featureId );
/** /**
* Select features by their ID * Select features by their ID
@ -1661,7 +1661,7 @@ class QgsVectorLayer : QgsMapLayer
private slots: private slots:
void onRelationsLoaded(); void onRelationsLoaded();
void onJoinedFieldsChanged(); void onJoinedFieldsChanged();
void onFeatureDeleted( const QgsFeatureId& fid ); void onFeatureDeleted( QgsFeatureId fid );
protected: protected:
/** Set the extent */ /** Set the extent */

View File

@ -179,7 +179,7 @@ class QgsVectorLayerCache : QObject
* @brief Is emitted when an attribute is changed. Is re-emitted after the layer itself emits this signal. * @brief Is emitted when an attribute is changed. Is re-emitted after the layer itself emits this signal.
* You should connect to this signal, to be sure, to not get a cached value if querying the cache. * You should connect to this signal, to be sure, to not get a cached value if querying the cache.
*/ */
void attributeValueChanged( const QgsFeatureId& fid, const int& field, const QVariant &value ); void attributeValueChanged( QgsFeatureId fid, const int& field, const QVariant &value );
/** /**
* Is emitted, when a new feature has been added to the layer and this cache. * Is emitted, when a new feature has been added to the layer and this cache.

View File

@ -165,7 +165,7 @@ void QgsMapToolNodeTool::canvasMoveEvent( QgsMapMouseEvent* e )
double deltaX = curPos.x() - pressPos.x(); double deltaX = curPos.x() - pressPos.x();
double deltaY = curPos.y() - pressPos.y(); double deltaY = curPos.y() - pressPos.y();
Q_FOREACH ( const QgsFeatureId& fid, mMoveRubberBands.keys() ) Q_FOREACH ( QgsFeatureId fid, mMoveRubberBands.keys() )
{ {
typedef QPair<QgsVertexId, QgsPointV2> MoveVertex; typedef QPair<QgsVertexId, QgsPointV2> MoveVertex;
Q_FOREACH ( const MoveVertex& pair, mMoveVertices[fid] ) Q_FOREACH ( const MoveVertex& pair, mMoveVertices[fid] )

View File

@ -458,7 +458,7 @@ int QgsMapToolLabel::dataDefinedColumnIndex( QgsPalLayerSettings::DataDefinedPro
return -1; return -1;
} }
bool QgsMapToolLabel::dataDefinedPosition( QgsVectorLayer* vlayer, const QgsFeatureId &featureId, double& x, bool& xSuccess, double& y, bool& ySuccess, int& xCol, int& yCol ) const bool QgsMapToolLabel::dataDefinedPosition( QgsVectorLayer* vlayer, QgsFeatureId featureId, double& x, bool& xSuccess, double& y, bool& ySuccess, int& xCol, int& yCol ) const
{ {
xSuccess = false; xSuccess = false;
ySuccess = false; ySuccess = false;
@ -513,7 +513,7 @@ bool QgsMapToolLabel::layerIsRotatable( QgsMapLayer* layer, int& rotationCol ) c
return false; return false;
} }
bool QgsMapToolLabel::dataDefinedRotation( QgsVectorLayer* vlayer, const QgsFeatureId &featureId, double& rotation, bool& rotationSuccess, bool ignoreXY ) const bool QgsMapToolLabel::dataDefinedRotation( QgsVectorLayer* vlayer, QgsFeatureId featureId, double& rotation, bool& rotationSuccess, bool ignoreXY ) const
{ {
rotationSuccess = false; rotationSuccess = false;
if ( !vlayer ) if ( !vlayer )
@ -549,7 +549,7 @@ bool QgsMapToolLabel::dataDefinedRotation( QgsVectorLayer* vlayer, const QgsFeat
return true; return true;
} }
bool QgsMapToolLabel::dataDefinedShowHide( QgsVectorLayer* vlayer, const QgsFeatureId &featureId, int& show, bool& showSuccess, int& showCol ) const bool QgsMapToolLabel::dataDefinedShowHide( QgsVectorLayer* vlayer, QgsFeatureId featureId, int& show, bool& showSuccess, int& showCol ) const
{ {
showSuccess = false; showSuccess = false;
if ( !vlayer ) if ( !vlayer )

View File

@ -128,7 +128,7 @@ class APP_EXPORT QgsMapToolLabel: public QgsMapTool
@param xCol out: index of the x position column @param xCol out: index of the x position column
@param yCol out: index of the y position column @param yCol out: index of the y position column
@return false if layer does not have data defined label position enabled*/ @return false if layer does not have data defined label position enabled*/
bool dataDefinedPosition( QgsVectorLayer* vlayer, const QgsFeatureId &featureId, double& x, bool& xSuccess, double& y, bool& ySuccess, int& xCol, int& yCol ) const; bool dataDefinedPosition( QgsVectorLayer* vlayer, QgsFeatureId featureId, double& x, bool& xSuccess, double& y, bool& ySuccess, int& xCol, int& yCol ) const;
/** Returns data defined rotation of a feature. /** Returns data defined rotation of a feature.
@param vlayer vector layer @param vlayer vector layer
@ -138,7 +138,7 @@ class APP_EXPORT QgsMapToolLabel: public QgsMapTool
@param ignoreXY ignore that x and y are required to be data-defined @param ignoreXY ignore that x and y are required to be data-defined
@return true if data defined rotation is enabled on the layer @return true if data defined rotation is enabled on the layer
*/ */
bool dataDefinedRotation( QgsVectorLayer* vlayer, const QgsFeatureId &featureId, double& rotation, bool& rotationSuccess, bool ignoreXY = false ) const; bool dataDefinedRotation( QgsVectorLayer* vlayer, QgsFeatureId featureId, double& rotation, bool& rotationSuccess, bool ignoreXY = false ) const;
/** Returns data defined show/hide of a feature. /** Returns data defined show/hide of a feature.
@param vlayer vector layer @param vlayer vector layer
@ -148,7 +148,7 @@ class APP_EXPORT QgsMapToolLabel: public QgsMapTool
@param showCol out: index of the show label column @param showCol out: index of the show label column
@return true if data defined show/hide is enabled on the layer @return true if data defined show/hide is enabled on the layer
*/ */
bool dataDefinedShowHide( QgsVectorLayer* vlayer, const QgsFeatureId &featureId, int& show, bool& showSuccess, int& showCol ) const; bool dataDefinedShowHide( QgsVectorLayer* vlayer, QgsFeatureId featureId, int& show, bool& showSuccess, int& showCol ) const;
private: private:
QgsPalLayerSettings mInvalidLabelSettings; QgsPalLayerSettings mInvalidLabelSettings;

View File

@ -152,7 +152,7 @@ void QgsMapToolShowHideLabels::showHideLabels( QMouseEvent * e )
QString editTxt = doHide ? tr( "Hid labels" ) : tr( "Showed labels" ); QString editTxt = doHide ? tr( "Hid labels" ) : tr( "Showed labels" );
vlayer->beginEditCommand( editTxt ); vlayer->beginEditCommand( editTxt );
Q_FOREACH ( const QgsFeatureId &fid, selectedFeatIds ) Q_FOREACH ( QgsFeatureId fid, selectedFeatIds )
{ {
if ( showHideLabel( vlayer, fid, doHide ) ) if ( showHideLabel( vlayer, fid, doHide ) )
{ {
@ -261,7 +261,7 @@ bool QgsMapToolShowHideLabels::selectedLabelFeatures( QgsVectorLayer* vlayer,
} }
bool QgsMapToolShowHideLabels::showHideLabel( QgsVectorLayer* vlayer, bool QgsMapToolShowHideLabels::showHideLabel( QgsVectorLayer* vlayer,
const QgsFeatureId &fid, QgsFeatureId fid,
bool hide ) bool hide )
{ {

View File

@ -66,7 +66,7 @@ class APP_EXPORT QgsMapToolShowHideLabels : public QgsMapToolLabel
//! Show or hide chosen label by setting data defined Show Label to 0 //! Show or hide chosen label by setting data defined Show Label to 0
bool showHideLabel( QgsVectorLayer* vlayer, bool showHideLabel( QgsVectorLayer* vlayer,
const QgsFeatureId &fid, QgsFeatureId fid,
bool hide ); bool hide );
}; };

View File

@ -359,7 +359,7 @@ namespace pal
void PointSet::splitPolygons( QLinkedList<PointSet*> &shapes_toProcess, void PointSet::splitPolygons( QLinkedList<PointSet*> &shapes_toProcess,
QLinkedList<PointSet*> &shapes_final, QLinkedList<PointSet*> &shapes_final,
double xrm, double yrm, const QgsFeatureId& uid ) double xrm, double yrm, QgsFeatureId uid )
{ {
#ifdef _DEBUG_ #ifdef _DEBUG_
std::cout << "splitPolygons: " << uid << std::endl; std::cout << "splitPolygons: " << uid << std::endl;

View File

@ -98,7 +98,7 @@ namespace pal
*/ */
static void splitPolygons( QLinkedList<PointSet *> &shapes_toProcess, static void splitPolygons( QLinkedList<PointSet *> &shapes_toProcess,
QLinkedList<PointSet *> &shapes_final, QLinkedList<PointSet *> &shapes_final,
double xrm, double yrm, const QgsFeatureId &uid ); double xrm, double yrm, QgsFeatureId uid );
/** Returns the squared minimum distance between the point set geometry and the point (px,py) /** Returns the squared minimum distance between the point set geometry and the point (px,py)
* Optionally, the nearest point is stored in (rx,ry). * Optionally, the nearest point is stored in (rx,ry).

View File

@ -258,7 +258,7 @@ class CORE_EXPORT QgsFeatureRequest
//! Set feature ID that should be fetched. //! Set feature ID that should be fetched.
QgsFeatureRequest& setFilterFid( QgsFeatureId fid ); QgsFeatureRequest& setFilterFid( QgsFeatureId fid );
//! Get the feature ID that should be fetched. //! Get the feature ID that should be fetched.
const QgsFeatureId& filterFid() const { return mFilterFid; } QgsFeatureId filterFid() const { return mFilterFid; }
//! Set feature IDs that should be fetched. //! Set feature IDs that should be fetched.
QgsFeatureRequest& setFilterFids( const QgsFeatureIds& fids ); QgsFeatureRequest& setFilterFids( const QgsFeatureIds& fids );

View File

@ -409,7 +409,7 @@ void QgsVectorLayer::drawVertexMarker( double x, double y, QPainter& p, QgsVecto
} }
} }
void QgsVectorLayer::select( const QgsFeatureId& fid ) void QgsVectorLayer::select( QgsFeatureId fid )
{ {
mSelectedFeatureIds.insert( fid ); mSelectedFeatureIds.insert( fid );
@ -3684,7 +3684,7 @@ void QgsVectorLayer::onJoinedFieldsChanged()
updateFields(); updateFields();
} }
void QgsVectorLayer::onFeatureDeleted( const QgsFeatureId& fid ) void QgsVectorLayer::onFeatureDeleted( QgsFeatureId fid )
{ {
if ( mEditCommandActive ) if ( mEditCommandActive )
mDeletedFids << fid; mDeletedFids << fid;

View File

@ -1621,7 +1621,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
* *
* @see select(QgsFeatureIds) * @see select(QgsFeatureIds)
*/ */
void select( const QgsFeatureId &featureId ); void select( QgsFeatureId featureId );
/** /**
* Select features by their ID * Select features by their ID
@ -1838,7 +1838,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
private slots: private slots:
void onJoinedFieldsChanged(); void onJoinedFieldsChanged();
void onFeatureDeleted( const QgsFeatureId& fid ); void onFeatureDeleted( QgsFeatureId fid );
protected: protected:
/** Set the extent */ /** Set the extent */

View File

@ -245,7 +245,7 @@ class CORE_EXPORT QgsVectorLayerCache : public QObject
* @brief Is emitted when an attribute is changed. Is re-emitted after the layer itself emits this signal. * @brief Is emitted when an attribute is changed. Is re-emitted after the layer itself emits this signal.
* You should connect to this signal, to be sure, to not get a cached value if querying the cache. * You should connect to this signal, to be sure, to not get a cached value if querying the cache.
*/ */
void attributeValueChanged( const QgsFeatureId& fid, const int& field, const QVariant &value ); void attributeValueChanged( QgsFeatureId fid, const int& field, const QVariant &value );
/** /**
* Is emitted, when a new feature has been added to the layer and this cache. * Is emitted, when a new feature has been added to the layer and this cache.

View File

@ -11,7 +11,7 @@
void QgsGeometryAngleCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const void QgsGeometryAngleCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const
{ {
const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids;
Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) Q_FOREACH ( QgsFeatureId featureid, featureIds )
{ {
if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 );
QgsFeature feature; QgsFeature feature;

View File

@ -13,7 +13,7 @@
void QgsGeometryAreaCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const void QgsGeometryAreaCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const
{ {
const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids;
Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) Q_FOREACH ( QgsFeatureId featureid, featureIds )
{ {
if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 );
QgsFeature feature; QgsFeature feature;
@ -121,7 +121,7 @@ bool QgsGeometryAreaCheck::mergeWithNeighbor( QgsFeature& feature, int partIdx,
QgsAbstractGeometryV2* geom = feature.geometry()->geometry(); QgsAbstractGeometryV2* geom = feature.geometry()->geometry();
// Search for touching neighboring geometries // Search for touching neighboring geometries
Q_FOREACH ( const QgsFeatureId& testId, mFeaturePool->getIntersects( feature.geometry()->boundingBox() ) ) Q_FOREACH ( QgsFeatureId testId, mFeaturePool->getIntersects( feature.geometry()->boundingBox() ) )
{ {
QgsFeature testFeature; QgsFeature testFeature;
if ( !mFeaturePool->get( testId, testFeature ) ) if ( !mFeaturePool->get( testId, testFeature ) )

View File

@ -49,7 +49,7 @@ double QgsGeometryCheckPrecision::reducedTolerance()
} }
QgsGeometryCheckError::QgsGeometryCheckError( const QgsGeometryCheck* check, QgsGeometryCheckError::QgsGeometryCheckError( const QgsGeometryCheck* check,
const QgsFeatureId& featureId, QgsFeatureId featureId,
const QgsPointV2& errorLocation, const QgsPointV2& errorLocation,
const QgsVertexId& vidx, const QgsVertexId& vidx,
const QVariant& value , ValueType valueType ) const QVariant& value , ValueType valueType )

View File

@ -87,14 +87,14 @@ class QgsGeometryCheckError
enum ValueType { ValueLength, ValueArea, ValueOther }; enum ValueType { ValueLength, ValueArea, ValueOther };
QgsGeometryCheckError( const QgsGeometryCheck* check, QgsGeometryCheckError( const QgsGeometryCheck* check,
const QgsFeatureId& featureId, QgsFeatureId featureId,
const QgsPointV2& errorLocation, const QgsPointV2& errorLocation,
const QgsVertexId& vidx = QgsVertexId(), const QgsVertexId& vidx = QgsVertexId(),
const QVariant& value = QVariant(), const QVariant& value = QVariant(),
ValueType valueType = ValueOther ); ValueType valueType = ValueOther );
virtual ~QgsGeometryCheckError(); virtual ~QgsGeometryCheckError();
const QgsGeometryCheck* check() const { return mCheck; } const QgsGeometryCheck* check() const { return mCheck; }
const QgsFeatureId& featureId() const { return mFeatureId; } QgsFeatureId featureId() const { return mFeatureId; }
virtual QgsAbstractGeometryV2* geometry(); virtual QgsAbstractGeometryV2* geometry();
virtual QgsRectangle affectedAreaBBox() { return geometry() ? geometry()->boundingBox() : QgsRectangle(); } virtual QgsRectangle affectedAreaBBox() { return geometry() ? geometry()->boundingBox() : QgsRectangle(); }
virtual QString description() const { return mCheck->errorDescription(); } virtual QString description() const { return mCheck->errorDescription(); }

View File

@ -12,7 +12,7 @@
void QgsGeometryContainedCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &messages, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const void QgsGeometryContainedCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &messages, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const
{ {
const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids;
Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) Q_FOREACH ( QgsFeatureId featureid, featureIds )
{ {
if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 );
QgsFeature feature; QgsFeature feature;
@ -24,7 +24,7 @@ void QgsGeometryContainedCheck::collectErrors( QList<QgsGeometryCheckError*>& er
QgsGeometryEngine* geomEngine = QgsGeomUtils::createGeomEngine( feature.geometry()->geometry(), QgsGeometryCheckPrecision::tolerance() ); QgsGeometryEngine* geomEngine = QgsGeomUtils::createGeomEngine( feature.geometry()->geometry(), QgsGeometryCheckPrecision::tolerance() );
QgsFeatureIds ids = mFeaturePool->getIntersects( feature.geometry()->geometry()->boundingBox() ); QgsFeatureIds ids = mFeaturePool->getIntersects( feature.geometry()->geometry()->boundingBox() );
Q_FOREACH ( const QgsFeatureId& otherid, ids ) Q_FOREACH ( QgsFeatureId otherid, ids )
{ {
if ( otherid == featureid ) if ( otherid == featureid )
{ {

View File

@ -14,12 +14,12 @@ class QgsGeometryContainedCheckError : public QgsGeometryCheckError
{ {
public: public:
QgsGeometryContainedCheckError( const QgsGeometryCheck* check, QgsGeometryContainedCheckError( const QgsGeometryCheck* check,
const QgsFeatureId& featureId, QgsFeatureId featureId,
const QgsPointV2& errorLocation, const QgsPointV2& errorLocation,
const QgsFeatureId& otherId QgsFeatureId otherId
) )
: QgsGeometryCheckError( check, featureId, errorLocation, QgsVertexId(), otherId, ValueOther ), mOtherId( otherId ) { } : QgsGeometryCheckError( check, featureId, errorLocation, QgsVertexId(), otherId, ValueOther ), mOtherId( otherId ) { }
const QgsFeatureId& otherId() const { return mOtherId; } QgsFeatureId otherId() const { return mOtherId; }
bool isEqual( QgsGeometryCheckError* other ) const override bool isEqual( QgsGeometryCheckError* other ) const override
{ {

View File

@ -11,7 +11,7 @@
void QgsGeometryDegeneratePolygonCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const void QgsGeometryDegeneratePolygonCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const
{ {
const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids;
Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) Q_FOREACH ( QgsFeatureId featureid, featureIds )
{ {
if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 );
QgsFeature feature; QgsFeature feature;

View File

@ -14,7 +14,7 @@
void QgsGeometryDuplicateCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &messages, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const void QgsGeometryDuplicateCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &messages, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const
{ {
const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids;
Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) Q_FOREACH ( QgsFeatureId featureid, featureIds )
{ {
if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 );
QgsFeature feature; QgsFeature feature;
@ -26,7 +26,7 @@ void QgsGeometryDuplicateCheck::collectErrors( QList<QgsGeometryCheckError*>& er
QList<QgsFeatureId> duplicates; QList<QgsFeatureId> duplicates;
QgsFeatureIds ids = mFeaturePool->getIntersects( feature.geometry()->geometry()->boundingBox() ); QgsFeatureIds ids = mFeaturePool->getIntersects( feature.geometry()->geometry()->boundingBox() );
Q_FOREACH ( const QgsFeatureId& id, ids ) Q_FOREACH ( QgsFeatureId id, ids )
{ {
// > : only report overlaps once // > : only report overlaps once
if ( id >= featureid ) if ( id >= featureid )
@ -77,7 +77,7 @@ void QgsGeometryDuplicateCheck::fixError( QgsGeometryCheckError* error, int meth
QgsGeometryEngine* geomEngine = QgsGeomUtils::createGeomEngine( feature.geometry()->geometry(), QgsGeometryCheckPrecision::tolerance() ); QgsGeometryEngine* geomEngine = QgsGeomUtils::createGeomEngine( feature.geometry()->geometry(), QgsGeometryCheckPrecision::tolerance() );
QgsGeometryDuplicateCheckError* duplicateError = static_cast<QgsGeometryDuplicateCheckError*>( error ); QgsGeometryDuplicateCheckError* duplicateError = static_cast<QgsGeometryDuplicateCheckError*>( error );
Q_FOREACH ( const QgsFeatureId& id, duplicateError->duplicates() ) Q_FOREACH ( QgsFeatureId id, duplicateError->duplicates() )
{ {
QgsFeature testFeature; QgsFeature testFeature;
if ( !mFeaturePool->get( id, testFeature ) ) if ( !mFeaturePool->get( id, testFeature ) )

View File

@ -14,7 +14,7 @@ class QgsGeometryDuplicateCheckError : public QgsGeometryCheckError
{ {
public: public:
QgsGeometryDuplicateCheckError( const QgsGeometryCheck* check, QgsGeometryDuplicateCheckError( const QgsGeometryCheck* check,
const QgsFeatureId& featureId, QgsFeatureId featureId,
const QgsPointV2& errorLocation, const QgsPointV2& errorLocation,
const QList<QgsFeatureId>& duplicates ) const QList<QgsFeatureId>& duplicates )
: QgsGeometryCheckError( check, featureId, errorLocation, QgsVertexId(), duplicatesString( duplicates ) ), mDuplicates( duplicates ) { } : QgsGeometryCheckError( check, featureId, errorLocation, QgsVertexId(), duplicatesString( duplicates ) ), mDuplicates( duplicates ) { }

View File

@ -12,7 +12,7 @@
void QgsGeometryDuplicateNodesCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const void QgsGeometryDuplicateNodesCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const
{ {
const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids;
Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) Q_FOREACH ( QgsFeatureId featureid, featureIds )
{ {
if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 );
QgsFeature feature; QgsFeature feature;

View File

@ -19,7 +19,7 @@ void QgsGeometryGapCheck::collectErrors( QList<QgsGeometryCheckError*>& errors,
// Collect geometries, build spatial index // Collect geometries, build spatial index
QList<const QgsAbstractGeometryV2*> geomList; QList<const QgsAbstractGeometryV2*> geomList;
const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids;
Q_FOREACH ( const QgsFeatureId& id, featureIds ) Q_FOREACH ( QgsFeatureId id, featureIds )
{ {
QgsFeature feature; QgsFeature feature;
if ( mFeaturePool->get( id, feature ) ) if ( mFeaturePool->get( id, feature ) )
@ -159,7 +159,7 @@ bool QgsGeometryGapCheck::mergeWithNeighbor( QgsGeometryGapCheckError* err, Chan
QgsAbstractGeometryV2* errGeometry = QgsGeomUtils::getGeomPart( err->geometry(), 0 ); QgsAbstractGeometryV2* errGeometry = QgsGeomUtils::getGeomPart( err->geometry(), 0 );
// Search for touching neighboring geometries // Search for touching neighboring geometries
Q_FOREACH ( const QgsFeatureId& testId, err->neighbors() ) Q_FOREACH ( QgsFeatureId testId, err->neighbors() )
{ {
QgsFeature testFeature; QgsFeature testFeature;
if ( !mFeaturePool->get( testId, testFeature ) ) if ( !mFeaturePool->get( testId, testFeature ) )

View File

@ -11,7 +11,7 @@
void QgsGeometryHoleCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const void QgsGeometryHoleCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const
{ {
const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids;
Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) Q_FOREACH ( QgsFeatureId featureid, featureIds )
{ {
if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 );
QgsFeature feature; QgsFeature feature;

View File

@ -11,7 +11,7 @@
void QgsGeometryMultipartCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const void QgsGeometryMultipartCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const
{ {
const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids;
Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) Q_FOREACH ( QgsFeatureId featureid, featureIds )
{ {
if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 );
QgsFeature feature; QgsFeature feature;

View File

@ -12,7 +12,7 @@
void QgsGeometryOverlapCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &messages, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const void QgsGeometryOverlapCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &messages, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const
{ {
const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids;
Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) Q_FOREACH ( QgsFeatureId featureid, featureIds )
{ {
if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 );
QgsFeature feature; QgsFeature feature;
@ -24,7 +24,7 @@ void QgsGeometryOverlapCheck::collectErrors( QList<QgsGeometryCheckError*>& erro
QgsGeometryEngine* geomEngine = QgsGeomUtils::createGeomEngine( geom, QgsGeometryCheckPrecision::tolerance() ); QgsGeometryEngine* geomEngine = QgsGeomUtils::createGeomEngine( geom, QgsGeometryCheckPrecision::tolerance() );
QgsFeatureIds ids = mFeaturePool->getIntersects( feature.geometry()->boundingBox() ); QgsFeatureIds ids = mFeaturePool->getIntersects( feature.geometry()->boundingBox() );
Q_FOREACH ( const QgsFeatureId& otherid, ids ) Q_FOREACH ( QgsFeatureId otherid, ids )
{ {
// >= : only report overlaps once // >= : only report overlaps once
if ( otherid >= featureid ) if ( otherid >= featureid )

View File

@ -14,12 +14,12 @@ class QgsGeometryOverlapCheckError : public QgsGeometryCheckError
{ {
public: public:
QgsGeometryOverlapCheckError( const QgsGeometryCheck* check, QgsGeometryOverlapCheckError( const QgsGeometryCheck* check,
const QgsFeatureId& featureId, QgsFeatureId featureId,
const QgsPointV2& errorLocation, const QgsPointV2& errorLocation,
const QVariant& value, const QVariant& value,
const QgsFeatureId& otherId ) QgsFeatureId otherId )
: QgsGeometryCheckError( check, featureId, errorLocation, QgsVertexId(), value, ValueArea ), mOtherId( otherId ) { } : QgsGeometryCheckError( check, featureId, errorLocation, QgsVertexId(), value, ValueArea ), mOtherId( otherId ) { }
const QgsFeatureId& otherId() const { return mOtherId; } QgsFeatureId otherId() const { return mOtherId; }
bool isEqual( QgsGeometryCheckError* other ) const override bool isEqual( QgsGeometryCheckError* other ) const override
{ {

View File

@ -14,7 +14,7 @@
void QgsGeometrySegmentLengthCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const void QgsGeometrySegmentLengthCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const
{ {
const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids;
Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) Q_FOREACH ( QgsFeatureId featureid, featureIds )
{ {
if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 );
QgsFeature feature; QgsFeature feature;

View File

@ -57,7 +57,7 @@ bool QgsGeometrySelfIntersectionCheckError::handleChanges( const QgsGeometryChec
void QgsGeometrySelfIntersectionCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const void QgsGeometrySelfIntersectionCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const
{ {
const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids;
Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) Q_FOREACH ( QgsFeatureId featureid, featureIds )
{ {
if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 );
QgsFeature feature; QgsFeature feature;

View File

@ -15,7 +15,7 @@ class QgsGeometrySelfIntersectionCheckError : public QgsGeometryCheckError
{ {
public: public:
QgsGeometrySelfIntersectionCheckError( const QgsGeometryCheck* check, QgsGeometrySelfIntersectionCheckError( const QgsGeometryCheck* check,
const QgsFeatureId& featureId, QgsFeatureId featureId,
const QgsPointV2& errorLocation, const QgsPointV2& errorLocation,
const QgsVertexId& vidx, const QgsVertexId& vidx,
const QgsGeometryUtils::SelfIntersection& inter ) const QgsGeometryUtils::SelfIntersection& inter )

View File

@ -18,7 +18,7 @@
void QgsGeometryTypeCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const void QgsGeometryTypeCheck::collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &/*messages*/, QAtomicInt* progressCounter , const QgsFeatureIds &ids ) const
{ {
const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids; const QgsFeatureIds& featureIds = ids.isEmpty() ? mFeaturePool->getFeatureIds() : ids;
Q_FOREACH ( const QgsFeatureId& featureid, featureIds ) Q_FOREACH ( QgsFeatureId featureid, featureIds )
{ {
if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 ); if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 );
QgsFeature feature; QgsFeature feature;

View File

@ -14,7 +14,7 @@ class QgsGeometryTypeCheckError : public QgsGeometryCheckError
{ {
public: public:
QgsGeometryTypeCheckError( const QgsGeometryCheck* check, QgsGeometryTypeCheckError( const QgsGeometryCheck* check,
const QgsFeatureId& featureId, QgsFeatureId featureId,
const QgsPointV2& errorLocation, const QgsPointV2& errorLocation,
QgsWKBTypes::Type flatType ) QgsWKBTypes::Type flatType )
: QgsGeometryCheckError( check, featureId, errorLocation ) : QgsGeometryCheckError( check, featureId, errorLocation )

View File

@ -98,7 +98,7 @@ bool QgsGeometryChecker::fixError( QgsGeometryCheckError* error, int method )
// Determine what to recheck // Determine what to recheck
// - Collect all features which were changed, get affected area // - Collect all features which were changed, get affected area
QgsFeatureIds recheckFeatures; QgsFeatureIds recheckFeatures;
Q_FOREACH ( const QgsFeatureId& id, changes.keys() ) Q_FOREACH ( QgsFeatureId id, changes.keys() )
{ {
bool removed = false; bool removed = false;
Q_FOREACH ( const QgsGeometryCheck::Change& change, changes.value( id ) ) Q_FOREACH ( const QgsGeometryCheck::Change& change, changes.value( id ) )

View File

@ -48,7 +48,7 @@ QgsFeaturePool::QgsFeaturePool( QgsVectorLayer *layer, bool selectedOnly )
} }
} }
bool QgsFeaturePool::get( const QgsFeatureId& id , QgsFeature& feature ) bool QgsFeaturePool::get( QgsFeatureId id , QgsFeature& feature )
{ {
QMutexLocker lock( &mLayerMutex ); QMutexLocker lock( &mLayerMutex );
QgsFeature* pfeature = mFeatureCache.object( id ); QgsFeature* pfeature = mFeatureCache.object( id );

View File

@ -31,7 +31,7 @@ class QgsFeaturePool
{ {
public: public:
QgsFeaturePool( QgsVectorLayer* layer, bool selectedOnly = false ); QgsFeaturePool( QgsVectorLayer* layer, bool selectedOnly = false );
bool get( const QgsFeatureId& id, QgsFeature& feature ); bool get( QgsFeatureId id, QgsFeature& feature );
void addFeature( QgsFeature &feature ); void addFeature( QgsFeature &feature );
void updateFeature( QgsFeature &feature ); void updateFeature( QgsFeature &feature );
void deleteFeature( QgsFeature &feature ); void deleteFeature( QgsFeature &feature );

View File

@ -52,7 +52,7 @@ QFuture<void> QgsGeometrySnapper::processFeatures()
return QtConcurrent::map( mFeatures, ProcessFeatureWrapper( this ) ); return QtConcurrent::map( mFeatures, ProcessFeatureWrapper( this ) );
} }
void QgsGeometrySnapper::processFeature( const QgsFeatureId &id ) void QgsGeometrySnapper::processFeature( QgsFeatureId id )
{ {
// Get current feature // Get current feature
QgsFeature feature; QgsFeature feature;
@ -75,7 +75,7 @@ void QgsGeometrySnapper::processFeature( const QgsFeatureId &id )
mIndexMutex.lock(); mIndexMutex.lock();
QList<QgsFeatureId> refFeatureIds = mIndex.intersects( feature.geometry()->boundingBox() ); QList<QgsFeatureId> refFeatureIds = mIndex.intersects( feature.geometry()->boundingBox() );
mIndexMutex.unlock(); mIndexMutex.unlock();
Q_FOREACH ( const QgsFeatureId& refId, refFeatureIds ) Q_FOREACH ( QgsFeatureId refId, refFeatureIds )
{ {
QgsFeature refFeature; QgsFeature refFeature;
if ( getFeature( mReferenceLayer, mReferenceLayerMutex, refId, refFeature ) ) if ( getFeature( mReferenceLayer, mReferenceLayerMutex, refId, refFeature ) )
@ -232,7 +232,7 @@ void QgsGeometrySnapper::processFeature( const QgsFeatureId &id )
mAdjustLayerMutex.unlock(); mAdjustLayerMutex.unlock();
} }
bool QgsGeometrySnapper::getFeature( QgsVectorLayer *layer, QMutex &mutex, const QgsFeatureId &id, QgsFeature &feature ) bool QgsGeometrySnapper::getFeature( QgsVectorLayer *layer, QMutex &mutex, QgsFeatureId id, QgsFeature &feature )
{ {
QMutexLocker locker( &mutex ); QMutexLocker locker( &mutex );
QgsFeatureRequest req( id ); QgsFeatureRequest req( id );

View File

@ -40,7 +40,7 @@ class QgsGeometrySnapper : public QObject
{ {
QgsGeometrySnapper* instance; QgsGeometrySnapper* instance;
explicit ProcessFeatureWrapper( QgsGeometrySnapper* _instance ) : instance( _instance ) {} explicit ProcessFeatureWrapper( QgsGeometrySnapper* _instance ) : instance( _instance ) {}
void operator()( const QgsFeatureId& id ) { instance->processFeature( id ); } void operator()( QgsFeatureId id ) { instance->processFeature( id ); }
}; };
enum PointFlag { SnappedToRefNode, SnappedToRefSegment, Unsnapped }; enum PointFlag { SnappedToRefNode, SnappedToRefSegment, Unsnapped };
@ -57,8 +57,8 @@ class QgsGeometrySnapper : public QObject
QMutex mAdjustLayerMutex; QMutex mAdjustLayerMutex;
QMutex mReferenceLayerMutex; QMutex mReferenceLayerMutex;
void processFeature( const QgsFeatureId& id ); void processFeature( QgsFeatureId id );
bool getFeature( QgsVectorLayer* layer, QMutex& mutex, const QgsFeatureId &id, QgsFeature& feature ); bool getFeature( QgsVectorLayer* layer, QMutex& mutex, QgsFeatureId id, QgsFeature& feature );
int polyLineSize( const QgsAbstractGeometryV2* geom, int iPart, int iRing ) const; int polyLineSize( const QgsAbstractGeometryV2* geom, int iPart, int iRing ) const;
}; };

View File

@ -64,7 +64,7 @@ QgsVirtualLayerFeatureIterator::QgsVirtualLayerFeatureIterator( QgsVirtualLayerF
{ {
QString values = quotedColumn( mDefinition.uid() ) + " IN ("; QString values = quotedColumn( mDefinition.uid() ) + " IN (";
bool first = true; bool first = true;
Q_FOREACH ( const QgsFeatureId &v, request.filterFids() ) Q_FOREACH ( QgsFeatureId v, request.filterFids() )
{ {
if ( !first ) if ( !first )
{ {