Skip to content

Commit

Permalink
Fix allow fallback determination for reversed operations
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 17, 2020
1 parent e3b1649 commit 69950ae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/core/qgscoordinatetransformcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ bool QgsCoordinateTransformContext::allowFallbackTransform( const QgsCoordinateR

d->mLock.lockForRead();
QgsCoordinateTransformContextPrivate::OperationDetails res = d->mSourceDestDatumTransforms.value( qMakePair( srcKey, destKey ), QgsCoordinateTransformContextPrivate::OperationDetails() );
if ( res.operation.isEmpty() )
{
// try to reverse
res = d->mSourceDestDatumTransforms.value( qMakePair( destKey, srcKey ), QgsCoordinateTransformContextPrivate::OperationDetails() );
}
d->mLock.unlock();
return res.allowFallback;
#else
Expand Down
14 changes: 12 additions & 2 deletions tests/src/python/test_qgscoordinatetransformcontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ def testSourceDestinationDatumTransformsProj6(self):
QgsCoordinateReferenceSystem('EPSG:3111')))
self.assertTrue(
context.allowFallbackTransform(QgsCoordinateReferenceSystem('EPSG:3111'), QgsCoordinateReferenceSystem('EPSG:4283')))
self.assertTrue(
context.allowFallbackTransform(QgsCoordinateReferenceSystem('EPSG:4283'), QgsCoordinateReferenceSystem('EPSG:3111')))

self.assertTrue(
context.hasTransform(QgsCoordinateReferenceSystem('EPSG:4283'), QgsCoordinateReferenceSystem('EPSG:3111')))
Expand All @@ -186,11 +188,19 @@ def testSourceDestinationDatumTransformsProj6(self):
QgsCoordinateReferenceSystem('EPSG:3111')), proj_string_2)
self.assertFalse(context.mustReverseCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:4283'),
QgsCoordinateReferenceSystem('EPSG:3111')))
self.assertFalse(
context.allowFallbackTransform(QgsCoordinateReferenceSystem('EPSG:4283'), QgsCoordinateReferenceSystem('EPSG:3111')))
context.removeCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:4283'),
QgsCoordinateReferenceSystem('EPSG:3111'))

self.assertTrue(context.addCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:4283'),
QgsCoordinateReferenceSystem('EPSG:3113'), proj_string_2, False))
self.assertFalse(
context.allowFallbackTransform(QgsCoordinateReferenceSystem('EPSG:4283'), QgsCoordinateReferenceSystem('EPSG:3113')))
self.assertFalse(
context.allowFallbackTransform(QgsCoordinateReferenceSystem('EPSG:3113'), QgsCoordinateReferenceSystem('EPSG:4283')))

context.removeCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:4283'),
QgsCoordinateReferenceSystem('EPSG:3113'))

proj_string_2 = '+proj=pipeline +step +inv +proj=utm +zone=56 +south +ellps=GRS80 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1'
self.assertTrue(context.addCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:28356'),
QgsCoordinateReferenceSystem(4283), proj_string_2))
Expand Down

0 comments on commit 69950ae

Please sign in to comment.