本文整理汇总了Python中viewer.Viewer.startViewer方法的典型用法代码示例。如果您正苦于以下问题:Python Viewer.startViewer方法的具体用法?Python Viewer.startViewer怎么用?Python Viewer.startViewer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类viewer.Viewer
的用法示例。
在下文中一共展示了Viewer.startViewer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EarthMineQGIS
# 需要导入模块: from viewer import Viewer [as 别名]
# 或者: from viewer.Viewer import startViewer [as 别名]
#.........这里部分代码省略.........
"""
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))
settings[key] = value
return settings
@pyqtSlot()
def ready(self):
"""
Called when the viewer is ready to be started. At this point the viewer hasn't been loaded
so no other methods apart from startViewer will be handled.
"""
settings = self.earthmine_settings()
self.viewer.startViewer(settings)
@pyqtSlot()
def viewerReady(self):
"""
Called once the viewer is loaded and ready to get location events.
"""
self.disconnect_signals()
self.connect_signals()
self.iface.projectRead.connect(self.connect_signals)
self.canvas.layersChanged.connect(self.layers_changed)
self.canvas.selectionChanged.connect(self.selection_changed)
self.canvas.selectionChanged.connect(self.viewer.selection_changed)
QgsMapLayerRegistry.instance().layersRemoved.connect(self.layers_removed)
QgsMapLayerRegistry.instance().layerWasAdded.connect(self.connect_layer_signals)
self.center_on_canvas()
self.viewer.activelayercombo.setLayer(self.iface.activeLayer())
def center_on_canvas(self):
point = self.canvas.extent().center()
transform = self.coordinatetransform()
point = transform.transform(point, QgsCoordinateTransform.ReverseTransform)
self.viewer.set_location(point)
self.viewer.infoaction.toggle()
def selection_changed(self, layer):
ids = [feature.id() for feature in layer.selectedFeatures()]
if not ids:
self.viewer.clear_selection(layer.id())
else: