/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/projdialog.py
ViewVC logotype

Contents of /branches/WIP-pyshapelib-bramz/Thuban/UI/projdialog.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 717 - (show annotations)
Wed Apr 23 08:59:57 2003 UTC (21 years, 10 months ago) by jonathan
Original Path: trunk/thuban/Thuban/UI/projdialog.py
File MIME type: text/x-python
File size: 23606 byte(s)
Projection dialog. Allows the user to select from a list
of projection templates and optionally edit them and save new ones.

(ProjFrame): New. Main dialog.
(ProjPanel): Base class for projection specific panels.
(TMPanel): Projection panel for Transverse Mercartor.
(UTMPanel): Projection panel for Universal Transverse Mercartor.
(LCCPanel): Projection panel for Lambert Conic Conformal.
(GeoPanel): Projetion panel for Geographic Projection.

1 #!/usr/bin/env python
2 # generated by wxGlade 0.2.1 on Thu Apr 17 11:51:39 2003
3
4 from wxPython.wx import *
5
6 from Thuban import _
7
8 from Thuban.Model.proj import Projection
9
10 from Thuban.Model.resource import GetUserProjFiles, GetSystemProjFiles
11 from Thuban.UI.dialogs import NonModalDialog
12
13 ID_PROJ_ADVANCED = 4001
14 ID_PROJ_PROJCHOICE = 4002
15 ID_PROJ_SAVEAS = 4003
16 ID_PROJ_NEW = 4004
17 ID_PROJ_TRY = 4005
18 ID_PROJ_REVERT = 4006
19 ID_PROJ_OK = 4007
20 ID_PROJ_CLOSE = 4008
21 ID_PROJ_AVAIL = 4009
22
23
24 class ProjFrame(NonModalDialog):
25
26
27 def __init__(self, parent, name, receiver, *args, **kwds):
28 #
29 # Changes to the wxGlade generated code:
30 # o call NonModalDialog.__init__(self, parent, name, "")
31 # o remove default choices in combo box
32 #
33
34 self.editing = False
35 self.receiver = receiver
36 self.originalProjection = -1
37 self.curProjPanel = None
38
39 self.projPanels = []
40 self.projPanels.append(
41 ("tmerc", _("Transverse Mercartor"), TMPanel))
42 self.projPanels.append(
43 ("utm", _("Universal Transverse Mercartor"), UTMPanel))
44 self.projPanels.append(
45 ("lcc", _("Lambert Conic Conformal"), LCCPanel))
46 self.projPanels.append(
47 ("latlong", _("Geographic"), GeoPanel))
48
49 # begin wxGlade: ProjFrame.__init__
50 #kwds["style"] = wxDEFAULT_FRAME_STYLE
51 NonModalDialog.__init__(self, parent, name, "")
52 self.panel_1 = wxPanel(self, -1)
53 self.label_5 = wxStaticText(self.panel_1, -1, _("Available Projections:"))
54 self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL, style=wxLB_SINGLE|wxLB_SORT)
55 self.button_advanced = wxButton(self.panel_1, ID_PROJ_ADVANCED, _("Advanced >>"))
56 self.label_2 = wxStaticText(self.panel_1, -1, _("Name:"))
57 self.projname = wxTextCtrl(self.panel_1, -1, "")
58 self.label_3 = wxStaticText(self.panel_1, -1, _("Projection:"))
59 self.projchoice = wxChoice(self.panel_1, ID_PROJ_PROJCHOICE)
60 self.button_new = wxButton(self.panel_1, ID_PROJ_NEW, _("New"))
61 self.button_saveas = wxButton(self.panel_1, ID_PROJ_SAVEAS, _("Save"))
62 self.button_try = wxButton(self.panel_1, ID_PROJ_TRY, _("Try"))
63 self.button_revert = wxButton(self.panel_1, ID_PROJ_REVERT, _("Revert"))
64 self.button_ok = wxButton(self.panel_1, ID_PROJ_OK, _("OK"))
65 self.button_close = wxButton(self.panel_1, ID_PROJ_CLOSE, _("Close"))
66
67 self.__set_properties()
68 self.__do_layout()
69 # end wxGlade
70
71 self.sizer_edit.GetStaticBox().Show(False)
72 self.sizer_mainctrls.Show(self.sizer_edit, False)
73 self.topBox.Layout()
74
75 EVT_BUTTON(self, ID_PROJ_TRY, self._OnTry)
76 EVT_BUTTON(self, ID_PROJ_REVERT, self._OnRevert)
77 EVT_BUTTON(self, ID_PROJ_OK, self._OnOK)
78 EVT_BUTTON(self, ID_PROJ_CLOSE, self._OnClose)
79 EVT_BUTTON(self, ID_PROJ_ADVANCED, self._OnAdvanced)
80 EVT_CHOICE(self, ID_PROJ_PROJCHOICE, self._OnProjChoice)
81 EVT_LISTBOX(self, ID_PROJ_AVAIL, self._OnProjAvail)
82
83 EVT_BUTTON(self, ID_PROJ_NEW, self._OnNew)
84 EVT_BUTTON(self, ID_PROJ_SAVEAS, self._OnSave)
85
86 def GetReceiver(self):
87 return self.receiver
88
89 def _OnTry(self, event):
90 self.__SetProjection()
91
92 def _OnRevert(self, event):
93 if self.originalProjection != -1:
94 self.receiver.SetProjection(self.originalProjection)
95
96 def _OnOK(self, event):
97 self.__SetProjection()
98 self.Close()
99
100 def _OnClose(self, event):
101 self.Close()
102
103 def _OnAdvanced(self, event):
104 self.sizer_edit.GetStaticBox().Show(True)
105 self.sizer_mainctrls.Show(self.sizer_edit, True)
106 self.topBox.Fit(self)
107 self.topBox.SetSizeHints(self)
108 self.topBox.Layout()
109
110 self.editing = True
111
112 self.__DoOnProjAvail()
113
114 self.button_advanced.Enable(False)
115
116 def _OnNew(self, event):
117 print "_OnNew"
118 self.availprojs.SetSelection(-1)
119 self.projname.Clear()
120 self.curProjPanel.Clear()
121
122 def _OnSave(self, event):
123 print "_OnSave"
124
125 def _OnProjAvail(self, event):
126 self.__DoOnProjAvail()
127
128 def __DoOnProjAvail(self):
129 print "_OnProjAvail"
130
131 if not self.editing: return
132
133 sel = self.availprojs.GetSelection()
134 if sel == -1: return
135
136 proj = self.availprojs.GetClientData(sel)
137 assert proj != None
138
139 self.projname.SetValue(proj.GetName())
140
141 myProjType = proj.GetParameter("proj")
142 i = 0
143 for projType, name, clazz in self.projPanels:
144 if myProjType == projType:
145 self.projchoice.SetSelection(i)
146 self.__DoOnProjChoice()
147 self.curProjPanel.SetProjection(proj)
148 i += 1
149
150 def _OnProjChoice(self, event):
151 self.__DoOnProjChoice()
152
153 def __DoOnProjChoice(self):
154 print "_OnProjChoice()"
155 choice = self.projchoice
156
157 sel = choice.GetSelection()
158 if sel == -1: return
159
160 clazz, obj = choice.GetClientData(choice.GetSelection())
161
162 if obj is None:
163 obj = clazz(self)
164 choice.SetClientData(sel, [clazz, obj])
165
166 if self.curProjPanel is not None:
167 self.curProjPanel.Hide()
168 self.sizer_projctrls.Remove(self.curProjPanel)
169
170 self.curProjPanel = obj
171 self.curProjPanel.Show()
172
173 print "++", self.topBox.GetSize(), self.GetSize()
174 print "!!", self.sizer_projctrls.GetSize(), \
175 self.sizer_edit.GetSize(), \
176 self.sizer_mainctrls.GetSize(), \
177 self.sizer_panel.GetSize()
178 self.sizer_projctrls.Add(self.curProjPanel, 1, wxALL|wxEXPAND, 3)
179 #print "$$", self.sizer_projctrls.GetSize()
180 # self.topBox.Fit(self)
181 # self.topBox.SetSizeHints(self)
182 # self.topBox.Layout()
183
184 self.sizer_panel.SetSizeHints(self.panel_1)
185 w, h = self.sizer_panel.GetSize()
186 self.topBox.SetDimension(0, 0, w, h)
187
188 #self.sizer_panel.Fit(self.panel_1)
189 self.topBox.Fit(self)
190 #self.SetAutoLayout(1)
191 self.topBox.SetSizeHints(self)
192 self.SetSize(self.topBox.GetSize())
193 print "!!", self.sizer_projctrls.GetSize(), \
194 self.sizer_edit.GetSize(), \
195 self.sizer_mainctrls.GetSize(), \
196 self.sizer_panel.GetSize()
197 print "--", self.topBox.GetSize(), self.GetSize()
198
199
200
201 def __SetProjection(self):
202
203 #
204 # save the original projection only once in case
205 # we try to apply several different projections
206 #
207 if self.originalProjection == -1:
208 self.originalProjection = self.receiver.GetProjection()
209
210 sel = self.availprojs.GetSelection()
211 proj = -1
212
213 if self.editing:
214 if self.curProjPanel is not None:
215 proj = Projection(self.curProjPanel.GetParameters())
216 elif sel != -1:
217 proj = self.availprojs.GetClientData(sel)
218
219 if proj != -1:
220 if proj is not None:
221 print proj.GetAllParameters()
222 self.receiver.SetProjection(proj)
223
224
225 def __set_properties(self):
226 self.availprojs.Append("<None>", None)
227
228 projfiles = GetSystemProjFiles()
229 for projfile in projfiles:
230 for proj in projfile.GetProjections():
231 self.availprojs.Append(proj.GetName(), proj)
232
233 projfiles = GetUserProjFiles()
234 for projfile in projfiles:
235 for proj in projfile.GetProjections():
236 self.availprojs.Append(proj.GetName(), proj)
237
238 proj = self.receiver.GetProjection()
239 if proj is not None:
240 self.availprojs.Append("## " + proj.GetName() + " ##", proj)
241
242 for proj, name, clazz in self.projPanels:
243 self.projchoice.Append(name, [clazz, None])
244
245 # begin wxGlade: ProjFrame.__set_properties
246 self.SetTitle(_("Projections"))
247 self.availprojs.SetSelection(0)
248 self.projchoice.SetSelection(0)
249 # end wxGlade
250
251 def __do_layout(self):
252 # begin wxGlade: ProjFrame.__do_layout
253 self.topBox = wxBoxSizer(wxVERTICAL)
254 self.sizer_panel = wxBoxSizer(wxVERTICAL)
255 sizer_6 = wxBoxSizer(wxHORIZONTAL)
256 self.sizer_mainctrls = wxBoxSizer(wxHORIZONTAL)
257 self.sizer_edit = wxStaticBoxSizer(wxStaticBox(self.panel_1, -1, _("Edit")), wxHORIZONTAL)
258 sizer_11 = wxBoxSizer(wxVERTICAL)
259 self.sizer_projctrls = wxBoxSizer(wxVERTICAL)
260 sizer_14 = wxBoxSizer(wxHORIZONTAL)
261 sizer_13 = wxBoxSizer(wxHORIZONTAL)
262 grid_sizer_1 = wxFlexGridSizer(2, 2, 0, 0)
263 grid_sizer_1.Add(self.label_5, 0, wxLEFT|wxRIGHT|wxTOP, 4)
264 grid_sizer_1.Add(20, 20, 0, wxEXPAND, 0)
265 grid_sizer_1.Add(self.availprojs, 1, wxALL|wxEXPAND, 4)
266 grid_sizer_1.Add(self.button_advanced, 0, wxALL, 4)
267 grid_sizer_1.AddGrowableRow(1)
268 grid_sizer_1.AddGrowableCol(0)
269 self.sizer_mainctrls.Add(grid_sizer_1, 1, wxEXPAND, 0)
270 sizer_13.Add(self.label_2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4)
271 sizer_13.Add(self.projname, 1, wxALL, 4)
272 self.sizer_projctrls.Add(sizer_13, 0, wxEXPAND, 0)
273 sizer_14.Add(self.label_3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4)
274 sizer_14.Add(self.projchoice, 1, wxALL|wxEXPAND, 4)
275 self.sizer_projctrls.Add(sizer_14, 0, wxEXPAND, 0)
276 self.sizer_edit.Add(self.sizer_projctrls, 1, wxEXPAND, 0)
277 sizer_11.Add(self.button_new, 0, wxALL|wxEXPAND, 4)
278 sizer_11.Add(self.button_saveas, 0, wxALL|wxEXPAND, 4)
279 self.sizer_edit.Add(sizer_11, 0, wxALL|wxEXPAND, 4)
280 self.sizer_mainctrls.Add(self.sizer_edit, 0, wxALL|wxEXPAND, 4)
281 self.sizer_panel.Add(self.sizer_mainctrls, 1, wxEXPAND, 0)
282 sizer_6.Add(20, 20, 1, wxEXPAND, 0)
283 sizer_6.Add(self.button_try, 0, wxALL, 4)
284 sizer_6.Add(20, 20, 1, 0, 0)
285 sizer_6.Add(self.button_revert, 0, wxALL, 4)
286 sizer_6.Add(20, 20, 1, 0, 0)
287 sizer_6.Add(self.button_ok, 0, wxALL, 4)
288 sizer_6.Add(20, 20, 1, 0, 0)
289 sizer_6.Add(self.button_close, 0, wxALL, 4)
290 sizer_6.Add(20, 20, 1, wxEXPAND, 0)
291 self.sizer_panel.Add(sizer_6, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 0)
292 self.panel_1.SetAutoLayout(1)
293 self.panel_1.SetSizer(self.sizer_panel)
294 self.sizer_panel.Fit(self.panel_1)
295 self.sizer_panel.SetSizeHints(self.panel_1)
296 self.topBox.Add(self.panel_1, 1, wxEXPAND, 0)
297 self.SetAutoLayout(1)
298 self.SetSizer(self.topBox)
299 self.topBox.Fit(self)
300 self.topBox.SetSizeHints(self)
301 self.Layout()
302 # end wxGlade
303
304 # end of class ProjFrame
305
306
307 class ProjPanel(wxPanel):
308 """Base class for all projection panels."""
309
310 def __init__(self, parent):
311 wxPanel.__init__(self, parent, -1)
312
313 self.__ellps = wxChoice(self, -1)
314 self.ellpsData = [("bessel", _("Bessel 1841")),
315 ("clrk66", _("Clarke 1866")),
316 ("clrk80", _("Clarke 1880")),
317 ("GRS80" , _("GRS 1980 (IUGG, 1980)")),
318 ("intl" , _("International 1909 (Hayford)")),
319 ("WGS84" , _("WGS 84"))]
320
321 for tag, name in self.ellpsData:
322 self.__ellps.Append(name, tag)
323
324 self.__ellps.SetSelection(0)
325
326 def _DoLayout(self, childPanel = None):
327
328 panelSizer = wxBoxSizer(wxVERTICAL)
329
330 if childPanel is not None:
331 panelSizer.Add(childPanel, 0, wxALL|wxEXPAND, 4)
332
333 sizer = wxBoxSizer(wxHORIZONTAL)
334 sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0, wxALL, 4)
335 sizer.Add(self.__ellps, 1, wxALL|wxEXPAND, 4)
336 panelSizer.Add(sizer, 0, wxALL|wxEXPAND, 4)
337
338 self.SetAutoLayout(1)
339 self.SetSizer(panelSizer)
340 panelSizer.Fit(self)
341 panelSizer.SetSizeHints(self)
342 self.Layout()
343
344 def SetProjection(self, proj):
345 if proj is not None:
346 param = proj.GetParameter("ellps")
347 i = 0
348 for tag, name in self.ellpsData:
349 if param == tag:
350 self.__ellps.SetSelection(i)
351 return # returning early!
352 i += 1
353
354 #
355 # if proj is none, or the parameter couldn't be found...
356 #
357 self.__ellps.SetSelection(0)
358
359 def GetParameters(self):
360 print "asdfsdf"
361 return ["ellps=" + self.__ellps.GetClientData(
362 self.__ellps.GetSelection())]
363
364
365 ID_TMPANEL_LAT = 4001
366 ID_TMPANEL_LONG = 4002
367 ID_TMPANEL_FASLE_EAST = 4003
368 ID_TMPANEL_FALSE_NORTH = 4004
369 ID_TMPANEL_SCALE = 4005
370
371 class UnknownProjPanel(ProjPanel):
372 def __init__(self, parent):
373 ProjPanel.__init__(self, parent)
374
375 self._DoLayout()
376
377 def _DoLayout(self):
378 sizer = wxBoxSizer(wxVERTICAL)
379
380 sizer.Add(wxStaticText(self, -1,
381 _("Thuban does not know the parameters for the " +
382 "current projection and cannot display a " +
383 "configuration panel.")))
384
385 ProjPanel._DoLayout(self, sizer)
386
387 def GetProjName(self):
388 return "Unknown"
389
390 def SetProjection(self, proj):
391 pass
392
393 def GetParameters(self):
394 return None
395
396 class TMPanel(ProjPanel):
397 """Projection panel for Transverse Mercartor."""
398
399 def __init__(self, parent):
400 ProjPanel.__init__(self, parent)
401
402 self.__latitude = wxTextCtrl(self, ID_TMPANEL_LAT)
403 self.__longitude = wxTextCtrl(self, ID_TMPANEL_LONG)
404 self.__falseEast = wxTextCtrl(self, ID_TMPANEL_FASLE_EAST)
405 self.__falseNorth = wxTextCtrl(self, ID_TMPANEL_FALSE_NORTH)
406 self.__scale = wxTextCtrl(self, ID_TMPANEL_SCALE)
407
408 self._DoLayout()
409
410 def _DoLayout(self):
411
412 sizer = wxFlexGridSizer(4, 4, 0, 0)
413 sizer.Add(wxStaticText(self, -1, _("Latitude:")), 0, wxALL, 4)
414 sizer.Add(self.__latitude, 0, wxALL, 4)
415 sizer.Add(wxStaticText(self, -1, _("False Easting:")), 0, wxALL, 4)
416 sizer.Add(self.__falseEast, 0, wxALL, 4)
417 sizer.Add(wxStaticText(self, -1, _("Longitude:")), 0, wxALL, 4)
418 sizer.Add(self.__longitude, 0, wxALL, 4)
419 sizer.Add(wxStaticText(self, -1, _("False Northing:")), 0, wxALL, 4)
420 sizer.Add(self.__falseNorth, 0, wxALL, 4)
421 sizer.Add(wxStaticText(self, -1, _("Scale Factor:")), 0, wxALL, 4)
422 sizer.Add(self.__scale, 0, wxALL, 4)
423
424 ProjPanel._DoLayout(self, sizer)
425
426 def GetProjName(self):
427 return _("Transverse Mercartor")
428
429 def SetProjection(self, proj):
430 ProjPanel.SetProjection(self, proj)
431
432 self.__latitude.SetValue(proj.GetParameter("lat_0"))
433 self.__longitude.SetValue(proj.GetParameter("lon_0"))
434 self.__falseEast.SetValue(proj.GetParameter("x_0"))
435 self.__falseNorth.SetValue(proj.GetParameter("y_0"))
436 self.__scale.SetValue(proj.GetParameter("k"))
437
438 ProjPanel.SetProjection(self, proj)
439
440 def GetParameters(self):
441 print "** asdfsdf"
442 params = ["proj=tmerc",
443 "lat_0=" + self.__latitude.GetValue(),
444 "lon_0=" + self.__longitude.GetValue(),
445 "x_0=" + self.__falseEast.GetValue(),
446 "y_0=" + self.__falseNorth.GetValue(),
447 "k=" + self.__scale.GetValue()]
448 params.extend(ProjPanel.GetParameters(self))
449 return params
450
451 def Clear(self):
452 self.__latitude.Clear()
453 self.__longitude.Clear()
454 self.__falseEast.Clear()
455 self.__falseNorth.Clear()
456 self.__scale.Clear()
457
458 ProjPanel.Clear(self)
459
460 ID_UTMPANEL_ZONE = 4001
461 ID_UTMPANEL_SOUTH = 4002
462 ID_UTMPANEL_PROP = 4003
463
464 class UTMPanel(ProjPanel):
465 """Projection Panel for Universal Transverse Mercartor."""
466
467 def __init__(self, parent):
468 ProjPanel.__init__(self, parent)
469
470 self.parent = parent
471
472 self.__zone = wxSpinCtrl(self, ID_UTMPANEL_ZONE, "1", min=1, max=60)
473 self.__south = wxCheckBox(self, ID_UTMPANEL_SOUTH,
474 _("Southern Hemisphere"))
475 self.__propButton = wxButton(self, ID_UTMPANEL_PROP, _("Propose"))
476
477 self._DoLayout()
478
479 EVT_BUTTON(self, ID_UTMPANEL_PROP, self._OnPropose)
480
481 def _DoLayout(self):
482
483 sizer = wxBoxSizer(wxVERTICAL)
484 psizer = wxBoxSizer(wxHORIZONTAL)
485 psizer.Add(wxStaticText(self, -1, _("Zone:")), 0, wxALL, 4)
486 psizer.Add(self.__zone, 0, wxALL, 4)
487 psizer.Add(self.__propButton, 0, wxALL, 4)
488 sizer.Add(psizer, 0, wxALL, 4)
489 sizer.Add(self.__south, 0, wxALL, 4)
490
491 ProjPanel._DoLayout(self, sizer)
492
493 def GetProjName(self):
494 return _("Universal Transverse Mercartor")
495
496 def SetProjection(self, proj):
497 self.__zone.SetValue(int(proj.GetParameter("zone")))
498 self.__south.SetValue(proj.GetParameter("south") != "")
499 ProjPanel.SetProjection(self, proj)
500
501 def GetParameters(self):
502 print "** asdfsdf"
503 params = ["proj=utm", "zone=" + str(self.__zone.GetValue())]
504 if self.__south.IsChecked():
505 params.append("south")
506
507 params.extend(ProjPanel.GetParameters(self))
508 return params
509
510 def Clear(self):
511 self.__zone.SetValue(1)
512 self.__south.SetValue(False)
513 ProjPanel.Clear(self)
514
515 def _OnPropose(self, event):
516 UTMProposeZoneDialog
517 dlg = UTMProposeZoneDialog(self, self.parent.GetReceiver().BoundingBox())
518 if dlg.ShowModal() == wxID_OK:
519 self.__zone.SetValue(dlg.GetProposedZone())
520
521 class LCCPanel(ProjPanel):
522 """Projection Panel for Lambert Conic Conformal."""
523
524 def __init__(self, parent):
525 ProjPanel.__init__(self, parent)
526
527 self.__fspLatitude = wxTextCtrl(self, -1)
528 self.__sspLatitude = wxTextCtrl(self, -1)
529 self.__originLat = wxTextCtrl(self, -1)
530 self.__meridian = wxTextCtrl(self, -1)
531 self.__falseEast = wxTextCtrl(self, -1)
532 self.__falseNorth = wxTextCtrl(self, -1)
533
534 self._DoLayout()
535
536 def _DoLayout(self):
537
538 sizer = wxFlexGridSizer(6, 2, 0, 0)
539 sizer.Add(wxStaticText(self, -1,
540 _("Latitude of first standard parallel:")))
541 sizer.Add(self.__fspLatitude, 0, wxALL, 4)
542 sizer.Add(wxStaticText(self, -1,
543 _("Latitude of second standard parallel:")))
544 sizer.Add(self.__sspLatitude, 0, wxALL, 4)
545 sizer.Add(wxStaticText(self, -1, _("Latitude of origin:")))
546 sizer.Add(self.__originLat, 0, wxALL, 4)
547 sizer.Add(wxStaticText(self, -1, _("Central Meridian:")))
548 sizer.Add(self.__meridian, 0, wxALL, 4)
549 sizer.Add(wxStaticText(self, -1, _("False Easting:")))
550 sizer.Add(self.__falseEast, 0, wxALL, 4)
551 sizer.Add(wxStaticText(self, -1, _("False Northing:")))
552 sizer.Add(self.__falseNorth, 0, wxALL, 4)
553
554 ProjPanel._DoLayout(self, sizer)
555
556 def GetProjName(self):
557 return _("Lambert Conic Conformal")
558
559 def SetProjection(self, proj):
560 self.__fspLatitude.SetValue(proj.GetParameter("lat_1"))
561 self.__sspLatitude.SetValue(proj.GetParameter("lat_2"))
562 self.__originLat.SetValue(proj.GetParameter("lat_0"))
563 self.__meridian.SetValue(proj.GetParameter("lon_0"))
564 self.__falseEast.SetValue(proj.GetParameter("x_0"))
565 self.__falseNorth.SetValue(proj.GetParameter("y_0"))
566
567 ProjPanel.SetProjection(self, proj)
568
569 def GetParameters(self):
570 params = ["proj=lcc",
571 "lat_1=" + self.__fspLatitude.GetValue(),
572 "lat_2=" + self.__sspLatitude.GetValue(),
573 "lat_0=" + self.__originLat.GetValue(),
574 "lon_0=" + self.__meridian.GetValue(),
575 "x_0=" + self.__falseEast.GetValue(),
576 "y_0=" + self.__falseNorth.GetValue()]
577
578 params.extend(ProjPanel.GetParameters(self))
579 return params
580
581 def Clear(self):
582 self.__fspLatitude.Clear()
583 self.__sspLatitude.Clear()
584 self.__originLat.Clear()
585 self.__meridian.Clear()
586 self.__falseEast.Clear()
587 self.__falseNorth.Clear()
588
589 ProjPanel.Clear(self)
590
591 class GeoPanel(ProjPanel):
592 """Projection Panel for a Geographic Projection."""
593
594 def __init__(self, parent):
595 ProjPanel.__init__(self, parent)
596 ProjPanel._DoLayout(self, None)
597
598 def GetProjName(self):
599 return _("Geographic")
600
601 def SetProjection(self, proj):
602 ProjPanel.SetProjection(self, proj)
603
604 def GetParameters(self):
605 params = ["proj=latlong"]
606 params.extend(ProjPanel.GetParameters(self))
607 return params
608
609 def Clear(self):
610 ProjPanel.Clear(self)
611
612
613 ID_UTM_PROPOSE_ZONE_DIALOG_TAKE = 4001
614 ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL = 4002
615 class UTMProposeZoneDialog(wxDialog):
616
617 """Propose a sensible Zone considering the current map extent."""
618
619 def __init__(self, parent, (x, y, x2, y2)):
620 wxDialog.__init__(self, parent, -1, _("Projection: Propose UTM Zone"),
621 wxDefaultPosition, wxSize(200, 100))
622 self.parent = parent
623 #x, y, x2, y2 = elf.parent.parent.map_bounding_box
624 x = x + 180
625 x2 = x2 + 180
626 center = (x2 - x) / 2 + x
627 self.proposedZone = int(center / 6 + 1)
628 self.dialogLayout()
629
630 def dialogLayout(self):
631 topBox = wxBoxSizer(wxVERTICAL)
632
633 textBox = wxBoxSizer(wxVERTICAL)
634 textBox.Add(wxStaticText(self, -1, _("The current map extent center " +
635 "lies in UTM Zone")),
636 0, wxALIGN_CENTER|wxALL, 4)
637 textBox.Add(wxStaticText(self, -1, str(self.proposedZone)),
638 0, wxALIGN_CENTER|wxALL, 4)
639
640 topBox.Add(textBox, 1, wxEXPAND|wxALL, 4)
641
642 buttonBox = wxBoxSizer(wxHORIZONTAL)
643 buttonBox.Add(wxButton(self, ID_UTM_PROPOSE_ZONE_DIALOG_TAKE,
644 _("Take")), 0, wxALL, 4)
645 buttonBox.Add(wxButton(self, ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL,
646 _("Cancel")), 0, wxALL, 4)
647 topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10)
648 EVT_BUTTON(self, ID_UTM_PROPOSE_ZONE_DIALOG_TAKE, self.OnTake)
649 EVT_BUTTON(self, ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL, self.OnCancel)
650
651 self.SetAutoLayout(True)
652 self.SetSizer(topBox)
653 topBox.Fit(self)
654 topBox.SetSizeHints(self)
655
656 def OnTake(self, event):
657 self.EndModal(wxID_OK)
658
659 def OnCancel(self, event):
660 self.EndModal(wxID_CANCEL)
661
662 def GetProposedZone(self):
663 return self.proposedZone

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26