Skip to content

Commit 25d9936

Browse files
authoredApr 6, 2017
[OGR] fix feature count issue for OSM datasets (fixes #16402) (#4322)
1 parent b601467 commit 25d9936

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed
 

‎python/core/qgsvectordataprovider.sip

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ class QgsVectorDataProvider : QgsDataProvider
5757
/** Bitmask of all provider's editing capabilities */
5858
static const int EditingCapabilities;
5959

60+
/**
61+
* Enumeration of feature count states
62+
*/
63+
enum FeatureCountState
64+
{
65+
//! Feature count not yet computed
66+
Uncounted = -2,
67+
//! Provider returned an unknown feature count
68+
UnknownCount = -1,
69+
};
70+
6071
/**
6172
* Constructor of the vector provider
6273
* @param uri uniform resource locator (URI) for a dataset

‎src/core/qgsvectordataprovider.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,17 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
112112
ChangeAttributeValues | ChangeGeometries | AddAttributes | DeleteAttributes |
113113
RenameAttributes;
114114

115+
/**
116+
* Enumeration of feature count states
117+
*/
118+
enum FeatureCountState
119+
{
120+
//! Feature count not yet computed
121+
Uncounted = -2,
122+
//! Provider returned an unknown feature count
123+
UnknownCount = -1,
124+
};
125+
115126
/**
116127
* Constructor of the vector provider
117128
* \param uri uniform resource locator (URI) for a dataset

‎src/providers/ogr/qgsogrprovider.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ QgsOgrProvider::QgsOgrProvider( QString const &uri )
378378
, ogrDriver( nullptr )
379379
, mValid( false )
380380
, mOGRGeomType( wkbUnknown )
381-
, mFeaturesCounted( -1 )
381+
, mFeaturesCounted( QgsVectorDataProvider::Uncounted )
382382
, mWriteAccess( false )
383383
, mWriteAccessPossible( false )
384384
, mDynamicWriteAccess( false )
@@ -450,7 +450,7 @@ bool QgsOgrProvider::setSubsetString( const QString &theSQL, bool updateFeatureC
450450
if ( !ogrDataSource )
451451
return false;
452452

453-
if ( theSQL == mSubsetString && mFeaturesCounted >= 0 )
453+
if ( theSQL == mSubsetString && mFeaturesCounted != QgsVectorDataProvider::Uncounted )
454454
return true;
455455

456456
OGRLayerH prevLayer = ogrLayer;
@@ -3300,7 +3300,7 @@ void QgsOgrProvider::recalculateFeatureCount()
33003300
{
33013301
if ( !ogrLayer )
33023302
{
3303-
mFeaturesCounted = 0;
3303+
mFeaturesCounted = QgsVectorDataProvider::Uncounted;
33043304
return;
33053305
}
33063306

@@ -3316,6 +3316,10 @@ void QgsOgrProvider::recalculateFeatureCount()
33163316
if ( mOgrGeometryTypeFilter == wkbUnknown )
33173317
{
33183318
mFeaturesCounted = OGR_L_GetFeatureCount( ogrLayer, true );
3319+
if ( mFeaturesCounted == -1 )
3320+
{
3321+
mFeaturesCounted = QgsVectorDataProvider::UnknownCount;
3322+
}
33193323
}
33203324
else
33213325
{

0 commit comments

Comments
 (0)
Please sign in to comment.