本文整理匯總了Python中qgis.core.QgsMultiPolygon類的典型用法代碼示例。如果您正苦於以下問題:Python QgsMultiPolygon類的具體用法?Python QgsMultiPolygon怎麽用?Python QgsMultiPolygon使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了QgsMultiPolygon類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: convertToPolygons
def convertToPolygons(self, geometry):
surfaces = self.getSurfaces(geometry.constGet())
output_wkb = self.convertWkbToPolygons(geometry.wkbType())
out_geom = None
if QgsWkbTypes.flatType(output_wkb) == QgsWkbTypes.MultiPolygon:
out_geom = QgsMultiPolygon()
else:
out_geom = QgsMultiSurface()
for surface in surfaces:
out_geom.addGeometry(surface)
return out_geom
示例2: txestGeometryRendering
def txestGeometryRendering(self):
'''Tests rendering a bunch of different geometries, including bad/odd geometries.'''
empty_multipolygon = QgsMultiPolygon()
empty_multipolygon.addGeometry(QgsPolygon())
empty_polygon = QgsPolygon()
empty_linestring = QgsLineString()
tests = [{'name': 'Point',
'wkt': 'Point (1 2)',
'reference_image': 'point'},
{'name': 'MultiPoint',
'wkt': 'MultiPoint ((10 30),(40 20),(30 10),(20 10))',
'reference_image': 'multipoint'},
{'name': 'LineString',
'wkt': 'LineString (0 0,3 4,4 3)',
'reference_image': 'linestring'},
{'name': 'Empty LineString',
'geom': QgsGeometry(empty_linestring),
'reference_image': 'empty'},
{'name': 'MultiLineString',
'wkt': 'MultiLineString ((0 0, 1 0, 1 1, 2 1, 2 0), (3 1, 5 1, 5 0, 6 0))',
'reference_image': 'multilinestring'},
{'name': 'Polygon',
'wkt': 'Polygon ((0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7 , 5 7, 5 5))',
'reference_image': 'polygon'},
{'name': 'Empty Polygon',
'geom': QgsGeometry(empty_polygon),
'reference_image': 'empty'},
{'name': 'MultiPolygon',
'wkt': 'MultiPolygon (((0 0, 1 0, 1 1, 2 1, 2 2, 0 2, 0 0)),((4 0, 5 0, 5 2, 3 2, 3 1, 4 1, 4 0)))',
'reference_image': 'multipolygon'},
{'name': 'Empty MultiPolygon',
'geom': QgsGeometry(empty_multipolygon),
'reference_image': 'empty'},
{'name': 'CircularString',
'wkt': 'CIRCULARSTRING(268 415,227 505,227 406)',
'reference_image': 'circular_string'},
{'name': 'CompoundCurve',
'wkt': 'COMPOUNDCURVE((5 3, 5 13), CIRCULARSTRING(5 13, 7 15, 9 13), (9 13, 9 3), CIRCULARSTRING(9 3, 7 1, 5 3))',
'reference_image': 'compound_curve'},
{'name': 'CurvePolygon',
'wkt': 'CURVEPOLYGON(CIRCULARSTRING(1 3, 3 5, 4 7, 7 3, 1 3))',
'reference_image': 'curve_polygon'},
{'name': 'MultiCurve',
'wkt': 'MultiCurve((5 5,3 5,3 3,0 3),CIRCULARSTRING(0 0, 2 1,2 2))',
'reference_image': 'multicurve'},
{'name': 'CurvePolygon_no_arc', # refs #14028
'wkt': 'CURVEPOLYGON(LINESTRING(1 3, 3 5, 4 7, 7 3, 1 3))',
'reference_image': 'curve_polygon_no_arc'}]
for test in tests:
def get_geom():
if 'geom' not in test:
geom = QgsGeometry.fromWkt(test['wkt'])
assert geom and not geom.isNull(), 'Could not create geometry {}'.format(test['wkt'])
else:
geom = test['geom']
return geom
geom = get_geom()
rendered_image = self.renderGeometry(geom)
assert self.imageCheck(test['name'], test['reference_image'], rendered_image)
# Note - each test is repeated with the same geometry and reference image, but with added
# z and m dimensions. This tests that presence of the dimensions does not affect rendering
# test with Z
geom_z = get_geom()
geom_z.get().addZValue(5)
rendered_image = self.renderGeometry(geom_z)
assert self.imageCheck(test['name'] + 'Z', test['reference_image'], rendered_image)
# test with ZM
geom_z.get().addMValue(15)
rendered_image = self.renderGeometry(geom_z)
assert self.imageCheck(test['name'] + 'ZM', test['reference_image'], rendered_image)
# test with M
geom_m = get_geom()
geom_m.get().addMValue(15)
rendered_image = self.renderGeometry(geom_m)
assert self.imageCheck(test['name'] + 'M', test['reference_image'], rendered_image)