Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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
  • Loading branch information
wonder-sk committed May 30, 2019
1 parent 056833e commit d3342ad
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/providers/wcs/qgswcscapabilities.cpp
Expand Up @@ -59,6 +59,30 @@ QgsWcsCapabilities::QgsWcsCapabilities( QgsDataSourceUri const &uri )
retrieveServerCapabilities();
}

QgsWcsCapabilities::QgsWcsCapabilities( const QgsWcsCapabilities &other )
: QObject()
, mUri( other.mUri )
, mVersion( other.mVersion )
, mCapabilitiesResponse( other.mCapabilitiesResponse )
, mCapabilitiesDom( other.mCapabilitiesDom )
, mServiceExceptionReportDom( other.mServiceExceptionReportDom )
, mCapabilities( other.mCapabilities )
, mCoveragesSupported( other.mCoveragesSupported )
// intentionally omitted:
// - mCapabilitiesReply
// - mErrorTitle
// - mError
// - mErrorFormat
, mCoverageCount( other.mCoverageCount )
, mCoverageParents( other.mCoverageParents )
, mCoverageParentIdentifiers( other.mCoverageParentIdentifiers )
, mUserName( other.mUserName )
, mPassword( other.mPassword )
, mCacheLoadControl( other.mCacheLoadControl )
{
}


void QgsWcsCapabilities::parseUri()
{
mCacheLoadControl = QNetworkRequest::PreferNetwork;
Expand Down
2 changes: 2 additions & 0 deletions src/providers/wcs/qgswcscapabilities.h
Expand Up @@ -91,6 +91,8 @@ class QgsWcsCapabilities : public QObject
*
*/
explicit QgsWcsCapabilities( QgsDataSourceUri const &uri );
//! copy constructor
explicit QgsWcsCapabilities( const QgsWcsCapabilities &other );
QgsWcsCapabilities() = default;

void setUri( QgsDataSourceUri const &uri );
Expand Down
60 changes: 59 additions & 1 deletion src/providers/wcs/qgswcsprovider.cpp
Expand Up @@ -355,6 +355,63 @@ QgsWcsProvider::QgsWcsProvider( const QString &uri, const ProviderOptions &optio
QgsDebugMsg( QStringLiteral( "Constructed OK, provider valid." ) );
}

QgsWcsProvider::QgsWcsProvider( const QgsWcsProvider &other, const QgsDataProvider::ProviderOptions &providerOptions )
: QgsRasterDataProvider( other.dataSourceUri(), providerOptions )
, mHttpUri( other.mHttpUri )
, mBaseUrl( other.mBaseUrl )
, mIdentifier( other.mIdentifier )
, mTime( other.mTime )
, mFormat( other.mFormat )
, mValid( other.mValid )
, mCapabilities( other.mCapabilities )
, mCoverageSummary( other.mCoverageSummary )
, mSrid( other.mSrid )
, mCoverageExtent( other.mCoverageExtent )
, mWidth( other.mWidth )
, mHeight( other.mHeight )
, mXBlockSize( other.mXBlockSize )
, mYBlockSize( other.mYBlockSize )
, mHasSize( other.mHasSize )
, mBandCount( other.mBandCount )
, mGdalDataType( other.mGdalDataType )
, mSrcGdalDataType( other.mSrcGdalDataType )
, mColorTables( other.mColorTables )
, mExtentForLayer( other.mExtentForLayer )
, mCrsForLayer( other.mCrsForLayer )
, mQueryableForLayer( other.mQueryableForLayer )
, mCoverageCrs( other.mCoverageCrs )
// intentionally omitted:
// - mCachedData
// - mCachedMemFilename
// - mCachedMemFile
// - mCachedGdalDataset
// - mCachedError
// - mCachedViewExtent
// - mCachedViewWidth
// - mCachedViewHeight
, mMaxWidth( other.mMaxWidth )
, mMaxHeight( other.mMaxHeight )
// intentionally omitted:
// - mErrorCaption
// - mError
// - mErrorFormat
, mCoordinateTransform( other.mCoordinateTransform )
, mExtentDirty( other.mExtentDirty )
, mGetFeatureInfoUrlBase( other.mGetFeatureInfoUrlBase )
, mServiceMetadataURL( other.mServiceMetadataURL )
, mAuth( other.mAuth )
, mIgnoreGetCoverageUrl( other.mIgnoreGetCoverageUrl )
, mIgnoreAxisOrientation( other.mIgnoreAxisOrientation )
, mInvertAxisOrientation( other.mInvertAxisOrientation )
, mCrs( other.mCrs )
, mFixBox( other.mFixBox )
, mFixRotate( other.mFixRotate )
, mCacheLoadControl( other.mCacheLoadControl )
{
mCachedMemFilename = QStringLiteral( "/vsimem/qgis/wcs/%0.dat" ).arg( reinterpret_cast<std::uintptr_t>( this ) );
}


bool QgsWcsProvider::parseUri( const QString &uriString )
{

Expand Down Expand Up @@ -431,7 +488,8 @@ QgsWcsProvider::~QgsWcsProvider()
QgsWcsProvider *QgsWcsProvider::clone() const
{
QgsDataProvider::ProviderOptions providerOptions;
QgsWcsProvider *provider = new QgsWcsProvider( dataSourceUri(), providerOptions );
providerOptions.transformContext = transformContext();
QgsWcsProvider *provider = new QgsWcsProvider( *this, providerOptions );
provider->copyBaseSettings( *this );
return provider;
}
Expand Down
2 changes: 2 additions & 0 deletions src/providers/wcs/qgswcsprovider.h
Expand Up @@ -118,6 +118,8 @@ class QgsWcsProvider : public QgsRasterDataProvider, QgsGdalProviderBase
*/
explicit QgsWcsProvider( const QString &uri, const QgsDataProvider::ProviderOptions &providerOptions );

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

~QgsWcsProvider() override;

Expand Down

0 comments on commit d3342ad

Please sign in to comment.