Skip to content

Commit 39f0922

Browse files
committedJun 22, 2018
[WFS provider] Fix #7170 / properly take into account feature count limit (refs #18935)
1 parent b8c11b8 commit 39f0922

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed
 

‎src/providers/wfs/qgswfsfeatureiterator.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,10 @@ void QgsWFSFeatureDownloader::run( bool serializeFeatures, int maxFeatures )
480480
success = true;
481481
QgsGmlStreamingParser *parser = mShared->createParser();
482482

483+
if ( maxTotalFeatures > 0 && mTotalDownloadedFeatureCount >= maxTotalFeatures )
484+
{
485+
break;
486+
}
483487
int maxFeaturesThisRequest = static_cast<int>(
484488
std::min( maxTotalFeatures - mTotalDownloadedFeatureCount,
485489
static_cast<qint64>( std::numeric_limits<int>::max() ) ) );

‎src/providers/wfs/qgswfsprovider.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,15 +1684,15 @@ bool QgsWFSProvider::getCapabilities()
16841684
}
16851685

16861686
mShared->mWFSVersion = mShared->mCaps.version;
1687-
if ( mShared->mURI.maxNumFeatures() > 0 && mShared->mCaps.maxFeatures > 0 )
1687+
if ( mShared->mURI.maxNumFeatures() > 0 && mShared->mCaps.maxFeatures > 0 && !( mShared->mCaps.supportsPaging && mShared->mURI.pagingEnabled() ) )
16881688
{
16891689
mShared->mMaxFeatures = std::min( mShared->mURI.maxNumFeatures(), mShared->mCaps.maxFeatures );
16901690
}
16911691
else if ( mShared->mURI.maxNumFeatures() > 0 )
16921692
{
16931693
mShared->mMaxFeatures = mShared->mURI.maxNumFeatures();
16941694
}
1695-
else if ( mShared->mCaps.maxFeatures > 0 )
1695+
else if ( mShared->mCaps.maxFeatures > 0 && !( mShared->mCaps.supportsPaging && mShared->mURI.pagingEnabled() ) )
16961696
{
16971697
mShared->mMaxFeatures = mShared->mCaps.maxFeatures;
16981698
}
@@ -1705,20 +1705,24 @@ bool QgsWFSProvider::getCapabilities()
17051705
{
17061706
if ( mShared->mURI.pageSize() > 0 )
17071707
{
1708-
if ( mShared->mMaxFeatures > 0 )
1708+
if ( mShared->mCaps.maxFeatures > 0 )
17091709
{
1710-
mShared->mPageSize = std::min( mShared->mURI.pageSize(), mShared->mMaxFeatures );
1710+
mShared->mPageSize = std::min( mShared->mURI.pageSize(), mShared->mCaps.maxFeatures );
17111711
}
17121712
else
17131713
{
17141714
mShared->mPageSize = mShared->mURI.pageSize();
17151715
}
17161716
}
1717+
else if ( mShared->mCaps.maxFeatures > 0 )
1718+
{
1719+
mShared->mPageSize = mShared->mCaps.maxFeatures;
1720+
}
17171721
else
17181722
{
17191723
QgsSettings settings;
17201724
mShared->mPageSize = settings.value( QStringLiteral( "wfs/max_feature_count_if_not_provided" ), "1000" ).toInt();
1721-
QgsDebugMsg( QString( "Server declares paging but does not advertize max feature count and user did not specify it. Using %1" ).arg( mShared->mMaxFeatures ) );
1725+
QgsDebugMsg( QString( "Server declares paging but does not advertize max feature count and user did not specify it. Using %1" ).arg( mShared->mPageSize ) );
17221726
}
17231727
}
17241728
else

‎src/providers/wfs/qgswfsshareddata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ void QgsWFSSharedData::endOfDownload( bool success, int featureCount,
978978
pushError( errorMsgOut );
979979
}
980980

981-
bool bDownloadLimit = truncatedResponse || ( !mCaps.supportsPaging && featureCount == mMaxFeatures && mMaxFeatures > 0 );
981+
bool bDownloadLimit = truncatedResponse || ( featureCount >= mMaxFeatures && mMaxFeatures > 0 );
982982

983983
mDownloadFinished = true;
984984
if ( success && !mRect.isEmpty() )

0 commit comments

Comments
 (0)
Please sign in to comment.