Skip to content
Permalink
Browse files

datum transforms have reversible source/dest

  • Loading branch information
3nids authored and nyalldawson committed Nov 28, 2017
1 parent d18dac0 commit 4eab13df8a1287fd426916a675436b3918897220
@@ -115,6 +115,9 @@ class QgsCoordinateTransformContext
%Docstring
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.
:rtype: bool
%End

@@ -126,6 +129,10 @@ class QgsCoordinateTransformContext

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

.. note::

source and destination are reversible.
:rtype: QPair< int, int >
%End

@@ -127,6 +127,7 @@ void QgsCoordinateTransformContext::removeSourceDestinationDatumTransform( const
bool QgsCoordinateTransformContext::hasTransform( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination ) const
{
QPair<int, int> t = calculateDatumTransforms( source, destination );
// calculateDatumTransforms already takes care of switching source and destination
return t.first != -1 || t.second != -1;
}

@@ -138,6 +139,12 @@ QPair<int, int> QgsCoordinateTransformContext::calculateDatumTransforms( const Q
d->mLock.lockForRead();
// highest priority is exact match for source/dest pair
QPair< int, int > res = d->mSourceDestDatumTransforms.value( qMakePair( srcKey, destKey ), qMakePair( -1, -1 ) );
if ( res == qMakePair( -1, -1 ) )
{
// try to reverse
QPair< int, int > res2 = d->mSourceDestDatumTransforms.value( qMakePair( destKey, srcKey ), qMakePair( -1, -1 ) );
res = qMakePair( res2.second, res2.first );
}
d->mLock.unlock();
return res;

@@ -212,6 +212,7 @@ class CORE_EXPORT QgsCoordinateTransformContext
/**
* Returns true if the context has a valid datum transform to use
* when transforming from the specified \a source CRS to \a destination CRS.
* \note source and destination are reversible.
*/
bool hasTransform( const QgsCoordinateReferenceSystem &source,
const QgsCoordinateReferenceSystem &destination ) const;
@@ -222,6 +223,8 @@ class CORE_EXPORT QgsCoordinateTransformContext
*
* Returns -1 if a datum transform should not be used for the source or
* destination.
*
* \note source and destination are reversible.
*/
QPair< int, int > calculateDatumTransforms( const QgsCoordinateReferenceSystem &source,
const QgsCoordinateReferenceSystem &destination ) const;

0 comments on commit 4eab13d

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