mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Move datum transform structs out to their own header, to avoid
need to include private header file
This commit is contained in:
parent
1c7e140263
commit
25c3e135b0
@ -30,6 +30,7 @@
|
||||
%Include qgsdataitemproviderregistry.sip
|
||||
%Include qgsdatasourceuri.sip
|
||||
%Include qgsdatetimestatisticalsummary.sip
|
||||
%Include qgsdatumtransform.sip
|
||||
%Include qgsdbfilterproxymodel.sip
|
||||
%Include qgsdefaultvalue.sip
|
||||
%Include qgsdiagramrenderer.sip
|
||||
|
@ -254,36 +254,7 @@ otherwise points are transformed from destination to source CRS.
|
||||
Returns true if the transform short circuits because the source and destination are equivalent.
|
||||
%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
|
||||
|
||||
int destinationTransformId;
|
||||
%Docstring
|
||||
ID for the datum transform to use when projecting to the destination CRS.
|
||||
|
||||
.. seealso:: :py:func:`QgsCoordinateTransform.datumTransformCrsInfo()`
|
||||
%End
|
||||
|
||||
bool operator==( const QgsCoordinateTransform::TransformPair &other ) const;
|
||||
|
||||
bool operator!=( const QgsCoordinateTransform::TransformPair &other ) const;
|
||||
|
||||
};
|
||||
|
||||
static QList< QgsCoordinateTransform::TransformPair > datumTransformations( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination );
|
||||
static QList< QgsDatumTransform::TransformPair > datumTransformations( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination );
|
||||
%Docstring
|
||||
Returns a list of datum transformations which are available for the given ``source`` and ``destination`` CRS.
|
||||
|
||||
@ -313,61 +284,7 @@ Returns -1 if matching datum ID was not found.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
struct TransformInfo
|
||||
{
|
||||
int datumTransformId;
|
||||
%Docstring
|
||||
Datum transform ID
|
||||
%End
|
||||
|
||||
int epsgCode;
|
||||
%Docstring
|
||||
EPSG code for the transform, or 0 if not found in EPSG database
|
||||
%End
|
||||
|
||||
QString sourceCrsAuthId;
|
||||
%Docstring
|
||||
Source CRS auth ID
|
||||
%End
|
||||
|
||||
QString destinationCrsAuthId;
|
||||
%Docstring
|
||||
Destination CRS auth ID
|
||||
%End
|
||||
|
||||
QString sourceCrsDescription;
|
||||
%Docstring
|
||||
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 );
|
||||
static QgsDatumTransform::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
|
||||
|
@ -65,7 +65,7 @@ Clears all stored transform information from the context.
|
||||
|
||||
|
||||
|
||||
QMap< QPair< QString, QString>, QgsCoordinateTransform::TransformPair > sourceDestinationDatumTransforms() const;
|
||||
QMap< QPair< QString, QString>, QgsDatumTransform::TransformPair > sourceDestinationDatumTransforms() const;
|
||||
%Docstring
|
||||
Returns the stored mapping for source to destination CRS pairs to associated datum transforms to use.
|
||||
The map keys will be QgsCoordinateReferenceSystems.authid()s.
|
||||
@ -123,7 +123,7 @@ when transforming from the specified ``source`` CRS to ``destination`` CRS.
|
||||
source and destination are reversible.
|
||||
%End
|
||||
|
||||
QgsCoordinateTransform::TransformPair calculateDatumTransforms( const QgsCoordinateReferenceSystem &source,
|
||||
QgsDatumTransform::TransformPair calculateDatumTransforms( const QgsCoordinateReferenceSystem &source,
|
||||
const QgsCoordinateReferenceSystem &destination ) const;
|
||||
%Docstring
|
||||
Returns the pair of source and destination datum transforms to use
|
||||
|
114
python/core/qgsdatumtransform.sip
Normal file
114
python/core/qgsdatumtransform.sip
Normal file
@ -0,0 +1,114 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/qgsdatumtransform.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
class QgsDatumTransform
|
||||
{
|
||||
%Docstring
|
||||
Contains methods and classes relating the datum transformations.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsdatumtransform.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
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
|
||||
|
||||
int destinationTransformId;
|
||||
%Docstring
|
||||
ID for the datum transform to use when projecting to the destination CRS.
|
||||
|
||||
.. seealso:: :py:func:`QgsCoordinateTransform.datumTransformCrsInfo()`
|
||||
%End
|
||||
|
||||
bool operator==( const QgsDatumTransform::TransformPair &other ) const;
|
||||
|
||||
bool operator!=( const QgsDatumTransform::TransformPair &other ) const;
|
||||
|
||||
};
|
||||
|
||||
struct TransformInfo
|
||||
{
|
||||
int datumTransformId;
|
||||
%Docstring
|
||||
Datum transform ID
|
||||
%End
|
||||
|
||||
int epsgCode;
|
||||
%Docstring
|
||||
EPSG code for the transform, or 0 if not found in EPSG database
|
||||
%End
|
||||
|
||||
QString sourceCrsAuthId;
|
||||
%Docstring
|
||||
Source CRS auth ID
|
||||
%End
|
||||
|
||||
QString destinationCrsAuthId;
|
||||
%Docstring
|
||||
Destination CRS auth ID
|
||||
%End
|
||||
|
||||
QString sourceCrsDescription;
|
||||
%Docstring
|
||||
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
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/qgsdatumtransform.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -85,7 +85,7 @@ QVariant QgsDatumTransformTableModel::data( const QModelIndex &index, int role )
|
||||
QPair< QString, QString> crses = mTransformContext.sourceDestinationDatumTransforms().keys().at( index.row() );
|
||||
sourceCrs = crses.first;
|
||||
destinationCrs = crses.second;
|
||||
const QgsCoordinateTransform::TransformPair transforms = mTransformContext.sourceDestinationDatumTransforms().value( crses );
|
||||
const QgsDatumTransform::TransformPair transforms = mTransformContext.sourceDestinationDatumTransforms().value( crses );
|
||||
sourceTransform = transforms.sourceTransformId;
|
||||
destinationTransform = transforms.destinationTransformId;
|
||||
#ifdef singlesourcedest
|
||||
|
@ -854,7 +854,6 @@ SET(QGIS_CORE_HDRS
|
||||
qgscoordinateformatter.h
|
||||
qgscoordinatetransform.h
|
||||
qgscoordinatetransformcontext.h
|
||||
qgscoordinatetransformcontext_p.h
|
||||
qgscoordinateutils.h
|
||||
qgsdartmeasurement.h
|
||||
qgsdatadefinedsizelegend.h
|
||||
@ -862,6 +861,7 @@ SET(QGIS_CORE_HDRS
|
||||
qgsdataitemproviderregistry.h
|
||||
qgsdatasourceuri.h
|
||||
qgsdatetimestatisticalsummary.h
|
||||
qgsdatumtransform.h
|
||||
qgsdbfilterproxymodel.h
|
||||
qgsdefaultvalue.h
|
||||
qgsdiagramrenderer.h
|
||||
|
@ -691,9 +691,9 @@ const char *finder( const char *name )
|
||||
|
||||
|
||||
|
||||
QList< QgsCoordinateTransform::TransformPair > QgsCoordinateTransform::datumTransformations( const QgsCoordinateReferenceSystem &srcCRS, const QgsCoordinateReferenceSystem &destCRS )
|
||||
QList< QgsDatumTransform::TransformPair > QgsCoordinateTransform::datumTransformations( const QgsCoordinateReferenceSystem &srcCRS, const QgsCoordinateReferenceSystem &destCRS )
|
||||
{
|
||||
QList< QgsCoordinateTransform::TransformPair > transformations;
|
||||
QList< QgsDatumTransform::TransformPair > transformations;
|
||||
|
||||
QString srcGeoId = srcCRS.geographicCrsAuthId();
|
||||
QString destGeoId = destCRS.geographicCrsAuthId();
|
||||
@ -735,20 +735,20 @@ QList< QgsCoordinateTransform::TransformPair > QgsCoordinateTransform::datumTran
|
||||
//add direct datum transformations
|
||||
for ( int transform : qgis::as_const( directTransforms ) )
|
||||
{
|
||||
transformations.push_back( TransformPair( transform, -1 ) );
|
||||
transformations.push_back( QgsDatumTransform::TransformPair( transform, -1 ) );
|
||||
}
|
||||
|
||||
//add direct datum transformations
|
||||
for ( int transform : qgis::as_const( directTransforms ) )
|
||||
{
|
||||
transformations.push_back( TransformPair( -1, transform ) );
|
||||
transformations.push_back( QgsDatumTransform::TransformPair( -1, transform ) );
|
||||
}
|
||||
|
||||
for ( int srcTransform : qgis::as_const( srcToWgs84 ) )
|
||||
{
|
||||
for ( int destTransform : qgis::as_const( destToWgs84 ) )
|
||||
{
|
||||
transformations.push_back( TransformPair( srcTransform, destTransform ) );
|
||||
transformations.push_back( QgsDatumTransform::TransformPair( srcTransform, destTransform ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -821,9 +821,9 @@ int QgsCoordinateTransform::projStringToDatumTransformId( const QString &string
|
||||
return QgsCoordinateTransformPrivate::transformIdFromString( string );
|
||||
}
|
||||
|
||||
QgsCoordinateTransform::TransformInfo QgsCoordinateTransform::datumTransformInfo( int datumTransform )
|
||||
QgsDatumTransform::TransformInfo QgsCoordinateTransform::datumTransformInfo( int datumTransform )
|
||||
{
|
||||
TransformInfo info;
|
||||
QgsDatumTransform::TransformInfo info;
|
||||
|
||||
sqlite3_database_unique_ptr database;
|
||||
int openResult = database.open_v2( QgsApplication::srsDatabaseFilePath(), SQLITE_OPEN_READONLY, nullptr );
|
||||
|
@ -312,52 +312,12 @@ class CORE_EXPORT QgsCoordinateTransform
|
||||
*/
|
||||
bool isShortCircuited() const;
|
||||
|
||||
/**
|
||||
* Contains datum transform information.
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
struct TransformPair
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor for a TransformPair with the specified \a sourceTransformId
|
||||
* and \a destinationTransformId transforms.
|
||||
*/
|
||||
TransformPair( int sourceTransformId = -1, int destinationTransformId = -1 )
|
||||
: sourceTransformId( sourceTransformId )
|
||||
, destinationTransformId( destinationTransformId )
|
||||
{}
|
||||
|
||||
/**
|
||||
* ID for the datum transform to use when projecting from the source CRS.
|
||||
* \see QgsCoordinateTransform::datumTransformCrsInfo()
|
||||
*/
|
||||
int sourceTransformId = -1;
|
||||
|
||||
/**
|
||||
* ID for the datum transform to use when projecting to the destination CRS.
|
||||
* \see QgsCoordinateTransform::datumTransformCrsInfo()
|
||||
*/
|
||||
int destinationTransformId = -1;
|
||||
|
||||
bool operator==( const QgsCoordinateTransform::TransformPair &other ) const
|
||||
{
|
||||
return other.sourceTransformId == sourceTransformId && other.destinationTransformId == destinationTransformId;
|
||||
}
|
||||
|
||||
bool operator!=( const QgsCoordinateTransform::TransformPair &other ) const
|
||||
{
|
||||
return other.sourceTransformId != sourceTransformId || other.destinationTransformId != destinationTransformId;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a list of datum transformations which are available for the given \a source and \a destination CRS.
|
||||
* \see datumTransformToProj()
|
||||
* \see datumTransformInfo()
|
||||
*/
|
||||
static QList< QgsCoordinateTransform::TransformPair > datumTransformations( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination );
|
||||
static QList< QgsDatumTransform::TransformPair > datumTransformations( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination );
|
||||
|
||||
/**
|
||||
* Returns a proj string representing the specified \a datumTransformId datum transform ID.
|
||||
@ -375,44 +335,6 @@ class CORE_EXPORT QgsCoordinateTransform
|
||||
*/
|
||||
static int projStringToDatumTransformId( const QString &string );
|
||||
|
||||
/**
|
||||
* Contains datum transform information.
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
struct TransformInfo
|
||||
{
|
||||
//! Datum transform ID
|
||||
int datumTransformId = -1;
|
||||
|
||||
//! EPSG code for the transform, or 0 if not found in EPSG database
|
||||
int epsgCode = 0;
|
||||
|
||||
//! Source CRS auth ID
|
||||
QString sourceCrsAuthId;
|
||||
|
||||
//! Destination CRS auth ID
|
||||
QString destinationCrsAuthId;
|
||||
|
||||
//! Source CRS description
|
||||
QString sourceCrsDescription;
|
||||
|
||||
//! Destination CRS description
|
||||
QString destinationCrsDescription;
|
||||
|
||||
//! Transform remarks
|
||||
QString remarks;
|
||||
|
||||
//! Scope of transform
|
||||
QString scope;
|
||||
|
||||
//! True if transform is the preferred transform to use for the source/destination CRS combination
|
||||
bool preferred = false;
|
||||
|
||||
//! True if transform is deprecated
|
||||
bool deprecated = false;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns detailed information about the specified \a datumTransformId.
|
||||
* If \a datumTransformId was not a valid transform ID, a TransformInfo with TransformInfo::datumTransformId of
|
||||
@ -420,7 +342,7 @@ class CORE_EXPORT QgsCoordinateTransform
|
||||
* \see datumTransformations()
|
||||
* \see datumTransformToProj()
|
||||
*/
|
||||
static QgsCoordinateTransform::TransformInfo datumTransformInfo( int datumTransformId );
|
||||
static QgsDatumTransform::TransformInfo datumTransformInfo( int datumTransformId );
|
||||
|
||||
/**
|
||||
* Returns the ID of the datum transform to use when projecting from the source
|
||||
|
@ -217,10 +217,10 @@ bool QgsCoordinateTransformPrivate::initialize()
|
||||
return mIsValid;
|
||||
}
|
||||
|
||||
void QgsCoordinateTransformPrivate::calculateTransforms()
|
||||
void QgsCoordinateTransformPrivate::calculateTransforms( const QgsCoordinateTransformContext &context )
|
||||
{
|
||||
// recalculate datum transforms from context
|
||||
QgsCoordinateTransform::TransformPair transforms = mContext.calculateDatumTransforms( mSourceCRS, mDestCRS );
|
||||
QgsDatumTransform::TransformPair transforms = context.calculateDatumTransforms( mSourceCRS, mDestCRS );
|
||||
mSourceDatumTransform = transforms.sourceTransformId;
|
||||
mDestinationDatumTransform = transforms.destinationTransformId;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ void QgsCoordinateTransformContext::removeDestinationDatumTransform( const QgsCo
|
||||
|
||||
#endif
|
||||
|
||||
QMap<QPair<QString, QString>, QgsCoordinateTransform::TransformPair> QgsCoordinateTransformContext::sourceDestinationDatumTransforms() const
|
||||
QMap<QPair<QString, QString>, QgsDatumTransform::TransformPair> QgsCoordinateTransformContext::sourceDestinationDatumTransforms() const
|
||||
{
|
||||
d->mLock.lockForRead();
|
||||
auto res = d->mSourceDestDatumTransforms;
|
||||
@ -118,7 +118,7 @@ bool QgsCoordinateTransformContext::addSourceDestinationDatumTransform( const Qg
|
||||
|
||||
d.detach();
|
||||
d->mLock.lockForWrite();
|
||||
d->mSourceDestDatumTransforms.insert( qMakePair( sourceCrs.authid(), destinationCrs.authid() ), QgsCoordinateTransform::TransformPair( sourceTransform, destinationTransform ) );
|
||||
d->mSourceDestDatumTransforms.insert( qMakePair( sourceCrs.authid(), destinationCrs.authid() ), QgsDatumTransform::TransformPair( sourceTransform, destinationTransform ) );
|
||||
d->mLock.unlock();
|
||||
return true;
|
||||
}
|
||||
@ -130,24 +130,24 @@ void QgsCoordinateTransformContext::removeSourceDestinationDatumTransform( const
|
||||
|
||||
bool QgsCoordinateTransformContext::hasTransform( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination ) const
|
||||
{
|
||||
QgsCoordinateTransform::TransformPair t = calculateDatumTransforms( source, destination );
|
||||
QgsDatumTransform::TransformPair t = calculateDatumTransforms( source, destination );
|
||||
// calculateDatumTransforms already takes care of switching source and destination
|
||||
return t.sourceTransformId != -1 || t.destinationTransformId != -1;
|
||||
}
|
||||
|
||||
QgsCoordinateTransform::TransformPair QgsCoordinateTransformContext::calculateDatumTransforms( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination ) const
|
||||
QgsDatumTransform::TransformPair QgsCoordinateTransformContext::calculateDatumTransforms( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination ) const
|
||||
{
|
||||
QString srcKey = source.authid();
|
||||
QString destKey = destination.authid();
|
||||
|
||||
d->mLock.lockForRead();
|
||||
// highest priority is exact match for source/dest pair
|
||||
QgsCoordinateTransform::TransformPair res = d->mSourceDestDatumTransforms.value( qMakePair( srcKey, destKey ), QgsCoordinateTransform::TransformPair( -1, -1 ) );
|
||||
QgsDatumTransform::TransformPair res = d->mSourceDestDatumTransforms.value( qMakePair( srcKey, destKey ), QgsDatumTransform::TransformPair( -1, -1 ) );
|
||||
if ( res.sourceTransformId == -1 && res.destinationTransformId == -1 )
|
||||
{
|
||||
// try to reverse
|
||||
QgsCoordinateTransform::TransformPair res2 = d->mSourceDestDatumTransforms.value( qMakePair( destKey, srcKey ), QgsCoordinateTransform::TransformPair( -1, -1 ) );
|
||||
res = QgsCoordinateTransform::TransformPair( res2.destinationTransformId, res2.sourceTransformId );
|
||||
QgsDatumTransform::TransformPair res2 = d->mSourceDestDatumTransforms.value( qMakePair( destKey, srcKey ), QgsDatumTransform::TransformPair( -1, -1 ) );
|
||||
res = QgsDatumTransform::TransformPair( res2.destinationTransformId, res2.sourceTransformId );
|
||||
}
|
||||
d->mLock.unlock();
|
||||
return res;
|
||||
@ -217,7 +217,7 @@ bool QgsCoordinateTransformContext::readXml( const QDomElement &element, const Q
|
||||
}
|
||||
}
|
||||
|
||||
d->mSourceDestDatumTransforms.insert( qMakePair( key1, key2 ), QgsCoordinateTransform::TransformPair( datumId1, datumId2 ) );
|
||||
d->mSourceDestDatumTransforms.insert( qMakePair( key1, key2 ), QgsDatumTransform::TransformPair( datumId1, datumId2 ) );
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -347,7 +347,7 @@ void QgsCoordinateTransformContext::readSettings()
|
||||
QMap< QPair< QString, QString >, QPair< int, int > >::const_iterator transformIt = transforms.constBegin();
|
||||
for ( ; transformIt != transforms.constEnd(); ++transformIt )
|
||||
{
|
||||
d->mSourceDestDatumTransforms.insert( transformIt.key(), QgsCoordinateTransform::TransformPair( transformIt.value().first, transformIt.value().second ) );
|
||||
d->mSourceDestDatumTransforms.insert( transformIt.key(), QgsDatumTransform::TransformPair( transformIt.value().first, transformIt.value().second ) );
|
||||
}
|
||||
|
||||
d->mLock.unlock();
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "qgis_core.h"
|
||||
#include "qgis.h"
|
||||
#include "qgscoordinatetransformcontext_p.h"
|
||||
#include "qgscoordinatetransform.h"
|
||||
#include "qgsdatumtransform.h"
|
||||
|
||||
class QgsReadWriteContext;
|
||||
|
||||
@ -181,7 +181,7 @@ class CORE_EXPORT QgsCoordinateTransformContext
|
||||
*
|
||||
* \see addSourceDestinationDatumTransform()
|
||||
*/
|
||||
QMap< QPair< QString, QString>, QgsCoordinateTransform::TransformPair > sourceDestinationDatumTransforms() const;
|
||||
QMap< QPair< QString, QString>, QgsDatumTransform::TransformPair > sourceDestinationDatumTransforms() const;
|
||||
|
||||
/**
|
||||
* Adds a new \a sourceTransform and \a destinationTransform to use when projecting coordinates
|
||||
@ -228,7 +228,7 @@ class CORE_EXPORT QgsCoordinateTransformContext
|
||||
*
|
||||
* \note source and destination are reversible.
|
||||
*/
|
||||
QgsCoordinateTransform::TransformPair calculateDatumTransforms( const QgsCoordinateReferenceSystem &source,
|
||||
QgsDatumTransform::TransformPair calculateDatumTransforms( const QgsCoordinateReferenceSystem &source,
|
||||
const QgsCoordinateReferenceSystem &destination ) const;
|
||||
|
||||
/**
|
||||
|
@ -38,7 +38,7 @@
|
||||
#define SIP_NO_FILE
|
||||
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
#include "qgscoordinatetransform.h"
|
||||
#include "qgsdatumtransform.h"
|
||||
|
||||
class QgsCoordinateTransformContextPrivate : public QSharedData
|
||||
{
|
||||
@ -63,7 +63,7 @@ class QgsCoordinateTransformContextPrivate : public QSharedData
|
||||
* Mapping for datum transforms to use for source/destination CRS pairs.
|
||||
* Matching records from this map will take precedence over other transform maps.
|
||||
*/
|
||||
QMap< QPair< QString, QString >, QgsCoordinateTransform::TransformPair > mSourceDestDatumTransforms;
|
||||
QMap< QPair< QString, QString >, QgsDatumTransform::TransformPair > mSourceDestDatumTransforms;
|
||||
|
||||
#if 0
|
||||
//! Mapping for datum transforms to use for source CRS
|
||||
|
112
src/core/qgsdatumtransform.h
Normal file
112
src/core/qgsdatumtransform.h
Normal file
@ -0,0 +1,112 @@
|
||||
/***************************************************************************
|
||||
qgsdatumtransform.h
|
||||
------------------------
|
||||
begin : Dec 2017
|
||||
copyright : (C) 2017 Nyall Dawson
|
||||
email : nyall dot dawson at gmail dot com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef QGSDATUMTRANSFORM_H
|
||||
#define QGSDATUMTRANSFORM_H
|
||||
|
||||
#include "qgis_core.h"
|
||||
#include <QString>
|
||||
|
||||
/**
|
||||
* Contains methods and classes relating the datum transformations.
|
||||
* \ingroup core
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
class CORE_EXPORT QgsDatumTransform
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Contains datum transform information.
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
struct TransformPair
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor for a TransformPair with the specified \a sourceTransformId
|
||||
* and \a destinationTransformId transforms.
|
||||
*/
|
||||
TransformPair( int sourceTransformId = -1, int destinationTransformId = -1 )
|
||||
: sourceTransformId( sourceTransformId )
|
||||
, destinationTransformId( destinationTransformId )
|
||||
{}
|
||||
|
||||
/**
|
||||
* ID for the datum transform to use when projecting from the source CRS.
|
||||
* \see QgsCoordinateTransform::datumTransformCrsInfo()
|
||||
*/
|
||||
int sourceTransformId = -1;
|
||||
|
||||
/**
|
||||
* ID for the datum transform to use when projecting to the destination CRS.
|
||||
* \see QgsCoordinateTransform::datumTransformCrsInfo()
|
||||
*/
|
||||
int destinationTransformId = -1;
|
||||
|
||||
bool operator==( const QgsDatumTransform::TransformPair &other ) const
|
||||
{
|
||||
return other.sourceTransformId == sourceTransformId && other.destinationTransformId == destinationTransformId;
|
||||
}
|
||||
|
||||
bool operator!=( const QgsDatumTransform::TransformPair &other ) const
|
||||
{
|
||||
return other.sourceTransformId != sourceTransformId || other.destinationTransformId != destinationTransformId;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Contains datum transform information.
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
struct TransformInfo
|
||||
{
|
||||
//! Datum transform ID
|
||||
int datumTransformId = -1;
|
||||
|
||||
//! EPSG code for the transform, or 0 if not found in EPSG database
|
||||
int epsgCode = 0;
|
||||
|
||||
//! Source CRS auth ID
|
||||
QString sourceCrsAuthId;
|
||||
|
||||
//! Destination CRS auth ID
|
||||
QString destinationCrsAuthId;
|
||||
|
||||
//! Source CRS description
|
||||
QString sourceCrsDescription;
|
||||
|
||||
//! Destination CRS description
|
||||
QString destinationCrsDescription;
|
||||
|
||||
//! Transform remarks
|
||||
QString remarks;
|
||||
|
||||
//! Scope of transform
|
||||
QString scope;
|
||||
|
||||
//! True if transform is the preferred transform to use for the source/destination CRS combination
|
||||
bool preferred = false;
|
||||
|
||||
//! True if transform is deprecated
|
||||
bool deprecated = false;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
#endif // QGSDATUMTRANSFORM_H
|
@ -71,7 +71,7 @@ void QgsDatumTransformDialog::load( const QPair<int, int> &selectedDatumTransfor
|
||||
{
|
||||
mDatumTransformTreeWidget->clear();
|
||||
|
||||
for ( const QgsCoordinateTransform::TransformPair &transform : qgis::as_const( mDatumTransforms ) )
|
||||
for ( const QgsDatumTransform::TransformPair &transform : qgis::as_const( mDatumTransforms ) )
|
||||
{
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
bool itemDisabled = false;
|
||||
@ -87,7 +87,7 @@ void QgsDatumTransformDialog::load( const QPair<int, int> &selectedDatumTransfor
|
||||
item->setText( i, QgsCoordinateTransform::datumTransformToProj( nr ) );
|
||||
|
||||
//Describe datums in a tooltip
|
||||
QgsCoordinateTransform::TransformInfo info = QgsCoordinateTransform::datumTransformInfo( nr );
|
||||
QgsDatumTransform::TransformInfo info = QgsCoordinateTransform::datumTransformInfo( nr );
|
||||
if ( info.datumTransformId == -1 )
|
||||
continue;
|
||||
|
||||
|
@ -71,7 +71,7 @@ class GUI_EXPORT QgsDatumTransformDialog : public QDialog, private Ui::QgsDatumT
|
||||
void setOKButtonEnabled();
|
||||
|
||||
|
||||
QList< QgsCoordinateTransform::TransformPair > mDatumTransforms;
|
||||
QList< QgsDatumTransform::TransformPair > mDatumTransforms;
|
||||
QgsCoordinateReferenceSystem mSourceCrs;
|
||||
QgsCoordinateReferenceSystem mDestinationCrs;
|
||||
};
|
||||
|
@ -188,8 +188,8 @@ void TestQgsCoordinateTransform::contextShared()
|
||||
original.addSourceDestinationDatumTransform( QgsCoordinateReferenceSystem( 3111 ), QgsCoordinateReferenceSystem( 3113 ), 1, 2 );
|
||||
|
||||
QgsCoordinateTransformContext copy( original );
|
||||
QMap< QPair< QString, QString >, QgsCoordinateTransform::TransformPair > expected;
|
||||
expected.insert( qMakePair( QStringLiteral( "EPSG:3111" ), QStringLiteral( "EPSG:3113" ) ), QgsCoordinateTransform::TransformPair( 1, 2 ) );
|
||||
QMap< QPair< QString, QString >, QgsDatumTransform::TransformPair > expected;
|
||||
expected.insert( qMakePair( QStringLiteral( "EPSG:3111" ), QStringLiteral( "EPSG:3113" ) ), QgsDatumTransform::TransformPair( 1, 2 ) );
|
||||
QCOMPARE( original.sourceDestinationDatumTransforms(), expected );
|
||||
QCOMPARE( copy.sourceDestinationDatumTransforms(), expected );
|
||||
|
||||
@ -197,19 +197,19 @@ void TestQgsCoordinateTransform::contextShared()
|
||||
copy.addSourceDestinationDatumTransform( QgsCoordinateReferenceSystem( 3111 ), QgsCoordinateReferenceSystem( 3113 ), 3, 4 );
|
||||
QCOMPARE( original.sourceDestinationDatumTransforms(), expected );
|
||||
|
||||
expected.insert( qMakePair( QStringLiteral( "EPSG:3111" ), QStringLiteral( "EPSG:3113" ) ), QgsCoordinateTransform::TransformPair( 3, 4 ) );
|
||||
expected.insert( qMakePair( QStringLiteral( "EPSG:3111" ), QStringLiteral( "EPSG:3113" ) ), QgsDatumTransform::TransformPair( 3, 4 ) );
|
||||
QCOMPARE( copy.sourceDestinationDatumTransforms(), expected );
|
||||
|
||||
// copy via assignment
|
||||
QgsCoordinateTransformContext copy2;
|
||||
copy2 = original;
|
||||
expected.insert( qMakePair( QStringLiteral( "EPSG:3111" ), QStringLiteral( "EPSG:3113" ) ), QgsCoordinateTransform::TransformPair( 1, 2 ) );
|
||||
expected.insert( qMakePair( QStringLiteral( "EPSG:3111" ), QStringLiteral( "EPSG:3113" ) ), QgsDatumTransform::TransformPair( 1, 2 ) );
|
||||
QCOMPARE( original.sourceDestinationDatumTransforms(), expected );
|
||||
QCOMPARE( copy2.sourceDestinationDatumTransforms(), expected );
|
||||
|
||||
copy2.addSourceDestinationDatumTransform( QgsCoordinateReferenceSystem( 3111 ), QgsCoordinateReferenceSystem( 3113 ), 3, 4 );
|
||||
QCOMPARE( original.sourceDestinationDatumTransforms(), expected );
|
||||
expected.insert( qMakePair( QStringLiteral( "EPSG:3111" ), QStringLiteral( "EPSG:3113" ) ), QgsCoordinateTransform::TransformPair( 3, 4 ) );
|
||||
expected.insert( qMakePair( QStringLiteral( "EPSG:3111" ), QStringLiteral( "EPSG:3113" ) ), QgsDatumTransform::TransformPair( 3, 4 ) );
|
||||
QCOMPARE( copy2.sourceDestinationDatumTransforms(), expected );
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ import qgis # NOQA
|
||||
from qgis.core import (QgsCoordinateReferenceSystem,
|
||||
QgsCoordinateTransformContext,
|
||||
QgsCoordinateTransform,
|
||||
QgsDatumTransform,
|
||||
QgsReadWriteContext,
|
||||
QgsProject,
|
||||
QgsSettings)
|
||||
@ -114,79 +115,79 @@ class TestQgsCoordinateTransformContext(unittest.TestCase):
|
||||
context.hasTransform(QgsCoordinateReferenceSystem('EPSG:3111'), QgsCoordinateReferenceSystem('EPSG:4326')))
|
||||
self.assertFalse(
|
||||
context.hasTransform(QgsCoordinateReferenceSystem('EPSG:3113'), QgsCoordinateReferenceSystem('EPSG:4283')))
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(1, 2)})
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsDatumTransform.TransformPair(1, 2)})
|
||||
self.assertTrue(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:28356'),
|
||||
QgsCoordinateReferenceSystem(4283), 3, 4))
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(3, 4)})
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsDatumTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsDatumTransform.TransformPair(3, 4)})
|
||||
self.assertTrue(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:28356'),
|
||||
QgsCoordinateReferenceSystem(28357), 7, 8))
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsCoordinateTransform.TransformPair(7, 8)})
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsDatumTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsDatumTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsDatumTransform.TransformPair(7, 8)})
|
||||
self.assertTrue(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:28356'),
|
||||
QgsCoordinateReferenceSystem('EPSG:28357'), 9, 11))
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsCoordinateTransform.TransformPair(9, 11)})
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsDatumTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsDatumTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsDatumTransform.TransformPair(9, 11)})
|
||||
|
||||
# invalid additions
|
||||
self.assertFalse(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(),
|
||||
QgsCoordinateReferenceSystem('EPSG:28357'), 9, 11))
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsCoordinateTransform.TransformPair(9, 11)})
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsDatumTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsDatumTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsDatumTransform.TransformPair(9, 11)})
|
||||
self.assertFalse(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:3111'),
|
||||
QgsCoordinateReferenceSystem(), 9, 11))
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsCoordinateTransform.TransformPair(9, 11)})
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsDatumTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsDatumTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsDatumTransform.TransformPair(9, 11)})
|
||||
|
||||
# indicate no transform required
|
||||
self.assertTrue(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(28357),
|
||||
QgsCoordinateReferenceSystem(28356), -1, -1))
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsCoordinateTransform.TransformPair(9, 11),
|
||||
('EPSG:28357', 'EPSG:28356'): QgsCoordinateTransform.TransformPair(-1, -1)})
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsDatumTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsDatumTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsDatumTransform.TransformPair(9, 11),
|
||||
('EPSG:28357', 'EPSG:28356'): QgsDatumTransform.TransformPair(-1, -1)})
|
||||
self.assertTrue(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(3111),
|
||||
QgsCoordinateReferenceSystem(28356), 17, -1))
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsCoordinateTransform.TransformPair(9, 11),
|
||||
('EPSG:28357', 'EPSG:28356'): QgsCoordinateTransform.TransformPair(-1, -1),
|
||||
('EPSG:3111', 'EPSG:28356'): QgsCoordinateTransform.TransformPair(17, -1)})
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsDatumTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsDatumTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsDatumTransform.TransformPair(9, 11),
|
||||
('EPSG:28357', 'EPSG:28356'): QgsDatumTransform.TransformPair(-1, -1),
|
||||
('EPSG:3111', 'EPSG:28356'): QgsDatumTransform.TransformPair(17, -1)})
|
||||
self.assertTrue(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(3113),
|
||||
QgsCoordinateReferenceSystem(28356), -1, 18))
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsCoordinateTransform.TransformPair(9, 11),
|
||||
('EPSG:28357', 'EPSG:28356'): QgsCoordinateTransform.TransformPair(-1, -1),
|
||||
('EPSG:3111', 'EPSG:28356'): QgsCoordinateTransform.TransformPair(17, -1),
|
||||
('EPSG:3113', 'EPSG:28356'): QgsCoordinateTransform.TransformPair(-1, 18)})
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsDatumTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsDatumTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsDatumTransform.TransformPair(9, 11),
|
||||
('EPSG:28357', 'EPSG:28356'): QgsDatumTransform.TransformPair(-1, -1),
|
||||
('EPSG:3111', 'EPSG:28356'): QgsDatumTransform.TransformPair(17, -1),
|
||||
('EPSG:3113', 'EPSG:28356'): QgsDatumTransform.TransformPair(-1, 18)})
|
||||
# remove non-existing
|
||||
context.removeSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(3113), QgsCoordinateReferenceSystem(3111))
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsCoordinateTransform.TransformPair(9, 11),
|
||||
('EPSG:28357', 'EPSG:28356'): QgsCoordinateTransform.TransformPair(-1, -1),
|
||||
('EPSG:3111', 'EPSG:28356'): QgsCoordinateTransform.TransformPair(17, -1),
|
||||
('EPSG:3113', 'EPSG:28356'): QgsCoordinateTransform.TransformPair(-1, 18)})
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsDatumTransform.TransformPair(1, 2),
|
||||
('EPSG:28356', 'EPSG:4283'): QgsDatumTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsDatumTransform.TransformPair(9, 11),
|
||||
('EPSG:28357', 'EPSG:28356'): QgsDatumTransform.TransformPair(-1, -1),
|
||||
('EPSG:3111', 'EPSG:28356'): QgsDatumTransform.TransformPair(17, -1),
|
||||
('EPSG:3113', 'EPSG:28356'): QgsDatumTransform.TransformPair(-1, 18)})
|
||||
|
||||
# remove existing
|
||||
context.removeSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(3111),
|
||||
QgsCoordinateReferenceSystem(4283))
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:28356', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsCoordinateTransform.TransformPair(9, 11),
|
||||
('EPSG:28357', 'EPSG:28356'): QgsCoordinateTransform.TransformPair(-1, -1),
|
||||
('EPSG:3111', 'EPSG:28356'): QgsCoordinateTransform.TransformPair(17, -1),
|
||||
('EPSG:3113', 'EPSG:28356'): QgsCoordinateTransform.TransformPair(-1, 18)})
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:28356', 'EPSG:4283'): QgsDatumTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsDatumTransform.TransformPair(9, 11),
|
||||
('EPSG:28357', 'EPSG:28356'): QgsDatumTransform.TransformPair(-1, -1),
|
||||
('EPSG:3111', 'EPSG:28356'): QgsDatumTransform.TransformPair(17, -1),
|
||||
('EPSG:3113', 'EPSG:28356'): QgsDatumTransform.TransformPair(-1, 18)})
|
||||
context.removeSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(3111),
|
||||
QgsCoordinateReferenceSystem(28356))
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:28356', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsCoordinateTransform.TransformPair(9, 11),
|
||||
('EPSG:28357', 'EPSG:28356'): QgsCoordinateTransform.TransformPair(-1, -1),
|
||||
('EPSG:3113', 'EPSG:28356'): QgsCoordinateTransform.TransformPair(-1, 18)})
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:28356', 'EPSG:4283'): QgsDatumTransform.TransformPair(3, 4),
|
||||
('EPSG:28356', 'EPSG:28357'): QgsDatumTransform.TransformPair(9, 11),
|
||||
('EPSG:28357', 'EPSG:28356'): QgsDatumTransform.TransformPair(-1, -1),
|
||||
('EPSG:3113', 'EPSG:28356'): QgsDatumTransform.TransformPair(-1, 18)})
|
||||
|
||||
context.clear()
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {})
|
||||
@ -244,7 +245,7 @@ class TestQgsCoordinateTransformContext(unittest.TestCase):
|
||||
#empty context
|
||||
self.assertEqual(context.calculateDatumTransforms(QgsCoordinateReferenceSystem('EPSG:3111'),
|
||||
QgsCoordinateReferenceSystem('EPSG:4283')),
|
||||
QgsCoordinateTransform.TransformPair(-1, -1))
|
||||
QgsDatumTransform.TransformPair(-1, -1))
|
||||
|
||||
#add specific source/dest pair - should take precedence
|
||||
context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:28356'),
|
||||
@ -252,17 +253,17 @@ class TestQgsCoordinateTransformContext(unittest.TestCase):
|
||||
3, 4)
|
||||
self.assertEqual(context.calculateDatumTransforms(QgsCoordinateReferenceSystem('EPSG:28356'),
|
||||
QgsCoordinateReferenceSystem('EPSG:4283')),
|
||||
QgsCoordinateTransform.TransformPair(3, 4))
|
||||
QgsDatumTransform.TransformPair(3, 4))
|
||||
self.assertEqual(context.calculateDatumTransforms(QgsCoordinateReferenceSystem('EPSG:3111'),
|
||||
QgsCoordinateReferenceSystem('EPSG:4283')),
|
||||
QgsCoordinateTransform.TransformPair(-1, -1))
|
||||
QgsDatumTransform.TransformPair(-1, -1))
|
||||
self.assertEqual(context.calculateDatumTransforms(QgsCoordinateReferenceSystem('EPSG:28356'),
|
||||
QgsCoordinateReferenceSystem('EPSG:3111')),
|
||||
QgsCoordinateTransform.TransformPair(-1, -1))
|
||||
QgsDatumTransform.TransformPair(-1, -1))
|
||||
# check that reverse transforms are automatically supported
|
||||
self.assertEqual(context.calculateDatumTransforms(QgsCoordinateReferenceSystem('EPSG:4283'),
|
||||
QgsCoordinateReferenceSystem('EPSG:28356')),
|
||||
QgsCoordinateTransform.TransformPair(4, 3))
|
||||
QgsDatumTransform.TransformPair(4, 3))
|
||||
|
||||
@unittest.skip('ifdefed out in c++ until required')
|
||||
def testWriteReadXmlSingleVariant(self):
|
||||
@ -316,8 +317,8 @@ class TestQgsCoordinateTransformContext(unittest.TestCase):
|
||||
self.assertTrue(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(4205),
|
||||
QgsCoordinateReferenceSystem(4326), source_id_2, dest_id_2))
|
||||
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:4204', 'EPSG:4326'): QgsCoordinateTransform.TransformPair(source_id_1, dest_id_1),
|
||||
('EPSG:4205', 'EPSG:4326'): QgsCoordinateTransform.TransformPair(source_id_2, dest_id_2)})
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:4204', 'EPSG:4326'): QgsDatumTransform.TransformPair(source_id_1, dest_id_1),
|
||||
('EPSG:4205', 'EPSG:4326'): QgsDatumTransform.TransformPair(source_id_2, dest_id_2)})
|
||||
|
||||
# save to xml
|
||||
doc = QDomDocument("testdoc")
|
||||
@ -329,8 +330,8 @@ class TestQgsCoordinateTransformContext(unittest.TestCase):
|
||||
context2.readXml(elem, QgsReadWriteContext())
|
||||
|
||||
# check result
|
||||
self.assertEqual(context2.sourceDestinationDatumTransforms(), {('EPSG:4204', 'EPSG:4326'): QgsCoordinateTransform.TransformPair(source_id_1, dest_id_1),
|
||||
('EPSG:4205', 'EPSG:4326'): QgsCoordinateTransform.TransformPair(source_id_2, dest_id_2)})
|
||||
self.assertEqual(context2.sourceDestinationDatumTransforms(), {('EPSG:4204', 'EPSG:4326'): QgsDatumTransform.TransformPair(source_id_1, dest_id_1),
|
||||
('EPSG:4205', 'EPSG:4326'): QgsDatumTransform.TransformPair(source_id_2, dest_id_2)})
|
||||
|
||||
def testMissingTransforms(self):
|
||||
# fudge context xml with a missing transform
|
||||
@ -366,7 +367,7 @@ class TestQgsCoordinateTransformContext(unittest.TestCase):
|
||||
QgsCoordinateReferenceSystem('EPSG:4283'), 1, 2)
|
||||
project.setTransformContext(context)
|
||||
self.assertEqual(len(context_changed_spy), 1)
|
||||
self.assertEqual(project.transformContext().sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsCoordinateTransform.TransformPair(1, 2)})
|
||||
self.assertEqual(project.transformContext().sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): QgsDatumTransform.TransformPair(1, 2)})
|
||||
|
||||
def testReadWriteSettings(self):
|
||||
context = QgsCoordinateTransformContext()
|
||||
@ -391,8 +392,8 @@ class TestQgsCoordinateTransformContext(unittest.TestCase):
|
||||
QgsCoordinateReferenceSystem(4326), source_id_2, dest_id_2))
|
||||
|
||||
self.assertEqual(context.sourceDestinationDatumTransforms(),
|
||||
{('EPSG:4204', 'EPSG:4326'): QgsCoordinateTransform.TransformPair(source_id_1, dest_id_1),
|
||||
('EPSG:4205', 'EPSG:4326'): QgsCoordinateTransform.TransformPair(source_id_2, dest_id_2)})
|
||||
{('EPSG:4204', 'EPSG:4326'): QgsDatumTransform.TransformPair(source_id_1, dest_id_1),
|
||||
('EPSG:4205', 'EPSG:4326'): QgsDatumTransform.TransformPair(source_id_2, dest_id_2)})
|
||||
|
||||
# save to settings
|
||||
context.writeSettings()
|
||||
@ -404,8 +405,8 @@ class TestQgsCoordinateTransformContext(unittest.TestCase):
|
||||
|
||||
# check result
|
||||
self.assertEqual(context2.sourceDestinationDatumTransforms(),
|
||||
{('EPSG:4204', 'EPSG:4326'): QgsCoordinateTransform.TransformPair(source_id_1, dest_id_1),
|
||||
('EPSG:4205', 'EPSG:4326'): QgsCoordinateTransform.TransformPair(source_id_2, dest_id_2)})
|
||||
{('EPSG:4204', 'EPSG:4326'): QgsDatumTransform.TransformPair(source_id_1, dest_id_1),
|
||||
('EPSG:4205', 'EPSG:4326'): QgsDatumTransform.TransformPair(source_id_2, dest_id_2)})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
x
Reference in New Issue
Block a user