Skip to content
Permalink
Browse files

Step2 of coordinate traform context passing: SIP broken

  • Loading branch information
elpaso authored and nyalldawson committed Apr 17, 2019
1 parent c21cd35 commit dcf206232c42a38ce45658d249063069e74e7ffa
@@ -61,12 +61,14 @@ Abstract base class for spatial data provider implementations.
QgsCoordinateTransformContext coordinateTransformContext;
};

QgsDataProvider( const QString &uri = QString(), const QgsDataProvider::ProviderOptions &options = QgsDataProvider::ProviderOptions() );
QgsDataProvider( const QString &uri = QString(), const QgsDataProvider::ProviderOptions &options = QgsDataProvider::ProviderOptions() ):
%Docstring
Create a new dataprovider with the specified in the ``uri``.

Additional creation options are specified within the ``options`` value.
%End
mDataSourceURI( uri ),
mOptions( options );

virtual QgsCoordinateReferenceSystem crs() const = 0;
%Docstring
@@ -386,6 +388,28 @@ Returns ``True`` if metadata was successfully written to the data provider.
.. seealso:: :py:func:`layerMetadata`

.. versionadded:: 3.0
%End

QgsDataProvider::ProviderOptions options() const;
%Docstring
Returns data provider options

.. seealso:: :py:func:`setOptions`

.. seealso:: :py:func:`optionsChanged`

.. versionadded:: 3.10
%End

void setOptions( const QgsDataProvider::ProviderOptions &options );
%Docstring
Sets data provider options to ``options``

.. seealso:: :py:func:`options`

.. seealso:: :py:func:`optionsChanged`

.. versionadded:: 3.10
%End

signals:
@@ -423,6 +447,17 @@ Emitted when the datasource issues a notification.
.. versionadded:: 3.0
%End

void optionsChanged( const QgsDataProvider::ProviderOptions &options );
%Docstring
Emitted when the data provider options has changed

.. seealso:: :py:func:`setOptions`

.. seealso:: :py:func:`options`

.. versionadded:: 3.10
%End


protected:

@@ -70,7 +70,7 @@ class CORE_EXPORT QgsCoordinateTransformContext
*/
QgsCoordinateTransformContext();

~QgsCoordinateTransformContext();
~QgsCoordinateTransformContext() ;

/**
* Copy constructor
@@ -46,3 +46,14 @@ bool QgsDataProvider::renderInPreview( const PreviewContext &context )
{
return context.lastRenderingTimeMs <= context.maxRenderingTimeMs;
}

QgsDataProvider::ProviderOptions QgsDataProvider::options() const
{
return mOptions;
}

void QgsDataProvider::setOptions( const QgsDataProvider::ProviderOptions &options )
{
mOptions = options;
emit optionsChanged( options );
}
@@ -91,6 +91,9 @@ class CORE_EXPORT QgsDataProvider : public QObject

/**
* Setting options for creating vector data providers.
*
* \note coordinateTransformContext was added in QGIS 3.10
*
* \since QGIS 3.2
*/
struct ProviderOptions
@@ -103,10 +106,10 @@ class CORE_EXPORT QgsDataProvider : public QObject
*
* Additional creation options are specified within the \a options value.
*/
QgsDataProvider( const QString &uri = QString(), const QgsDataProvider::ProviderOptions &options = QgsDataProvider::ProviderOptions() )
: mDataSourceURI( uri )
QgsDataProvider( const QString &uri = QString(), const QgsDataProvider::ProviderOptions &options = QgsDataProvider::ProviderOptions() ):
mDataSourceURI( uri ),
mOptions( options )
{
Q_UNUSED( options );
}

/**
@@ -523,6 +526,26 @@ class CORE_EXPORT QgsDataProvider : public QObject
*/
virtual bool writeLayerMetadata( const QgsLayerMetadata &metadata ) { Q_UNUSED( metadata ); return false; }

/**
* Returns data provider options
*
* \see setOptions()
* \see optionsChanged()
*
* \since QGIS 3.10
*/
QgsDataProvider::ProviderOptions options() const;

/**
* Sets data provider options to \a options
*
* \see options()
* \see optionsChanged()
*
* \since QGIS 3.10
*/
void setOptions( const QgsDataProvider::ProviderOptions &options );

signals:

/**
@@ -556,6 +579,16 @@ class CORE_EXPORT QgsDataProvider : public QObject
*/
void notify( const QString &msg );

/**
* Emitted when the data provider options has changed
*
* \see setOptions()
* \see options()
*
* \since QGIS 3.10
*/
void optionsChanged( const QgsDataProvider::ProviderOptions &options );


protected:

@@ -582,6 +615,9 @@ class CORE_EXPORT QgsDataProvider : public QObject
QString mDataSourceURI;

QMap< int, QVariant > mProviderProperties;

QgsDataProvider::ProviderOptions mOptions;

};


@@ -117,9 +117,7 @@ QgsAfsProvider::QgsAfsProvider( const QString &uri, const ProviderOptions &optio
if ( mSharedData->mExtent.isEmpty() )
{
mSharedData->mExtent = originalExtent;
Q_NOWARN_DEPRECATED_PUSH
mSharedData->mExtent = QgsCoordinateTransform( extentCrs, mSharedData->mSourceCRS ).transformBoundingBox( mSharedData->mExtent );
Q_NOWARN_DEPRECATED_POP
mSharedData->mExtent = QgsCoordinateTransform( extentCrs, mSharedData->mSourceCRS, options.coordinateTransformContext ).transformBoundingBox( mSharedData->mExtent );
}

QString objectIdFieldName;
@@ -160,6 +160,12 @@ bool QgsWmsSettings::parseUri( const QString &uriString )
// ----------------------


QgsWmsCapabilities::QgsWmsCapabilities( const QgsDataProvider::ProviderOptions &options ):
mOptions( options )
{

}

bool QgsWmsCapabilities::parseResponse( const QByteArray &response, QgsWmsParserSettings settings )
{
mParserSettings = settings;
@@ -828,12 +834,8 @@ void QgsWmsCapabilities::parseLayer( QDomElement const &e, QgsWmsLayerProperty &
try
{
QgsCoordinateReferenceSystem src = QgsCoordinateReferenceSystem::fromOgcWmsCrs( e1.attribute( QStringLiteral( "SRS" ) ) );

QgsCoordinateReferenceSystem dst = QgsCoordinateReferenceSystem::fromOgcWmsCrs( DEFAULT_LATLON_CRS );

Q_NOWARN_DEPRECATED_PUSH
QgsCoordinateTransform ct( src, dst );
Q_NOWARN_DEPRECATED_POP
QgsCoordinateTransform ct( src, dst, mOptions.coordinateTransformContext );
layerProperty.ex_GeographicBoundingBox = ct.transformBoundingBox( layerProperty.ex_GeographicBoundingBox );
}
catch ( QgsCsException &cse )
@@ -26,6 +26,8 @@
#include "qgsrectangle.h"
#include "qgsrasteriterator.h"
#include "qgsapplication.h"
#include "qgsdataprovider.h"


class QNetworkReply;

@@ -626,7 +628,11 @@ class QgsWmsSettings
class QgsWmsCapabilities
{
public:
QgsWmsCapabilities() = default;

/**
* Constructs a QgsWmsCapabilities object with the given \a options
*/
QgsWmsCapabilities( const QgsDataProvider::ProviderOptions &options = QgsDataProvider::ProviderOptions() );

bool isValid() const { return mValid; }

@@ -759,6 +765,10 @@ class QgsWmsCapabilities
//temporarily caches invert axis setting for each crs
QHash<QString, bool> mCrsInvertAxis;

private:

QgsDataProvider::ProviderOptions mOptions;

friend class QgsWmsProvider;
};

@@ -1193,7 +1193,7 @@ bool QgsWmsProvider::retrieveServerCapabilities( bool forceRefresh )
return false;
}

QgsWmsCapabilities caps;
QgsWmsCapabilities caps( options() );
if ( !caps.parseResponse( downloadCaps.response(), mSettings.parserSettings() ) )
{
mErrorFormat = caps.lastErrorFormat();
@@ -1217,9 +1217,8 @@ void QgsWmsProvider::setupXyzCapabilities( const QString &uri )
QgsDataSourceUri parsedUri;
parsedUri.setEncodedUri( uri );

Q_NOWARN_DEPRECATED_PUSH
QgsCoordinateTransform ct( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), QgsCoordinateReferenceSystem( mSettings.mCrsId ) );
Q_NOWARN_DEPRECATED_POP
QgsCoordinateTransform ct( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), QgsCoordinateReferenceSystem( mSettings.mCrsId ),
options().coordinateTransformContext );

// the whole world is projected to a square:
// X going from 180 W to 180 E

0 comments on commit dcf2062

Please sign in to comment.
You can’t perform that action at this time.