Skip to content
Permalink
Browse files

Merge pull request #2505 from radosuav/processing_extent

[Processing] Check layer projection when using it for subset extent
  • Loading branch information
volaya committed Nov 27, 2015
2 parents 0a21d91 + c58981f commit 17e1bd6be34d91bb708600108df933047736f034
Showing with 15 additions and 3 deletions.
  1. +15 −3 python/plugins/processing/gui/ExtentSelectionPanel.py
@@ -30,13 +30,15 @@
from PyQt4 import uic
from PyQt4.QtGui import QMenu, QAction, QCursor, QInputDialog

from qgis.gui import QgsMessageBar
from qgis.core import QgsRasterLayer, QgsVectorLayer
from qgis.utils import iface

from processing.gui.RectangleMapTool import RectangleMapTool
from processing.core.parameters import ParameterRaster
from processing.core.parameters import ParameterVector
from processing.core.parameters import ParameterMultipleInput
from processing.core.ProcessingConfig import ProcessingConfig
from processing.tools import dataobjects

pluginPath = os.path.split(os.path.dirname(__file__))[0]
@@ -150,12 +152,22 @@ def useLayerExtent(self):
extents = [CANVAS_KEY]
layers = dataobjects.getAllLayers()
for layer in layers:
extents.append(layer.name())
extentsDict[layer.name()] = layer.extent()
authid = layer.crs().authid()
if ProcessingConfig.getSetting(ProcessingConfig.SHOW_CRS_DEF) \
and authid is not None:
layerName = u'{} [{}]'.format(layer.name(), authid)
else:
layerName = layer.name()
extents.append(layerName)
extentsDict[layerName] = {"extent": layer.extent(), "authid": authid}
(item, ok) = QInputDialog.getItem(self, self.tr('Select extent'),
self.tr('Use extent from'), extents, False)
if ok:
self.setValueFromRect(extentsDict[item])
self.setValueFromRect(extentsDict[item]["extent"])
if extentsDict[item]["authid"] != iface.mapCanvas().mapRenderer().destinationCrs().authid():
iface.messageBar().pushMessage(self.tr("Warning"),
self.tr("The projection of the chosen layer is not the same as canvas projection! The selected extent might not be what was intended."),
QgsMessageBar.WARNING, 8)

def selectOnCanvas(self):
canvas = iface.mapCanvas()

0 comments on commit 17e1bd6

Please sign in to comment.
You can’t perform that action at this time.