本文整理汇总了Python中qgis.core.QgsCoordinateTransformContext类的典型用法代码示例。如果您正苦于以下问题:Python QgsCoordinateTransformContext类的具体用法?Python QgsCoordinateTransformContext怎么用?Python QgsCoordinateTransformContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QgsCoordinateTransformContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testWriteReadXml
def testWriteReadXml(self):
# setup a context
context = QgsCoordinateTransformContext()
source_id_1 = QgsDatumTransform.datumTransformations(QgsCoordinateReferenceSystem(4204),
QgsCoordinateReferenceSystem(4326))[0].sourceTransformId
dest_id_1 = QgsDatumTransform.datumTransformations(QgsCoordinateReferenceSystem(4204),
QgsCoordinateReferenceSystem(4326))[0].destinationTransformId
source_id_2 = QgsDatumTransform.datumTransformations(QgsCoordinateReferenceSystem(4205),
QgsCoordinateReferenceSystem(4326))[0].sourceTransformId
dest_id_2 = QgsDatumTransform.datumTransformations(QgsCoordinateReferenceSystem(4205),
QgsCoordinateReferenceSystem(4326))[0].destinationTransformId
self.assertTrue(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(4204),
QgsCoordinateReferenceSystem(4326), source_id_1, dest_id_1))
self.assertTrue(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(4205),
QgsCoordinateReferenceSystem(4326), 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")
elem = doc.createElement("test")
context.writeXml(elem, QgsReadWriteContext())
# restore from xml
context2 = QgsCoordinateTransformContext()
context2.readXml(elem, QgsReadWriteContext())
# check result
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)})
开发者ID:alexbruy,项目名称:QGIS,代码行数:34,代码来源:test_qgscoordinatetransformcontext.py
示例2: testMissingTransformsProj6
def testMissingTransformsProj6(self):
return # TODO -- this seems impossible to determine with existing PROJ6 api
# fudge context xml with a missing transform
doc = QDomDocument("testdoc")
elem = doc.createElement("test")
contextElem = doc.createElement("transformContext")
transformElem = doc.createElement("srcDest")
transformElem.setAttribute("source", 'EPSG:4204')
transformElem.setAttribute("dest", 'EPSG:4326')
# fake a proj string with a grid which will NEVER exist
fake_proj = '+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +inv +proj=hgridshift +grids=this_is_not_a_real_grid.gsb +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1'
transformElem.setAttribute("coordinateOp", fake_proj)
contextElem.appendChild(transformElem)
elem2 = doc.createElement("test2")
elem2.appendChild(contextElem)
# restore from xml
context2 = QgsCoordinateTransformContext()
ok, errors = context2.readXml(elem2, QgsReadWriteContext())
self.assertFalse(ok)
# check result
self.assertEqual(errors, ['not valid'])
开发者ID:digitalsatori,项目名称:QGIS,代码行数:25,代码来源:test_qgscoordinatetransformcontext.py
示例3: testWriteReadXmlProj6
def testWriteReadXmlProj6(self):
# setup a context
context = QgsCoordinateTransformContext()
proj_1 = '+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=push +v_3 +step +proj=cart +ellps=intl +step +proj=helmert +x=-18.944 +y=-379.364 +z=-24.063 +rx=-0.04 +ry=0.764 +rz=-6.431 +s=3.657 +convention=coordinate_frame +step +inv +proj=cart +ellps=WGS84 +step +proj=pop +v_3 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1'
proj_2 = '+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=push +v_3 +step +proj=cart +ellps=intl +step +proj=helmert +x=-150 +y=-250 +z=-1 +step +inv +proj=cart +ellps=WGS84 +step +proj=pop +v_3 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1'
self.assertTrue(context.addCoordinateOperation(QgsCoordinateReferenceSystem(4204),
QgsCoordinateReferenceSystem(4326), proj_1))
self.assertTrue(context.addCoordinateOperation(QgsCoordinateReferenceSystem(4205),
QgsCoordinateReferenceSystem(4326), proj_2))
self.assertEqual(context.coordinateOperations(),
{('EPSG:4204', 'EPSG:4326'): proj_1,
('EPSG:4205', 'EPSG:4326'): proj_2})
# save to xml
doc = QDomDocument("testdoc")
elem = doc.createElement("test")
context.writeXml(elem, QgsReadWriteContext())
# restore from xml
context2 = QgsCoordinateTransformContext()
context2.readXml(elem, QgsReadWriteContext())
# check result
self.assertEqual(context2.coordinateOperations(),
{('EPSG:4204', 'EPSG:4326'): proj_1,
('EPSG:4205', 'EPSG:4326'): proj_2})
开发者ID:digitalsatori,项目名称:QGIS,代码行数:29,代码来源:test_qgscoordinatetransformcontext.py
示例4: testContext
def testContext(self):
"""
Various tests to ensure that datum transforms are correctly set respecting context
"""
context = QgsCoordinateTransformContext()
context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:28356'),
QgsCoordinateReferenceSystem('EPSG:4283'),
3, 4)
transform = QgsCoordinateTransform(QgsCoordinateReferenceSystem('EPSG:28354'), QgsCoordinateReferenceSystem('EPSG:28353'), context)
self.assertEqual(list(transform.context().sourceDestinationDatumTransforms().keys()), [('EPSG:28356', 'EPSG:4283')])
# should be no datum transforms
self.assertEqual(transform.sourceDatumTransformId(), -1)
self.assertEqual(transform.destinationDatumTransformId(), -1)
# matching source
transform = QgsCoordinateTransform(QgsCoordinateReferenceSystem('EPSG:28356'), QgsCoordinateReferenceSystem('EPSG:28353'), context)
self.assertEqual(transform.sourceDatumTransformId(), -1)
self.assertEqual(transform.destinationDatumTransformId(), -1)
# matching dest
transform = QgsCoordinateTransform(QgsCoordinateReferenceSystem('EPSG:28354'),
QgsCoordinateReferenceSystem('EPSG:4283'), context)
self.assertEqual(transform.sourceDatumTransformId(), -1)
self.assertEqual(transform.destinationDatumTransformId(), -1)
# matching src/dest pair
transform = QgsCoordinateTransform(QgsCoordinateReferenceSystem('EPSG:28356'),
QgsCoordinateReferenceSystem('EPSG:4283'), context)
self.assertEqual(transform.sourceDatumTransformId(), 3)
self.assertEqual(transform.destinationDatumTransformId(), 4)
# test manual overwriting
transform.setSourceDatumTransformId(11)
transform.setDestinationDatumTransformId(13)
self.assertEqual(transform.sourceDatumTransformId(), 11)
self.assertEqual(transform.destinationDatumTransformId(), 13)
# test that auto datum setting occurs when updating src/dest crs
transform.setSourceCrs(QgsCoordinateReferenceSystem('EPSG:28356'))
self.assertEqual(transform.sourceDatumTransformId(), 3)
self.assertEqual(transform.destinationDatumTransformId(), 4)
transform.setSourceDatumTransformId(11)
transform.setDestinationDatumTransformId(13)
transform.setDestinationCrs(QgsCoordinateReferenceSystem('EPSG:4283'))
self.assertEqual(transform.sourceDatumTransformId(), 3)
self.assertEqual(transform.destinationDatumTransformId(), 4)
transform.setSourceDatumTransformId(11)
transform.setDestinationDatumTransformId(13)
# delayed context set
transform = QgsCoordinateTransform()
self.assertEqual(transform.sourceDatumTransformId(), -1)
self.assertEqual(transform.destinationDatumTransformId(), -1)
transform.setSourceCrs(QgsCoordinateReferenceSystem('EPSG:28356'))
transform.setDestinationCrs(QgsCoordinateReferenceSystem('EPSG:4283'))
self.assertEqual(transform.sourceDatumTransformId(), -1)
self.assertEqual(transform.destinationDatumTransformId(), -1)
transform.setContext(context)
self.assertEqual(transform.sourceDatumTransformId(), 3)
self.assertEqual(transform.destinationDatumTransformId(), 4)
self.assertEqual(list(transform.context().sourceDestinationDatumTransforms().keys()), [('EPSG:28356', 'EPSG:4283')])
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:60,代码来源:test_qgscoordinatetransform.py
示例5: testTransformContextSignalIsEmitted
def testTransformContextSignalIsEmitted(self):
"""Test that when a project transform context changes a transformContextChanged signal is emitted"""
p = QgsProject()
spy = QSignalSpy(p.transformContextChanged)
ctx = QgsCoordinateTransformContext()
ctx.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3857), 1234, 1235)
p.setTransformContext(ctx)
self.assertEqual(len(spy), 1)
开发者ID:boundlessgeo,项目名称:QGIS,代码行数:9,代码来源:test_qgsproject.py
示例6: TestQgsRasterLayerTransformContext
class TestQgsRasterLayerTransformContext(unittest.TestCase):
def setUp(self):
"""Prepare tc"""
super(TestQgsRasterLayerTransformContext, self).setUp()
self.ctx = QgsCoordinateTransformContext()
self.ctx.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3857), 1234, 1235)
self.rpath = os.path.join(unitTestDataPath(), 'landsat.tif')
def testTransformContextIsSetInCtor(self):
"""Test transform context can be set from ctor"""
rl = QgsRasterLayer(self.rpath, 'raster')
self.assertFalse(rl.transformContext().hasTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3857)))
options = QgsRasterLayer.LayerOptions(transformContext=self.ctx)
rl = QgsRasterLayer(self.rpath, 'raster', 'gdal', options)
self.assertTrue(rl.transformContext().hasTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3857)))
def testTransformContextInheritsFromProject(self):
"""Test that when a layer is added to a project it inherits its context"""
rl = QgsRasterLayer(self.rpath, 'raster')
self.assertFalse(rl.transformContext().hasTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3857)))
p = QgsProject()
self.assertFalse(p.transformContext().hasTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3857)))
p.setTransformContext(self.ctx)
self.assertTrue(p.transformContext().hasTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3857)))
p.addMapLayers([rl])
self.assertTrue(rl.transformContext().hasTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3857)))
def testTransformContextIsSyncedFromProject(self):
"""Test that when a layer is synced when project context changes"""
rl = QgsRasterLayer(self.rpath, 'raster')
self.assertFalse(rl.transformContext().hasTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3857)))
p = QgsProject()
self.assertFalse(p.transformContext().hasTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3857)))
p.setTransformContext(self.ctx)
self.assertTrue(p.transformContext().hasTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3857)))
p.addMapLayers([rl])
self.assertTrue(rl.transformContext().hasTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3857)))
# Now change the project context
tc2 = QgsCoordinateTransformContext()
p.setTransformContext(tc2)
self.assertFalse(p.transformContext().hasTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3857)))
self.assertFalse(rl.transformContext().hasTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3857)))
p.setTransformContext(self.ctx)
self.assertTrue(p.transformContext().hasTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3857)))
self.assertTrue(rl.transformContext().hasTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3857)))
开发者ID:m-kuhn,项目名称:QGIS,代码行数:55,代码来源:test_qgsrasterlayer.py
示例7: testCalculateSourceDest
def testCalculateSourceDest(self):
context = QgsCoordinateTransformContext()
#empty context
self.assertEqual(context.calculateDatumTransforms(QgsCoordinateReferenceSystem('EPSG:3111'),
QgsCoordinateReferenceSystem('EPSG:4283')),
QgsDatumTransform.TransformPair(-1, -1))
#add specific source/dest pair - should take precedence
context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:28356'),
QgsCoordinateReferenceSystem('EPSG:4283'),
3, 4)
self.assertEqual(context.calculateDatumTransforms(QgsCoordinateReferenceSystem('EPSG:28356'),
QgsCoordinateReferenceSystem('EPSG:4283')),
QgsDatumTransform.TransformPair(3, 4))
self.assertEqual(context.calculateDatumTransforms(QgsCoordinateReferenceSystem('EPSG:3111'),
QgsCoordinateReferenceSystem('EPSG:4283')),
QgsDatumTransform.TransformPair(-1, -1))
self.assertEqual(context.calculateDatumTransforms(QgsCoordinateReferenceSystem('EPSG:28356'),
QgsCoordinateReferenceSystem('EPSG:3111')),
QgsDatumTransform.TransformPair(-1, -1))
# check that reverse transforms are automatically supported
self.assertEqual(context.calculateDatumTransforms(QgsCoordinateReferenceSystem('EPSG:4283'),
QgsCoordinateReferenceSystem('EPSG:28356')),
QgsDatumTransform.TransformPair(4, 3))
开发者ID:alexbruy,项目名称:QGIS,代码行数:25,代码来源:test_qgscoordinatetransformcontext.py
示例8: testCalculateSourceDestProj6
def testCalculateSourceDestProj6(self):
context = QgsCoordinateTransformContext()
# empty context
self.assertEqual(context.calculateCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:3111'),
QgsCoordinateReferenceSystem('EPSG:4283')),
'')
# add specific source/dest pair - should take precedence
context.addCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:28356'),
QgsCoordinateReferenceSystem('EPSG:4283'),
'proj 1')
self.assertEqual(context.calculateCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:28356'),
QgsCoordinateReferenceSystem('EPSG:4283')),
'proj 1')
self.assertEqual(context.calculateCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:3111'),
QgsCoordinateReferenceSystem('EPSG:4283')),
'')
self.assertEqual(context.calculateCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:28356'),
QgsCoordinateReferenceSystem('EPSG:3111')),
'')
# check that reverse transforms are automatically supported
self.assertEqual(context.calculateCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:4283'),
QgsCoordinateReferenceSystem('EPSG:28356')),
'proj 1')
开发者ID:digitalsatori,项目名称:QGIS,代码行数:25,代码来源:test_qgscoordinatetransformcontext.py
示例9: testContextProj6
def testContextProj6(self):
"""
Various tests to ensure that datum transforms are correctly set respecting context
"""
context = QgsCoordinateTransformContext()
context.addCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:28356'),
QgsCoordinateReferenceSystem('EPSG:4283'),
'proj')
transform = QgsCoordinateTransform(QgsCoordinateReferenceSystem('EPSG:28354'), QgsCoordinateReferenceSystem('EPSG:28353'), context)
self.assertEqual(list(transform.context().coordinateOperations().keys()), [('EPSG:28356', 'EPSG:4283')])
# should be no coordinate operation
self.assertEqual(transform.coordinateOperation(), '')
# matching source
transform = QgsCoordinateTransform(QgsCoordinateReferenceSystem('EPSG:28356'), QgsCoordinateReferenceSystem('EPSG:28353'), context)
self.assertEqual(transform.coordinateOperation(), '')
# matching dest
transform = QgsCoordinateTransform(QgsCoordinateReferenceSystem('EPSG:28354'),
QgsCoordinateReferenceSystem('EPSG:4283'), context)
self.assertEqual(transform.coordinateOperation(), '')
# matching src/dest pair
transform = QgsCoordinateTransform(QgsCoordinateReferenceSystem('EPSG:28356'),
QgsCoordinateReferenceSystem('EPSG:4283'), context)
self.assertEqual(transform.coordinateOperation(), 'proj')
# test manual overwriting
transform.setCoordinateOperation('proj2')
self.assertEqual(transform.coordinateOperation(), 'proj2')
# test that auto operation setting occurs when updating src/dest crs
transform.setSourceCrs(QgsCoordinateReferenceSystem('EPSG:28356'))
self.assertEqual(transform.coordinateOperation(), 'proj')
transform.setCoordinateOperation('proj2')
transform.setDestinationCrs(QgsCoordinateReferenceSystem('EPSG:4283'))
self.assertEqual(transform.coordinateOperation(), 'proj')
transform.setCoordinateOperation('proj2')
# delayed context set
transform = QgsCoordinateTransform()
self.assertEqual(transform.coordinateOperation(), '')
transform.setSourceCrs(QgsCoordinateReferenceSystem('EPSG:28356'))
transform.setDestinationCrs(QgsCoordinateReferenceSystem('EPSG:4283'))
self.assertEqual(transform.coordinateOperation(), '')
transform.setContext(context)
self.assertEqual(transform.coordinateOperation(), 'proj')
self.assertEqual(list(transform.context().coordinateOperations().keys()), [('EPSG:28356', 'EPSG:4283')])
开发者ID:digitalsatori,项目名称:QGIS,代码行数:49,代码来源:test_qgscoordinatetransform.py
示例10: testMissingTransforms
def testMissingTransforms(self):
# fudge context xml with a missing transform
doc = QDomDocument("testdoc")
elem = doc.createElement("test")
contextElem = doc.createElement("transformContext")
transformElem = doc.createElement("srcDest")
transformElem.setAttribute("source", 'EPSG:4204')
transformElem.setAttribute("dest", 'EPSG:4326')
transformElem.setAttribute("sourceTransform", 'not valid')
transformElem.setAttribute("destTransform", 'not valid 2')
contextElem.appendChild(transformElem)
elem2 = doc.createElement("test2")
elem2.appendChild(contextElem)
# restore from xml
context2 = QgsCoordinateTransformContext()
ok, errors = context2.readXml(elem2, QgsReadWriteContext())
self.assertFalse(ok)
# check result
self.assertEqual(errors, ['not valid', 'not valid 2'])
开发者ID:alexbruy,项目名称:QGIS,代码行数:22,代码来源:test_qgscoordinatetransformcontext.py
示例11: testEqualOperator
def testEqualOperator(self):
context1 = QgsCoordinateTransformContext()
context2 = QgsCoordinateTransformContext()
self.assertTrue(context1 == context2)
context1.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:3111'),
QgsCoordinateReferenceSystem('EPSG:4283'), 1, 2)
self.assertFalse(context1 == context2)
context2.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:3111'),
QgsCoordinateReferenceSystem('EPSG:4283'), 1, 2)
self.assertTrue(context1 == context2)
开发者ID:alexbruy,项目名称:QGIS,代码行数:12,代码来源:test_qgscoordinatetransformcontext.py
示例12: testEqualOperatorProj6
def testEqualOperatorProj6(self):
context1 = QgsCoordinateTransformContext()
context2 = QgsCoordinateTransformContext()
self.assertTrue(context1 == context2)
context1.addCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:3111'),
QgsCoordinateReferenceSystem('EPSG:4283'), 'p1')
self.assertFalse(context1 == context2)
context2.addCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:3111'),
QgsCoordinateReferenceSystem('EPSG:4283'), 'p1')
self.assertTrue(context1 == context2)
开发者ID:digitalsatori,项目名称:QGIS,代码行数:12,代码来源:test_qgscoordinatetransformcontext.py
示例13: testSourceDestinationDatumTransformsProj6
def testSourceDestinationDatumTransformsProj6(self):
context = QgsCoordinateTransformContext()
self.assertEqual(context.sourceDestinationDatumTransforms(), {})
proj_string = '+proj=pipeline +step +inv +proj=lcc +lat_0=-37 +lon_0=145 +lat_1=-36 +lat_2=-38 +x_0=2500000 +y_0=2500000 +ellps=GRS80 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1'
self.assertFalse(
context.hasTransform(QgsCoordinateReferenceSystem('EPSG:3111'), QgsCoordinateReferenceSystem('EPSG:4283')))
self.assertTrue(context.addCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:3111'),
QgsCoordinateReferenceSystem('EPSG:4283'), proj_string))
self.assertTrue(
context.hasTransform(QgsCoordinateReferenceSystem('EPSG:3111'), QgsCoordinateReferenceSystem('EPSG:4283')))
self.assertFalse(
context.hasTransform(QgsCoordinateReferenceSystem('EPSG:3111'), QgsCoordinateReferenceSystem('EPSG:4326')))
self.assertFalse(
context.hasTransform(QgsCoordinateReferenceSystem('EPSG:3113'), QgsCoordinateReferenceSystem('EPSG:4283')))
self.assertEqual(context.coordinateOperations(), {('EPSG:3111', 'EPSG:4283'): proj_string})
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))
self.assertEqual(context.coordinateOperations(), {('EPSG:3111', 'EPSG:4283'): proj_string,
('EPSG:28356', 'EPSG:4283'): proj_string_2})
proj_string_3 = '+proj=pipeline +step +inv +proj=utm +zone=56 +south +ellps=GRS80 +step +proj=utm +zone=57 +south +ellps=GRS80'
self.assertTrue(context.addCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:28356'),
QgsCoordinateReferenceSystem(28357), proj_string_3))
self.assertEqual(context.coordinateOperations(), {('EPSG:3111', 'EPSG:4283'): proj_string,
('EPSG:28356', 'EPSG:4283'): proj_string_2,
('EPSG:28356', 'EPSG:28357'): proj_string_3})
self.assertTrue(context.addCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:28356'),
QgsCoordinateReferenceSystem('EPSG:28357'),
'some other proj string'))
self.assertEqual(context.coordinateOperations(), {('EPSG:3111', 'EPSG:4283'): proj_string,
('EPSG:28356', 'EPSG:4283'): proj_string_2,
('EPSG:28356', 'EPSG:28357'): 'some other proj string'})
# invalid additions
self.assertFalse(context.addCoordinateOperation(QgsCoordinateReferenceSystem(),
QgsCoordinateReferenceSystem('EPSG:28357'), 'bad proj'))
self.assertEqual(context.coordinateOperations(), {('EPSG:3111', 'EPSG:4283'): proj_string,
('EPSG:28356', 'EPSG:4283'): proj_string_2,
('EPSG:28356', 'EPSG:28357'): 'some other proj string'})
self.assertFalse(context.addCoordinateOperation(QgsCoordinateReferenceSystem('EPSG:3111'),
QgsCoordinateReferenceSystem(), 'bad proj'))
self.assertEqual(context.coordinateOperations(), {('EPSG:3111', 'EPSG:4283'): proj_string,
('EPSG:28356', 'EPSG:4283'): proj_string_2,
('EPSG:28356', 'EPSG:28357'): 'some other proj string'})
# indicate no transform required
self.assertTrue(context.addCoordinateOperation(QgsCoordinateReferenceSystem(28357),
QgsCoordinateReferenceSystem(28356), ''))
self.assertEqual(context.coordinateOperations(), {('EPSG:3111', 'EPSG:4283'): proj_string,
('EPSG:28356', 'EPSG:4283'): proj_string_2,
('EPSG:28356', 'EPSG:28357'): 'some other proj string',
('EPSG:28357', 'EPSG:28356'): ''})
# remove non-existing
context.removeCoordinateOperation(QgsCoordinateReferenceSystem(3113), QgsCoordinateReferenceSystem(3111))
self.assertEqual(context.coordinateOperations(), {('EPSG:3111', 'EPSG:4283'): proj_string,
('EPSG:28356', 'EPSG:4283'): proj_string_2,
('EPSG:28356', 'EPSG:28357'): 'some other proj string',
('EPSG:28357', 'EPSG:28356'): ''})
# remove existing
context.removeCoordinateOperation(QgsCoordinateReferenceSystem(3111),
QgsCoordinateReferenceSystem(4283))
self.assertEqual(context.coordinateOperations(), {('EPSG:28356', 'EPSG:4283'): proj_string_2,
('EPSG:28356', 'EPSG:28357'): 'some other proj string',
('EPSG:28357', 'EPSG:28356'): ''})
context.removeCoordinateOperation(QgsCoordinateReferenceSystem(28356),
QgsCoordinateReferenceSystem(28357))
self.assertEqual(context.coordinateOperations(), {('EPSG:28356', 'EPSG:4283'): proj_string_2,
('EPSG:28357', 'EPSG:28356'): ''})
context.clear()
self.assertEqual(context.coordinateOperations(), {})
开发者ID:digitalsatori,项目名称:QGIS,代码行数:73,代码来源:test_qgscoordinatetransformcontext.py
示例14: setUp
def setUp(self):
"""Prepare tc"""
super(TestQgsRasterLayerTransformContext, self).setUp()
self.ctx = QgsCoordinateTransformContext()
self.ctx.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem(4326), QgsCoordinateReferenceSystem(3857), 1234, 1235)
self.rpath = os.path.join(unitTestDataPath(), 'landsat.tif')
开发者ID:m-kuhn,项目名称:QGIS,代码行数:6,代码来源:test_qgsrasterlayer.py
示例15: testReadWriteSettingsProj6
def testReadWriteSettingsProj6(self):
context = QgsCoordinateTransformContext()
context.readSettings()
proj_1 = '+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=push +v_3 +step +proj=cart +ellps=intl +step +proj=helmert +x=-18.944 +y=-379.364 +z=-24.063 +rx=-0.04 +ry=0.764 +rz=-6.431 +s=3.657 +convention=coordinate_frame +step +inv +proj=cart +ellps=WGS84 +step +proj=pop +v_3 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1'
proj_2 = '+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=push +v_3 +step +proj=cart +ellps=intl +step +proj=helmert +x=-150 +y=-250 +z=-1 +step +inv +proj=cart +ellps=WGS84 +step +proj=pop +v_3 +step +proj=unitconvert +xy_in=rad +xy_out=deg +step +proj=axisswap +order=2,1'
# should be empty
self.assertEqual(context.coordinateOperations(), {})
self.assertTrue(context.addCoordinateOperation(QgsCoordinateReferenceSystem(4204),
QgsCoordinateReferenceSystem(4326), proj_1))
self.assertTrue(context.addCoordinateOperation(QgsCoordinateReferenceSystem(4205),
QgsCoordinateReferenceSystem(4326), proj_2))
self.assertEqual(context.coordinateOperations(),
{('EPSG:4204', 'EPSG:4326'): proj_1,
('EPSG:4205', 'EPSG:4326'): proj_2})
# save to settings
context.writeSettings()
# restore from settings
context2 = QgsCoordinateTransformContext()
self.assertEqual(context2.coordinateOperations(), {})
context2.readSettings()
# check result
self.assertEqual(context2.coordinateOperations(),
{('EPSG:4204', 'EPSG:4326'): proj_1,
('EPSG:4205', 'EPSG:4326'): proj_2})
开发者ID:digitalsatori,项目名称:QGIS,代码行数:31,代码来源:test_qgscoordinatetransformcontext.py
示例16: testDestDatumTransforms
def testDestDatumTransforms(self):
context = QgsCoordinateTransformContext()
self.assertEqual(context.destinationDatumTransforms(), {})
self.assertTrue(context.addDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:3111'), 1))
self.assertEqual(context.destinationDatumTransforms(), {'EPSG:3111': 1})
self.assertTrue(context.addDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:28356'), 2))
self.assertEqual(context.destinationDatumTransforms(), {'EPSG:3111': 1, 'EPSG:28356': 2})
self.assertTrue(context.addDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:28356'), 3))
self.assertEqual(context.destinationDatumTransforms(), {'EPSG:3111': 1, 'EPSG:28356': 3})
self.assertTrue(context.addDestinationDatumTransform(QgsCoordinateReferenceSystem(28356), 3))
self.assertEqual(context.destinationDatumTransforms(), {'EPSG:3111': 1, 'EPSG:28356': 3})
# invalid crs should fail
self.assertFalse(context.addDestinationDatumTransform(QgsCoordinateReferenceSystem(), 4))
self.assertEqual(context.destinationDatumTransforms(), {'EPSG:3111': 1, 'EPSG:28356': 3})
# indicate no transform required
self.assertTrue(context.addDestinationDatumTransform(QgsCoordinateReferenceSystem(28357), -1))
self.assertEqual(context.destinationDatumTransforms(), {'EPSG:3111': 1, 'EPSG:28356': 3, 'EPSG:28357': -1})
# removing non-existing
context.removeSourceDatumTransform(QgsCoordinateReferenceSystem(28354))
self.assertEqual(context.destinationDatumTransforms(), {'EPSG:3111': 1, 'EPSG:28356': 3, 'EPSG:28357': -1})
# remove existing
context.removeDestinationDatumTransform(QgsCoordinateReferenceSystem(28356))
self.assertEqual(context.destinationDatumTransforms(), {'EPSG:3111': 1, 'EPSG:28357': -1})
context.clear()
self.assertEqual(context.destinationDatumTransforms(), {})
开发者ID:alexbruy,项目名称:QGIS,代码行数:30,代码来源:test_qgscoordinatetransformcontext.py
示例17: testReadWriteSettings
def testReadWriteSettings(self):
context = QgsCoordinateTransformContext()
context.readSettings()
source_id_1 = QgsDatumTransform.datumTransformations(QgsCoordinateReferenceSystem(4204),
QgsCoordinateReferenceSystem(4326))[0].sourceTransformId
dest_id_1 = QgsDatumTransform.datumTransformations(QgsCoordinateReferenceSystem(4204),
QgsCoordinateReferenceSystem(4326))[0].destinationTransformId
source_id_2 = QgsDatumTransform.datumTransformations(QgsCoordinateReferenceSystem(4205),
QgsCoordinateReferenceSystem(4326))[0].sourceTransformId
dest_id_2 = QgsDatumTransform.datumTransformations(QgsCoordinateReferenceSystem(4205),
QgsCoordinateReferenceSystem(4326))[0].destinationTransformId
# should be empty
self.assertEqual(context.sourceDestinationDatumTransforms(), {})
self.assertTrue(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:4204'),
QgsCoordinateReferenceSystem('EPSG:4326'), source_id_1, dest_id_1))
self.assertTrue(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:4205'),
QgsCoordinateReferenceSystem(4326), 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 settings
context.writeSettings()
# restore from settings
context2 = QgsCoordinateTransformContext()
self.assertEqual(context2.sourceDestinationDatumTransforms(), {})
context2.readSettings()
# check result
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)})
开发者ID:alexbruy,项目名称:QGIS,代码行数:38,代码来源:test_qgscoordinatetransformcontext.py
示例18: testWriteReadXmlSingleVariant
def testWriteReadXmlSingleVariant(self):
# setup a context
context = QgsCoordinateTransformContext()
self.assertTrue(context.addSourceDatumTransform(QgsCoordinateReferenceSystem('EPSG:3111'), 1))
self.assertTrue(context.addSourceDatumTransform(QgsCoordinateReferenceSystem('EPSG:28356'), 2))
self.assertTrue(context.addDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:3113'), 11))
self.assertTrue(context.addDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:28355'), 12))
self.assertTrue(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:3111'),
QgsCoordinateReferenceSystem('EPSG:4283'), 1, 2))
self.assertTrue(context.addSourceDestinationDatumTransform(QgsCoordinateReferenceSystem('EPSG:28356'),
QgsCoordinateReferenceSystem(4283), 3, 4))
self.assertEqual(context.sourceDatumTransforms(), {'EPSG:3111': 1, 'EPSG:28356': 2})
self.assertEqual(context.destinationDatumTransforms(), {'EPSG:3113': 11, 'EPSG:28355': 12})
self.assertEqual(context.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): (1, 2),
('EPSG:28356', 'EPSG:4283'): (3, 4)})
# save to xml
doc = QDomDocument("testdoc")
elem = doc.createElement("test")
context.writeXml(elem, QgsReadWriteContext())
# restore from xml
context2 = QgsCoordinateTransformContext()
context2.readXml(elem, QgsReadWriteContext())
# check result
self.assertEqual(context2.sourceDatumTransforms(), {'EPSG:3111': 1, 'EPSG:28356': 2})
self.assertEqual(context2.destinationDatumTransforms(), {'EPSG:3113': 11, 'EPSG:28355': 12})
self.assertEqual(context2.sourceDestinationDatumTransforms(), {('EPSG:3111', 'EPSG:4283'): (1, 2),
('EPSG:28356', 'EPSG:4283'): (3, 4)})
开发者ID:alexbruy,项目名称:QGIS,代码行数:31,代码来源:test_qgscoordinatetransformcontext.py
示例19: testCalculate
def testCalculate(self):
context = QgsCoordinateTransformContext()
#empty context
self.assertEqual(context.calculateDatumTransforms(QgsCoordinateReferenceSystem('EPSG:3111'),
QgsCoordinateReferenceSystem('EPSG:4283')),
(-1, -1))
#add src transform
context.addSourceDatumTransform(QgsCoordinateReferenceSystem('EPSG:28356'), 1)
self.asser
|
请发表评论