6 |
# Read the file COPYING coming with Thuban for details. |
# Read the file COPYING coming with Thuban for details. |
7 |
|
|
8 |
""" |
""" |
9 |
Dialogs to the geographic projection library PROJ4 |
Dialogs to the geographic projection library PROJ |
10 |
""" |
""" |
11 |
|
|
12 |
__version__ = "$Revision$" |
__version__ = "$Revision$" |
19 |
ID_PROJECTION_OK = 4001 |
ID_PROJECTION_OK = 4001 |
20 |
ID_PROJECTION_CANCEL = 4002 |
ID_PROJECTION_CANCEL = 4002 |
21 |
|
|
22 |
ID_UTM_DIALOG_OK = 4101 |
ID_UTM_DIALOG_OK = 4101 |
23 |
ID_UTM_DIALOG_CANCEL = 4102 |
ID_UTM_DIALOG_CANCEL = 4102 |
24 |
|
ID_UTM_DIALOG_PROPOSE_ZONE = 4103 |
25 |
|
|
26 |
|
ID_UTM_PROPOSE_ZONE_DIALOG_TAKE = 4201 |
27 |
|
ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL = 4202 |
28 |
|
|
29 |
projectionDict = {'None' : 'None', 'UTM' : 'utm'} |
projectionDict = {'None' : 'None', 'UTM' : 'utm'} |
30 |
projectionMapping = {'None' : 'None', 'utm' : 'UTM'} |
projectionMapping = {'None' : 'None', 'utm' : 'UTM'} |
33 |
|
|
34 |
"""Let the user select a projection and specify related parameters""" |
"""Let the user select a projection and specify related parameters""" |
35 |
|
|
36 |
def __init__(self, parent, projectionParamsList): |
def __init__(self, parent, projectionParamsList, map_bounding_box): |
37 |
wxDialog.__init__(self, parent, -1, "Projection", |
wxDialog.__init__(self, parent, -1, "Projection", |
38 |
style = wxRESIZE_BORDER) |
style = wxRESIZE_BORDER) |
39 |
|
|
40 |
|
self.map_bounding_box = map_bounding_box |
41 |
self.dialogLayout() |
self.dialogLayout() |
42 |
self.projectionParams={} |
self.projectionParams={} |
43 |
combo = self.projection |
combo = self.projection |
174 |
for zone in range(1,61): |
for zone in range(1,61): |
175 |
self.zone.Append(str(zone)) |
self.zone.Append(str(zone)) |
176 |
zoneBox.Add(self.zone, 0, wxALIGN_CENTER|wxALL, 4) |
zoneBox.Add(self.zone, 0, wxALIGN_CENTER|wxALL, 4) |
177 |
|
zoneBox.Add(wxButton(self, ID_UTM_DIALOG_PROPOSE_ZONE, "Propose"), |
178 |
|
0, wxALL, 4) |
179 |
|
EVT_BUTTON(self, ID_UTM_DIALOG_PROPOSE_ZONE, self.OnProposeZone) |
180 |
|
|
181 |
topBox.Add(zoneBox, 1, wxEXPAND|wxALL, 4) |
topBox.Add(zoneBox, 1, wxEXPAND|wxALL, 4) |
182 |
|
|
204 |
topBox.Fit(self) |
topBox.Fit(self) |
205 |
topBox.SetSizeHints(self) |
topBox.SetSizeHints(self) |
206 |
|
|
207 |
|
def OnProposeZone(self, event): |
208 |
|
dlg = UTMProposeZoneDialog(self) |
209 |
|
if dlg.ShowModal(): |
210 |
|
return true |
211 |
|
else: |
212 |
|
return false |
213 |
|
|
214 |
def OnOK(self, event): |
def OnOK(self, event): |
215 |
self.parent.projectionParams = {} |
self.parent.projectionParams = {} |
216 |
self.parent.projectionParams['zone'] = self.zone.GetStringSelection() |
self.parent.projectionParams['zone'] = self.zone.GetStringSelection() |
221 |
def OnCancel(self, event): |
def OnCancel(self, event): |
222 |
self.Close(false) |
self.Close(false) |
223 |
|
|
224 |
|
class UTMProposeZoneDialog(wxDialog): |
225 |
|
|
226 |
|
"""Propose a sensible Zone considering the current map extent.""" |
227 |
|
|
228 |
|
def __init__(self, parent): |
229 |
|
wxDialog.__init__(self, parent, -1, "Projection: Propose UTM Zone", |
230 |
|
wxDefaultPosition, wxSize(200, 100)) |
231 |
|
self.parent = parent |
232 |
|
x, y, x2, y2 = self.parent.parent.map_bounding_box |
233 |
|
x = x + 180 |
234 |
|
x2 = x2 + 180 |
235 |
|
center = (x2 - x) / 2 + x |
236 |
|
self.proposedZone = str(int(center / 6 + 1)) |
237 |
|
self.dialogLayout() |
238 |
|
|
239 |
|
def dialogLayout(self): |
240 |
|
topBox = wxBoxSizer(wxVERTICAL) |
241 |
|
|
242 |
|
textBox = wxBoxSizer(wxVERTICAL) |
243 |
|
textBox.Add(wxStaticText(self, -1, "The current map extent center " + |
244 |
|
"lies in UTM Zone"), |
245 |
|
0, wxALIGN_CENTER|wxALL, 4) |
246 |
|
textBox.Add(wxStaticText(self, -1, self.proposedZone), |
247 |
|
0, wxALIGN_CENTER|wxALL, 4) |
248 |
|
|
249 |
|
topBox.Add(textBox, 1, wxEXPAND|wxALL, 4) |
250 |
|
|
251 |
|
buttonBox = wxBoxSizer(wxHORIZONTAL) |
252 |
|
buttonBox.Add(wxButton(self, ID_UTM_PROPOSE_ZONE_DIALOG_TAKE, "Take"), |
253 |
|
0, wxALL, 4) |
254 |
|
buttonBox.Add(wxButton(self, ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL, |
255 |
|
"Cancel"), 0, wxALL, 4) |
256 |
|
topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10) |
257 |
|
EVT_BUTTON(self, ID_UTM_PROPOSE_ZONE_DIALOG_TAKE, self.OnTake) |
258 |
|
EVT_BUTTON(self, ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL, self.OnCancel) |
259 |
|
|
260 |
|
self.SetAutoLayout(true) |
261 |
|
self.SetSizer(topBox) |
262 |
|
topBox.Fit(self) |
263 |
|
topBox.SetSizeHints(self) |
264 |
|
|
265 |
|
def OnTake(self, event): |
266 |
|
self.parent.zone.SetSelection(self.parent.zone.FindString(self.proposedZone)) |
267 |
|
self.Close(true) |
268 |
|
|
269 |
|
def OnCancel(self, event): |
270 |
|
self.Close(false) |