Skip to content

Commit d3342ad

Browse files
committedMay 30, 2019
[wcs] safer and faster rendering of WCS layers
Redering of WCS layers has been quite inefficient since introduction of multi-threaded rendering in QGIS 2.4: whenever map rendering was starting, copying of WCS provider involved running full initialization of WCS provider which typically does three(!) network requests in the constructor (get capabilities + 2x check to work around some incompatibilities of WCS servers). This was both slow and potentially dangerous because of embedded QEventLoop for the network requests. This is now gone and when WCS provider gets cloned (e.g. when starting map rendering), it just gets copy of data without any extra work. Avoiding embedded QEventLoop fixes a crash in 3D view when loading tiles. Fixes #28800 Fixes #26706
1 parent 056833e commit d3342ad

File tree

4 files changed

+87
-1
lines changed

4 files changed

+87
-1
lines changed
 

‎src/providers/wcs/qgswcscapabilities.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,30 @@ QgsWcsCapabilities::QgsWcsCapabilities( QgsDataSourceUri const &uri )
5959
retrieveServerCapabilities();
6060
}
6161

62+
QgsWcsCapabilities::QgsWcsCapabilities( const QgsWcsCapabilities &other )
63+
: QObject()
64+
, mUri( other.mUri )
65+
, mVersion( other.mVersion )
66+
, mCapabilitiesResponse( other.mCapabilitiesResponse )
67+
, mCapabilitiesDom( other.mCapabilitiesDom )
68+
, mServiceExceptionReportDom( other.mServiceExceptionReportDom )
69+
, mCapabilities( other.mCapabilities )
70+
, mCoveragesSupported( other.mCoveragesSupported )
71+
// intentionally omitted:
72+
// - mCapabilitiesReply
73+
// - mErrorTitle
74+
// - mError
75+
// - mErrorFormat
76+
, mCoverageCount( other.mCoverageCount )
77+
, mCoverageParents( other.mCoverageParents )
78+
, mCoverageParentIdentifiers( other.mCoverageParentIdentifiers )
79+
, mUserName( other.mUserName )
80+
, mPassword( other.mPassword )
81+
, mCacheLoadControl( other.mCacheLoadControl )
82+
{
83+
}
84+
85+
6286
void QgsWcsCapabilities::parseUri()
6387
{
6488
mCacheLoadControl = QNetworkRequest::PreferNetwork;

‎src/providers/wcs/qgswcscapabilities.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ class QgsWcsCapabilities : public QObject
9191
*
9292
*/
9393
explicit QgsWcsCapabilities( QgsDataSourceUri const &uri );
94+
//! copy constructor
95+
explicit QgsWcsCapabilities( const QgsWcsCapabilities &other );
9496
QgsWcsCapabilities() = default;
9597

9698
void setUri( QgsDataSourceUri const &uri );

‎src/providers/wcs/qgswcsprovider.cpp

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,63 @@ QgsWcsProvider::QgsWcsProvider( const QString &uri, const ProviderOptions &optio
355355
QgsDebugMsg( QStringLiteral( "Constructed OK, provider valid." ) );
356356
}
357357

358+
QgsWcsProvider::QgsWcsProvider( const QgsWcsProvider &other, const QgsDataProvider::ProviderOptions &providerOptions )
359+
: QgsRasterDataProvider( other.dataSourceUri(), providerOptions )
360+
, mHttpUri( other.mHttpUri )
361+
, mBaseUrl( other.mBaseUrl )
362+
, mIdentifier( other.mIdentifier )
363+
, mTime( other.mTime )
364+
, mFormat( other.mFormat )
365+
, mValid( other.mValid )
366+
, mCapabilities( other.mCapabilities )
367+
, mCoverageSummary( other.mCoverageSummary )
368+
, mSrid( other.mSrid )
369+
, mCoverageExtent( other.mCoverageExtent )
370+
, mWidth( other.mWidth )
371+
, mHeight( other.mHeight )
372+
, mXBlockSize( other.mXBlockSize )
373+
, mYBlockSize( other.mYBlockSize )
374+
, mHasSize( other.mHasSize )
375+
, mBandCount( other.mBandCount )
376+
, mGdalDataType( other.mGdalDataType )
377+
, mSrcGdalDataType( other.mSrcGdalDataType )
378+
, mColorTables( other.mColorTables )
379+
, mExtentForLayer( other.mExtentForLayer )
380+
, mCrsForLayer( other.mCrsForLayer )
381+
, mQueryableForLayer( other.mQueryableForLayer )
382+
, mCoverageCrs( other.mCoverageCrs )
383+
// intentionally omitted:
384+
// - mCachedData
385+
// - mCachedMemFilename
386+
// - mCachedMemFile
387+
// - mCachedGdalDataset
388+
// - mCachedError
389+
// - mCachedViewExtent
390+
// - mCachedViewWidth
391+
// - mCachedViewHeight
392+
, mMaxWidth( other.mMaxWidth )
393+
, mMaxHeight( other.mMaxHeight )
394+
// intentionally omitted:
395+
// - mErrorCaption
396+
// - mError
397+
// - mErrorFormat
398+
, mCoordinateTransform( other.mCoordinateTransform )
399+
, mExtentDirty( other.mExtentDirty )
400+
, mGetFeatureInfoUrlBase( other.mGetFeatureInfoUrlBase )
401+
, mServiceMetadataURL( other.mServiceMetadataURL )
402+
, mAuth( other.mAuth )
403+
, mIgnoreGetCoverageUrl( other.mIgnoreGetCoverageUrl )
404+
, mIgnoreAxisOrientation( other.mIgnoreAxisOrientation )
405+
, mInvertAxisOrientation( other.mInvertAxisOrientation )
406+
, mCrs( other.mCrs )
407+
, mFixBox( other.mFixBox )
408+
, mFixRotate( other.mFixRotate )
409+
, mCacheLoadControl( other.mCacheLoadControl )
410+
{
411+
mCachedMemFilename = QStringLiteral( "/vsimem/qgis/wcs/%0.dat" ).arg( reinterpret_cast<std::uintptr_t>( this ) );
412+
}
413+
414+
358415
bool QgsWcsProvider::parseUri( const QString &uriString )
359416
{
360417

@@ -431,7 +488,8 @@ QgsWcsProvider::~QgsWcsProvider()
431488
QgsWcsProvider *QgsWcsProvider::clone() const
432489
{
433490
QgsDataProvider::ProviderOptions providerOptions;
434-
QgsWcsProvider *provider = new QgsWcsProvider( dataSourceUri(), providerOptions );
491+
providerOptions.transformContext = transformContext();
492+
QgsWcsProvider *provider = new QgsWcsProvider( *this, providerOptions );
435493
provider->copyBaseSettings( *this );
436494
return provider;
437495
}

‎src/providers/wcs/qgswcsprovider.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ class QgsWcsProvider : public QgsRasterDataProvider, QgsGdalProviderBase
118118
*/
119119
explicit QgsWcsProvider( const QString &uri, const QgsDataProvider::ProviderOptions &providerOptions );
120120

121+
//! copy constructor
122+
explicit QgsWcsProvider( const QgsWcsProvider &other, const QgsDataProvider::ProviderOptions &providerOptions );
121123

122124
~QgsWcsProvider() override;
123125

0 commit comments

Comments
 (0)
Please sign in to comment.