Skip to content

Commit

Permalink
[OAPIF provider] Add subsetString support and server-side datetime fi…
Browse files Browse the repository at this point in the history
…ltering

Funded by Planet
  • Loading branch information
rouault authored and nyalldawson committed Oct 25, 2019
1 parent bc8ee7a commit 3d2f9f1
Show file tree
Hide file tree
Showing 11 changed files with 505 additions and 28 deletions.
14 changes: 13 additions & 1 deletion src/providers/wfs/qgsbackgroundcachedfeatureiterator.cpp
Expand Up @@ -121,11 +121,23 @@ void QgsThreadedFeatureDownloader::run()

// -------------------------

static QgsFeatureRequest addSubsetToFeatureRequest( const QgsFeatureRequest &requestIn,
const QgsBackgroundCachedSharedData *shared )
{
if ( shared->clientSideFilterExpression().isEmpty() )
{
return requestIn;
}
QgsFeatureRequest requestOut( requestIn );
requestOut.combineFilterExpression( shared->clientSideFilterExpression() );
return requestOut;
}

QgsBackgroundCachedFeatureIterator::QgsBackgroundCachedFeatureIterator(
QgsBackgroundCachedFeatureSource *source, bool ownSource,
std::shared_ptr<QgsBackgroundCachedSharedData> shared,
const QgsFeatureRequest &request )
: QgsAbstractFeatureIteratorFromSource<QgsBackgroundCachedFeatureSource>( source, ownSource, request )
: QgsAbstractFeatureIteratorFromSource<QgsBackgroundCachedFeatureSource>( source, ownSource, addSubsetToFeatureRequest( request, shared.get() ) )
, mShared( shared )
{
if ( mRequest.destinationCrs().isValid() && mRequest.destinationCrs() != mShared->sourceCrs() )
Expand Down
5 changes: 3 additions & 2 deletions src/providers/wfs/qgsbackgroundcachedshareddata.cpp
Expand Up @@ -94,6 +94,7 @@ void QgsBackgroundCachedSharedData::invalidateCache()
mCachedRegions = QgsSpatialIndex();
mRegions.clear();
mRect = QgsRectangle();
mComputedExtent = QgsRectangle();
mRequestLimit = 0;
mFeatureCount = 0;
mFeatureCountExact = false;
Expand Down Expand Up @@ -1210,11 +1211,11 @@ QString QgsBackgroundCachedSharedData::getMD5( const QgsFeature &f )
return hash.result().toHex();
}

void QgsBackgroundCachedSharedData::setFeatureCount( int featureCount )
void QgsBackgroundCachedSharedData::setFeatureCount( int featureCount, bool featureCountExact )
{
QMutexLocker locker( &mMutex );
mFeatureCountRequestIssued = true;
mFeatureCountExact = true;
mFeatureCountExact = featureCountExact;
mFeatureCount = featureCount;
}

Expand Down
11 changes: 10 additions & 1 deletion src/providers/wfs/qgsbackgroundcachedshareddata.h
Expand Up @@ -125,6 +125,9 @@ class QgsBackgroundCachedSharedData
//! Returns a unique identifier made from feature content
static QString getMD5( const QgsFeature &f );

//! Filter expression to apply on client side
const QString &clientSideFilterExpression() const { return mClientSideFilterExpression; }

//// Actions

/**
Expand All @@ -146,7 +149,7 @@ class QgsBackgroundCachedSharedData
void endOfDownload( bool success, int featureCount, bool truncatedResponse, bool interrupted, const QString &errorMsg );

//! Force an update of the feature count
void setFeatureCount( int featureCount );
void setFeatureCount( int featureCount, bool featureCountExact );

//! Returns the name of temporary directory. To be paired with releaseCacheDirectory()
QString acquireCacheDirectory();
Expand Down Expand Up @@ -178,6 +181,9 @@ class QgsBackgroundCachedSharedData
//! SELECT DISTINCT
bool mDistinctSelect = false;

//! Filter expression to apply on client side
QString mClientSideFilterExpression;

//! Server-side or user-side limit of downloaded features (including with paging). Valid if > 0
int mMaxFeatures = 0;

Expand All @@ -187,6 +193,9 @@ class QgsBackgroundCachedSharedData
//! Bounding box for the layer as returned by GetCapabilities
QgsRectangle mCapabilityExtent;

//! Flag is a /items request returns a numberMatched property
bool mHasNumberMatched = false;

//////////// Methods

//! Should be called in the destructor of the implementation of this class !
Expand Down

0 comments on commit 3d2f9f1

Please sign in to comment.