mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-17 00:09:36 -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"
|
#include "qgsvectortilelayer.h"
|
||||||
%End
|
%End
|
||||||
public:
|
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
|
%Docstring
|
||||||
Constructs a new vector tile layer
|
Constructs a new vector tile layer
|
||||||
%End
|
%End
|
||||||
|
@ -2159,7 +2159,8 @@ void QgisApp::handleDropUriList( const QgsMimeDataUtils::UriList &lst )
|
|||||||
{
|
{
|
||||||
QgsTemporaryCursorOverride busyCursor( Qt::WaitCursor );
|
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;
|
bool ok = false;
|
||||||
layer->loadDefaultMetadata( ok );
|
layer->loadDefaultMetadata( ok );
|
||||||
|
|
||||||
@ -6004,7 +6005,8 @@ QgsVectorTileLayer *QgisApp::addVectorTileLayerPrivate( const QString &url, cons
|
|||||||
QgsDebugMsgLevel( "completeBaseName: " + base, 2 );
|
QgsDebugMsgLevel( "completeBaseName: " + base, 2 );
|
||||||
|
|
||||||
// create the layer
|
// 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() )
|
if ( !layer || !layer->isValid() )
|
||||||
{
|
{
|
||||||
@ -7609,7 +7611,8 @@ bool QgisApp::openLayer( const QString &fileName, bool allowInteractive )
|
|||||||
QUrlQuery uq;
|
QUrlQuery uq;
|
||||||
uq.addQueryItem( QStringLiteral( "type" ), QStringLiteral( "mbtiles" ) );
|
uq.addQueryItem( QStringLiteral( "type" ), QStringLiteral( "mbtiles" ) );
|
||||||
uq.addQueryItem( QStringLiteral( "url" ), fileName );
|
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() )
|
if ( vtLayer->isValid() )
|
||||||
{
|
{
|
||||||
QgsProject::instance()->addMapLayer( vtLayer.release() );
|
QgsProject::instance()->addMapLayer( vtLayer.release() );
|
||||||
|
@ -107,7 +107,10 @@ QgsAnnotationLayer::QgsAnnotationLayer( const QString &name, const LayerOptions
|
|||||||
{
|
{
|
||||||
mShouldValidateCrs = false;
|
mShouldValidateCrs = false;
|
||||||
mValid = true;
|
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.reset( QgsPaintEffectRegistry::defaultStack() );
|
||||||
mPaintEffect->setEnabled( false );
|
mPaintEffect->setEnabled( false );
|
||||||
@ -325,6 +328,9 @@ QgsRectangle QgsAnnotationLayer::extent() const
|
|||||||
|
|
||||||
void QgsAnnotationLayer::setTransformContext( const QgsCoordinateTransformContext &context )
|
void QgsAnnotationLayer::setTransformContext( const QgsCoordinateTransformContext &context )
|
||||||
{
|
{
|
||||||
|
if ( mDataProvider )
|
||||||
|
mDataProvider->setTransformContext( context );
|
||||||
|
|
||||||
mTransformContext = context;
|
mTransformContext = context;
|
||||||
invalidateWgs84Extent();
|
invalidateWgs84Extent();
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,10 @@ QgsMapLayer *QgsMapLayerFactory::createLayer( const QString &uri, const QString
|
|||||||
}
|
}
|
||||||
|
|
||||||
case QgsMapLayerType::VectorTileLayer:
|
case QgsMapLayerType::VectorTileLayer:
|
||||||
return new QgsVectorTileLayer( uri, name );
|
{
|
||||||
|
const QgsVectorTileLayer::LayerOptions vectorTileOptions( options.transformContext );
|
||||||
|
return new QgsVectorTileLayer( uri, name, vectorTileOptions );
|
||||||
|
}
|
||||||
|
|
||||||
case QgsMapLayerType::AnnotationLayer:
|
case QgsMapLayerType::AnnotationLayer:
|
||||||
{
|
{
|
||||||
|
@ -36,8 +36,9 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUrlQuery>
|
#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 )
|
: QgsMapLayer( QgsMapLayerType::VectorTileLayer, baseName )
|
||||||
|
, mTransformContext( options.transformContext )
|
||||||
{
|
{
|
||||||
mDataSource = uri;
|
mDataSource = uri;
|
||||||
|
|
||||||
@ -129,7 +130,7 @@ bool QgsVectorTileLayer::loadDataSource()
|
|||||||
|
|
||||||
setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ) );
|
setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ) );
|
||||||
|
|
||||||
const QgsDataProvider::ProviderOptions providerOptions { transformContext() };
|
const QgsDataProvider::ProviderOptions providerOptions { mTransformContext };
|
||||||
const QgsDataProvider::ReadFlags flags;
|
const QgsDataProvider::ReadFlags flags;
|
||||||
mDataProvider.reset( new QgsVectorTileDataProvider( providerOptions, flags ) );
|
mDataProvider.reset( new QgsVectorTileDataProvider( providerOptions, flags ) );
|
||||||
mProviderKey = mDataProvider->name();
|
mProviderKey = mDataProvider->name();
|
||||||
@ -207,7 +208,8 @@ QgsVectorTileLayer::~QgsVectorTileLayer() = default;
|
|||||||
|
|
||||||
QgsVectorTileLayer *QgsVectorTileLayer::clone() const
|
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 );
|
layer->setRenderer( renderer() ? renderer()->clone() : nullptr );
|
||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
@ -385,7 +387,10 @@ bool QgsVectorTileLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QStr
|
|||||||
|
|
||||||
void QgsVectorTileLayer::setTransformContext( const QgsCoordinateTransformContext &transformContext )
|
void QgsVectorTileLayer::setTransformContext( const QgsCoordinateTransformContext &transformContext )
|
||||||
{
|
{
|
||||||
Q_UNUSED( transformContext )
|
if ( mDataProvider )
|
||||||
|
mDataProvider->setTransformContext( transformContext );
|
||||||
|
|
||||||
|
mTransformContext = transformContext;
|
||||||
invalidateWgs84Extent();
|
invalidateWgs84Extent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,8 +85,29 @@ class CORE_EXPORT QgsVectorTileLayer : public QgsMapLayer
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
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
|
//! 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;
|
~QgsVectorTileLayer() override;
|
||||||
|
|
||||||
#ifdef SIP_RUN
|
#ifdef SIP_RUN
|
||||||
@ -195,6 +216,8 @@ class CORE_EXPORT QgsVectorTileLayer : public QgsMapLayer
|
|||||||
|
|
||||||
QVariantMap mArcgisLayerConfiguration;
|
QVariantMap mArcgisLayerConfiguration;
|
||||||
|
|
||||||
|
QgsCoordinateTransformContext mTransformContext;
|
||||||
|
|
||||||
std::unique_ptr< QgsDataProvider > mDataProvider;
|
std::unique_ptr< QgsDataProvider > mDataProvider;
|
||||||
|
|
||||||
bool setupArcgisVectorTileServiceConnection( const QString &uri, const QgsDataSourceUri &dataSourceUri );
|
bool setupArcgisVectorTileServiceConnection( const QString &uri, const QgsDataSourceUri &dataSourceUri );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user