QGIS API Documentation  3.4.15-Madeira (e83d02e274)
Public Member Functions | List of all members
QgsCoordinateTransformContext Class Reference

Contains information about the context in which a coordinate transform is executed. More...

#include <qgscoordinatetransformcontext.h>

Public Member Functions

 QgsCoordinateTransformContext ()
 Constructor for QgsCoordinateTransformContext. More...
 
 QgsCoordinateTransformContext (const QgsCoordinateTransformContext &rhs)
 Copy constructor. More...
 
 ~QgsCoordinateTransformContext ()
 
bool addSourceDestinationDatumTransform (const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, int sourceTransformId, int destinationTransformId)
 Adds a new sourceTransform and destinationTransform to use when projecting coordinates from the specified sourceCrs to the specified destinationCrs. More...
 
QgsDatumTransform::TransformPair calculateDatumTransforms (const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination) const
 Returns the pair of source and destination datum transforms to use for a transform from the specified source CRS to destination CRS. More...
 
void clear ()
 Clears all stored transform information from the context. More...
 
bool hasTransform (const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination) const
 Returns true if the context has a valid datum transform to use when transforming from the specified source CRS to destination CRS. More...
 
QgsCoordinateTransformContextoperator= (const QgsCoordinateTransformContext &rhs)
 Assignment operator. More...
 
bool operator== (const QgsCoordinateTransformContext &rhs) const
 
void readSettings ()
 Reads the context's state from application settings. More...
 
bool readXml (const QDomElement &element, const QgsReadWriteContext &context, QStringList &missingTransforms)
 Reads the context's state from a DOM element. More...
 
void removeSourceDestinationDatumTransform (const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs)
 Removes the source to destination datum transform pair for the specified sourceCrs and destinationCrs. More...
 
QMap< QPair< QString, QString >, QgsDatumTransform::TransformPairsourceDestinationDatumTransforms () const
 Returns the stored mapping for source to destination CRS pairs to associated datum transforms to use. More...
 
void writeSettings ()
 Write the context's state to application settings. More...
 
void writeXml (QDomElement &element, const QgsReadWriteContext &context) const
 Writes the context's state to a DOM element. More...
 

Detailed Description

Contains information about the context in which a coordinate transform is executed.

The context stores various information regarding which coordinate transforms should be used when transforming points from a source to destination coordinate reference system.

The highest priority transforms are those set using addSourceDestinationDatumTransform() and which the transform has a matching source to destination CRS pair.

Failing this, if the source CRS has a matching transform specified by addSourceDatumTransform() then this datum transform will be used. The same logic applies for destination CRS transforms set using addDestinationDatumTransform().

Note
QgsCoordinateTransformContext objects are thread safe for read and write.
QgsCoordinateTransformContext objects are implicitly shared.
See also
QgsDatumTransform
QgsCoordinateTransform
Since
QGIS 3.0

Definition at line 64 of file qgscoordinatetransformcontext.h.

Constructor & Destructor Documentation

QgsCoordinateTransformContext::QgsCoordinateTransformContext ( )

Constructor for QgsCoordinateTransformContext.

Definition at line 23 of file qgscoordinatetransformcontext.cpp.

QgsCoordinateTransformContext::~QgsCoordinateTransformContext ( )
default
QgsCoordinateTransformContext::QgsCoordinateTransformContext ( const QgsCoordinateTransformContext rhs)

Copy constructor.

Definition at line 29 of file qgscoordinatetransformcontext.cpp.

Member Function Documentation

bool QgsCoordinateTransformContext::addSourceDestinationDatumTransform ( const QgsCoordinateReferenceSystem sourceCrs,
const QgsCoordinateReferenceSystem destinationCrs,
int  sourceTransformId,
int  destinationTransformId 
)

Adds a new sourceTransform and destinationTransform to use when projecting coordinates from the specified sourceCrs to the specified destinationCrs.

If either sourceTransformId or destinationTransformId is -1, then no datum transform is required for transformations for that source or destination.

Returns true if the new transform pair was added successfully.

Note
Transforms set using this method will override any specific source or destination transforms set by addSourceDatumTransform() or addDestinationDatumTransform().
See also
sourceDestinationDatumTransforms()
removeSourceDestinationDatumTransform()

Definition at line 130 of file qgscoordinatetransformcontext.cpp.

QgsDatumTransform::TransformPair QgsCoordinateTransformContext::calculateDatumTransforms ( const QgsCoordinateReferenceSystem source,
const QgsCoordinateReferenceSystem destination 
) const

Returns the pair of source and destination datum transforms to use for a transform from the specified source CRS to destination CRS.

Returns an ID of -1 if a datum transform should not be used for the source or destination.

Note
source and destination are reversible.

Definition at line 154 of file qgscoordinatetransformcontext.cpp.

void QgsCoordinateTransformContext::clear ( )

Clears all stored transform information from the context.

Definition at line 52 of file qgscoordinatetransformcontext.cpp.

bool QgsCoordinateTransformContext::hasTransform ( const QgsCoordinateReferenceSystem source,
const QgsCoordinateReferenceSystem destination 
) const

Returns true if the context has a valid datum transform to use when transforming from the specified source CRS to destination CRS.

Note
source and destination are reversible.

Definition at line 147 of file qgscoordinatetransformcontext.cpp.

QgsCoordinateTransformContext & QgsCoordinateTransformContext::operator= ( const QgsCoordinateTransformContext rhs)

Assignment operator.

Definition at line 33 of file qgscoordinatetransformcontext.cpp.

bool QgsCoordinateTransformContext::operator== ( const QgsCoordinateTransformContext rhs) const

Definition at line 39 of file qgscoordinatetransformcontext.cpp.

void QgsCoordinateTransformContext::readSettings ( )

Reads the context's state from application settings.

See also
readSettings()

Definition at line 316 of file qgscoordinatetransformcontext.cpp.

bool QgsCoordinateTransformContext::readXml ( const QDomElement &  element,
const QgsReadWriteContext context,
QStringList &  missingTransforms 
)

Reads the context's state from a DOM element.

Returns false if transforms stored in the XML are not available. In this case missingTransforms will be filled with missing datum transform strings.

See also
writeXml()

Definition at line 180 of file qgscoordinatetransformcontext.cpp.

void QgsCoordinateTransformContext::removeSourceDestinationDatumTransform ( const QgsCoordinateReferenceSystem sourceCrs,
const QgsCoordinateReferenceSystem destinationCrs 
)

Removes the source to destination datum transform pair for the specified sourceCrs and destinationCrs.

See also
addSourceDestinationDatumTransform()

Definition at line 142 of file qgscoordinatetransformcontext.cpp.

QMap< QPair< QString, QString >, QgsDatumTransform::TransformPair > QgsCoordinateTransformContext::sourceDestinationDatumTransforms ( ) const

Returns the stored mapping for source to destination CRS pairs to associated datum transforms to use.

The map keys will be QgsCoordinateReferenceSystems::authid()s.

If either the source transform ID or destination transform ID is -1, then no datum transform is required for transformations for that source or destination.

Warning
This method should not be used to calculate the corresponding datum transforms to use for a coordinate transform. Instead, always use calculateDatumTransforms() to determine this.
See also
addSourceDestinationDatumTransform()

Definition at line 121 of file qgscoordinatetransformcontext.cpp.

void QgsCoordinateTransformContext::writeSettings ( )

Write the context's state to application settings.

See also
writeSettings()

Definition at line 373 of file qgscoordinatetransformcontext.cpp.

void QgsCoordinateTransformContext::writeXml ( QDomElement &  element,
const QgsReadWriteContext context 
) const

Writes the context's state to a DOM element.

See also
readXml()

Definition at line 275 of file qgscoordinatetransformcontext.cpp.


The documentation for this class was generated from the following files: