本文整理汇总了Python中qgis.PyQt.QtCore.QVariant.value方法的典型用法代码示例。如果您正苦于以下问题:Python QVariant.value方法的具体用法?Python QVariant.value怎么用?Python QVariant.value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtCore.QVariant
的用法示例。
在下文中一共展示了QVariant.value方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testRectangle
# 需要导入模块: from qgis.PyQt.QtCore import QVariant [as 别名]
# 或者: from qgis.PyQt.QtCore.QVariant import value [as 别名]
def testRectangle(self):
rect = QgsReferencedRectangle(QgsRectangle(0.0, 1.0, 20.0, 10.0), QgsCoordinateReferenceSystem('epsg:3111'))
self.assertEqual(rect.xMinimum(), 0.0)
self.assertEqual(rect.yMinimum(), 1.0)
self.assertEqual(rect.xMaximum(), 20.0)
self.assertEqual(rect.yMaximum(), 10.0)
self.assertEqual(rect.crs().authid(), 'EPSG:3111')
rect.setCrs(QgsCoordinateReferenceSystem('epsg:28356'))
self.assertEqual(rect.crs().authid(), 'EPSG:28356')
# in variant
v = QVariant(QgsReferencedRectangle(QgsRectangle(1.0, 2.0, 3.0, 4.0), QgsCoordinateReferenceSystem('epsg:3111')))
self.assertEqual(v.value().xMinimum(), 1.0)
self.assertEqual(v.value().yMinimum(), 2.0)
self.assertEqual(v.value().xMaximum(), 3.0)
self.assertEqual(v.value().yMaximum(), 4.0)
self.assertEqual(v.value().crs().authid(), 'EPSG:3111')
# to rectangle
r = QgsRectangle(rect)
self.assertEqual(r.xMinimum(), 0.0)
self.assertEqual(r.yMinimum(), 1.0)
self.assertEqual(r.xMaximum(), 20.0)
self.assertEqual(r.yMaximum(), 10.0)
# test that QgsReferencedRectangle IS a QgsRectangle
r2 = QgsRectangle(5, 6, 30, 40)
r2.combineExtentWith(rect)
self.assertEqual(r2.xMinimum(), 0.0)
self.assertEqual(r2.yMinimum(), 1.0)
self.assertEqual(r2.xMaximum(), 30.0)
self.assertEqual(r2.yMaximum(), 40.0)
示例2: testPoint
# 需要导入模块: from qgis.PyQt.QtCore import QVariant [as 别名]
# 或者: from qgis.PyQt.QtCore.QVariant import value [as 别名]
def testPoint(self):
point = QgsReferencedPointXY(QgsPointXY(1.0, 2.0), QgsCoordinateReferenceSystem('epsg:3111'))
self.assertEqual(point.x(), 1.0)
self.assertEqual(point.y(), 2.0)
self.assertEqual(point.crs().authid(), 'EPSG:3111')
point.setCrs(QgsCoordinateReferenceSystem('epsg:28356'))
self.assertEqual(point.crs().authid(), 'EPSG:28356')
# in variant
v = QVariant(QgsReferencedPointXY(QgsPointXY(3.0, 4.0), QgsCoordinateReferenceSystem('epsg:3111')))
self.assertEqual(v.value().x(), 3.0)
self.assertEqual(v.value().y(), 4.0)
self.assertEqual(v.value().crs().authid(), 'EPSG:3111')
# to QgsPointXY
p = QgsPointXY(point)
self.assertEqual(p.x(), 1.0)
self.assertEqual(p.y(), 2.0)