Skip to content
Permalink
Browse files

[OGR] fix feature count issue for OSM datasets (fixes #16402) (#4322)

  • Loading branch information
nirvn committed Apr 6, 2017
1 parent b601467 commit 25d9936df8ab920519e0f44f01c7a7bf457b7601
Showing with 29 additions and 3 deletions.
  1. +11 −0 python/core/qgsvectordataprovider.sip
  2. +11 −0 src/core/qgsvectordataprovider.h
  3. +7 −3 src/providers/ogr/qgsogrprovider.cpp
@@ -57,6 +57,17 @@ class QgsVectorDataProvider : QgsDataProvider
/** Bitmask of all provider's editing capabilities */
static const int EditingCapabilities;

/**
* Enumeration of feature count states
*/
enum FeatureCountState
{
//! Feature count not yet computed
Uncounted = -2,
//! Provider returned an unknown feature count
UnknownCount = -1,
};

/**
* Constructor of the vector provider
* @param uri uniform resource locator (URI) for a dataset
@@ -112,6 +112,17 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
ChangeAttributeValues | ChangeGeometries | AddAttributes | DeleteAttributes |
RenameAttributes;

/**
* Enumeration of feature count states
*/
enum FeatureCountState
{
//! Feature count not yet computed
Uncounted = -2,
//! Provider returned an unknown feature count
UnknownCount = -1,
};

/**
* Constructor of the vector provider
* \param uri uniform resource locator (URI) for a dataset
@@ -378,7 +378,7 @@ QgsOgrProvider::QgsOgrProvider( QString const &uri )
, ogrDriver( nullptr )
, mValid( false )
, mOGRGeomType( wkbUnknown )
, mFeaturesCounted( -1 )
, mFeaturesCounted( QgsVectorDataProvider::Uncounted )
, mWriteAccess( false )
, mWriteAccessPossible( false )
, mDynamicWriteAccess( false )
@@ -450,7 +450,7 @@ bool QgsOgrProvider::setSubsetString( const QString &theSQL, bool updateFeatureC
if ( !ogrDataSource )
return false;

if ( theSQL == mSubsetString && mFeaturesCounted >= 0 )
if ( theSQL == mSubsetString && mFeaturesCounted != QgsVectorDataProvider::Uncounted )
return true;

OGRLayerH prevLayer = ogrLayer;
@@ -3300,7 +3300,7 @@ void QgsOgrProvider::recalculateFeatureCount()
{
if ( !ogrLayer )
{
mFeaturesCounted = 0;
mFeaturesCounted = QgsVectorDataProvider::Uncounted;
return;
}

@@ -3316,6 +3316,10 @@ void QgsOgrProvider::recalculateFeatureCount()
if ( mOgrGeometryTypeFilter == wkbUnknown )
{
mFeaturesCounted = OGR_L_GetFeatureCount( ogrLayer, true );
if ( mFeaturesCounted == -1 )
{
mFeaturesCounted = QgsVectorDataProvider::UnknownCount;
}
}
else
{

0 comments on commit 25d9936

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