本文整理汇总了Python中viewer.Viewer.edit_feature方法的典型用法代码示例。如果您正苦于以下问题:Python Viewer.edit_feature方法的具体用法?Python Viewer.edit_feature怎么用?Python Viewer.edit_feature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类viewer.Viewer
的用法示例。
在下文中一共展示了Viewer.edit_feature方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EarthMineQGIS
# 需要导入模块: from viewer import Viewer [as 别名]
# 或者: from viewer.Viewer import edit_feature [as 别名]
#.........这里部分代码省略.........
featuredata = to_feature_data(layer.id(), feature, renderer, transform)
geomtype = layer.geometryType()
layerdata = dict(id=layer.id(), geomtype=QGis.vectorGeometryType(geomtype))
self.viewer.load_features(layerdata, featuredata)
def _layer_feature_delete(self, featureid):
layer = self.sender()
if not layer:
return
self.layer_feature_delete(layer, featureid)
def layer_feature_delete(self, layer, featureid):
if not self.viewer:
return
self.viewer.remove_feature(layer.id(), featureid)
def _layer_geometry_changed(self, featureid, geometry):
layer = self.sender()
if not layer:
return
self.layer_geometry_changed(layer, featureid, geometry)
def layer_geometry_changed(self, layer, featureid, geometry):
if not self.viewer:
return
geomtype = layer.geometryType()
if geomtype == QGis.Point:
geom = geometry.asPoint()
transform = self.coordinatetransform(layer)
point = transform.transform(geom, QgsCoordinateTransform.ReverseTransform)
location = dict(lat=point.y(), lng=point.x())
self.viewer.edit_feature(layer.id(), featureid, [location])
elif geomtype == QGis.Line:
self.layer_feature_delete(layer, featureid)
self.layer_feature_added(layer, featureid)
def connect_layer_signals(self, layer):
if not layer.type() == QgsMapLayer.VectorLayer:
return
layer.featureAdded.connect(self._layer_feature_added)
layer.featureDeleted.connect(self._layer_feature_delete)
layer.editingStarted.connect(self.layer_editstate_changed)
layer.editingStopped.connect(self.layer_editstate_changed)
# HACK The new style doesn't work here
# http://hub.qgis.org/issues/6573
signal = SIGNAL("geometryChanged(QgsFeatureId, QgsGeometry&)")
self.connect(layer, signal, self._layer_geometry_changed)
self.load_layer_features(layers=[layer])
def layer_editstate_changed(self):
layer = self.sender()
if layer == self.iface.activeLayer():
self.viewer.layer_changed(layer)
def disconnect_signals(self):
self.disconnect_projectsignals()
for layer in maplayers():
if not layer.type() == QgsMapLayer.VectorLayer:
return
safe_disconnect(layer.featureAdded, self._layer_feature_added)
safe_disconnect(layer.featureDeleted, self._layer_feature_delete)