Skip to content

Commit

Permalink
Added python test for qgscoordinatetransform
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux committed Aug 26, 2012
1 parent 91c0771 commit 9f26cc7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ ADD_PYTHON_TEST(PyQgsGeometry test_qgsgeometry.py)
ADD_PYTHON_TEST(PyQgsRasterLayer test_qgsrasterlayer.py)
ADD_PYTHON_TEST(PyQgsMemoryProvider test_qgsmemoryprovider.py)
ADD_PYTHON_TEST(PyQgsLogger test_qgslogger.py)
ADD_PYTHON_TEST(PyQgsCoordinateTransform test_qgscoordinatetransform.py)
34 changes: 34 additions & 0 deletions tests/src/python/test_qgscoordinatetransform.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import unittest

from qgis.core import (QgsRectangle,
QgsCoordinateReferenceSystem,
QgsCoordinateTransform,
QGis)

# Convenience instances in case you may need them
# not used in this test
#from utilities import getQgisTestApp
#QGISAPP, CANVAS, IFACE, PARENT = getQgisTestApp()

class TestQgsCoordinateTransform(unittest.TestCase):

def testTransformBoundingBox(self):
myExtent = QgsRectangle(242270, 6043737, 246330, 6045897)
myGeoCrs = QgsCoordinateReferenceSystem()
myGeoCrs.createFromId(4326, QgsCoordinateReferenceSystem.EpsgCrsId)
myUtmCrs = QgsCoordinateReferenceSystem()
myUtmCrs.createFromId(32756, QgsCoordinateReferenceSystem.EpsgCrsId)
myXForm = QgsCoordinateTransform(myGeoCrs, myUtmCrs)
myProjectedExtent = myXForm.transformBoundingBox(myExtent)
#myProjectedExtent.xMinimum()
#myProjectedExtent.xMaximum()
myExpectedExtent = ''
myMessage = ('Expected:\n%s\nGot:\n%s\n' %
( myExpectedExtent,
myProjectedExtent.toString())

assert myExpectedExtent == myProjectedExtent, myMessage

if __name__ == '__main__':
unittest.main()

0 comments on commit 9f26cc7

Please sign in to comment.