本文整理匯總了Python中qgis.core.QgsMultiLineString類的典型用法代碼示例。如果您正苦於以下問題:Python QgsMultiLineString類的具體用法?Python QgsMultiLineString怎麽用?Python QgsMultiLineString使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了QgsMultiLineString類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: convertToLines
def convertToLines(self, geometry):
rings = self.getRings(geometry.constGet())
output_wkb = self.convertWkbToLines(geometry.wkbType())
out_geom = None
if QgsWkbTypes.flatType(output_wkb) == QgsWkbTypes.MultiLineString:
out_geom = QgsMultiLineString()
else:
out_geom = QgsMultiCurve()
for ring in rings:
out_geom.addGeometry(ring)
return out_geom
示例2: convertToMultiLineStrings
def convertToMultiLineStrings(self, geom):
if QgsWkbTypes.geometryType(geom.wkbType()) == QgsWkbTypes.PointGeometry:
raise QgsProcessingException(
self.tr('Cannot convert from {0} to MultiLineStrings').format(QgsWkbTypes.displayString(geom.wkbType())))
elif QgsWkbTypes.geometryType(geom.wkbType()) == QgsWkbTypes.LineGeometry:
if QgsWkbTypes.isMultiType(geom.wkbType()):
return [geom]
else:
# line to multiLine
ml = QgsMultiLineString()
ml.addGeometry(geom.constGet().clone())
return [QgsGeometry(ml)]
else:
# polygons to multilinestring
# we just use the boundary here - that consists of all rings in the (multi)polygon
return [QgsGeometry(geom.constGet().boundary())]