本文整理汇总了Python中viewer.Viewer.set_location方法的典型用法代码示例。如果您正苦于以下问题:Python Viewer.set_location方法的具体用法?Python Viewer.set_location怎么用?Python Viewer.set_location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类viewer.Viewer
的用法示例。
在下文中一共展示了Viewer.set_location方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EarthMineQGIS
# 需要导入模块: from viewer import Viewer [as 别名]
# 或者: from viewer.Viewer import set_location [as 别名]
#.........这里部分代码省略.........
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)
safe_disconnect(layer.editingStarted, self.layer_editstate_changed)
safe_disconnect(layer.editingStopped, self.layer_editstate_changed)
# HACK The new style doesn't work here
# http://hub.qgis.org/issues/6573
signal = SIGNAL("geometryChanged(QgsFeatureId, QgsGeometry&)")
self.disconnect(layer, signal, self._layer_geometry_changed)
def connect_signals(self):
for layer in maplayers():
self.connect_layer_signals(layer)
self.center_on_canvas()
def set_viewer_location(self, point, mousebutton):
transform = self.coordinatetransform()
point = transform.transform(point, QgsCoordinateTransform.ReverseTransform)
self.viewer.set_location(point)
def distancearea(self):
area = QgsDistanceArea()
dest = self.canvas.mapRenderer().destinationCrs()
area.setSourceCrs(dest)
return area, dest.mapUnits()
def coordinatetransform(self, layer=None):
"""
Return the transform for WGS84 -> QGIS projection.
"""
source = QgsCoordinateReferenceSystem()
source.createFromWkt(
'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]'
)
if not layer:
dest = self.canvas.mapRenderer().destinationCrs()
else:
dest = layer.crs()
transform = QgsCoordinateTransform(source, dest)
return transform
def earthmine_settings(self):
settings = {}
with settinggroup(self.settings, "plugins/Earthmine"):
for key in ["serviceUrl", "baseDataUrl", "apiKey", "secretKey", "viewerUrl"]:
if not self.settings.contains(key):
raise EarthmineSettingsError("{} not set".format(key))
value = self.settings.value(key, type=str)
if value is None:
raise EarthmineSettingsError("{} not set".format(key))