Skip to content
Permalink
Browse files
Update featureCount() methods to return long long for Win64 compatibi…
…lity
  • Loading branch information
rouault authored and nyalldawson committed Jun 15, 2021
1 parent 5a9968c commit 92fc43505de8b1a781834380bbc1a8cf61c84292
Showing with 158 additions and 160 deletions.
  1. +1 −1 python/core/auto_generated/processing/qgsprocessingutils.sip.in
  2. +1 −1 python/core/auto_generated/qgsfeaturesource.sip.in
  3. +2 −2 python/core/auto_generated/vector/qgsvectordataprovider.sip.in
  4. +2 −2 python/core/auto_generated/vector/qgsvectorlayer.sip.in
  5. +1 −1 python/core/auto_generated/vector/qgsvectorlayercache.sip.in
  6. +1 −1 python/core/auto_generated/vector/qgsvectorlayerfeaturecounter.sip.in
  7. +1 −1 python/core/auto_generated/vector/qgsvectorlayerfeatureiterator.sip.in
  8. +1 −1 src/app/qgsattributetabledialog.cpp
  9. +2 −2 src/core/processing/qgsprocessingutils.cpp
  10. +1 −1 src/core/processing/qgsprocessingutils.h
  11. +2 −2 src/core/providers/memory/qgsmemoryprovider.cpp
  12. +1 −1 src/core/providers/memory/qgsmemoryprovider.h
  13. +14 −14 src/core/providers/ogr/qgsogrprovider.cpp
  14. +2 −2 src/core/providers/ogr/qgsogrprovider.h
  15. +1 −1 src/core/qgsfeaturesource.h
  16. +1 −1 src/core/qgsvectorfilewriter.cpp
  17. +1 −1 src/core/qgsvectorfilewriter.h
  18. +2 −2 src/core/vector/qgsvectordataprovider.h
  19. +2 −2 src/core/vector/qgsvectorlayer.cpp
  20. +3 −3 src/core/vector/qgsvectorlayer.h
  21. +1 −1 src/core/vector/qgsvectorlayercache.cpp
  22. +1 −1 src/core/vector/qgsvectorlayercache.h
  23. +2 −2 src/core/vector/qgsvectorlayerexporter.cpp
  24. +2 −2 src/core/vector/qgsvectorlayerfeaturecounter.cpp
  25. +3 −3 src/core/vector/qgsvectorlayerfeaturecounter.h
  26. +1 −1 src/core/vector/qgsvectorlayerfeatureiterator.cpp
  27. +1 −1 src/core/vector/qgsvectorlayerfeatureiterator.h
  28. +1 −1 src/providers/arcgisrest/qgsafsprovider.cpp
  29. +1 −1 src/providers/arcgisrest/qgsafsprovider.h
  30. +1 −1 src/providers/arcgisrest/qgsafsshareddata.h
  31. +1 −1 src/providers/db2/qgsdb2provider.cpp
  32. +1 −1 src/providers/db2/qgsdb2provider.h
  33. +1 −1 src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
  34. +2 −2 src/providers/delimitedtext/qgsdelimitedtextprovider.h
  35. +1 −1 src/providers/gpx/qgsgpxprovider.cpp
  36. +1 −1 src/providers/gpx/qgsgpxprovider.h
  37. +1 −1 src/providers/grass/qgsgrassprovider.cpp
  38. +1 −1 src/providers/grass/qgsgrassprovider.h
  39. +3 −3 src/providers/hana/qgshanaprovider.cpp
  40. +3 −3 src/providers/hana/qgshanaprovider.h
  41. +3 −3 src/providers/mssql/qgsmssqlprovider.cpp
  42. +2 −2 src/providers/mssql/qgsmssqlprovider.h
  43. +2 −2 src/providers/oracle/qgsoracleprovider.cpp
  44. +2 −2 src/providers/oracle/qgsoracleprovider.h
  45. +10 −10 src/providers/postgres/qgspostgresprovider.cpp
  46. +6 −6 src/providers/postgres/qgspostgresprovider.h
  47. +2 −2 src/providers/spatialite/qgsspatialiteprovider.cpp
  48. +2 −2 src/providers/spatialite/qgsspatialiteprovider.h
  49. +1 −1 src/providers/virtual/qgsvirtuallayerprovider.cpp
  50. +1 −1 src/providers/virtual/qgsvirtuallayerprovider.h
  51. +2 −2 src/providers/wfs/qgsbackgroundcachedfeatureiterator.cpp
  52. +4 −4 src/providers/wfs/qgsbackgroundcachedfeatureiterator.h
  53. +4 −4 src/providers/wfs/qgsbackgroundcachedshareddata.cpp
  54. +8 −8 src/providers/wfs/qgsbackgroundcachedshareddata.h
  55. +6 −6 src/providers/wfs/qgsoapifprovider.cpp
  56. +5 −5 src/providers/wfs/qgsoapifprovider.h
  57. +1 −1 src/providers/wfs/qgswfscapabilities.h
  58. +6 −6 src/providers/wfs/qgswfsdatasourceuri.cpp
  59. +3 −3 src/providers/wfs/qgswfsdatasourceuri.h
  60. +4 −6 src/providers/wfs/qgswfsfeatureiterator.cpp
  61. +5 −5 src/providers/wfs/qgswfsfeatureiterator.h
  62. +1 −1 src/providers/wfs/qgswfsprovider.cpp
  63. +1 −1 src/providers/wfs/qgswfsprovider.h
  64. +3 −3 src/providers/wfs/qgswfsshareddata.cpp
  65. +3 −3 src/providers/wfs/qgswfsshareddata.h
@@ -439,7 +439,7 @@ iterator, eg by restricting the returned attributes or geometry.

virtual QgsWkbTypes::Type wkbType() const;

virtual long featureCount() const;
virtual long long featureCount() const;

virtual QString sourceName() const;

@@ -75,7 +75,7 @@ if the feature count is unknown.
sipRes = true;
%End

virtual long featureCount() const = 0;
virtual long long featureCount() const = 0;
%Docstring
Returns the number of features contained in the source, or -1
if the feature count is unknown.
@@ -113,12 +113,12 @@ Query the provider for features specified in request.
Returns the geometry type which is returned by this layer
%End

virtual long featureCount() const = 0;
virtual long long featureCount() const = 0;

%Docstring
Number of features in the layer

:return: long containing number of features
:return: number of features
%End

virtual bool empty() const;
@@ -1052,7 +1052,7 @@ Writes the symbology of the layer into the document provided in SLD 1.1 format
virtual bool readSld( const QDomNode &node, QString &errorMessage ) ${SIP_FINAL};


long featureCount( const QString &legendKey ) const;
long long featureCount( const QString &legendKey ) const;
%Docstring
Number of features rendered with specified legend key. Features must be first
calculated by :py:func:`~QgsVectorLayer.countSymbolFeatures`
@@ -1792,7 +1792,7 @@ Returns list of attribute indexes. i.e. a list from 0 ... :py:func:`~QgsVectorLa
Returns the list of attributes which make up the layer's primary keys.
%End

virtual long featureCount() const ${SIP_FINAL};
virtual long long featureCount() const ${SIP_FINAL};

%Docstring
Returns feature count including changes which have not yet been committed
@@ -226,7 +226,7 @@ if the feature count is unknown.
sipRes = true;
%End

long featureCount() const;
long long featureCount() const;
%Docstring
Returns the number of features contained in the source, or -1
if the feature count is unknown.
@@ -41,7 +41,7 @@ Calculates the feature count and Ids per symbol
%End


long featureCount( const QString &legendKey ) const;
long long featureCount( const QString &legendKey ) const;
%Docstring
Returns the feature count for a particular ``legendKey``.
If the key has not been found, -1 will be returned.
@@ -192,7 +192,7 @@ the QgsVectorLayerSelectedFeatureSource will not be reflected.

virtual QgsWkbTypes::Type wkbType() const;

virtual long featureCount() const;
virtual long long featureCount() const;

virtual QString sourceName() const;

@@ -387,7 +387,7 @@ void QgsAttributeTableDialog::updateTitle()
: qobject_cast<QWidget *>( this );
w->setWindowTitle( tr( " %1 — Features Total: %2, Filtered: %3, Selected: %4" )
.arg( mLayer->name() )
.arg( std::max( static_cast< long >( mMainView->featureCount() ), mLayer->featureCount() ) ) // layer count may be estimated, so use larger of the two
.arg( std::max( static_cast< long long >( mMainView->featureCount() ), mLayer->featureCount() ) ) // layer count may be estimated, so use larger of the two
.arg( mMainView->filteredFeatureCount() )
.arg( mLayer->selectedFeatureCount() )
);
@@ -1311,12 +1311,12 @@ QgsWkbTypes::Type QgsProcessingFeatureSource::wkbType() const
return mSource->wkbType();
}

long QgsProcessingFeatureSource::featureCount() const
long long QgsProcessingFeatureSource::featureCount() const
{
if ( mFeatureLimit == -1 )
return mSource->featureCount();
else
return std::min( mFeatureLimit, static_cast< long long >( mSource->featureCount() ) );
return std::min( mFeatureLimit, mSource->featureCount() );
}

QString QgsProcessingFeatureSource::sourceName() const
@@ -506,7 +506,7 @@ class CORE_EXPORT QgsProcessingFeatureSource : public QgsFeatureSource
QgsCoordinateReferenceSystem sourceCrs() const override;
QgsFields fields() const override;
QgsWkbTypes::Type wkbType() const override;
long featureCount() const override;
long long featureCount() const override;
QString sourceName() const override;
QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const override;
QVariant minimumValue( int fieldIndex ) const override;
@@ -367,14 +367,14 @@ QgsWkbTypes::Type QgsMemoryProvider::wkbType() const
return mWkbType;
}

long QgsMemoryProvider::featureCount() const
long long QgsMemoryProvider::featureCount() const
{
if ( mSubsetString.isEmpty() )
return mFeatures.count();

// subset string set, no alternative but testing each feature
QgsFeatureIterator fit = QgsFeatureIterator( new QgsMemoryFeatureIterator( new QgsMemoryFeatureSource( this ), true, QgsFeatureRequest().setNoAttributes() ) );
int count = 0;
long long count = 0;
QgsFeature feature;
while ( fit.nextFeature( feature ) )
{
@@ -56,7 +56,7 @@ class QgsMemoryProvider final: public QgsVectorDataProvider
QString storageType() const override;
QgsFeatureIterator getFeatures( const QgsFeatureRequest &request ) const override;
QgsWkbTypes::Type wkbType() const override;
long featureCount() const override;
long long featureCount() const override;
QgsFields fields() const override;
bool addFeatures( QgsFeatureList &flist, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override;
bool deleteFeatures( const QgsFeatureIds &id ) override;
@@ -260,10 +260,10 @@ void QgsOgrProvider::repack()

}

if ( mFeaturesCounted != static_cast< long >( Qgis::FeatureCountState::Uncounted ) &&
mFeaturesCounted != static_cast< long >( Qgis::FeatureCountState::UnknownCount ) )
if ( mFeaturesCounted != static_cast< long long >( Qgis::FeatureCountState::Uncounted ) &&
mFeaturesCounted != static_cast< long long >( Qgis::FeatureCountState::UnknownCount ) )
{
long oldcount = mFeaturesCounted;
long long oldcount = mFeaturesCounted;
recalculateFeatureCount();
if ( oldcount != mFeaturesCounted )
emit dataChanged();
@@ -854,7 +854,7 @@ void QgsOgrProvider::addSubLayerDetailsToSubLayerList( int i, QgsOgrLayer *layer

if ( slowGeomTypeRetrieval || wkbFlatten( layerGeomType ) != wkbUnknown )
{
int layerFeatureCount = withFeatureCount ? layer->GetApproxFeatureCount() : -1;
long long layerFeatureCount = withFeatureCount ? layer->GetApproxFeatureCount() : -1;

QString geom = ogrWkbGeometryTypeName( layerGeomType );

@@ -1839,11 +1839,11 @@ QgsWkbTypes::Type QgsOgrProvider::wkbType() const
/**
* Returns the feature count
*/
long QgsOgrProvider::featureCount() const
long long QgsOgrProvider::featureCount() const
{
if ( ( mReadFlags & QgsDataProvider::SkipFeatureCount ) != 0 )
{
return static_cast< long >( Qgis::FeatureCountState::UnknownCount );
return static_cast< long long >( Qgis::FeatureCountState::UnknownCount );
}
if ( mRefreshFeatureCount )
{
@@ -2239,8 +2239,8 @@ bool QgsOgrProvider::addFeatures( QgsFeatureList &flist, Flags flags )
returnvalue = false;
}

if ( mFeaturesCounted != static_cast< long >( Qgis::FeatureCountState::Uncounted ) &&
mFeaturesCounted != static_cast< long >( Qgis::FeatureCountState::UnknownCount ) )
if ( mFeaturesCounted != static_cast< long long >( Qgis::FeatureCountState::Uncounted ) &&
mFeaturesCounted != static_cast< long long >( Qgis::FeatureCountState::UnknownCount ) )
{
if ( returnvalue )
mFeaturesCounted += flist.size();
@@ -2585,7 +2585,7 @@ bool QgsOgrProvider::_setSubsetString( const QString &theSQL, bool updateFeature
if ( !mOgrOrigLayer )
return false;

if ( theSQL == mSubsetString && mFeaturesCounted != static_cast< long >( Qgis::FeatureCountState::Uncounted ) )
if ( theSQL == mSubsetString && mFeaturesCounted != static_cast< long long >( Qgis::FeatureCountState::Uncounted ) )
return true;

const bool subsetStringHasChanged { theSQL != mSubsetString };
@@ -3205,8 +3205,8 @@ bool QgsOgrProvider::deleteFeatures( const QgsFeatureIds &id )
}
else
{
if ( mFeaturesCounted != static_cast< long >( Qgis::FeatureCountState::Uncounted ) &&
mFeaturesCounted != static_cast< long >( Qgis::FeatureCountState::UnknownCount ) )
if ( mFeaturesCounted != static_cast< long long >( Qgis::FeatureCountState::Uncounted ) &&
mFeaturesCounted != static_cast< long long >( Qgis::FeatureCountState::UnknownCount ) )
{
if ( returnvalue )
mFeaturesCounted -= id.size();
@@ -5046,7 +5046,7 @@ void QgsOgrProvider::recalculateFeatureCount() const
{
if ( !mOgrLayer )
{
mFeaturesCounted = static_cast< long >( Qgis::FeatureCountState::Uncounted );
mFeaturesCounted = static_cast< long long >( Qgis::FeatureCountState::Uncounted );
return;
}

@@ -5064,7 +5064,7 @@ void QgsOgrProvider::recalculateFeatureCount() const
mFeaturesCounted = mOgrLayer->GetApproxFeatureCount();
if ( mFeaturesCounted == -1 )
{
mFeaturesCounted = static_cast< long >( Qgis::FeatureCountState::UnknownCount );
mFeaturesCounted = static_cast< long long >( Qgis::FeatureCountState::UnknownCount );
}
}
else
@@ -5408,7 +5408,7 @@ void QgsOgrProvider::close()

void QgsOgrProvider::reloadProviderData()
{
mFeaturesCounted = static_cast< long >( Qgis::FeatureCountState::Uncounted );
mFeaturesCounted = static_cast< long long >( Qgis::FeatureCountState::Uncounted );
bool wasValid = mValid;
QgsOgrConnPool::instance()->invalidateConnections( QgsOgrProviderUtils::connectionPoolId( dataSourceUri( true ), mShareSameDatasetAmongLayers ) );
close();
@@ -122,7 +122,7 @@ class QgsOgrProvider final: public QgsVectorDataProvider
bool setSubsetString( const QString &theSQL, bool updateFeatureCount = true ) override;
QgsWkbTypes::Type wkbType() const override;
virtual size_t layerCount() const;
long featureCount() const override;
long long featureCount() const override;
QgsFields fields() const override;
QgsRectangle extent() const override;
QVariant defaultValue( int fieldId ) const override;
@@ -309,7 +309,7 @@ class QgsOgrProvider final: public QgsVectorDataProvider
//! Whether the next call to featureCount() should refresh the feature count
mutable bool mRefreshFeatureCount = true;

mutable long mFeaturesCounted = static_cast< long >( Qgis::FeatureCountState::Uncounted );
mutable long long mFeaturesCounted = static_cast< long long >( Qgis::FeatureCountState::Uncounted );

mutable QStringList mSubLayerList;

@@ -105,7 +105,7 @@ class CORE_EXPORT QgsFeatureSource
* Returns the number of features contained in the source, or -1
* if the feature count is unknown.
*/
virtual long featureCount() const = 0;
virtual long long featureCount() const = 0;

/**
* Determines if there are any features available in the source.
@@ -3148,7 +3148,7 @@ QgsVectorFileWriter::WriterError QgsVectorFileWriter::writeAsVectorFormatV2( Pre
QgsWkbTypes::Type destWkbType = details.destWkbType;

int lastProgressReport = 0;
long total = details.featureCount;
long long total = details.featureCount;

// Special rules for OGR layers
if ( details.providerType == QLatin1String( "ogr" ) && !details.dataSourceUri.isEmpty() )
@@ -958,7 +958,7 @@ class CORE_EXPORT QgsVectorFileWriter : public QgsFeatureSink
QgsWkbTypes::Type sourceWkbType = QgsWkbTypes::Unknown;
QgsFields sourceFields;
QString providerType;
long featureCount = 0;
long long featureCount = 0;
QgsFeatureIds selectedFeatureIds;
QString dataSourceUri;
QString storageType;
@@ -153,9 +153,9 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider, public QgsFeat

/**
* Number of features in the layer
* \returns long containing number of features
* \returns number of features
*/
long featureCount() const override = 0;
long long featureCount() const override = 0;

/**
* Returns TRUE if the layer does not contain any feature.
@@ -763,7 +763,7 @@ bool QgsVectorLayer::diagramsEnabled() const
return false;
}

long QgsVectorLayer::featureCount( const QString &legendKey ) const
long long QgsVectorLayer::featureCount( const QString &legendKey ) const
{
if ( !mSymbolFeatureCounted )
return -1;
@@ -3417,7 +3417,7 @@ QgsAttributeList QgsVectorLayer::primaryKeyAttributes() const
return pkAttributesList;
}

long QgsVectorLayer::featureCount() const
long long QgsVectorLayer::featureCount() const
{
if ( ! mDataProvider )
return -1;
@@ -1109,7 +1109,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* calculated by countSymbolFeatures()
* \returns number of features rendered by symbol or -1 if failed or counts are not available
*/
long featureCount( const QString &legendKey ) const;
long long featureCount( const QString &legendKey ) const;

/**
* Ids of features rendered with specified legend key. Features must be first
@@ -1708,7 +1708,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* If you need only the count of committed features call this method on this layer's provider.
* \returns the number of features on this layer or -1 if unknown.
*/
long featureCount() const FINAL;
long long featureCount() const FINAL;

/**
* Makes layer read-only (editing disabled) or not
@@ -2977,7 +2977,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
bool mSymbolFeatureCounted = false;

// Feature counts for each renderer legend key
QHash<QString, long> mSymbolFeatureCountMap;
QHash<QString, long long> mSymbolFeatureCountMap;
QHash<QString, QgsFeatureIds> mSymbolFeatureIdMap;

//! True while an undo command is active
@@ -209,7 +209,7 @@ QgsFields QgsVectorLayerCache::fields() const
return mLayer->fields();
}

long QgsVectorLayerCache::featureCount() const
long long QgsVectorLayerCache::featureCount() const
{
return mLayer->featureCount();
}
@@ -292,7 +292,7 @@ class CORE_EXPORT QgsVectorLayerCache : public QObject
* Returns the number of features contained in the source, or -1
* if the feature count is unknown.
*/
long featureCount() const;
long long featureCount() const;

protected:

@@ -387,8 +387,8 @@ Qgis::VectorExportResult QgsVectorLayerExporter::exportLayer( QgsVectorLayer *la
if ( !ct.isValid() )
shallTransform = false;

long n = 0;
long approxTotal = onlySelected ? layer->selectedFeatureCount() : layer->featureCount();
long long n = 0;
long long approxTotal = onlySelected ? layer->selectedFeatureCount() : layer->featureCount();

if ( errorMessage )
{
@@ -101,12 +101,12 @@ bool QgsVectorLayerFeatureCounter::run()
return true;
}

QHash<QString, long> QgsVectorLayerFeatureCounter::symbolFeatureCountMap() const
QHash<QString, long long> QgsVectorLayerFeatureCounter::symbolFeatureCountMap() const
{
return mSymbolFeatureCountMap;
}

long QgsVectorLayerFeatureCounter::featureCount( const QString &legendKey ) const
long long QgsVectorLayerFeatureCounter::featureCount( const QString &legendKey ) const
{
return mSymbolFeatureCountMap.value( legendKey, -1 );
}
Loading

0 comments on commit 92fc435

Please sign in to comment.