Skip to content

Commit

Permalink
Sipify
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 15, 2017
1 parent b287219 commit 13d1786
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 63 deletions.
189 changes: 143 additions & 46 deletions python/core/qgscoordinatetransform.sip
Expand Up @@ -55,7 +55,7 @@ Default constructor, creates an invalid QgsCoordinateTransform.

The ``context`` argument specifies the context under which the transform
will be applied, and is used for calculating necessary datum transforms
to utilise.
to utilize.

.. versionadded:: 3.0
%End
Expand All @@ -68,9 +68,21 @@ Default constructor, creates an invalid QgsCoordinateTransform.
to ``destination`` coordinate reference system, when used with the
given ``project``.

No reference to ``project`` is stored or utilised outside of the constructor,
No reference to ``project`` is stored or utilized outside of the constructor,
and it is used to retrieve the project's transform context only.

.. versionadded:: 3.0
%End

explicit QgsCoordinateTransform( const QgsCoordinateReferenceSystem &source,
const QgsCoordinateReferenceSystem &destination,
int sourceDatumTransformId,
int destinationDatumTransformId );
%Docstring
Constructs a QgsCoordinateTransform to transform from the ``source``
to ``destination`` coordinate reference system, with the specified
datum transforms.

.. versionadded:: 3.0
%End

Expand Down Expand Up @@ -226,91 +238,176 @@ Default constructor, creates an invalid QgsCoordinateTransform.
:rtype: bool
%End

struct TransformPair
{

TransformPair( int sourceTransformId = -1, int destinationTransformId = -1 );
%Docstring
Constructor for a TransformPair with the specified ``sourceTransformId``
and ``destinationTransformId`` transforms.
%End

int sourceTransformId;
%Docstring
ID for the datum transform to use when projecting from the source CRS.
.. seealso:: :py:func:`QgsCoordinateTransform.datumTransformCrsInfo()`
%End

static QString datumTransformString( int datumTransform );
int destinationTransformId;
%Docstring
:rtype: str
ID for the datum transform to use when projecting to the destination CRS.
.. seealso:: :py:func:`QgsCoordinateTransform.datumTransformCrsInfo()`
%End

static bool datumTransformCrsInfo( int datumTransform, int &epsgNr, QString &srcProjection, QString &dstProjection, QString &remarks, QString &scope, bool &preferred, bool &deprecated );
bool operator==( const QgsCoordinateTransform::TransformPair &other ) const;

bool operator!=( const QgsCoordinateTransform::TransformPair &other ) const;
%Docstring
Gets name of source and dest geographical CRS (to show in a tooltip)
:return: epsgNr epsg code of the transformation (or 0 if not in epsg db)*
:rtype: bool
%End

int sourceDatumTransform() const;
};

static QList< QgsCoordinateTransform::TransformPair > datumTransformations( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination );
%Docstring
Returns the index of the datum transform to use when projecting from the source
CRS.
Returns a list of datum transformations which are available for the given ``source`` and ``destination`` CRS.
.. seealso:: :py:func:`datumTransformToProj()`
.. seealso:: :py:func:`datumTransformInfo()`
:rtype: list of QgsCoordinateTransform.TransformPair
%End

This is usually calculated automatically from the transform's QgsCoordinateTransformContext,
but can be manually overwritten by a call to setSourceDatumTransform().
static QString datumTransformToProj( int datumTransformId );
%Docstring
Returns a proj string representing the specified ``datumTransformId`` datum transform ID.
.. seealso:: :py:func:`datumTransformations()`
.. seealso:: :py:func:`datumTransformInfo()`
:rtype: str
%End

.. seealso:: setSourceDatumTransform()
.. seealso:: destinationDatumTransform()
:rtype: int
struct TransformInfo
{
int datumTransformId;
%Docstring
Datum transform ID
%End

void setSourceDatumTransform( int datum );
int epsgCode;
%Docstring
Sets the index of the ``datum`` transform to use when projecting from the source
CRS.
EPSG code for the transform, or 0 if not found in EPSG database
%End

This is usually calculated automatically from the transform's QgsCoordinateTransformContext.
Calling this method will overwrite any automatically calculated datum transform.
QString sourceCrsAuthId;
%Docstring
Source CRS auth ID
%End

.. seealso:: sourceDatumTransform()
.. seealso:: setDestinationDatumTransform()
QString destinationCrsAuthId;
%Docstring
Destination CRS auth ID
%End

int destinationDatumTransform() const;
QString sourceCrsDescription;
%Docstring
Returns the index of the datum transform to use when projecting to the destination
Source CRS description
%End

QString destinationCrsDescription;
%Docstring
Destination CRS description
%End

QString remarks;
%Docstring
Transform remarks
%End

QString scope;
%Docstring
Scope of transform
%End

bool preferred;
%Docstring
True if transform is the preferred transform to use for the source/destination CRS combination
%End

bool deprecated;
%Docstring
True if transform is deprecated
%End

};

static QgsCoordinateTransform::TransformInfo datumTransformInfo( int datumTransformId );
%Docstring
Returns detailed information about the specified ``datumTransformId``.
If ``datumTransformId`` was not a valid transform ID, a TransformInfo with TransformInfo.datumTransformId of
-1 will be returned.
.. seealso:: :py:func:`datumTransformations()`
.. seealso:: :py:func:`datumTransformToProj()`
:rtype: QgsCoordinateTransform.TransformInfo
%End

int sourceDatumTransformId() const;
%Docstring
Returns the ID of the datum transform to use when projecting from the source
CRS.

This is usually calculated automatically from the transform's QgsCoordinateTransformContext,
but can be manually overwritten by a call to setDestinationDatumTransform().
but can be manually overwritten by a call to setSourceDatumTransformId().

.. seealso:: setDestinationDatumTransform()
.. seealso:: sourceDatumTransform()
.. seealso:: :py:func:`setSourceDatumTransformId()`
.. seealso:: :py:func:`destinationDatumTransformId()`
.. seealso:: :py:func:`datumTransformInfo()`
:rtype: int
%End

void setDestinationDatumTransform( int datum );
void setSourceDatumTransformId( int datumId );
%Docstring
Sets the index of the ``datum`` transform to use when projecting to the destination
Sets the ``datumId`` ID of the datum transform to use when projecting from the source
CRS.

This is usually calculated automatically from the transform's QgsCoordinateTransformContext.
Calling this method will overwrite any automatically calculated datum transform.

.. seealso:: destinationDatumTransform()
.. seealso:: setSourceDatumTransform()
.. seealso:: :py:func:`sourceDatumTransformId()`
.. seealso:: :py:func:`setDestinationDatumTransformId()`
.. seealso:: :py:func:`datumTransformInfo()`
%End

void initialize();
int destinationDatumTransformId() const;
%Docstring
initialize is used to actually create the Transformer instance
Returns the ID of the datum transform to use when projecting to the destination
CRS.

This is usually calculated automatically from the transform's QgsCoordinateTransformContext,
but can be manually overwritten by a call to setDestinationDatumTransformId().

.. seealso:: :py:func:`setDestinationDatumTransformId()`
.. seealso:: :py:func:`sourceDatumTransformId()`
.. seealso:: :py:func:`datumTransformInfo()`
:rtype: int
%End

bool readXml( const QDomNode &node );
void setDestinationDatumTransformId( int datumId );
%Docstring
Restores state from the given Dom node.
\param node The node from which state will be restored
:return: bool True on success, False on failure
.. seealso:: :py:func:`writeXml()`
:rtype: bool
Sets the ``datumId`` ID of the datum transform to use when projecting to the destination
CRS.

This is usually calculated automatically from the transform's QgsCoordinateTransformContext.
Calling this method will overwrite any automatically calculated datum transform.

.. seealso:: :py:func:`destinationDatumTransformId()`
.. seealso:: :py:func:`setSourceDatumTransformId()`
.. seealso:: :py:func:`datumTransformInfo()`
%End

bool writeXml( QDomNode &node, QDomDocument &document ) const;
static void invalidateCache();
%Docstring
Stores state to the given Dom node in the given document
\param node The node in which state will be restored
\param document The document in which state will be stored
:return: bool True on success, False on failure
.. seealso:: :py:func:`readXml()`
:rtype: bool
Clears the internal cache used to initialize QgsCoordinateTransform objects.
This should be called whenever the srs database has
been modified in order to ensure that outdated CRS transforms are not created.
.. versionadded:: 3.0
%End

};
Expand Down
16 changes: 8 additions & 8 deletions python/core/qgscoordinatetransformcontext.sip
Expand Up @@ -76,7 +76,7 @@ class QgsCoordinateTransformContext
to use for a coordinate transform. Instead, always use calculateDatumTransforms()
to determine this.

.. seealso:: addSourceDestinationDatumTransform()
.. seealso:: :py:func:`addSourceDestinationDatumTransform()`
:rtype: QMap< QPair< str, QString>, QgsCoordinateTransform.TransformPair >
%End

Expand All @@ -98,8 +98,8 @@ class QgsCoordinateTransformContext
Transforms set using this method will override any specific source or destination
transforms set by addSourceDatumTransform() or addDestinationDatumTransform().

.. seealso:: sourceDestinationDatumTransforms()
.. seealso:: removeSourceDestinationDatumTransform()
.. seealso:: :py:func:`sourceDestinationDatumTransforms()`
.. seealso:: :py:func:`removeSourceDestinationDatumTransform()`
:rtype: bool
%End

Expand All @@ -108,7 +108,7 @@ class QgsCoordinateTransformContext
%Docstring
Removes the source to destination datum transform pair for the specified ``sourceCrs`` and
``destinationCrs``.
.. seealso:: addSourceDestinationDatumTransform()
.. seealso:: :py:func:`addSourceDestinationDatumTransform()`
%End

bool hasTransform( const QgsCoordinateReferenceSystem &source,
Expand Down Expand Up @@ -140,26 +140,26 @@ class QgsCoordinateTransformContext
void readXml( const QDomElement &element, const QgsReadWriteContext &context );
%Docstring
Reads the context's state from a DOM ``element``.
.. seealso:: writeXml()
.. seealso:: :py:func:`writeXml()`
%End

void writeXml( QDomElement &element, const QgsReadWriteContext &context ) const;
%Docstring
Writes the context's state to a DOM ``element``.
.. seealso:: readXml()
.. seealso:: :py:func:`readXml()`
%End


void readSettings();
%Docstring
Reads the context's state from application settings.
.. seealso:: readSettings()
.. seealso:: :py:func:`readSettings()`
%End

void writeSettings();
%Docstring
Write the context's state to application settings.
.. seealso:: writeSettings()
.. seealso:: :py:func:`writeSettings()`
%End


Expand Down
4 changes: 2 additions & 2 deletions python/core/qgsmapsettings.sip
Expand Up @@ -311,7 +311,7 @@ Return the distance in geographical coordinates that equals to one pixel in the
from a source to destination coordinate reference system.

.. versionadded:: 3.0
.. seealso:: setTransformContext()
.. seealso:: :py:func:`setTransformContext()`
:rtype: QgsCoordinateTransformContext
%End

Expand All @@ -322,7 +322,7 @@ Return the distance in geographical coordinates that equals to one pixel in the
from a source to destination coordinate reference system.

.. versionadded:: 3.0
.. seealso:: transformContext()
.. seealso:: :py:func:`transformContext()`
%End

const QgsMapToPixel &mapToPixel() const;
Expand Down
10 changes: 5 additions & 5 deletions python/core/qgsproject.sip
Expand Up @@ -135,8 +135,8 @@ Returns the QgsProject singleton instance
from a source to destination coordinate reference system.

.. versionadded:: 3.0
.. seealso:: setTransformContext()
.. seealso:: transformContextChanged()
.. seealso:: :py:func:`setTransformContext()`
.. seealso:: :py:func:`transformContextChanged()`
:rtype: QgsCoordinateTransformContext
%End

Expand All @@ -147,8 +147,8 @@ Returns the QgsProject singleton instance
from a source to destination coordinate reference system.

.. versionadded:: 3.0
.. seealso:: transformContext()
.. seealso:: transformContextChanged()
.. seealso:: :py:func:`transformContext()`
.. seealso:: :py:func:`transformContextChanged()`
%End

void clear();
Expand Down Expand Up @@ -942,7 +942,7 @@ emitted whenever the configuration for snapping has changed
Emitted when the project transformContext() is changed.

.. versionadded:: 3.0
.. seealso:: transformContext()
.. seealso:: :py:func:`transformContext()`
%End

void transactionGroupsChanged();
Expand Down
4 changes: 2 additions & 2 deletions python/core/qgsrendercontext.sip
Expand Up @@ -117,7 +117,7 @@ class QgsRenderContext
from a source to destination coordinate reference system.

.. versionadded:: 3.0
.. seealso:: setTransformContext()
.. seealso:: :py:func:`setTransformContext()`
:rtype: QgsCoordinateTransformContext
%End

Expand All @@ -128,7 +128,7 @@ class QgsRenderContext
from a source to destination coordinate reference system.

.. versionadded:: 3.0
.. seealso:: transformContext()
.. seealso:: :py:func:`transformContext()`
%End

const QgsRectangle &extent() const;
Expand Down

0 comments on commit 13d1786

Please sign in to comment.