本文整理汇总了Python中viewer.Viewer.load_features方法的典型用法代码示例。如果您正苦于以下问题:Python Viewer.load_features方法的具体用法?Python Viewer.load_features怎么用?Python Viewer.load_features使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类viewer.Viewer
的用法示例。
在下文中一共展示了Viewer.load_features方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EarthMineQGIS
# 需要导入模块: from viewer import Viewer [as 别名]
# 或者: from viewer.Viewer import load_features [as 别名]
#.........这里部分代码省略.........
"""
Return the visible layers shown in the map canvas
:return:
"""
return (layer for layer, visible in self.layers_with_states() if visible)
def layers_with_states(self):
for layer in maplayers():
if not layer.type() == QgsMapLayer.VectorLayer:
continue
if not layer.geometryType() in [QGis.Point, QGis.Line]:
continue
yield layer, self.legend.isLayerVisible(layer)
def _layer_feature_added(self, featureid):
layer = self.sender()
if not layer:
return
self.layer_feature_added(layer, featureid)
def layer_feature_added(self, layer, featureid):
if not self.viewer:
return
feature = layer.getFeatures(QgsFeatureRequest(featureid)).next()
renderer = layer.rendererV2()
transform = self.coordinatetransform(layer)
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)