本文整理汇总了Python中qgis.core.QgsXmlUtils类的典型用法代码示例。如果您正苦于以下问题:Python QgsXmlUtils类的具体用法?Python QgsXmlUtils怎么用?Python QgsXmlUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QgsXmlUtils类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_invalid
def test_invalid(self):
"""
Test that invalid attributes are correctly loaded and written
"""
doc = QDomDocument("properties")
elem = QgsXmlUtils.writeVariant(None, doc)
prop2 = QgsXmlUtils.readVariant(elem)
self.assertIsNone(prop2)
示例2: test_list
def test_list(self):
"""
Test that lists are correctly loaded and written
"""
doc = QDomDocument("properties")
my_properties = [1, 4, 'a', 'test', 7.9]
elem = QgsXmlUtils.writeVariant(my_properties, doc)
prop2 = QgsXmlUtils.readVariant(elem)
self.assertEqual(my_properties, prop2)
示例3: test_integer
def test_integer(self):
"""
Test that maps are correctly loaded and written
"""
doc = QDomDocument("properties")
my_properties = {'a': 1, 'b': 2, 'c': 3, 'd': -1}
elem = QgsXmlUtils.writeVariant(my_properties, doc)
prop2 = QgsXmlUtils.readVariant(elem)
self.assertEqual(my_properties, prop2)
示例4: test_geom
def test_geom(self):
"""
Test that QgsGeometry values are correctly loaded and written
"""
doc = QDomDocument("properties")
g = QgsGeometry.fromWkt('Point(3 4)')
elem = QgsXmlUtils.writeVariant(g, doc)
g2 = QgsXmlUtils.readVariant(elem)
self.assertEqual(g2.asWkt(), 'Point (3 4)')
示例5: test_boolean
def test_boolean(self):
"""
Test that maps are correctly loaded and written
"""
doc = QDomDocument("properties")
my_properties = {'a': True, 'b': False}
elem = QgsXmlUtils.writeVariant(my_properties, doc)
prop2 = QgsXmlUtils.readVariant(elem)
self.assertEqual(my_properties, prop2)
示例6: test_double
def test_double(self):
"""
Test that maps are correctly loaded and written
"""
doc = QDomDocument("properties")
my_properties = {'a': 0.27, 'b': 1.0, 'c': 5}
elem = QgsXmlUtils.writeVariant(my_properties, doc)
prop2 = QgsXmlUtils.readVariant(elem)
self.assertEqual(my_properties, prop2)
示例7: test_string
def test_string(self):
"""
Test that maps are correctly loaded and written
"""
doc = QDomDocument("properties")
my_properties = {'a': 'a', 'b': 'b', 'c': 'something_else', 'empty': ''}
elem = QgsXmlUtils.writeVariant(my_properties, doc)
prop2 = QgsXmlUtils.readVariant(elem)
self.assertEqual(my_properties, prop2)
示例8: test_long
def test_long(self):
"""
Test that maps are correctly loaded and written
"""
doc = QDomDocument("properties")
# not sure if this actually does map to a long?
my_properties = {'a': 9223372036854775808}
elem = QgsXmlUtils.writeVariant(my_properties, doc)
prop2 = QgsXmlUtils.readVariant(elem)
self.assertEqual(my_properties, prop2)
示例9: test_crs
def test_crs(self):
"""
Test that QgsCoordinateReferenceSystem values are correctly loaded and written
"""
doc = QDomDocument("properties")
crs = QgsCoordinateReferenceSystem('epsg:3111')
elem = QgsXmlUtils.writeVariant(crs, doc)
crs2 = QgsXmlUtils.readVariant(elem)
self.assertTrue(crs2.isValid())
self.assertEqual(crs2.authid(), 'EPSG:3111')
crs = QgsCoordinateReferenceSystem()
elem = QgsXmlUtils.writeVariant(crs, doc)
crs2 = QgsXmlUtils.readVariant(elem)
self.assertFalse(crs2.isValid())