@@ -79,10 +79,14 @@ def __init__(self, dialog, param):
79
79
if param .defaultValue () is not None :
80
80
context = createContext ()
81
81
rect = QgsProcessingParameters .parameterAsExtent (param , {param .name (): param .defaultValue ()}, context )
82
+ crs = QgsProcessingParameters .parameterAsExtentCrs (param , {param .name (): param .defaultValue ()}, context )
82
83
if not rect .isNull ():
83
84
try :
84
85
s = '{},{},{},{}' .format (
85
86
rect .xMinimum (), rect .xMaximum (), rect .yMinimum (), rect .yMaximum ())
87
+ if crs .isValid ():
88
+ s += ' [' + crs .authid () + ']'
89
+ self .crs = crs
86
90
self .leText .setText (s )
87
91
except :
88
92
pass
@@ -133,10 +137,6 @@ def useLayerExtent(self):
133
137
self .tr ('Use extent from' ), extents , False )
134
138
if ok :
135
139
self .setValueFromRect (QgsReferencedRectangle (extentsDict [item ]["extent" ], QgsCoordinateReferenceSystem (extentsDict [item ]["authid" ])))
136
- if extentsDict [item ]["authid" ] != iface .mapCanvas ().mapSettings ().destinationCrs ().authid ():
137
- iface .messageBar ().pushMessage (self .tr ("Warning" ),
138
- self .tr ("The projection of the chosen layer is not the same as canvas projection! The selected extent might not be what was intended." ),
139
- QgsMessageBar .WARNING , 8 )
140
140
141
141
def selectOnCanvas (self ):
142
142
canvas = iface .mapCanvas ()
@@ -151,11 +151,14 @@ def setValueFromRect(self, r):
151
151
s = '{},{},{},{}' .format (
152
152
r .xMinimum (), r .xMaximum (), r .yMinimum (), r .yMaximum ())
153
153
154
- self .leText .setText (s )
155
154
try :
156
155
self .crs = r .crs ()
157
156
except :
158
157
self .crs = QgsProject .instance ().crs ()
158
+ if self .crs .isValid ():
159
+ s += ' [' + self .crs .authid () + ']'
160
+
161
+ self .leText .setText (s )
159
162
self .tool .reset ()
160
163
canvas = iface .mapCanvas ()
161
164
canvas .setMapTool (self .prevMapTool )
@@ -165,13 +168,7 @@ def setValueFromRect(self, r):
165
168
166
169
def getValue (self ):
167
170
if str (self .leText .text ()).strip () != '' :
168
- try :
169
- parts = self .leText .text ().split (',' )
170
- parts = [float (p ) for p in parts ]
171
- r = QgsReferencedRectangle (QgsRectangle (parts [0 ], parts [2 ], parts [1 ], parts [3 ]), self .crs )
172
- return r
173
- except :
174
- return str (self .leText .text ())
171
+ return str (self .leText .text ())
175
172
else :
176
173
return None
177
174
0 commit comments