Skip to content
Permalink
Browse files
Improve docs and python bindings for feature count
  • Loading branch information
m-kuhn committed May 11, 2017
1 parent d452f7f commit ed747ed
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
@@ -843,9 +843,17 @@ Return the provider type for this layer

bool countSymbolFeatures();
%Docstring
Count features for symbols. Feature counts may be get by featureCount().
\param showProgress show progress dialog
:return: true if calculated, false if failed or was canceled by user
Count features for symbols.
The method will return immediately. You will need to connect to the
symbolFeatureCountMapChanged() signal to be notified when the freshly updated
feature counts are ready.

.. note::

If you need to wait for the results, create and start your own QgsVectorLayerFeatureCounter
task and call waitForFinished().

.. versionadded:: 3.0
:rtype: bool
%End

@@ -32,6 +32,13 @@ class QgsVectorLayerFeatureCounter : QgsTask
virtual bool run();


long featureCount( const QString &legendKey ) const;
%Docstring
Get the feature count for a particular ``legendKey``.
If the key has not been found, -1 will be returned.
:rtype: long
%End

signals:

void symbolsCounted();
@@ -807,9 +807,15 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag = false );

/**
* Count features for symbols. Feature counts may be get by featureCount().
* \param showProgress show progress dialog
* \returns true if calculated, false if failed or was canceled by user
* Count features for symbols.
* The method will return immediately. You will need to connect to the
* symbolFeatureCountMapChanged() signal to be notified when the freshly updated
* feature counts are ready.
*
* \note If you need to wait for the results, create and start your own QgsVectorLayerFeatureCounter
* task and call waitForFinished().
*
* \since This is asynchroneous since QGIS 3.0
*/
bool countSymbolFeatures();

@@ -77,3 +77,8 @@ QHash<QString, long> QgsVectorLayerFeatureCounter::symbolFeatureCountMap() const
{
return mSymbolFeatureCountMap;
}

long QgsVectorLayerFeatureCounter::featureCount( const QString &legendKey ) const
{
return mSymbolFeatureCountMap.value( legendKey, -1 );
}
@@ -36,6 +36,12 @@ class CORE_EXPORT QgsVectorLayerFeatureCounter : public QgsTask
*/
QHash<QString, long> symbolFeatureCountMap() const SIP_SKIP;

/**
* Get the feature count for a particular \a legendKey.
* If the key has not been found, -1 will be returned.
*/
long featureCount( const QString &legendKey ) const;

signals:

/**

0 comments on commit ed747ed

Please sign in to comment.