1 |
jonathan |
717 |
#!/usr/bin/env python |
2 |
|
|
# generated by wxGlade 0.2.1 on Thu Apr 17 11:51:39 2003 |
3 |
|
|
|
4 |
jonathan |
730 |
import os, sys |
5 |
jonathan |
717 |
from wxPython.wx import * |
6 |
|
|
|
7 |
|
|
from Thuban import _ |
8 |
|
|
|
9 |
jonathan |
730 |
from Thuban.Model.proj import Projection, ProjFile |
10 |
jonathan |
717 |
|
11 |
jonathan |
730 |
from Thuban.Model.resource import GetUserProjFiles, GetSystemProjFiles, \ |
12 |
|
|
ReadProjFile, WriteProjFile |
13 |
jonathan |
717 |
from Thuban.UI.dialogs import NonModalDialog |
14 |
|
|
|
15 |
jonathan |
730 |
|
16 |
jonathan |
717 |
ID_PROJ_ADVANCED = 4001 |
17 |
|
|
ID_PROJ_PROJCHOICE = 4002 |
18 |
jonathan |
741 |
ID_PROJ_ADDTOLIST = 4003 |
19 |
jonathan |
717 |
ID_PROJ_NEW = 4004 |
20 |
|
|
ID_PROJ_TRY = 4005 |
21 |
|
|
ID_PROJ_REVERT = 4006 |
22 |
|
|
ID_PROJ_OK = 4007 |
23 |
|
|
ID_PROJ_CLOSE = 4008 |
24 |
|
|
ID_PROJ_AVAIL = 4009 |
25 |
jonathan |
730 |
ID_PROJ_SAVE = 4010 |
26 |
|
|
ID_PROJ_IMPORT = 4011 |
27 |
|
|
ID_PROJ_EXPORT = 4012 |
28 |
|
|
ID_PROJ_REMOVE = 4013 |
29 |
|
|
ID_PROJ_PROJNAME = 4014 |
30 |
jonathan |
717 |
|
31 |
jonathan |
730 |
CLIENT_PROJ = 0 |
32 |
|
|
CLIENT_PROJFILE = 1 |
33 |
jonathan |
717 |
|
34 |
|
|
class ProjFrame(NonModalDialog): |
35 |
|
|
|
36 |
|
|
def __init__(self, parent, name, receiver, *args, **kwds): |
37 |
jonathan |
730 |
"""Initialize the projection dialog. |
38 |
jonathan |
717 |
|
39 |
jonathan |
730 |
receiver -- An object that implements the following methods: |
40 |
|
|
SetProjection(projection) |
41 |
|
|
GetProjection() |
42 |
|
|
""" |
43 |
|
|
|
44 |
jonathan |
717 |
self.receiver = receiver |
45 |
|
|
self.originalProjection = -1 |
46 |
|
|
self.curProjPanel = None |
47 |
|
|
|
48 |
|
|
self.projPanels = [] |
49 |
|
|
self.projPanels.append( |
50 |
jonathan |
730 |
("tmerc", _("Transverse Mercator"), TMPanel)) |
51 |
jonathan |
717 |
self.projPanels.append( |
52 |
jonathan |
730 |
("utm", _("Universal Transverse Mercator"), UTMPanel)) |
53 |
jonathan |
717 |
self.projPanels.append( |
54 |
|
|
("lcc", _("Lambert Conic Conformal"), LCCPanel)) |
55 |
|
|
self.projPanels.append( |
56 |
|
|
("latlong", _("Geographic"), GeoPanel)) |
57 |
|
|
|
58 |
|
|
NonModalDialog.__init__(self, parent, name, "") |
59 |
jonathan |
730 |
# originally generate by wxGlade |
60 |
jonathan |
717 |
self.panel_1 = wxPanel(self, -1) |
61 |
jonathan |
730 |
self.panel_edit = wxPanel(self, -1) |
62 |
|
|
self.panel_buttons = wxPanel(self, -1) |
63 |
jonathan |
717 |
self.label_5 = wxStaticText(self.panel_1, -1, _("Available Projections:")) |
64 |
jonathan |
730 |
self.availprojs = wxListBox(self.panel_1, ID_PROJ_AVAIL, style=wxLB_EXTENDED |wxLB_SORT) |
65 |
|
|
self.projfilepath = wxStaticText(self.panel_1, -1, "") |
66 |
|
|
self.label_2 = wxStaticText(self.panel_edit, -1, _("Name:")) |
67 |
|
|
self.projname = wxTextCtrl(self.panel_edit, ID_PROJ_PROJNAME, "") |
68 |
|
|
self.label_3 = wxStaticText(self.panel_edit, -1, _("Projection:")) |
69 |
|
|
self.projchoice = wxChoice(self.panel_edit, ID_PROJ_PROJCHOICE) |
70 |
|
|
self.button_import = wxButton(self.panel_1, ID_PROJ_IMPORT, _("Import...")) |
71 |
|
|
self.button_export = wxButton(self.panel_1, ID_PROJ_EXPORT, _("Export...")) |
72 |
|
|
self.button_remove = wxButton(self.panel_1, ID_PROJ_REMOVE, _("Remove")) |
73 |
|
|
self.button_new = wxButton(self.panel_edit, ID_PROJ_NEW, _("New")) |
74 |
|
|
self.button_save = wxButton(self.panel_edit, ID_PROJ_SAVE,_("Save")) |
75 |
jonathan |
741 |
self.button_add = wxButton(self.panel_edit, ID_PROJ_ADDTOLIST, |
76 |
jonathan |
730 |
_("Add to List")) |
77 |
|
|
self.button_try = wxButton(self.panel_buttons, ID_PROJ_TRY, _("Try")) |
78 |
|
|
self.button_revert = wxButton(self.panel_buttons, ID_PROJ_REVERT, _("Revert")) |
79 |
|
|
self.button_ok = wxButton(self.panel_buttons, ID_PROJ_OK, _("OK")) |
80 |
|
|
self.button_close = wxButton(self.panel_buttons, ID_PROJ_CLOSE, _("Close")) |
81 |
jonathan |
717 |
|
82 |
|
|
self.__set_properties() |
83 |
|
|
self.__do_layout() |
84 |
jonathan |
730 |
# wxGlade |
85 |
jonathan |
717 |
|
86 |
jonathan |
730 |
self.__DoOnProjAvail() |
87 |
|
|
|
88 |
jonathan |
717 |
EVT_BUTTON(self, ID_PROJ_TRY, self._OnTry) |
89 |
|
|
EVT_BUTTON(self, ID_PROJ_REVERT, self._OnRevert) |
90 |
|
|
EVT_BUTTON(self, ID_PROJ_OK, self._OnOK) |
91 |
|
|
EVT_BUTTON(self, ID_PROJ_CLOSE, self._OnClose) |
92 |
|
|
EVT_CHOICE(self, ID_PROJ_PROJCHOICE, self._OnProjChoice) |
93 |
|
|
EVT_LISTBOX(self, ID_PROJ_AVAIL, self._OnProjAvail) |
94 |
jonathan |
730 |
EVT_BUTTON(self, ID_PROJ_IMPORT, self._OnImport) |
95 |
|
|
EVT_BUTTON(self, ID_PROJ_EXPORT, self._OnExport) |
96 |
|
|
EVT_BUTTON(self, ID_PROJ_REMOVE, self._OnRemove) |
97 |
jonathan |
717 |
|
98 |
|
|
EVT_BUTTON(self, ID_PROJ_NEW, self._OnNew) |
99 |
jonathan |
730 |
EVT_BUTTON(self, ID_PROJ_SAVE, self._OnSave) |
100 |
jonathan |
741 |
EVT_BUTTON(self, ID_PROJ_ADDTOLIST, self._OnAddToList) |
101 |
jonathan |
717 |
|
102 |
jonathan |
730 |
EVT_TEXT(self, ID_PROJ_PROJNAME, self._OnProjName) |
103 |
|
|
|
104 |
jonathan |
717 |
def GetReceiver(self): |
105 |
|
|
return self.receiver |
106 |
|
|
|
107 |
|
|
def _OnTry(self, event): |
108 |
|
|
self.__SetProjection() |
109 |
|
|
|
110 |
|
|
def _OnRevert(self, event): |
111 |
|
|
if self.originalProjection != -1: |
112 |
|
|
self.receiver.SetProjection(self.originalProjection) |
113 |
|
|
|
114 |
|
|
def _OnOK(self, event): |
115 |
|
|
self.__SetProjection() |
116 |
|
|
self.Close() |
117 |
|
|
|
118 |
|
|
def _OnClose(self, event): |
119 |
|
|
self.Close() |
120 |
|
|
|
121 |
jonathan |
730 |
def _OnNew(self, event): |
122 |
|
|
self.__DoOnNew() |
123 |
jonathan |
717 |
|
124 |
jonathan |
730 |
def _OnSave(self, event): |
125 |
jonathan |
717 |
|
126 |
jonathan |
730 |
sel = self.availprojs.GetSelections() |
127 |
|
|
assert len(sel) == 1, "button shouldn't be enabled" |
128 |
jonathan |
717 |
|
129 |
jonathan |
730 |
proj, projfile = self.availprojs.GetClientData(sel[0]) |
130 |
jonathan |
717 |
|
131 |
jonathan |
730 |
assert proj is not None and projfile is not None |
132 |
jonathan |
717 |
|
133 |
jonathan |
730 |
newproj = self.__GetProjection() |
134 |
jonathan |
717 |
|
135 |
jonathan |
730 |
if newproj is not None: |
136 |
|
|
projfile.Remove(proj) |
137 |
|
|
projfile.Add(newproj) |
138 |
|
|
try: |
139 |
|
|
WriteProjFile(projfile) |
140 |
|
|
except IOError, (errno, errstr): |
141 |
|
|
wxMessageDialog(self, |
142 |
|
|
_("The following error occured:\n") + |
143 |
jonathan |
741 |
projfile.GetFilename() + "\n" + errstr, |
144 |
jonathan |
730 |
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
145 |
|
|
self.__FillAvailList() |
146 |
|
|
|
147 |
jonathan |
741 |
def _OnAddToList(self, event): |
148 |
jonathan |
730 |
|
149 |
|
|
proj = self.__GetProjection() |
150 |
|
|
if proj is not None: |
151 |
|
|
self.__usrProjFile.Add(proj) |
152 |
|
|
try: |
153 |
|
|
WriteProjFile(self.__usrProjFile) |
154 |
|
|
except IOError, (errno, errstr): |
155 |
|
|
wxMessageDialog(self, |
156 |
|
|
_("The following error occured:\n") + |
157 |
jonathan |
741 |
self.__usrProjFile.GetFilename() + "\n" + errstr, |
158 |
jonathan |
730 |
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
159 |
|
|
self.__FillAvailList() |
160 |
|
|
|
161 |
jonathan |
717 |
def _OnProjAvail(self, event): |
162 |
|
|
self.__DoOnProjAvail() |
163 |
|
|
|
164 |
jonathan |
730 |
def _OnImport(self, event): |
165 |
|
|
|
166 |
|
|
dlg = wxFileDialog(self, _("Import"), style = wxOPEN) |
167 |
|
|
|
168 |
|
|
if dlg.ShowModal() == wxID_OK: |
169 |
|
|
path = dlg.GetPath() |
170 |
|
|
|
171 |
|
|
try: |
172 |
|
|
projFile = ReadProjFile(path) |
173 |
|
|
for proj in projFile.GetProjections(): |
174 |
|
|
self.__usrProjFile.Add(proj) |
175 |
|
|
WriteProjFile(self.__usrProjFile) |
176 |
|
|
except IOError, (errno, errstr): |
177 |
|
|
wxMessageDialog(self, |
178 |
|
|
_("The following error occured:\n") + |
179 |
|
|
dlg.GetPath() + "\n" + errstr, |
180 |
|
|
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
181 |
|
|
|
182 |
|
|
self.__FillAvailList() |
183 |
|
|
|
184 |
|
|
dlg.Destroy() |
185 |
|
|
|
186 |
|
|
def _OnExport(self, event): |
187 |
|
|
|
188 |
jonathan |
741 |
sel = self.availprojs.GetSelections() |
189 |
|
|
assert len(sel) != 0, "button should be disabled" |
190 |
jonathan |
730 |
|
191 |
|
|
dlg = wxFileDialog(self, _("Export"), |
192 |
jonathan |
741 |
style = wxSAVE|wxOVERWRITE_PROMPT) |
193 |
jonathan |
730 |
|
194 |
|
|
if dlg.ShowModal() == wxID_OK: |
195 |
|
|
path = dlg.GetPath() |
196 |
|
|
|
197 |
|
|
projFile = ProjFile(path) |
198 |
jonathan |
741 |
|
199 |
|
|
for i in sel: |
200 |
|
|
proj = self.availprojs.GetClientData(i)[CLIENT_PROJ] |
201 |
|
|
if proj is not None: |
202 |
|
|
projFile.Add(proj) |
203 |
|
|
|
204 |
jonathan |
730 |
try: |
205 |
|
|
WriteProjFile(projFile) |
206 |
|
|
except IOError, (errno, errstr): |
207 |
|
|
wxMessageDialog(self, |
208 |
|
|
_("The following error occured:\n") + |
209 |
|
|
dlg.GetPath() + "\n" + errstr, |
210 |
|
|
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
211 |
|
|
|
212 |
|
|
dlg.Destroy() |
213 |
|
|
|
214 |
|
|
def _OnRemove(self, event): |
215 |
|
|
|
216 |
|
|
sel = self.availprojs.GetSelections() |
217 |
|
|
assert len(sel) != 0, "button should be disabled!" |
218 |
|
|
|
219 |
|
|
# |
220 |
|
|
# remove the items backwards so the indices don't change |
221 |
|
|
# |
222 |
|
|
sel = list(sel) |
223 |
|
|
sel.sort() |
224 |
|
|
sel.reverse() |
225 |
|
|
|
226 |
|
|
newselection = -1 |
227 |
|
|
if len(sel) == 1: |
228 |
|
|
newselection = sel[0] - 1 |
229 |
|
|
if newselection < 0: |
230 |
|
|
newselection = 0 |
231 |
|
|
|
232 |
|
|
for i in sel: |
233 |
|
|
proj, projfile = self.availprojs.GetClientData(i) |
234 |
|
|
|
235 |
|
|
# |
236 |
|
|
# this could be the case if they selected <None> or |
237 |
|
|
# the currently used projection |
238 |
|
|
# |
239 |
|
|
if proj is not None and projfile is not None: |
240 |
|
|
projfile.Remove(proj) |
241 |
|
|
|
242 |
|
|
try: |
243 |
|
|
WriteProjFile(projfile) |
244 |
|
|
except IOError, (errno, errstr): |
245 |
|
|
wxMessageDialog(self, |
246 |
|
|
_("The following error occured:\n") + |
247 |
jonathan |
741 |
projfile.GetFilename() + "\n" + errstr, |
248 |
jonathan |
730 |
_("Error"), wxOK | wxICON_ERROR).ShowModal() |
249 |
|
|
|
250 |
|
|
|
251 |
|
|
self.__FillAvailList() |
252 |
|
|
|
253 |
|
|
# |
254 |
|
|
# this *could* produce incorrect results if the .proj files |
255 |
|
|
# change between the last list update and this selection |
256 |
|
|
# because the list has been repopulated. |
257 |
|
|
# |
258 |
|
|
if newselection != -1 and self.availprojs.GetCount() > 0: |
259 |
|
|
self.availprojs.SetSelection(newselection) |
260 |
|
|
|
261 |
|
|
def _OnProjName(self, event): |
262 |
|
|
self.__VerifyButtons() |
263 |
|
|
|
264 |
|
|
def __VerifyButtons(self): |
265 |
|
|
sel = self.availprojs.GetSelections() |
266 |
|
|
|
267 |
|
|
self.button_import.Enable(True) |
268 |
|
|
self.button_export.Enable(True) |
269 |
|
|
self.button_save.Enable(True) |
270 |
|
|
self.button_remove.Enable(True) |
271 |
|
|
|
272 |
|
|
self.panel_edit.Enable(True) |
273 |
|
|
|
274 |
|
|
if len(sel) == 0: |
275 |
|
|
self.button_import.Enable(True) |
276 |
|
|
self.button_export.Enable(False) |
277 |
|
|
self.button_remove.Enable(False) |
278 |
|
|
|
279 |
|
|
elif len(sel) == 1: |
280 |
|
|
|
281 |
|
|
proj, projFile = self.availprojs.GetClientData(sel[0]) |
282 |
|
|
|
283 |
|
|
self.button_save.Enable(len(self.projname.GetValue()) > 0) |
284 |
|
|
self.button_add.Enable(len(self.projname.GetValue()) > 0) |
285 |
|
|
|
286 |
|
|
if proj is None: |
287 |
|
|
self.button_export.Enable(False) |
288 |
|
|
self.button_remove.Enable(False) |
289 |
|
|
|
290 |
|
|
if projFile is None: |
291 |
|
|
self.button_save.Enable(False) |
292 |
|
|
|
293 |
|
|
else: |
294 |
|
|
self.panel_edit.Enable(False) |
295 |
|
|
|
296 |
|
|
def __DoOnNew(self): |
297 |
|
|
sel = self.availprojs.GetSelections() |
298 |
|
|
if len(sel) != 0: |
299 |
|
|
self.availprojs.SetSelection(sel, False) |
300 |
|
|
self.projname.Clear() |
301 |
|
|
self.curProjPanel.Clear() |
302 |
|
|
|
303 |
jonathan |
717 |
def __DoOnProjAvail(self): |
304 |
|
|
|
305 |
jonathan |
730 |
sel = self.availprojs.GetSelections() |
306 |
|
|
if len(sel) == 1: |
307 |
jonathan |
717 |
|
308 |
jonathan |
730 |
proj = self.availprojs.GetClientData(sel[0])[CLIENT_PROJ] |
309 |
|
|
projfile = self.availprojs.GetClientData(sel[0])[CLIENT_PROJFILE] |
310 |
jonathan |
717 |
|
311 |
jonathan |
730 |
if proj is None: |
312 |
|
|
# user selected <None> |
313 |
|
|
self.projname.Clear() |
314 |
|
|
else: |
315 |
|
|
|
316 |
|
|
if projfile is not None: |
317 |
jonathan |
741 |
self.projfilepath.SetLabel(projfile.GetFilename()) |
318 |
jonathan |
730 |
else: |
319 |
|
|
# only None if the currently used projection is selected |
320 |
|
|
self.projfilepath.SetLabel("") |
321 |
jonathan |
717 |
|
322 |
jonathan |
730 |
self.projname.SetValue(proj.GetName()) |
323 |
jonathan |
717 |
|
324 |
jonathan |
730 |
myProjType = proj.GetParameter("proj") |
325 |
|
|
i = 0 |
326 |
|
|
for projType, name, clazz in self.projPanels: |
327 |
|
|
if myProjType == projType: |
328 |
|
|
self.projchoice.SetSelection(i) |
329 |
|
|
self.__DoOnProjChoice() |
330 |
|
|
self.curProjPanel.SetProjection(proj) |
331 |
|
|
i += 1 |
332 |
jonathan |
717 |
|
333 |
jonathan |
730 |
self.__VerifyButtons() |
334 |
|
|
|
335 |
jonathan |
717 |
def _OnProjChoice(self, event): |
336 |
|
|
self.__DoOnProjChoice() |
337 |
|
|
|
338 |
|
|
def __DoOnProjChoice(self): |
339 |
|
|
choice = self.projchoice |
340 |
|
|
|
341 |
|
|
sel = choice.GetSelection() |
342 |
jonathan |
730 |
if sel != -1: |
343 |
jonathan |
717 |
|
344 |
jonathan |
730 |
clazz, obj = choice.GetClientData(sel) |
345 |
jonathan |
717 |
|
346 |
jonathan |
730 |
if obj is None: |
347 |
|
|
obj = clazz(self.panel_edit, self.receiver) |
348 |
|
|
choice.SetClientData(sel, [clazz, obj]) |
349 |
jonathan |
717 |
|
350 |
jonathan |
730 |
if self.curProjPanel is not None: |
351 |
|
|
self.curProjPanel.Hide() |
352 |
|
|
self.sizer_projctrls.Remove(self.curProjPanel) |
353 |
jonathan |
717 |
|
354 |
jonathan |
730 |
self.curProjPanel = obj |
355 |
|
|
self.curProjPanel.Show() |
356 |
jonathan |
717 |
|
357 |
jonathan |
730 |
self.sizer_projctrls.Add(self.curProjPanel, 1, |
358 |
|
|
wxALL|wxEXPAND|wxADJUST_MINSIZE, 3) |
359 |
|
|
self.sizer_projctrls.Layout() |
360 |
|
|
self.Layout() |
361 |
|
|
self.topBox.SetSizeHints(self) |
362 |
jonathan |
717 |
|
363 |
|
|
def __SetProjection(self): |
364 |
|
|
|
365 |
|
|
# |
366 |
|
|
# save the original projection only once in case |
367 |
|
|
# we try to apply several different projections |
368 |
|
|
# |
369 |
|
|
if self.originalProjection == -1: |
370 |
|
|
self.originalProjection = self.receiver.GetProjection() |
371 |
|
|
|
372 |
jonathan |
730 |
self.receiver.SetProjection(self.__GetProjection()) |
373 |
jonathan |
717 |
|
374 |
jonathan |
730 |
def __GetProjection(self): |
375 |
|
|
"""Return the packaged projection. |
376 |
jonathan |
717 |
|
377 |
jonathan |
730 |
Could be None. |
378 |
|
|
""" |
379 |
jonathan |
717 |
|
380 |
jonathan |
730 |
proj = None |
381 |
jonathan |
717 |
|
382 |
jonathan |
730 |
if self.curProjPanel is not None: |
383 |
|
|
proj = Projection(self.curProjPanel.GetParameters()) |
384 |
|
|
proj.SetName(self.projname.GetValue()) |
385 |
jonathan |
717 |
|
386 |
jonathan |
730 |
return proj |
387 |
|
|
|
388 |
|
|
def __FillAvailList(self): |
389 |
|
|
self.availprojs.Clear() |
390 |
|
|
|
391 |
|
|
# |
392 |
|
|
# the list can never be empty. there will always be |
393 |
|
|
# at least this one item |
394 |
|
|
# |
395 |
|
|
self.availprojs.Append("<None>", (None, None)) |
396 |
|
|
|
397 |
|
|
self.__sysProjFile = None |
398 |
|
|
self.__usrProjFile = None |
399 |
|
|
|
400 |
|
|
projfile = GetSystemProjFiles() |
401 |
|
|
if len(projfile) > 0: |
402 |
|
|
projfile = projfile[0] |
403 |
jonathan |
717 |
for proj in projfile.GetProjections(): |
404 |
jonathan |
730 |
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
405 |
|
|
self.__sysProjFile = projfile |
406 |
jonathan |
717 |
|
407 |
jonathan |
730 |
projfile = GetUserProjFiles() |
408 |
|
|
if len(projfile) > 0: |
409 |
|
|
projfile = projfile[0] |
410 |
jonathan |
717 |
for proj in projfile.GetProjections(): |
411 |
jonathan |
730 |
self.availprojs.Append(proj.GetName(), [proj, projfile]) |
412 |
|
|
self.__usrProjFile = projfile |
413 |
jonathan |
717 |
|
414 |
jonathan |
730 |
# projfiles = GetSystemProjFiles() |
415 |
|
|
# for projfile in projfiles: |
416 |
|
|
# for proj in projfile.GetProjections(): |
417 |
|
|
# self.availprojs.Append(proj.GetName(), [proj, projfile]) |
418 |
|
|
# self.__sysProjFiles = projfiles |
419 |
|
|
|
420 |
|
|
# projfiles = GetUserProjFiles() |
421 |
|
|
# for projfile in projfiles: |
422 |
|
|
# for proj in projfile.GetProjections(): |
423 |
|
|
# self.availprojs.Append(proj.GetName(), [proj, projfile]) |
424 |
|
|
# self.__usrProjFiles = projfiles |
425 |
|
|
|
426 |
jonathan |
717 |
proj = self.receiver.GetProjection() |
427 |
|
|
if proj is not None: |
428 |
jonathan |
741 |
self.availprojs.Append(_("%s (current)") % proj.GetName(), |
429 |
jonathan |
730 |
[proj, None]) |
430 |
jonathan |
717 |
|
431 |
|
|
for proj, name, clazz in self.projPanels: |
432 |
|
|
self.projchoice.Append(name, [clazz, None]) |
433 |
|
|
|
434 |
jonathan |
730 |
def __set_properties(self): |
435 |
|
|
self.__FillAvailList() |
436 |
|
|
|
437 |
jonathan |
717 |
# begin wxGlade: ProjFrame.__set_properties |
438 |
|
|
self.SetTitle(_("Projections")) |
439 |
|
|
self.availprojs.SetSelection(0) |
440 |
|
|
self.projchoice.SetSelection(0) |
441 |
|
|
# end wxGlade |
442 |
|
|
|
443 |
jonathan |
730 |
self.projname.SetMaxLength(32) |
444 |
|
|
|
445 |
jonathan |
717 |
def __do_layout(self): |
446 |
jonathan |
730 |
# originally generated by wxGlade |
447 |
|
|
|
448 |
jonathan |
717 |
self.topBox = wxBoxSizer(wxVERTICAL) |
449 |
|
|
self.sizer_panel = wxBoxSizer(wxVERTICAL) |
450 |
|
|
sizer_6 = wxBoxSizer(wxHORIZONTAL) |
451 |
|
|
self.sizer_mainctrls = wxBoxSizer(wxHORIZONTAL) |
452 |
jonathan |
730 |
self.sizer_edit = wxStaticBoxSizer(wxStaticBox(self.panel_edit, -1, _("Edit")), wxHORIZONTAL) |
453 |
jonathan |
717 |
sizer_11 = wxBoxSizer(wxVERTICAL) |
454 |
|
|
self.sizer_projctrls = wxBoxSizer(wxVERTICAL) |
455 |
|
|
sizer_14 = wxBoxSizer(wxHORIZONTAL) |
456 |
|
|
sizer_13 = wxBoxSizer(wxHORIZONTAL) |
457 |
jonathan |
730 |
sizer_15 = wxBoxSizer(wxVERTICAL) |
458 |
|
|
sizer_15.Add(self.button_import, 0, wxALL, 4) |
459 |
|
|
sizer_15.Add(self.button_export, 0, wxALL, 4) |
460 |
|
|
sizer_15.Add(20, 20, 0, wxEXPAND, 0) |
461 |
|
|
sizer_15.Add(self.button_remove, 0, wxALL|wxALIGN_BOTTOM, 4) |
462 |
|
|
|
463 |
|
|
# list controls |
464 |
|
|
grid_sizer_1 = wxFlexGridSizer(3, 2, 0, 0) |
465 |
jonathan |
717 |
grid_sizer_1.Add(self.label_5, 0, wxLEFT|wxRIGHT|wxTOP, 4) |
466 |
|
|
grid_sizer_1.Add(20, 20, 0, wxEXPAND, 0) |
467 |
jonathan |
730 |
grid_sizer_1.Add(self.availprojs, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4) |
468 |
|
|
grid_sizer_1.Add(sizer_15, 0, wxALL|wxEXPAND, 4) |
469 |
|
|
grid_sizer_1.Add(self.projfilepath, 0, wxALL|wxADJUST_MINSIZE, 4) |
470 |
jonathan |
717 |
grid_sizer_1.AddGrowableRow(1) |
471 |
|
|
grid_sizer_1.AddGrowableCol(0) |
472 |
jonathan |
730 |
|
473 |
|
|
# edit controls |
474 |
jonathan |
717 |
sizer_13.Add(self.label_2, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
475 |
|
|
sizer_13.Add(self.projname, 1, wxALL, 4) |
476 |
|
|
self.sizer_projctrls.Add(sizer_13, 0, wxEXPAND, 0) |
477 |
|
|
sizer_14.Add(self.label_3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) |
478 |
jonathan |
730 |
sizer_14.Add(self.projchoice, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4) |
479 |
jonathan |
717 |
self.sizer_projctrls.Add(sizer_14, 0, wxEXPAND, 0) |
480 |
|
|
self.sizer_edit.Add(self.sizer_projctrls, 1, wxEXPAND, 0) |
481 |
|
|
sizer_11.Add(self.button_new, 0, wxALL|wxEXPAND, 4) |
482 |
jonathan |
730 |
sizer_11.Add(self.button_save, 0, wxALL|wxEXPAND, 4) |
483 |
|
|
sizer_11.Add(self.button_add, 0, wxALL|wxEXPAND, 4) |
484 |
jonathan |
717 |
self.sizer_edit.Add(sizer_11, 0, wxALL|wxEXPAND, 4) |
485 |
jonathan |
730 |
|
486 |
jonathan |
717 |
sizer_6.Add(20, 20, 1, wxEXPAND, 0) |
487 |
|
|
sizer_6.Add(self.button_try, 0, wxALL, 4) |
488 |
|
|
sizer_6.Add(20, 20, 1, 0, 0) |
489 |
|
|
sizer_6.Add(self.button_revert, 0, wxALL, 4) |
490 |
|
|
sizer_6.Add(20, 20, 1, 0, 0) |
491 |
|
|
sizer_6.Add(self.button_ok, 0, wxALL, 4) |
492 |
|
|
sizer_6.Add(20, 20, 1, 0, 0) |
493 |
|
|
sizer_6.Add(self.button_close, 0, wxALL, 4) |
494 |
|
|
sizer_6.Add(20, 20, 1, wxEXPAND, 0) |
495 |
jonathan |
730 |
|
496 |
jonathan |
717 |
self.panel_1.SetAutoLayout(1) |
497 |
jonathan |
730 |
self.panel_1.SetSizer(grid_sizer_1) |
498 |
|
|
grid_sizer_1.Fit(self.panel_1) |
499 |
|
|
grid_sizer_1.SetSizeHints(self.panel_1) |
500 |
|
|
|
501 |
|
|
self.panel_edit.SetAutoLayout(1) |
502 |
|
|
self.panel_edit.SetSizer(self.sizer_edit) |
503 |
|
|
self.sizer_edit.Fit(self.panel_edit) |
504 |
|
|
self.sizer_edit.SetSizeHints(self.panel_edit) |
505 |
|
|
|
506 |
|
|
self.panel_buttons.SetAutoLayout(1) |
507 |
|
|
self.panel_buttons.SetSizer(sizer_6) |
508 |
|
|
sizer_6.Fit(self.panel_buttons) |
509 |
|
|
sizer_6.SetSizeHints(self.panel_buttons) |
510 |
|
|
|
511 |
|
|
self.sizer_mainctrls.Add(self.panel_1, 0, |
512 |
|
|
wxALL|wxEXPAND|wxADJUST_MINSIZE, 0) |
513 |
|
|
self.sizer_mainctrls.Add(self.panel_edit, 1, |
514 |
|
|
wxALL|wxEXPAND|wxADJUST_MINSIZE, 0) |
515 |
|
|
|
516 |
|
|
self.topBox.Add(self.sizer_mainctrls, 1, wxALL|wxEXPAND, 4) |
517 |
|
|
self.topBox.Add(self.panel_buttons, 0, wxEXPAND, 0) |
518 |
|
|
|
519 |
jonathan |
717 |
self.SetAutoLayout(1) |
520 |
|
|
self.SetSizer(self.topBox) |
521 |
|
|
self.topBox.Fit(self) |
522 |
|
|
self.topBox.SetSizeHints(self) |
523 |
|
|
self.Layout() |
524 |
|
|
|
525 |
|
|
# end of class ProjFrame |
526 |
|
|
|
527 |
|
|
|
528 |
|
|
class ProjPanel(wxPanel): |
529 |
|
|
"""Base class for all projection panels.""" |
530 |
|
|
|
531 |
|
|
def __init__(self, parent): |
532 |
|
|
wxPanel.__init__(self, parent, -1) |
533 |
|
|
|
534 |
|
|
self.__ellps = wxChoice(self, -1) |
535 |
|
|
self.ellpsData = [("bessel", _("Bessel 1841")), |
536 |
|
|
("clrk66", _("Clarke 1866")), |
537 |
|
|
("clrk80", _("Clarke 1880")), |
538 |
|
|
("GRS80" , _("GRS 1980 (IUGG, 1980)")), |
539 |
|
|
("intl" , _("International 1909 (Hayford)")), |
540 |
|
|
("WGS84" , _("WGS 84"))] |
541 |
|
|
|
542 |
|
|
for tag, name in self.ellpsData: |
543 |
|
|
self.__ellps.Append(name, tag) |
544 |
|
|
|
545 |
|
|
self.__ellps.SetSelection(0) |
546 |
|
|
|
547 |
|
|
def _DoLayout(self, childPanel = None): |
548 |
|
|
|
549 |
|
|
panelSizer = wxBoxSizer(wxVERTICAL) |
550 |
|
|
|
551 |
|
|
if childPanel is not None: |
552 |
|
|
panelSizer.Add(childPanel, 0, wxALL|wxEXPAND, 4) |
553 |
|
|
|
554 |
|
|
sizer = wxBoxSizer(wxHORIZONTAL) |
555 |
|
|
sizer.Add(wxStaticText(self, -1, _("Ellipsoid:")), 0, wxALL, 4) |
556 |
jonathan |
730 |
sizer.Add(self.__ellps, 1, wxALL|wxEXPAND|wxADJUST_MINSIZE, 4) |
557 |
jonathan |
717 |
panelSizer.Add(sizer, 0, wxALL|wxEXPAND, 4) |
558 |
|
|
|
559 |
|
|
self.SetAutoLayout(1) |
560 |
|
|
self.SetSizer(panelSizer) |
561 |
|
|
panelSizer.Fit(self) |
562 |
|
|
panelSizer.SetSizeHints(self) |
563 |
|
|
self.Layout() |
564 |
|
|
|
565 |
|
|
def SetProjection(self, proj): |
566 |
|
|
if proj is not None: |
567 |
|
|
param = proj.GetParameter("ellps") |
568 |
|
|
i = 0 |
569 |
|
|
for tag, name in self.ellpsData: |
570 |
|
|
if param == tag: |
571 |
|
|
self.__ellps.SetSelection(i) |
572 |
|
|
return # returning early! |
573 |
|
|
i += 1 |
574 |
|
|
|
575 |
|
|
# |
576 |
|
|
# if proj is none, or the parameter couldn't be found... |
577 |
|
|
# |
578 |
|
|
self.__ellps.SetSelection(0) |
579 |
|
|
|
580 |
|
|
def GetParameters(self): |
581 |
|
|
return ["ellps=" + self.__ellps.GetClientData( |
582 |
|
|
self.__ellps.GetSelection())] |
583 |
|
|
|
584 |
|
|
|
585 |
|
|
ID_TMPANEL_LAT = 4001 |
586 |
|
|
ID_TMPANEL_LONG = 4002 |
587 |
|
|
ID_TMPANEL_FASLE_EAST = 4003 |
588 |
|
|
ID_TMPANEL_FALSE_NORTH = 4004 |
589 |
|
|
ID_TMPANEL_SCALE = 4005 |
590 |
|
|
|
591 |
|
|
class UnknownProjPanel(ProjPanel): |
592 |
jonathan |
730 |
def __init__(self, parent, receiver): |
593 |
jonathan |
717 |
ProjPanel.__init__(self, parent) |
594 |
|
|
|
595 |
|
|
self._DoLayout() |
596 |
|
|
|
597 |
|
|
def _DoLayout(self): |
598 |
|
|
sizer = wxBoxSizer(wxVERTICAL) |
599 |
|
|
|
600 |
|
|
sizer.Add(wxStaticText(self, -1, |
601 |
|
|
_("Thuban does not know the parameters for the " + |
602 |
|
|
"current projection and cannot display a " + |
603 |
|
|
"configuration panel."))) |
604 |
|
|
|
605 |
|
|
ProjPanel._DoLayout(self, sizer) |
606 |
|
|
|
607 |
|
|
def GetProjName(self): |
608 |
|
|
return "Unknown" |
609 |
|
|
|
610 |
|
|
def SetProjection(self, proj): |
611 |
|
|
pass |
612 |
|
|
|
613 |
|
|
def GetParameters(self): |
614 |
|
|
return None |
615 |
|
|
|
616 |
|
|
class TMPanel(ProjPanel): |
617 |
jonathan |
730 |
"""Projection panel for Transverse Mercator.""" |
618 |
jonathan |
717 |
|
619 |
jonathan |
730 |
def __init__(self, parent, receiver): |
620 |
jonathan |
717 |
ProjPanel.__init__(self, parent) |
621 |
|
|
|
622 |
|
|
self.__latitude = wxTextCtrl(self, ID_TMPANEL_LAT) |
623 |
|
|
self.__longitude = wxTextCtrl(self, ID_TMPANEL_LONG) |
624 |
|
|
self.__falseEast = wxTextCtrl(self, ID_TMPANEL_FASLE_EAST) |
625 |
|
|
self.__falseNorth = wxTextCtrl(self, ID_TMPANEL_FALSE_NORTH) |
626 |
|
|
self.__scale = wxTextCtrl(self, ID_TMPANEL_SCALE) |
627 |
|
|
|
628 |
|
|
self._DoLayout() |
629 |
|
|
|
630 |
|
|
def _DoLayout(self): |
631 |
|
|
|
632 |
|
|
sizer = wxFlexGridSizer(4, 4, 0, 0) |
633 |
|
|
sizer.Add(wxStaticText(self, -1, _("Latitude:")), 0, wxALL, 4) |
634 |
|
|
sizer.Add(self.__latitude, 0, wxALL, 4) |
635 |
|
|
sizer.Add(wxStaticText(self, -1, _("False Easting:")), 0, wxALL, 4) |
636 |
|
|
sizer.Add(self.__falseEast, 0, wxALL, 4) |
637 |
|
|
sizer.Add(wxStaticText(self, -1, _("Longitude:")), 0, wxALL, 4) |
638 |
|
|
sizer.Add(self.__longitude, 0, wxALL, 4) |
639 |
|
|
sizer.Add(wxStaticText(self, -1, _("False Northing:")), 0, wxALL, 4) |
640 |
|
|
sizer.Add(self.__falseNorth, 0, wxALL, 4) |
641 |
|
|
sizer.Add(wxStaticText(self, -1, _("Scale Factor:")), 0, wxALL, 4) |
642 |
|
|
sizer.Add(self.__scale, 0, wxALL, 4) |
643 |
|
|
|
644 |
|
|
ProjPanel._DoLayout(self, sizer) |
645 |
|
|
|
646 |
|
|
def GetProjName(self): |
647 |
jonathan |
730 |
return _("Transverse Mercator") |
648 |
jonathan |
717 |
|
649 |
|
|
def SetProjection(self, proj): |
650 |
|
|
ProjPanel.SetProjection(self, proj) |
651 |
|
|
|
652 |
|
|
self.__latitude.SetValue(proj.GetParameter("lat_0")) |
653 |
|
|
self.__longitude.SetValue(proj.GetParameter("lon_0")) |
654 |
|
|
self.__falseEast.SetValue(proj.GetParameter("x_0")) |
655 |
|
|
self.__falseNorth.SetValue(proj.GetParameter("y_0")) |
656 |
|
|
self.__scale.SetValue(proj.GetParameter("k")) |
657 |
|
|
|
658 |
|
|
ProjPanel.SetProjection(self, proj) |
659 |
|
|
|
660 |
|
|
def GetParameters(self): |
661 |
|
|
params = ["proj=tmerc", |
662 |
|
|
"lat_0=" + self.__latitude.GetValue(), |
663 |
|
|
"lon_0=" + self.__longitude.GetValue(), |
664 |
|
|
"x_0=" + self.__falseEast.GetValue(), |
665 |
|
|
"y_0=" + self.__falseNorth.GetValue(), |
666 |
|
|
"k=" + self.__scale.GetValue()] |
667 |
|
|
params.extend(ProjPanel.GetParameters(self)) |
668 |
|
|
return params |
669 |
|
|
|
670 |
|
|
def Clear(self): |
671 |
|
|
self.__latitude.Clear() |
672 |
|
|
self.__longitude.Clear() |
673 |
|
|
self.__falseEast.Clear() |
674 |
|
|
self.__falseNorth.Clear() |
675 |
|
|
self.__scale.Clear() |
676 |
|
|
|
677 |
|
|
ProjPanel.Clear(self) |
678 |
|
|
|
679 |
|
|
ID_UTMPANEL_ZONE = 4001 |
680 |
|
|
ID_UTMPANEL_SOUTH = 4002 |
681 |
|
|
ID_UTMPANEL_PROP = 4003 |
682 |
|
|
|
683 |
|
|
class UTMPanel(ProjPanel): |
684 |
jonathan |
730 |
"""Projection Panel for Universal Transverse Mercator.""" |
685 |
jonathan |
717 |
|
686 |
jonathan |
730 |
def __init__(self, parent, receiver): |
687 |
jonathan |
717 |
ProjPanel.__init__(self, parent) |
688 |
|
|
|
689 |
jonathan |
730 |
self.receiver = receiver |
690 |
jonathan |
717 |
|
691 |
|
|
self.__zone = wxSpinCtrl(self, ID_UTMPANEL_ZONE, "1", min=1, max=60) |
692 |
|
|
self.__south = wxCheckBox(self, ID_UTMPANEL_SOUTH, |
693 |
|
|
_("Southern Hemisphere")) |
694 |
|
|
self.__propButton = wxButton(self, ID_UTMPANEL_PROP, _("Propose")) |
695 |
|
|
|
696 |
|
|
self._DoLayout() |
697 |
|
|
|
698 |
|
|
EVT_BUTTON(self, ID_UTMPANEL_PROP, self._OnPropose) |
699 |
|
|
|
700 |
|
|
def _DoLayout(self): |
701 |
|
|
|
702 |
|
|
sizer = wxBoxSizer(wxVERTICAL) |
703 |
|
|
psizer = wxBoxSizer(wxHORIZONTAL) |
704 |
|
|
psizer.Add(wxStaticText(self, -1, _("Zone:")), 0, wxALL, 4) |
705 |
|
|
psizer.Add(self.__zone, 0, wxALL, 4) |
706 |
|
|
psizer.Add(self.__propButton, 0, wxALL, 4) |
707 |
|
|
sizer.Add(psizer, 0, wxALL, 4) |
708 |
|
|
sizer.Add(self.__south, 0, wxALL, 4) |
709 |
|
|
|
710 |
|
|
ProjPanel._DoLayout(self, sizer) |
711 |
|
|
|
712 |
|
|
def GetProjName(self): |
713 |
jonathan |
730 |
return _("Universal Transverse Mercator") |
714 |
jonathan |
717 |
|
715 |
|
|
def SetProjection(self, proj): |
716 |
|
|
self.__zone.SetValue(int(proj.GetParameter("zone"))) |
717 |
|
|
self.__south.SetValue(proj.GetParameter("south") != "") |
718 |
|
|
ProjPanel.SetProjection(self, proj) |
719 |
|
|
|
720 |
|
|
def GetParameters(self): |
721 |
|
|
params = ["proj=utm", "zone=" + str(self.__zone.GetValue())] |
722 |
|
|
if self.__south.IsChecked(): |
723 |
|
|
params.append("south") |
724 |
|
|
|
725 |
|
|
params.extend(ProjPanel.GetParameters(self)) |
726 |
|
|
return params |
727 |
|
|
|
728 |
|
|
def Clear(self): |
729 |
|
|
self.__zone.SetValue(1) |
730 |
|
|
self.__south.SetValue(False) |
731 |
|
|
ProjPanel.Clear(self) |
732 |
|
|
|
733 |
|
|
def _OnPropose(self, event): |
734 |
|
|
UTMProposeZoneDialog |
735 |
jonathan |
730 |
dlg = UTMProposeZoneDialog(self, self.receiver.BoundingBox()) |
736 |
jonathan |
717 |
if dlg.ShowModal() == wxID_OK: |
737 |
|
|
self.__zone.SetValue(dlg.GetProposedZone()) |
738 |
|
|
|
739 |
|
|
class LCCPanel(ProjPanel): |
740 |
|
|
"""Projection Panel for Lambert Conic Conformal.""" |
741 |
|
|
|
742 |
jonathan |
730 |
def __init__(self, parent, receiver): |
743 |
jonathan |
717 |
ProjPanel.__init__(self, parent) |
744 |
|
|
|
745 |
|
|
self.__fspLatitude = wxTextCtrl(self, -1) |
746 |
|
|
self.__sspLatitude = wxTextCtrl(self, -1) |
747 |
|
|
self.__originLat = wxTextCtrl(self, -1) |
748 |
|
|
self.__meridian = wxTextCtrl(self, -1) |
749 |
|
|
self.__falseEast = wxTextCtrl(self, -1) |
750 |
|
|
self.__falseNorth = wxTextCtrl(self, -1) |
751 |
|
|
|
752 |
|
|
self._DoLayout() |
753 |
|
|
|
754 |
|
|
def _DoLayout(self): |
755 |
|
|
|
756 |
|
|
sizer = wxFlexGridSizer(6, 2, 0, 0) |
757 |
|
|
sizer.Add(wxStaticText(self, -1, |
758 |
|
|
_("Latitude of first standard parallel:"))) |
759 |
|
|
sizer.Add(self.__fspLatitude, 0, wxALL, 4) |
760 |
|
|
sizer.Add(wxStaticText(self, -1, |
761 |
|
|
_("Latitude of second standard parallel:"))) |
762 |
|
|
sizer.Add(self.__sspLatitude, 0, wxALL, 4) |
763 |
|
|
sizer.Add(wxStaticText(self, -1, _("Latitude of origin:"))) |
764 |
|
|
sizer.Add(self.__originLat, 0, wxALL, 4) |
765 |
|
|
sizer.Add(wxStaticText(self, -1, _("Central Meridian:"))) |
766 |
|
|
sizer.Add(self.__meridian, 0, wxALL, 4) |
767 |
|
|
sizer.Add(wxStaticText(self, -1, _("False Easting:"))) |
768 |
|
|
sizer.Add(self.__falseEast, 0, wxALL, 4) |
769 |
|
|
sizer.Add(wxStaticText(self, -1, _("False Northing:"))) |
770 |
|
|
sizer.Add(self.__falseNorth, 0, wxALL, 4) |
771 |
|
|
|
772 |
|
|
ProjPanel._DoLayout(self, sizer) |
773 |
|
|
|
774 |
|
|
def GetProjName(self): |
775 |
|
|
return _("Lambert Conic Conformal") |
776 |
|
|
|
777 |
|
|
def SetProjection(self, proj): |
778 |
|
|
self.__fspLatitude.SetValue(proj.GetParameter("lat_1")) |
779 |
|
|
self.__sspLatitude.SetValue(proj.GetParameter("lat_2")) |
780 |
|
|
self.__originLat.SetValue(proj.GetParameter("lat_0")) |
781 |
|
|
self.__meridian.SetValue(proj.GetParameter("lon_0")) |
782 |
|
|
self.__falseEast.SetValue(proj.GetParameter("x_0")) |
783 |
|
|
self.__falseNorth.SetValue(proj.GetParameter("y_0")) |
784 |
|
|
|
785 |
|
|
ProjPanel.SetProjection(self, proj) |
786 |
|
|
|
787 |
|
|
def GetParameters(self): |
788 |
|
|
params = ["proj=lcc", |
789 |
|
|
"lat_1=" + self.__fspLatitude.GetValue(), |
790 |
|
|
"lat_2=" + self.__sspLatitude.GetValue(), |
791 |
|
|
"lat_0=" + self.__originLat.GetValue(), |
792 |
|
|
"lon_0=" + self.__meridian.GetValue(), |
793 |
|
|
"x_0=" + self.__falseEast.GetValue(), |
794 |
|
|
"y_0=" + self.__falseNorth.GetValue()] |
795 |
|
|
|
796 |
|
|
params.extend(ProjPanel.GetParameters(self)) |
797 |
|
|
return params |
798 |
|
|
|
799 |
|
|
def Clear(self): |
800 |
|
|
self.__fspLatitude.Clear() |
801 |
|
|
self.__sspLatitude.Clear() |
802 |
|
|
self.__originLat.Clear() |
803 |
|
|
self.__meridian.Clear() |
804 |
|
|
self.__falseEast.Clear() |
805 |
|
|
self.__falseNorth.Clear() |
806 |
|
|
|
807 |
|
|
ProjPanel.Clear(self) |
808 |
|
|
|
809 |
|
|
class GeoPanel(ProjPanel): |
810 |
|
|
"""Projection Panel for a Geographic Projection.""" |
811 |
|
|
|
812 |
jonathan |
730 |
def __init__(self, parent, receiver): |
813 |
jonathan |
717 |
ProjPanel.__init__(self, parent) |
814 |
|
|
ProjPanel._DoLayout(self, None) |
815 |
|
|
|
816 |
|
|
def GetProjName(self): |
817 |
|
|
return _("Geographic") |
818 |
|
|
|
819 |
|
|
def SetProjection(self, proj): |
820 |
|
|
ProjPanel.SetProjection(self, proj) |
821 |
|
|
|
822 |
|
|
def GetParameters(self): |
823 |
|
|
params = ["proj=latlong"] |
824 |
|
|
params.extend(ProjPanel.GetParameters(self)) |
825 |
|
|
return params |
826 |
|
|
|
827 |
|
|
def Clear(self): |
828 |
|
|
ProjPanel.Clear(self) |
829 |
|
|
|
830 |
|
|
|
831 |
|
|
ID_UTM_PROPOSE_ZONE_DIALOG_TAKE = 4001 |
832 |
|
|
ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL = 4002 |
833 |
|
|
class UTMProposeZoneDialog(wxDialog): |
834 |
|
|
|
835 |
|
|
"""Propose a sensible Zone considering the current map extent.""" |
836 |
|
|
|
837 |
|
|
def __init__(self, parent, (x, y, x2, y2)): |
838 |
|
|
wxDialog.__init__(self, parent, -1, _("Projection: Propose UTM Zone"), |
839 |
|
|
wxDefaultPosition, wxSize(200, 100)) |
840 |
|
|
self.parent = parent |
841 |
|
|
#x, y, x2, y2 = elf.parent.parent.map_bounding_box |
842 |
|
|
x = x + 180 |
843 |
|
|
x2 = x2 + 180 |
844 |
|
|
center = (x2 - x) / 2 + x |
845 |
|
|
self.proposedZone = int(center / 6 + 1) |
846 |
|
|
self.dialogLayout() |
847 |
|
|
|
848 |
|
|
def dialogLayout(self): |
849 |
|
|
topBox = wxBoxSizer(wxVERTICAL) |
850 |
|
|
|
851 |
|
|
textBox = wxBoxSizer(wxVERTICAL) |
852 |
|
|
textBox.Add(wxStaticText(self, -1, _("The current map extent center " + |
853 |
|
|
"lies in UTM Zone")), |
854 |
|
|
0, wxALIGN_CENTER|wxALL, 4) |
855 |
|
|
textBox.Add(wxStaticText(self, -1, str(self.proposedZone)), |
856 |
|
|
0, wxALIGN_CENTER|wxALL, 4) |
857 |
|
|
|
858 |
|
|
topBox.Add(textBox, 1, wxEXPAND|wxALL, 4) |
859 |
|
|
|
860 |
|
|
buttonBox = wxBoxSizer(wxHORIZONTAL) |
861 |
|
|
buttonBox.Add(wxButton(self, ID_UTM_PROPOSE_ZONE_DIALOG_TAKE, |
862 |
|
|
_("Take")), 0, wxALL, 4) |
863 |
|
|
buttonBox.Add(wxButton(self, ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL, |
864 |
|
|
_("Cancel")), 0, wxALL, 4) |
865 |
|
|
topBox.Add(buttonBox, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10) |
866 |
|
|
EVT_BUTTON(self, ID_UTM_PROPOSE_ZONE_DIALOG_TAKE, self.OnTake) |
867 |
|
|
EVT_BUTTON(self, ID_UTM_PROPOSE_ZONE_DIALOG_CANCEL, self.OnCancel) |
868 |
|
|
|
869 |
|
|
self.SetAutoLayout(True) |
870 |
|
|
self.SetSizer(topBox) |
871 |
|
|
topBox.Fit(self) |
872 |
|
|
topBox.SetSizeHints(self) |
873 |
|
|
|
874 |
|
|
def OnTake(self, event): |
875 |
|
|
self.EndModal(wxID_OK) |
876 |
|
|
|
877 |
|
|
def OnCancel(self, event): |
878 |
|
|
self.EndModal(wxID_CANCEL) |
879 |
|
|
|
880 |
|
|
def GetProposedZone(self): |
881 |
|
|
return self.proposedZone |