|
30 | 30 | from PyQt4 import uic
|
31 | 31 | from PyQt4.QtGui import QMenu, QAction, QCursor, QInputDialog
|
32 | 32 |
|
| 33 | +from qgis.gui import QgsMessageBar |
33 | 34 | from qgis.core import QgsRasterLayer, QgsVectorLayer
|
34 | 35 | from qgis.utils import iface
|
35 | 36 |
|
36 | 37 | from processing.gui.RectangleMapTool import RectangleMapTool
|
37 | 38 | from processing.core.parameters import ParameterRaster
|
38 | 39 | from processing.core.parameters import ParameterVector
|
39 | 40 | from processing.core.parameters import ParameterMultipleInput
|
| 41 | +from processing.core.ProcessingConfig import ProcessingConfig |
40 | 42 | from processing.tools import dataobjects
|
41 | 43 |
|
42 | 44 | pluginPath = os.path.split(os.path.dirname(__file__))[0]
|
@@ -150,12 +152,22 @@ def useLayerExtent(self):
|
150 | 152 | extents = [CANVAS_KEY]
|
151 | 153 | layers = dataobjects.getAllLayers()
|
152 | 154 | for layer in layers:
|
153 |
| - extents.append(layer.name()) |
154 |
| - extentsDict[layer.name()] = layer.extent() |
| 155 | + authid = layer.crs().authid() |
| 156 | + if ProcessingConfig.getSetting(ProcessingConfig.SHOW_CRS_DEF) \ |
| 157 | + and authid is not None: |
| 158 | + layerName = u'{} [{}]'.format(layer.name(), authid) |
| 159 | + else: |
| 160 | + layerName = layer.name() |
| 161 | + extents.append(layerName) |
| 162 | + extentsDict[layerName] = {"extent": layer.extent(), "authid": authid} |
155 | 163 | (item, ok) = QInputDialog.getItem(self, self.tr('Select extent'),
|
156 | 164 | self.tr('Use extent from'), extents, False)
|
157 | 165 | if ok:
|
158 |
| - self.setValueFromRect(extentsDict[item]) |
| 166 | + self.setValueFromRect(extentsDict[item]["extent"]) |
| 167 | + if extentsDict[item]["authid"] != iface.mapCanvas().mapRenderer().destinationCrs().authid(): |
| 168 | + iface.messageBar().pushMessage(self.tr("Warning"), |
| 169 | + self.tr("The projection of the chosen layer is not the same as canvas projection! The selected extent might not be what was intended."), |
| 170 | + QgsMessageBar.WARNING, 8) |
159 | 171 |
|
160 | 172 | def selectOnCanvas(self):
|
161 | 173 | canvas = iface.mapCanvas()
|
|
0 commit comments