Skip to content
Permalink
Browse files

Remove duplicate QgsFeature::setFeatureId method

Leave just QgsFeature::setId and document api break
  • Loading branch information
nyalldawson authored and m-kuhn committed Jan 11, 2017
1 parent 3e2b4fc commit e656c63ab734af5ebc978f8eb8a66b2eaf634d40
Showing with 58 additions and 86 deletions.
  1. +1 −0 doc/api_break.dox
  2. +0 −6 python/core/qgsfeature.sip
  3. +1 −16 src/core/qgsfeature.cpp
  4. +1 −9 src/core/qgsfeature.h
  5. +1 −1 src/core/qgsogrutils.cpp
  6. +1 −1 src/core/qgsvectorlayerdiagramprovider.cpp
  7. +2 −2 src/core/qgsvectorlayerfeatureiterator.cpp
  8. +1 −1 src/core/qgsvectorlayerundocommand.cpp
  9. +3 −3 src/gui/attributetable/qgsattributetablemodel.cpp
  10. +1 −1 src/plugins/geometry_checker/utils/qgsfeaturepool.cpp
  11. +1 −1 src/providers/arcgisrest/qgsafsprovider.cpp
  12. +1 −1 src/providers/db2/qgsdb2featureiterator.cpp
  13. +1 −1 src/providers/db2/qgsdb2provider.cpp
  14. +1 −1 src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp
  15. +2 −2 src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
  16. +3 −3 src/providers/gpx/qgsgpxfeatureiterator.cpp
  17. +1 −1 src/providers/grass/qgsgrassfeatureiterator.cpp
  18. +1 −1 src/providers/memory/qgsmemoryprovider.cpp
  19. +1 −1 src/providers/mssql/qgsmssqlfeatureiterator.cpp
  20. +1 −1 src/providers/mssql/qgsmssqlprovider.cpp
  21. +1 −1 src/providers/ogr/qgsogrfeatureiterator.cpp
  22. +1 −1 src/providers/ogr/qgsogrprovider.cpp
  23. +1 −1 src/providers/oracle/qgsoraclefeatureiterator.cpp
  24. +3 −3 src/providers/oracle/qgsoracleprovider.cpp
  25. +1 −1 src/providers/postgres/qgspostgresfeatureiterator.cpp
  26. +4 −4 src/providers/postgres/qgspostgresprovider.cpp
  27. +2 −2 src/providers/spatialite/qgsspatialitefeatureiterator.cpp
  28. +1 −1 src/providers/spatialite/qgsspatialiteprovider.cpp
  29. +2 −2 src/providers/virtual/qgsvirtuallayerfeatureiterator.cpp
  30. +1 −1 src/providers/wfs/qgswfsfeatureiterator.cpp
  31. +1 −1 src/providers/wfs/qgswfsprovider.cpp
  32. +3 −3 src/providers/wfs/qgswfsshareddata.cpp
  33. +4 −4 tests/src/core/testqgsfeature.cpp
  34. +3 −3 tests/src/providers/grass/testqgsgrassprovider.cpp
  35. +4 −4 tests/src/python/test_layer_dependencies.py
  36. +1 −1 tests/src/python/test_qgsspatialindex.py
@@ -914,6 +914,7 @@ None will need to be modified, as the method will return an empty geometry if th
- The temporary constGeometry() method has been removed. Use geometry() instead.
- setFields( const QgsFields*, bool ) has been removed, use setFields( const QgsFields&, bool ) instead.
- fields() no longer returns a pointer, but instead a QgsFields value.
- The duplicate method setFeatureId() was removed. Use setId() instead.


QgsFeatureRendererV2 {#qgis_api_break_3_0_QgsFeatureRendererV2}
@@ -241,12 +241,6 @@ class QgsFeature
*/
QgsFeatureId id() const;

/** Sets the feature ID for this feature.
* @param id feature id
* @see id
*/
void setFeatureId( QgsFeatureId id );

/** Sets the feature ID for this feature.
* @param id feature id
* @see id
@@ -115,21 +115,6 @@ QgsGeometry QgsFeature::geometry() const
return d->geometry;
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests in testqgsfeature.cpp.
* See details in QEP #17
****************************************************************************/

void QgsFeature::setFeatureId( QgsFeatureId id )
{
if ( id == d->fid )
return;

d.detach();
d->fid = id;
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests in testqgsfeature.cpp.
@@ -324,7 +309,7 @@ QDataStream& operator>>( QDataStream& in, QgsFeature& feature )
bool valid;
QgsAttributes attr;
in >> id >> attr >> geometry >> valid;
feature.setFeatureId( id );
feature.setId( id );
feature.setGeometry( geometry );
feature.setAttributes( attr );
feature.setValid( valid );
@@ -172,22 +172,14 @@ class CORE_EXPORT QgsFeature
*/
bool operator!=( const QgsFeature& other ) const;



virtual ~QgsFeature();

/** Get the feature ID for this feature.
* @returns feature ID
* @see setFeatureId
* @see setId()
*/
QgsFeatureId id() const;

/** Sets the feature ID for this feature.
* @param id feature id
* @see id
*/
void setFeatureId( QgsFeatureId id );

/** Sets the feature ID for this feature.
* @param id feature id
* @see id
@@ -30,7 +30,7 @@ QgsFeature QgsOgrUtils::readOgrFeature( OGRFeatureH ogrFet, const QgsFields& fie
return feature;
}

feature.setFeatureId( OGR_F_GetFID( ogrFet ) );
feature.setId( OGR_F_GetFID( ogrFet ) );
feature.setValid( true );

if ( !readOgrFeatureGeometry( ogrFet, feature ) )
@@ -129,7 +129,7 @@ void QgsVectorLayerDiagramProvider::drawLabel( QgsRenderContext& context, pal::L
QgsFeature feature;
feature.setFields( mFields );
feature.setValid( true );
feature.setFeatureId( label->getFeaturePart()->featureId() );
feature.setId( label->getFeaturePart()->featureId() );
feature.setAttributes( dlf->attributes() );

//calculate top-left point for diagram
@@ -376,7 +376,7 @@ bool QgsVectorLayerFeatureIterator::fetchNextAddedFeature( QgsFeature& f )

void QgsVectorLayerFeatureIterator::useAddedFeature( const QgsFeature& src, QgsFeature& f )
{
f.setFeatureId( src.id() );
f.setId( src.id() );
f.setValid( true );
f.setFields( mSource->mFields );

@@ -450,7 +450,7 @@ bool QgsVectorLayerFeatureIterator::fetchNextChangedAttributeFeature( QgsFeature

void QgsVectorLayerFeatureIterator::useChangedAttributeFeature( QgsFeatureId fid, const QgsGeometry& geom, QgsFeature& f )
{
f.setFeatureId( fid );
f.setId( fid );
f.setValid( true );
f.setFields( mSource->mFields );

@@ -38,7 +38,7 @@ QgsVectorLayerUndoCommandAddFeature::QgsVectorLayerUndoCommandAddFeature( QgsVec
// Force a feature ID (to keep other functions in QGIS happy,
// providers will use their own new feature ID when we commit the new feature)
// and add to the known added features.
f.setFeatureId( addedIdLowWaterMark );
f.setId( addedIdLowWaterMark );

mFeature = f;
}
@@ -53,7 +53,7 @@ QgsAttributeTableModel::QgsAttributeTableModel( QgsVectorLayerCache *layerCache,
mFeatureRequest.setFlags( QgsFeatureRequest::NoGeometry );
}

mFeat.setFeatureId( std::numeric_limits<int>::min() );
mFeat.setId( std::numeric_limits<int>::min() );

if ( !layer()->hasGeometryType() )
mFeatureRequest.setFlags( QgsFeatureRequest::NoGeometry );
@@ -744,7 +744,7 @@ Qt::ItemFlags QgsAttributeTableModel::flags( const QModelIndex &index ) const

void QgsAttributeTableModel::reload( const QModelIndex &index1, const QModelIndex &index2 )
{
mFeat.setFeatureId( std::numeric_limits<int>::min() );
mFeat.setId( std::numeric_limits<int>::min() );
emit dataChanged( index1, index2 );
}

@@ -765,7 +765,7 @@ QgsFeature QgsAttributeTableModel::feature( const QModelIndex &idx ) const
{
QgsFeature f;
f.initAttributes( mAttributes.size() );
f.setFeatureId( rowToId( idx.row() ) );
f.setId( rowToId( idx.row() ) );
for ( int i = 0; i < mAttributes.size(); i++ )
{
f.setAttribute( mAttributes[i], data( index( idx.row(), i ), Qt::EditRole ) );
@@ -89,7 +89,7 @@ void QgsFeaturePool::addFeature( QgsFeature& feature )
features.append( feature );
mLayerMutex.lock();
mLayer->dataProvider()->addFeatures( features );
feature.setFeatureId( features.front().id() );
feature.setId( features.front().id() );
if ( mSelectedOnly )
{
QgsFeatureIds selectedFeatureIds = mLayer->selectedFeatureIds();
@@ -223,7 +223,7 @@ bool QgsAfsProvider::getFeature( QgsFeatureId id, QgsFeature &f, bool fetchGeome
QgsFeature feature;

// Set FID
feature.setFeatureId( startId + i );
feature.setId( startId + i );

// Set attributes
if ( !fetchAttribIdx.isEmpty() )
@@ -347,7 +347,7 @@ bool QgsDb2FeatureIterator::fetchFeature( QgsFeature& feature )
}
}
// QgsDebugMsg( QString( "Fid: %1; value: %2" ).arg( mSource->mFidColName ).arg( record.value( mSource->mFidColName ).toLongLong() ) );
feature.setFeatureId( mQuery->record().value( mSource->mFidColName ).toLongLong() );
feature.setId( mQuery->record().value( mSource->mFidColName ).toLongLong() );

if ( mSource->isSpatial() )
{
@@ -1146,7 +1146,7 @@ bool QgsDb2Provider::addFeatures( QgsFeatureList & flist )
return false;
}
}
it->setFeatureId( queryFid.value( 0 ).toLongLong() );
it->setId( queryFid.value( 0 ).toLongLong() );
writeCount++;
// QgsDebugMsg( QString( "count: %1; featureId: %2" ).arg( writeCount ).arg( queryFid.value( 0 ).toLongLong() ) );
}
@@ -331,7 +331,7 @@ bool QgsDelimitedTextFeatureIterator::nextFeatureInternal( QgsFeature& feature )

feature.setValid( true );
feature.setFields( mSource->mFields ); // allow name-based attribute lookups
feature.setFeatureId( fid );
feature.setId( fid );
feature.initAttributes( mSource->mFields.count() );
feature.setGeometry( geom );

@@ -473,7 +473,7 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes )
if ( buildSpatialIndex )
{
QgsFeature f;
f.setFeatureId( mFile->recordId() );
f.setId( mFile->recordId() );
f.setGeometry( geom );
mSpatialIndex->insertFeature( f );
}
@@ -528,7 +528,7 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes )
if ( buildSpatialIndex && qIsFinite( pt.x() ) && qIsFinite( pt.y() ) )
{
QgsFeature f;
f.setFeatureId( mFile->recordId() );
f.setId( mFile->recordId() );
f.setGeometry( QgsGeometry::fromPoint( pt ) );
mSpatialIndex->insertFeature( f );
}
@@ -191,7 +191,7 @@ bool QgsGPXFeatureIterator::readWaypoint( const QgsWaypoint& wpt, QgsFeature& fe
feature.setGeometry( *g );
delete g;
}
feature.setFeatureId( wpt.id );
feature.setId( wpt.id );
feature.setValid( true );
feature.setFields( mSource->mFields ); // allow name-based attribute lookups
feature.initAttributes( mSource->mFields.count() );
@@ -235,7 +235,7 @@ bool QgsGPXFeatureIterator::readRoute( const QgsRoute& rte, QgsFeature& feature
{
delete theGeometry;
}
feature.setFeatureId( rte.id );
feature.setId( rte.id );
feature.setValid( true );
feature.setFields( mSource->mFields ); // allow name-based attribute lookups
feature.initAttributes( mSource->mFields.count() );
@@ -278,7 +278,7 @@ bool QgsGPXFeatureIterator::readTrack( const QgsTrack& trk, QgsFeature& feature
{
delete theGeometry;
}
feature.setFeatureId( trk.id );
feature.setId( trk.id );
feature.setValid( true );
feature.setFields( mSource->mFields ); // allow name-based attribute lookups
feature.initAttributes( mSource->mFields.count() );
@@ -485,7 +485,7 @@ bool QgsGrassFeatureIterator::fetchFeature( QgsFeature& feature )
}
QgsDebugMsgLevel( QString( "lid = %1 type = %2 cat = %3 featureId = %4" ).arg( lid ).arg( type ).arg( cat ).arg( featureId ), 3 );

feature.setFeatureId( featureId );
feature.setId( featureId );
//feature.initAttributes( mSource->mFields.count() );
QgsDebugMsgLevel( QString( "mSource->mFields.size() = %1" ).arg( mSource->mFields.size() ), 3 );
feature.setFields( mSource->mFields ); // allow name-based attribute lookups
@@ -301,7 +301,7 @@ bool QgsMemoryProvider::addFeatures( QgsFeatureList & flist )
// TODO: sanity checks of fields and geometries
for ( QgsFeatureList::iterator it = flist.begin(); it != flist.end(); ++it )
{
it->setFeatureId( mNextFeatureId );
it->setId( mNextFeatureId );
it->setValid( true );

mFeatures.insert( mNextFeatureId, *it );
@@ -304,7 +304,7 @@ bool QgsMssqlFeatureIterator::fetchFeature( QgsFeature& feature )
feature.setAttribute( mAttributesToFetch.at( i ), v );
}

feature.setFeatureId( mQuery->record().value( mSource->mFidColName ).toLongLong() );
feature.setId( mQuery->record().value( mSource->mFidColName ).toLongLong() );

if ( mSource->isSpatial() )
{
@@ -1003,7 +1003,7 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
return false;
}
}
it->setFeatureId( query.value( 0 ).toLongLong() );
it->setId( query.value( 0 ).toLongLong() );
}

return true;
@@ -294,7 +294,7 @@ void QgsOgrFeatureIterator::getFeatureAttribute( OGRFeatureH ogrFet, QgsFeature

bool QgsOgrFeatureIterator::readFeature( OGRFeatureH fet, QgsFeature& feature ) const
{
feature.setFeatureId( OGR_F_GetFID( fet ) );
feature.setId( OGR_F_GetFID( fet ) );
feature.initAttributes( mSource->mFields.count() );
feature.setFields( mSource->mFields ); // allow name-based attribute lookups

@@ -1299,7 +1299,7 @@ bool QgsOgrProvider::addFeature( QgsFeature& f )
QgsFeatureId id = static_cast<QgsFeatureId>( OGR_F_GetFID( feature ) );
if ( id >= 0 )
{
f.setFeatureId( id );
f.setId( id );

if ( mFirstFieldIsFid && attrs.count() > 0 )
{
@@ -361,7 +361,7 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature& feature )
return false;
}

feature.setFeatureId( fid );
feature.setId( fid );
QgsDebugMsgLevel( QString( "fid=%1" ).arg( fid ), 5 );

// iterate attributes
@@ -1410,7 +1410,7 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist )

if ( mPrimaryKeyType == pktRowId )
{
features->setFeatureId( mShared->lookupFid( QList<QVariant>() << QVariant( ins.lastInsertId() ) ) );
features->setId( mShared->lookupFid( QList<QVariant>() << QVariant( ins.lastInsertId() ) ) );
QgsDebugMsgLevel( QString( "new fid=%1" ).arg( features->id() ), 4 );
}
else if ( mPrimaryKeyType == pktInt || mPrimaryKeyType == pktFidMap )
@@ -1448,7 +1448,7 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist )

if ( mPrimaryKeyType == pktInt )
{
features->setFeatureId( STRING_TO_FID( attributevec[ mPrimaryKeyAttrs[0] ] ) );
features->setId( STRING_TO_FID( attributevec[ mPrimaryKeyAttrs[0] ] ) );
}
else
{
@@ -1459,7 +1459,7 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist )
primaryKeyVals << attributevec[ idx ];
}

features->setFeatureId( mShared->lookupFid( QVariant( primaryKeyVals ) ) );
features->setId( mShared->lookupFid( QVariant( primaryKeyVals ) ) );
}
QgsDebugMsgLevel( QString( "new fid=%1" ).arg( features->id() ), 4 );
}
@@ -755,7 +755,7 @@ bool QgsPostgresFeatureIterator::getFeature( QgsPostgresResult &queryResult, int
return false;
}

feature.setFeatureId( fid );
feature.setId( fid );
QgsDebugMsgLevel( QString( "fid=%1" ).arg( fid ), 4 );

// iterate attributes
@@ -2146,7 +2146,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )

if ( mPrimaryKeyType == pktOid )
{
features->setFeatureId( result.PQoidValue() );
features->setId( result.PQoidValue() );
QgsDebugMsgLevel( QString( "new fid=%1" ).arg( features->id() ), 4 );
}
}
@@ -2160,11 +2160,11 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )

if ( mPrimaryKeyType == pktUint64 )
{
features->setFeatureId( STRING_TO_FID( attrs.at( mPrimaryKeyAttrs.at( 0 ) ) ) );
features->setId( STRING_TO_FID( attrs.at( mPrimaryKeyAttrs.at( 0 ) ) ) );
}
else if ( mPrimaryKeyType == pktInt )
{
features->setFeatureId( PKINT2FID( STRING_TO_FID( attrs.at( mPrimaryKeyAttrs.at( 0 ) ) ) ) );
features->setId( PKINT2FID( STRING_TO_FID( attrs.at( mPrimaryKeyAttrs.at( 0 ) ) ) ) );
}
else
{
@@ -2175,7 +2175,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )
primaryKeyVals << attrs.at( idx );
}

features->setFeatureId( mShared->lookupFid( primaryKeyVals ) );
features->setId( mShared->lookupFid( primaryKeyVals ) );
}
QgsDebugMsgLevel( QString( "new fid=%1" ).arg( features->id() ), 4 );
}
@@ -479,13 +479,13 @@ bool QgsSpatiaLiteFeatureIterator::getFeature( sqlite3_stmt *stmt, QgsFeature &f
// first column always contains the ROWID (or the primary key)
QgsFeatureId fid = sqlite3_column_int64( stmt, ic );
QgsDebugMsgLevel( QString( "fid=%1" ).arg( fid ), 3 );
feature.setFeatureId( fid );
feature.setId( fid );
}
else
{
// autoincrement a row number
mRowNumber++;
feature.setFeatureId( mRowNumber );
feature.setId( mRowNumber );
}
}
else if ( mFetchGeometry && ic == mGeomColIdx )
@@ -3970,7 +3970,7 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
if ( ret == SQLITE_DONE || ret == SQLITE_ROW )
{
// update feature id
feature->setFeatureId( sqlite3_last_insert_rowid( mSqliteHandle ) );
feature->setId( sqlite3_last_insert_rowid( mSqliteHandle ) );
mNumberFeatures++;
}
else

0 comments on commit e656c63

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