@@ -40,6 +40,7 @@ QgsWFSSharedData::QgsWFSSharedData( const QString &uri )
4040 , mSourceCRS( 0 )
4141 , mMaxFeatures( 0 )
4242 , mMaxFeaturesWasSetFromDefaultForPaging( false )
43+ , mRequestLimit( 0 )
4344 , mHideProgressDialog( mURI .hideDownloadProgressDialog() )
4445 , mDistinctSelect( false )
4546 , mHasWarnedAboutMissingFeatureId( false )
@@ -463,7 +464,7 @@ bool QgsWFSSharedData::createCache()
463464 return true ;
464465}
465466
466- int QgsWFSSharedData::registerToCache ( QgsWFSFeatureIterator *iterator, const QgsRectangle &rect )
467+ int QgsWFSSharedData::registerToCache ( QgsWFSFeatureIterator *iterator, int limit, const QgsRectangle &rect )
467468{
468469 // This locks prevents 2 readers to register at the same time (and particularly
469470 // destroy the current mDownloader at the same time)
@@ -527,10 +528,17 @@ int QgsWFSSharedData::registerToCache( QgsWFSFeatureIterator *iterator, const Qg
527528 {
528529 newDownloadNeeded = true ;
529530 }
531+ // If there's a ongoing download with a limitation, and the new download is
532+ // unlimited, we need a new download.
533+ else if ( !( mWFSVersion .startsWith ( QLatin1String ( " 1.0" ) ) ) && limit <= 0 && mRequestLimit > 0 )
534+ {
535+ newDownloadNeeded = true ;
536+ }
530537
531538 if ( newDownloadNeeded || !mDownloader )
532539 {
533540 mRect = rect;
541+ mRequestLimit = ( limit > 0 && !( mWFSVersion .startsWith ( QLatin1String ( " 1.0" ) ) ) ) ? limit : 0 ;
534542 // to prevent deadlock when waiting the end of the downloader thread that will try to take the mutex in serializeFeatures()
535543 mMutex .unlock ();
536544 delete mDownloader ;
@@ -918,16 +926,19 @@ void QgsWFSSharedData::serializeFeatures( QVector<QgsWFSFeatureGmlIdPair> &featu
918926
919927 {
920928 QMutexLocker locker ( &mMutex );
921- if ( !mFeatureCountExact )
922- mFeatureCount += featureListToCache.size ();
923- mTotalFeaturesAttemptedToBeCached += featureListToCache.size ();
924- if ( !localComputedExtent.isNull () && mComputedExtent .isNull () && !mTryFetchingOneFeature &&
925- !localComputedExtent.intersects ( mCapabilityExtent ) )
929+ if ( mRequestLimit != 1 )
926930 {
927- QgsMessageLog::logMessage ( tr ( " Layer extent reported by the server is not correct. "
928- " You may need to zoom again on layer while features are being downloaded" ), tr ( " WFS" ) );
931+ if ( !mFeatureCountExact )
932+ mFeatureCount += featureListToCache.size ();
933+ mTotalFeaturesAttemptedToBeCached += featureListToCache.size ();
934+ if ( !localComputedExtent.isNull () && mComputedExtent .isNull () && !mTryFetchingOneFeature &&
935+ !localComputedExtent.intersects ( mCapabilityExtent ) )
936+ {
937+ QgsMessageLog::logMessage ( tr ( " Layer extent reported by the server is not correct. "
938+ " You may need to zoom again on layer while features are being downloaded" ), tr ( " WFS" ) );
939+ }
940+ mComputedExtent = localComputedExtent;
929941 }
930- mComputedExtent = localComputedExtent;
931942 }
932943 }
933944
@@ -1010,19 +1021,22 @@ void QgsWFSSharedData::endOfDownload( bool success, int featureCount,
10101021 mCachedRegions = QgsSpatialIndex ();
10111022 }
10121023
1013- // In case the download was successful, we will remember this bbox
1014- // and if the download reached the download limit or not
1015- QgsFeature f;
1016- f.setGeometry ( QgsGeometry::fromRect ( mRect ) );
1017- QgsFeatureId id = mRegions .size ();
1018- f.setId ( id );
1019- f.initAttributes ( 1 );
1020- f.setAttribute ( 0 , QVariant ( bDownloadLimit ) );
1021- mRegions .push_back ( f );
1022- mCachedRegions .insertFeature ( f );
1024+ if ( mRequestLimit == 0 )
1025+ {
1026+ // In case the download was successful, we will remember this bbox
1027+ // and if the download reached the download limit or not
1028+ QgsFeature f;
1029+ f.setGeometry ( QgsGeometry::fromRect ( mRect ) );
1030+ QgsFeatureId id = mRegions .size ();
1031+ f.setId ( id );
1032+ f.initAttributes ( 1 );
1033+ f.setAttribute ( 0 , QVariant ( bDownloadLimit ) );
1034+ mRegions .push_back ( f );
1035+ mCachedRegions .insertFeature ( f );
1036+ }
10231037 }
10241038
1025- if ( mRect .isEmpty () && success && !bDownloadLimit && !mFeatureCountExact )
1039+ if ( mRect .isEmpty () && success && !bDownloadLimit && mRequestLimit == 0 && !mFeatureCountExact )
10261040 {
10271041 mFeatureCountExact = true ;
10281042 if ( featureCount != mFeatureCount )
@@ -1066,6 +1080,7 @@ void QgsWFSSharedData::invalidateCache()
10661080 mCachedRegions = QgsSpatialIndex ();
10671081 mRegions .clear ();
10681082 mRect = QgsRectangle ();
1083+ mRequestLimit = 0 ;
10691084 mGetFeatureHitsIssued = false ;
10701085 mFeatureCount = 0 ;
10711086 mFeatureCountExact = false ;
0 commit comments