Skip to content
Permalink
Browse files

[WFS provider] Fix #7170 / properly take into account feature count l…

…imit (refs #18935)
  • Loading branch information
rouault committed Jun 22, 2018
1 parent b8c11b8 commit 39f09228c89ae836ec3f3480cd3b834419d8760d
@@ -480,6 +480,10 @@ void QgsWFSFeatureDownloader::run( bool serializeFeatures, int maxFeatures )
success = true;
QgsGmlStreamingParser *parser = mShared->createParser();

if ( maxTotalFeatures > 0 && mTotalDownloadedFeatureCount >= maxTotalFeatures )
{
break;
}
int maxFeaturesThisRequest = static_cast<int>(
std::min( maxTotalFeatures - mTotalDownloadedFeatureCount,
static_cast<qint64>( std::numeric_limits<int>::max() ) ) );
@@ -1684,15 +1684,15 @@ bool QgsWFSProvider::getCapabilities()
}

mShared->mWFSVersion = mShared->mCaps.version;
if ( mShared->mURI.maxNumFeatures() > 0 && mShared->mCaps.maxFeatures > 0 )
if ( mShared->mURI.maxNumFeatures() > 0 && mShared->mCaps.maxFeatures > 0 && !( mShared->mCaps.supportsPaging && mShared->mURI.pagingEnabled() ) )
{
mShared->mMaxFeatures = std::min( mShared->mURI.maxNumFeatures(), mShared->mCaps.maxFeatures );
}
else if ( mShared->mURI.maxNumFeatures() > 0 )
{
mShared->mMaxFeatures = mShared->mURI.maxNumFeatures();
}
else if ( mShared->mCaps.maxFeatures > 0 )
else if ( mShared->mCaps.maxFeatures > 0 && !( mShared->mCaps.supportsPaging && mShared->mURI.pagingEnabled() ) )
{
mShared->mMaxFeatures = mShared->mCaps.maxFeatures;
}
@@ -1705,20 +1705,24 @@ bool QgsWFSProvider::getCapabilities()
{
if ( mShared->mURI.pageSize() > 0 )
{
if ( mShared->mMaxFeatures > 0 )
if ( mShared->mCaps.maxFeatures > 0 )
{
mShared->mPageSize = std::min( mShared->mURI.pageSize(), mShared->mMaxFeatures );
mShared->mPageSize = std::min( mShared->mURI.pageSize(), mShared->mCaps.maxFeatures );
}
else
{
mShared->mPageSize = mShared->mURI.pageSize();
}
}
else if ( mShared->mCaps.maxFeatures > 0 )
{
mShared->mPageSize = mShared->mCaps.maxFeatures;
}
else
{
QgsSettings settings;
mShared->mPageSize = settings.value( QStringLiteral( "wfs/max_feature_count_if_not_provided" ), "1000" ).toInt();
QgsDebugMsg( QString( "Server declares paging but does not advertize max feature count and user did not specify it. Using %1" ).arg( mShared->mMaxFeatures ) );
QgsDebugMsg( QString( "Server declares paging but does not advertize max feature count and user did not specify it. Using %1" ).arg( mShared->mPageSize ) );
}
}
else
@@ -978,7 +978,7 @@ void QgsWFSSharedData::endOfDownload( bool success, int featureCount,
pushError( errorMsgOut );
}

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

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

0 comments on commit 39f0922

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