Skip to content

Commit

Permalink
Tweak transform logic (only remove src/dest transforms when both tran…
Browse files Browse the repository at this point in the history
…sforms are -1)
  • Loading branch information
nyalldawson committed Dec 15, 2017
1 parent fed8a67 commit 754a6e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/qgscoordinatetransformcontext.cpp
Expand Up @@ -115,7 +115,7 @@ bool QgsCoordinateTransformContext::addSourceDestinationDatumTransform( const Qg

d.detach();
d->mLock.lockForWrite();
if ( sourceTransform == -1 || destinationTransform == -1 )
if ( sourceTransform == -1 && destinationTransform == -1 )
{
d->mSourceDestDatumTransforms.remove( qMakePair( sourceCrs.authid(), destinationCrs.authid() ) );
}
Expand Down
11 changes: 9 additions & 2 deletions tests/src/python/test_qgscoordinatetransformcontext.py
Expand Up @@ -129,11 +129,18 @@ def testSourceDestinationDatumTransforms(self):
# remove existing
self.assertTrue(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(3111),
QgsCoordinateReferenceSystem(4283), -1, 3))
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:28356', 'EPSG:4283'): (3, 4),
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): (-1, 3),
('EPSG:28356', 'EPSG:4283'): (3, 4),
('EPSG:28356', 'EPSG:28357'): (9, 11)})
self.assertTrue(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(28356),
QgsCoordinateReferenceSystem(28357), 1, -1))
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:28356', 'EPSG:4283'): (3, 4)})
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): (-1, 3),
('EPSG:28356', 'EPSG:4283'): (3, 4),
('EPSG:28356', 'EPSG:28357'): (1, -1)})
self.assertTrue(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(28356),
QgsCoordinateReferenceSystem(28357), -1, -1))
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): (-1, 3),
('EPSG:28356', 'EPSG:4283'): (3, 4)})

context.clear()
self.assertEqual(context.sourceDestinationDatumTransforms(), {})
Expand Down

0 comments on commit 754a6e0

Please sign in to comment.