mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
Merge pull request #45262 from nyalldawson/provider
Always pass on transform context to providers, even minimal ones
This commit is contained in:
commit
08ad87f123
@ -71,7 +71,20 @@ Currently supported decoders:
|
||||
#include "qgsvectortilelayer.h"
|
||||
%End
|
||||
public:
|
||||
explicit QgsVectorTileLayer( const QString &path = QString(), const QString &baseName = QString() );
|
||||
|
||||
|
||||
struct LayerOptions
|
||||
{
|
||||
|
||||
explicit LayerOptions( const QgsCoordinateTransformContext &transformContext = QgsCoordinateTransformContext( ) );
|
||||
%Docstring
|
||||
Constructor for LayerOptions with optional ``transformContext``.
|
||||
%End
|
||||
|
||||
QgsCoordinateTransformContext transformContext;
|
||||
};
|
||||
|
||||
explicit QgsVectorTileLayer( const QString &path = QString(), const QString &baseName = QString(), const QgsVectorTileLayer::LayerOptions &options = QgsVectorTileLayer::LayerOptions() );
|
||||
%Docstring
|
||||
Constructs a new vector tile layer
|
||||
%End
|
||||
|
@ -2159,7 +2159,8 @@ void QgisApp::handleDropUriList( const QgsMimeDataUtils::UriList &lst )
|
||||
{
|
||||
QgsTemporaryCursorOverride busyCursor( Qt::WaitCursor );
|
||||
|
||||
QgsVectorTileLayer *layer = new QgsVectorTileLayer( uri, u.name );
|
||||
const QgsVectorTileLayer::LayerOptions options( QgsProject::instance()->transformContext() );
|
||||
QgsVectorTileLayer *layer = new QgsVectorTileLayer( uri, u.name, options );
|
||||
bool ok = false;
|
||||
layer->loadDefaultMetadata( ok );
|
||||
|
||||
@ -6004,7 +6005,8 @@ QgsVectorTileLayer *QgisApp::addVectorTileLayerPrivate( const QString &url, cons
|
||||
QgsDebugMsgLevel( "completeBaseName: " + base, 2 );
|
||||
|
||||
// create the layer
|
||||
std::unique_ptr<QgsVectorTileLayer> layer( new QgsVectorTileLayer( url, base ) );
|
||||
const QgsVectorTileLayer::LayerOptions options( QgsProject::instance()->transformContext() );
|
||||
std::unique_ptr<QgsVectorTileLayer> layer( new QgsVectorTileLayer( url, base, options ) );
|
||||
|
||||
if ( !layer || !layer->isValid() )
|
||||
{
|
||||
@ -7609,7 +7611,8 @@ bool QgisApp::openLayer( const QString &fileName, bool allowInteractive )
|
||||
QUrlQuery uq;
|
||||
uq.addQueryItem( QStringLiteral( "type" ), QStringLiteral( "mbtiles" ) );
|
||||
uq.addQueryItem( QStringLiteral( "url" ), fileName );
|
||||
std::unique_ptr<QgsVectorTileLayer> vtLayer( new QgsVectorTileLayer( uq.toString(), fileInfo.completeBaseName() ) );
|
||||
const QgsVectorTileLayer::LayerOptions options( QgsProject::instance()->transformContext() );
|
||||
std::unique_ptr<QgsVectorTileLayer> vtLayer( new QgsVectorTileLayer( uq.toString(), fileInfo.completeBaseName(), options ) );
|
||||
if ( vtLayer->isValid() )
|
||||
{
|
||||
QgsProject::instance()->addMapLayer( vtLayer.release() );
|
||||
|
@ -107,7 +107,10 @@ QgsAnnotationLayer::QgsAnnotationLayer( const QString &name, const LayerOptions
|
||||
{
|
||||
mShouldValidateCrs = false;
|
||||
mValid = true;
|
||||
mDataProvider = new QgsAnnotationLayerDataProvider( QgsDataProvider::ProviderOptions(), QgsDataProvider::ReadFlags() );
|
||||
|
||||
QgsDataProvider::ProviderOptions providerOptions;
|
||||
providerOptions.transformContext = options.transformContext;
|
||||
mDataProvider = new QgsAnnotationLayerDataProvider( providerOptions, QgsDataProvider::ReadFlags() );
|
||||
|
||||
mPaintEffect.reset( QgsPaintEffectRegistry::defaultStack() );
|
||||
mPaintEffect->setEnabled( false );
|
||||
@ -325,6 +328,9 @@ QgsRectangle QgsAnnotationLayer::extent() const
|
||||
|
||||
void QgsAnnotationLayer::setTransformContext( const QgsCoordinateTransformContext &context )
|
||||
{
|
||||
if ( mDataProvider )
|
||||
mDataProvider->setTransformContext( context );
|
||||
|
||||
mTransformContext = context;
|
||||
invalidateWgs84Extent();
|
||||
}
|
||||
|
@ -95,7 +95,10 @@ QgsMapLayer *QgsMapLayerFactory::createLayer( const QString &uri, const QString
|
||||
}
|
||||
|
||||
case QgsMapLayerType::VectorTileLayer:
|
||||
return new QgsVectorTileLayer( uri, name );
|
||||
{
|
||||
const QgsVectorTileLayer::LayerOptions vectorTileOptions( options.transformContext );
|
||||
return new QgsVectorTileLayer( uri, name, vectorTileOptions );
|
||||
}
|
||||
|
||||
case QgsMapLayerType::AnnotationLayer:
|
||||
{
|
||||
|
@ -36,8 +36,9 @@
|
||||
#include <QUrl>
|
||||
#include <QUrlQuery>
|
||||
|
||||
QgsVectorTileLayer::QgsVectorTileLayer( const QString &uri, const QString &baseName )
|
||||
QgsVectorTileLayer::QgsVectorTileLayer( const QString &uri, const QString &baseName, const LayerOptions &options )
|
||||
: QgsMapLayer( QgsMapLayerType::VectorTileLayer, baseName )
|
||||
, mTransformContext( options.transformContext )
|
||||
{
|
||||
mDataSource = uri;
|
||||
|
||||
@ -129,7 +130,7 @@ bool QgsVectorTileLayer::loadDataSource()
|
||||
|
||||
setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ) );
|
||||
|
||||
const QgsDataProvider::ProviderOptions providerOptions { transformContext() };
|
||||
const QgsDataProvider::ProviderOptions providerOptions { mTransformContext };
|
||||
const QgsDataProvider::ReadFlags flags;
|
||||
mDataProvider.reset( new QgsVectorTileDataProvider( providerOptions, flags ) );
|
||||
mProviderKey = mDataProvider->name();
|
||||
@ -207,7 +208,8 @@ QgsVectorTileLayer::~QgsVectorTileLayer() = default;
|
||||
|
||||
QgsVectorTileLayer *QgsVectorTileLayer::clone() const
|
||||
{
|
||||
QgsVectorTileLayer *layer = new QgsVectorTileLayer( source(), name() );
|
||||
const QgsVectorTileLayer::LayerOptions options( mTransformContext );
|
||||
QgsVectorTileLayer *layer = new QgsVectorTileLayer( source(), name(), options );
|
||||
layer->setRenderer( renderer() ? renderer()->clone() : nullptr );
|
||||
return layer;
|
||||
}
|
||||
@ -385,7 +387,10 @@ bool QgsVectorTileLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QStr
|
||||
|
||||
void QgsVectorTileLayer::setTransformContext( const QgsCoordinateTransformContext &transformContext )
|
||||
{
|
||||
Q_UNUSED( transformContext )
|
||||
if ( mDataProvider )
|
||||
mDataProvider->setTransformContext( transformContext );
|
||||
|
||||
mTransformContext = transformContext;
|
||||
invalidateWgs84Extent();
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,29 @@ class CORE_EXPORT QgsVectorTileLayer : public QgsMapLayer
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
|
||||
/**
|
||||
* Setting options for loading vector tile layers.
|
||||
*
|
||||
* \since QGIS 3.22
|
||||
*/
|
||||
struct LayerOptions
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor for LayerOptions with optional \a transformContext.
|
||||
*/
|
||||
explicit LayerOptions( const QgsCoordinateTransformContext &transformContext = QgsCoordinateTransformContext( ) )
|
||||
: transformContext( transformContext )
|
||||
{}
|
||||
|
||||
//! Coordinate transform context
|
||||
QgsCoordinateTransformContext transformContext;
|
||||
};
|
||||
|
||||
//! Constructs a new vector tile layer
|
||||
explicit QgsVectorTileLayer( const QString &path = QString(), const QString &baseName = QString() );
|
||||
explicit QgsVectorTileLayer( const QString &path = QString(), const QString &baseName = QString(), const QgsVectorTileLayer::LayerOptions &options = QgsVectorTileLayer::LayerOptions() );
|
||||
~QgsVectorTileLayer() override;
|
||||
|
||||
#ifdef SIP_RUN
|
||||
@ -195,6 +216,8 @@ class CORE_EXPORT QgsVectorTileLayer : public QgsMapLayer
|
||||
|
||||
QVariantMap mArcgisLayerConfiguration;
|
||||
|
||||
QgsCoordinateTransformContext mTransformContext;
|
||||
|
||||
std::unique_ptr< QgsDataProvider > mDataProvider;
|
||||
|
||||
bool setupArcgisVectorTileServiceConnection( const QString &uri, const QgsDataSourceUri &dataSourceUri );
|
||||
|
Loading…
x
Reference in New Issue
Block a user