本文整理匯總了Python中qgis.analysis.QgsGeometrySnapper.snapFeatures方法的典型用法代碼示例。如果您正苦於以下問題:Python QgsGeometrySnapper.snapFeatures方法的具體用法?Python QgsGeometrySnapper.snapFeatures怎麽用?Python QgsGeometrySnapper.snapFeatures使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qgis.analysis.QgsGeometrySnapper
的用法示例。
在下文中一共展示了QgsGeometrySnapper.snapFeatures方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: processAlgorithm
# 需要導入模塊: from qgis.analysis import QgsGeometrySnapper [as 別名]
# 或者: from qgis.analysis.QgsGeometrySnapper import snapFeatures [as 別名]
def processAlgorithm(self, feedback):
layer = dataobjects.getLayerFromString(self.getParameterValue(self.INPUT))
reference_layer = dataobjects.getLayerFromString(self.getParameterValue(self.REFERENCE_LAYER))
tolerance = self.getParameterValue(self.TOLERANCE)
mode = self.getParameterValue(self.BEHAVIOR)
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(
layer.fields(), layer.wkbType(), layer.crs())
features = vector.features(layer)
self.processed = 0
self.feedback = feedback
self.total = 100.0 / len(features)
if self.getParameterValue(self.INPUT) != self.getParameterValue(self.REFERENCE_LAYER):
snapper = QgsGeometrySnapper(reference_layer)
snapper.featureSnapped.connect(self.featureSnapped)
snapped_features = snapper.snapFeatures(features, tolerance, mode)
for f in snapped_features:
writer.addFeature(QgsFeature(f))
else:
# snapping internally
snapper = QgsInternalGeometrySnapper(tolerance, mode)
processed = 0
for f in features:
out_feature = f
out_feature.setGeometry(snapper.snapFeature(f))
writer.addFeature(out_feature)
processed += 1
feedback.setProgress(processed * self.total)
del writer
示例2: processAlgorithm
# 需要導入模塊: from qgis.analysis import QgsGeometrySnapper [as 別名]
# 或者: from qgis.analysis.QgsGeometrySnapper import snapFeatures [as 別名]
def processAlgorithm(self, progress):
layer = dataobjects.getObjectFromUri(self.getParameterValue(self.INPUT))
reference_layer = dataobjects.getObjectFromUri(self.getParameterValue(self.REFERENCE_LAYER))
tolerance = self.getParameterValue(self.TOLERANCE)
mode = self.getParameterValue(self.BEHAVIOUR)
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(layer.fields(), layer.wkbType(), layer.crs())
features = vector.features(layer)
self.processed = 0
self.progress = progress
self.total = 100.0 / len(features)
snapper = QgsGeometrySnapper(reference_layer)
snapper.featureSnapped.connect(self.featureSnapped)
snapped_features = snapper.snapFeatures(features, tolerance, mode)
for f in snapped_features:
writer.addFeature(QgsFeature(f))
del writer