2 @package location_wizard.wizard
4 @brief Location wizard - creates a new GRASS Location. User can choose
10 - wizard::CoordinateSystemPage
11 - wizard::ProjectionsPage
13 - wizard::ProjParamsPage
16 - wizard::GeoreferencedFilePage
21 - wizard::LocationWizard
22 - wizard::WizardWithHelpButton
24 (C) 2007-2013 by the GRASS Development Team
26 This program is free software under the GNU General Public License
27 (>=v2). Read the file COPYING that comes with GRASS for details.
29 @author Michael Barton
30 @author Jachym Cepicky
31 @author Martin Landa <landa.martin gmail.com>
37 import wx.lib.mixins.listctrl
as listmix
38 import wx.wizard
as wiz
39 import wx.lib.scrolledpanel
as scrolled
41 from core
import globalvar
42 from core
import utils
43 from core.gcmd import RunCommand, GError, GMessage, GWarning
61 """!Class to make wizard pages. Generic methods to make labels,
62 text entries, and buttons.
66 self.
page = wiz.WizardPageSimple.__init__(self, parent)
69 self.
title = wx.StaticText(parent = self, id = wx.ID_ANY, label = title)
70 self.title.SetFont(wx.Font(13, wx.SWISS, wx.NORMAL, wx.BOLD))
74 self.
sizer = wx.GridBagSizer(vgap = 0, hgap = 0)
78 self.pagesizer.Add(item = self.
title, proportion = 0,
79 flag = wx.ALIGN_CENTRE | wx.ALL,
81 self.pagesizer.Add(item = wx.StaticLine(self, -1), proportion = 0,
82 flag = wx.EXPAND | wx.ALL,
84 self.pagesizer.Add(item = self.
sizer, proportion = 1,
87 self.SetAutoLayout(
True)
92 """!Wizard page for setting GIS data directory and location name"""
93 def __init__(self, wizard, parent, grassdatabase):
94 TitledPage.__init__(self, wizard, _(
"Define GRASS Database and Location Name"))
104 self.
tgisdbase = self.MakeTextCtrl(grassdatabase, size = (300, -1))
105 self.
tlocation = self.MakeTextCtrl(
"newLocation", size = (300, -1))
110 self.sizer.Add(item = self.MakeLabel(_(
"GIS Data Directory:")),
111 flag = wx.ALIGN_RIGHT |
112 wx.ALIGN_CENTER_VERTICAL |
116 flag = wx.ALIGN_LEFT |
117 wx.ALIGN_CENTER_VERTICAL |
120 self.sizer.Add(item = self.
bbrowse,
121 flag = wx.ALIGN_LEFT |
122 wx.ALIGN_CENTER_VERTICAL |
126 self.sizer.Add(item = self.MakeLabel(
"%s:" % _(
"Project Location"),
127 tooltip = _(
"Name of location directory in GIS Data Directory")),
128 flag = wx.ALIGN_RIGHT |
129 wx.ALIGN_CENTER_VERTICAL |
133 flag = wx.ALIGN_LEFT |
134 wx.ALIGN_CENTER_VERTICAL |
138 self.sizer.Add(item = self.MakeLabel(
"%s:" % _(
"Location Title"),
139 tooltip = _(
"Optional location title, "
140 "you can leave this field blank.")),
141 flag = wx.ALIGN_RIGHT |
142 wx.ALIGN_TOP | wx.ALIGN_CENTER_VERTICAL |
146 flag = wx.ALIGN_LEFT |
147 wx.ALIGN_CENTER_VERTICAL |
149 pos = (3, 2), span = (1, 2))
150 self.sizer.AddGrowableCol(3)
158 def _nameValidationFailed(self, ctrl):
159 message = _(
"Name <%(name)s> is not a valid name for location. "
160 "Please use only ASCII characters excluding %(chars)s "
161 "and space.") % {
'name': ctrl.GetValue(),
'chars':
'/"\'@,=*~'}
162 GError(parent=self, message=message, caption=_(
"Invalid location name"))
165 """!Name for new location was changed"""
166 nextButton = wx.FindWindowById(wx.ID_FORWARD)
167 if len(event.GetString()) > 0:
168 if not nextButton.IsEnabled():
176 """!Choose GRASS data directory"""
177 dlg = wx.DirDialog(self, _(
"Choose GRASS data directory:"),
178 os.getcwd(), wx.DD_DEFAULT_STYLE)
179 if dlg.ShowModal() == wx.ID_OK:
187 if os.path.isdir(os.path.join(self.tgisdbase.GetValue(), self.tlocation.GetValue())):
188 error = _(
"Location already exists in GRASS Database.")
191 GError(parent = self,
192 message=
"%s <%s>.%s%s" % (_(
"Unable to create location"),
193 str(self.tlocation.GetValue()),
199 self.
location = self.tlocation.GetValue()
201 self.
locTitle = self.tlocTitle.GetValue()
204 GWarning(parent = self,
205 message = _(
"Title of the location is limited only to one line and "
206 "256 characters. The rest of the text will be ignored."))
207 self.
locTitle = self.locTitle.split(os.linesep)[0][:255]
210 """!Wizard page for choosing method for location creation"""
212 TitledPage.__init__(self, wizard, _(
"Choose method for creating a new location"))
218 self.
radio1 = wx.RadioButton(parent = self, id = wx.ID_ANY,
219 label = _(
"Select coordinate system parameters from a list"),
221 self.
radio2 = wx.RadioButton(parent = self, id = wx.ID_ANY,
222 label = _(
"Select EPSG code of spatial reference system"))
223 self.
radio3 = wx.RadioButton(parent = self, id = wx.ID_ANY,
224 label = _(
"Read projection and datum terms from a "
225 "georeferenced data file"))
226 self.
radio4 = wx.RadioButton(parent = self, id = wx.ID_ANY,
227 label = _(
"Read projection and datum terms from a "
228 "Well Known Text (WKT) .prj file"))
229 self.
radio5 = wx.RadioButton(parent = self, id = wx.ID_ANY,
230 label = _(
"Specify projection and datum terms using custom "
231 "PROJ.4 parameters"))
232 self.
radio6 = wx.RadioButton(parent = self, id = wx.ID_ANY,
233 label = _(
"Create a generic Cartesian coordinate system (XY)"))
236 self.sizer.SetVGap(10)
237 self.sizer.Add(item = self.
radio1,
238 flag = wx.ALIGN_LEFT, pos = (1, 1))
239 self.sizer.Add(item = self.
radio2,
240 flag = wx.ALIGN_LEFT, pos = (2, 1))
241 self.sizer.Add(item = self.
radio3,
242 flag = wx.ALIGN_LEFT, pos = (3, 1))
243 self.sizer.Add(item = self.
radio4,
244 flag = wx.ALIGN_LEFT, pos = (4, 1))
245 self.sizer.Add(item = self.
radio5,
246 flag = wx.ALIGN_LEFT, pos = (5, 1))
247 self.sizer.Add(item = self.
radio6,
248 flag = wx.ALIGN_LEFT, pos = (6, 1))
249 self.sizer.AddGrowableCol(1)
252 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio1.GetId())
253 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio2.GetId())
254 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio3.GetId())
255 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio4.GetId())
256 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio5.GetId())
257 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio6.GetId())
258 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
265 self.radio1.SetValue(
True)
267 if coordsys ==
'proj':
268 self.radio1.SetValue(
True)
269 if coordsys ==
"epsg":
270 self.radio2.SetValue(
True)
271 if coordsys ==
"file":
272 self.radio3.SetValue(
True)
273 if coordsys ==
"wkt":
274 self.radio4.SetValue(
True)
275 if coordsys ==
"custom":
276 self.radio5.SetValue(
True)
278 self.radio6.SetValue(
True)
280 if event.GetDirection():
281 if coordsys ==
'proj':
282 self.SetNext(self.parent.projpage)
283 self.parent.sumpage.SetPrev(self.parent.datumpage)
284 if coordsys ==
"epsg":
285 self.SetNext(self.parent.epsgpage)
286 self.parent.sumpage.SetPrev(self.parent.epsgpage)
287 if coordsys ==
"file":
288 self.SetNext(self.parent.filepage)
289 self.parent.sumpage.SetPrev(self.parent.filepage)
290 if coordsys ==
"wkt":
291 self.SetNext(self.parent.wktpage)
292 self.parent.sumpage.SetPrev(self.parent.wktpage)
293 if coordsys ==
"custom":
294 self.SetNext(self.parent.custompage)
295 self.parent.sumpage.SetPrev(self.parent.custompage)
297 self.SetNext(self.parent.sumpage)
298 self.parent.sumpage.SetPrev(self.parent.csystemspage)
300 if not wx.FindWindowById(wx.ID_FORWARD).IsEnabled():
301 wx.FindWindowById(wx.ID_FORWARD).Enable()
306 if event.GetId() == self.radio1.GetId():
308 self.SetNext(self.parent.projpage)
309 self.parent.sumpage.SetPrev(self.parent.datumpage)
310 elif event.GetId() == self.radio2.GetId():
312 self.SetNext(self.parent.epsgpage)
313 self.parent.sumpage.SetPrev(self.parent.epsgpage)
314 elif event.GetId() == self.radio3.GetId():
316 self.SetNext(self.parent.filepage)
317 self.parent.sumpage.SetPrev(self.parent.filepage)
318 elif event.GetId() == self.radio4.GetId():
320 self.SetNext(self.parent.wktpage)
321 self.parent.sumpage.SetPrev(self.parent.wktpage)
322 elif event.GetId() == self.radio5.GetId():
324 self.SetNext(self.parent.custompage)
325 self.parent.sumpage.SetPrev(self.parent.custompage)
326 elif event.GetId() == self.radio6.GetId():
328 self.SetNext(self.parent.sumpage)
329 self.parent.sumpage.SetPrev(self.parent.csystemspage)
332 """!Wizard page for selecting projection (select coordinate system option)"""
334 TitledPage.__init__(self, wizard, _(
"Choose projection"))
342 self.
tproj = self.MakeTextCtrl(
"", size = (200,-1))
345 self.
searchb = wx.SearchCtrl(self, size = (200,-1),
346 style = wx.TE_PROCESS_ENTER)
350 columns = [_(
'Code'), _(
'Description')])
351 self.projlist.resizeLastColumn(30)
354 self.sizer.Add(item = self.MakeLabel(_(
"Projection code:")),
355 flag = wx.ALIGN_LEFT |
356 wx.ALIGN_CENTER_VERTICAL |
357 wx.ALL, border = 5, pos = (1, 1))
358 self.sizer.Add(item = self.
tproj,
359 flag = wx.ALIGN_RIGHT | wx.EXPAND | wx.ALL,
360 border = 5, pos = (1, 2))
362 self.sizer.Add(item = self.MakeLabel(_(
"Search in description:")),
363 flag = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
364 border = 5, pos = (2, 1))
365 self.sizer.Add(item = self.
searchb,
366 flag = wx.ALIGN_RIGHT | wx.EXPAND | wx.ALL,
367 border = 5, pos = (2, 2))
369 self.sizer.Add(item = self.
projlist,
372 wx.ALL, border = 5, pos = (3, 1), span = (1, 3))
373 self.sizer.AddGrowableCol(3)
374 self.sizer.AddGrowableRow(3)
377 self.tproj.Bind(wx.EVT_TEXT, self.
OnText)
378 self.tproj.Bind(wx.EVT_TEXT_ENTER, self.
OnText)
379 self.searchb.Bind(wx.EVT_TEXT_ENTER, self.
OnSearch)
380 self.projlist.Bind(wx.EVT_LIST_ITEM_SELECTED, self.
OnItemSelected)
382 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
385 if event.GetDirection()
and self.
proj not in self.parent.projections.keys():
389 """!Projection name changed"""
390 self.
proj = event.GetString().lower()
392 nextButton = wx.FindWindowById(wx.ID_FORWARD)
393 if self.
proj not in self.parent.projections.keys()
and nextButton.IsEnabled():
394 nextButton.Enable(
False)
396 if self.
proj in self.parent.projections.keys():
397 if self.
proj ==
'stp':
398 wx.MessageBox(
'Currently State Plane projections must be selected using the '
399 'text-based setup (g.setproj), or entered by EPSG code or '
400 'custom PROJ.4 terms.',
401 'Warning', wx.ICON_WARNING)
403 self.tproj.SetValue(self.
proj)
404 nextButton.Enable(
False)
406 elif self.proj.lower() ==
'll':
407 self.
p4proj =
'+proj=longlat'
409 self.
p4proj =
'+proj=' + self.proj.lower()
414 if len(self.
proj) == 0:
416 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
418 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
423 """!Search projection by desc"""
424 str = event.GetString()
426 self.
proj, self.
projdesc = self.projlist.Search(index = [0,1], pattern = event.GetString())
433 """!Projection selected"""
434 index = event.m_itemIndex
437 self.
proj = self.projlist.GetItem(index, 0).GetText().lower()
438 self.tproj.SetValue(self.
proj)
443 listmix.ListCtrlAutoWidthMixin,
444 listmix.ColumnSorterMixin):
445 """!Generic list (for projections, ellipsoids, etc.)"""
448 wx.ListCtrl.__init__(self, parent = parent, id = wx.ID_ANY,
449 style = wx.LC_REPORT |
454 wx.LC_SORT_ASCENDING, size = (550, 125))
463 for column
in columns:
464 self.InsertColumn(i, column)
470 self.attr1.SetBackgroundColour(wx.Colour(238,238,238))
472 self.attr2.SetBackgroundColour(
"white")
477 for i
in range(self.GetColumnCount()):
478 self.SetColumnWidth(i, wx.LIST_AUTOSIZE_USEHEADER)
479 if self.GetColumnWidth(i) < 80:
480 self.SetColumnWidth(i, 80)
485 listmix.ListCtrlAutoWidthMixin.__init__(self)
486 listmix.ColumnSorterMixin.__init__(self, self.GetColumnCount())
488 self.
il = wx.ImageList(16, 16)
489 self.
sm_up = self.il.Add(wx.ArtProvider_GetBitmap(wx.ART_GO_UP, wx.ART_TOOLBAR,
491 self.
sm_dn = self.il.Add(wx.ArtProvider_GetBitmap(wx.ART_GO_DOWN, wx.ART_TOOLBAR,
493 self.SetImageList(self.
il, wx.IMAGE_LIST_SMALL)
499 self.SortListItems(col = 0, ascending =
True)
518 self.DeleteAllItems()
522 for i
in range(1, len(value)):
524 self.itemIndexMap.append(row)
527 self.SetItemCount(row)
530 self.SetColumnWidth(0, 80)
531 self.SetColumnWidth(1, 300)
535 except StandardError, e:
536 wx.MessageBox(parent = self,
537 message = _(
"Unable to read list: %s") % e,
538 caption = _(
"Error"), style = wx.OK | wx.ICON_ERROR)
541 """!Sort by column"""
542 self.
_col = event.GetColumn()
547 info.m_mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE
549 for column
in range(self.GetColumnCount()):
550 info.m_text = self.GetColumn(column).GetText()
551 self.SetColumn(column, info)
556 """!Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py"""
566 """!Get item attributes"""
568 if ( index % 2) == 0:
575 items = list(self.itemDataMap.keys())
583 colName = self.GetColumn(self.
_col).GetText()
584 ascending = self._colSortFlag[self.
_col]
590 cmpVal = locale.strcoll(str(item1), str(item2))
592 cmpVal = cmp(item1, item2)
597 cmpVal = apply(cmp, self.GetSecondarySortValues(self.
_col, key1, key2))
605 """!Used by listmix.ColumnSorterMixin"""
609 """!Search projection by description
610 Return first found item or None
617 pattern = pattern.lower()
625 except UnicodeDecodeError:
636 """!Wizard page for selecting method of setting coordinate system
637 parameters (select coordinate system option)
640 TitledPage.__init__(self, wizard, _(
"Choose projection parameters"))
653 radioSBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
654 label =
" %s " % _(
"Select datum or ellipsoid (next page)"))
655 radioSBSizer = wx.StaticBoxSizer(radioSBox)
656 self.sizer.Add(item = radioSBSizer, pos = (0, 1),
657 flag = wx.EXPAND | wx.ALIGN_TOP | wx.TOP, border = 10)
658 self.sizer.AddGrowableCol(1)
660 self.
radio1 = wx.RadioButton(parent = self, id = wx.ID_ANY,
661 label = _(
"Datum with associated ellipsoid"),
663 self.
radio2 = wx.RadioButton(parent = self, id = wx.ID_ANY,
664 label = _(
"Ellipsoid only"))
667 if self.radio1.GetValue() ==
False and self.radio2.GetValue() ==
False:
668 self.radio1.SetValue(
True)
669 self.SetNext(self.parent.datumpage)
672 radioSBSizer.Add(item = self.
radio1,
673 flag = wx.ALIGN_LEFT | wx.RIGHT, border = 20)
674 radioSBSizer.Add(item = self.
radio2,
675 flag = wx.ALIGN_LEFT)
678 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio1.GetId())
679 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio2.GetId())
680 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.
OnPageChange)
681 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
684 """!Parameter value changed"""
686 val = event.GetString()
693 win = self.FindWindowById(id)
694 if param[
'type'] ==
'zone':
701 if param[
'type'] ==
'bool':
702 param[
'value'] = event.GetSelection()
709 """!Go to next page"""
710 if event.GetDirection():
712 for id, param
in self.pparam.iteritems():
713 if param[
'type'] ==
'bool':
714 if param[
'value'] ==
False:
719 if param[
'value']
is None:
720 wx.MessageBox(parent = self,
721 message = _(
'You must enter a value for %s') % param[
'desc'],
722 caption = _(
'Error'), style = wx.ICON_ERROR | wx.CENTRE)
725 self.
p4projparams += (
' +' + param[
'proj4'] +
'=' + str(param[
'value']))
729 self.
projdesc = self.parent.projections[self.parent.projpage.proj][0]
732 self.
paramSBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
733 label = _(
" Enter parameters for %s projection ") % self.
projdesc)
734 paramSBSizer = wx.StaticBoxSizer(self.
paramSBox)
736 self.
panel = scrolled.ScrolledPanel(parent = self, id = wx.ID_ANY)
737 self.panel.SetupScrolling()
741 self.sizer.Add(item = paramSBSizer, pos = (1, 1),
743 paramSBSizer.Add(item = self.
panel, proportion = 1,
744 flag = wx.ALIGN_CENTER | wx.EXPAND)
746 paramSBSizer.Fit(self.
panel)
749 if event.GetDirection():
750 self.prjParamSizer.Clear(
True)
751 self.paramSBox.SetLabel(_(
" Enter parameters for %s projection ") % self.
projdesc)
754 for paramgrp
in self.parent.projections[self.parent.projpage.proj][1]:
757 param = self.
pparam[id] = {
'type' : self.parent.paramdesc[paramgrp[0]][0],
758 'proj4': self.parent.paramdesc[paramgrp[0]][1],
759 'desc' : self.parent.paramdesc[paramgrp[0]][2] }
762 if param[
'type'] ==
'bool':
764 elif param[
'type'] ==
'zone':
766 param[
'desc'] +=
' (1-60)'
768 param[
'value'] = paramgrp[2]
770 label = wx.StaticText(parent = self.
panel, id = wx.ID_ANY, label = param[
'desc'],
771 style = wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE)
772 if param[
'type'] ==
'bool':
773 win = wx.Choice(parent = self.
panel, id = id, size = (100,-1),
774 choices = [_(
'No'), _(
'Yes')])
775 win.SetSelection(param[
'value'])
777 elif param[
'type'] ==
'zone':
778 win = wx.SpinCtrl(parent = self.
panel, id = id,
780 style = wx.SP_ARROW_KEYS | wx.SP_WRAP,
782 win.SetValue(param[
'value'])
786 win = wx.TextCtrl(parent = self.
panel, id = id,
787 value = param[
'value'],
790 if paramgrp[1] ==
'noask':
793 self.prjParamSizer.Add(item = label, pos = (row, 1),
794 flag = wx.ALIGN_RIGHT |
795 wx.ALIGN_CENTER_VERTICAL |
796 wx.RIGHT, border = 5)
797 self.prjParamSizer.Add(item = win, pos = (row, 2),
798 flag = wx.ALIGN_LEFT |
799 wx.ALIGN_CENTER_VERTICAL |
802 self.sizer.AddGrowableRow(1)
803 self.panel.SetSize(self.panel.GetBestSize())
808 if not wx.FindWindowById(wx.ID_FORWARD).IsEnabled():
809 wx.FindWindowById(wx.ID_FORWARD).Enable()
815 if event.GetId() == self.radio1.GetId():
816 self.SetNext(self.parent.datumpage)
817 self.parent.sumpage.SetPrev(self.parent.datumpage)
818 elif event.GetId() == self.radio2.GetId():
819 self.SetNext(self.parent.ellipsepage)
820 self.parent.sumpage.SetPrev(self.parent.ellipsepage)
823 """!Wizard page for selecting datum (with associated ellipsoid)
824 and datum transformation parameters (select coordinate system option)
828 TitledPage.__init__(self, wizard, _(
"Specify geodetic datum"))
838 self.
tdatum = self.MakeTextCtrl(
"", size = (200,-1))
841 self.
searchb = wx.SearchCtrl(self, size = (200,-1),
842 style = wx.TE_PROCESS_ENTER)
846 for key
in self.parent.datums.keys():
847 data.append([key, self.parent.datums[key][0], self.parent.datums[key][1]])
850 columns = [_(
'Code'), _(
'Ellipsoid'), _(
'Description')])
851 self.datumlist.resizeLastColumn(10)
854 self.sizer.Add(item = self.MakeLabel(_(
"Datum code:")),
855 flag = wx.ALIGN_LEFT |
856 wx.ALIGN_CENTER_VERTICAL |
857 wx.ALL, border = 5, pos = (1, 1))
858 self.sizer.Add(item = self.
tdatum,
859 flag = wx.ALIGN_LEFT |
860 wx.ALIGN_CENTER_VERTICAL |
861 wx.ALL, border = 5, pos = (1, 2))
863 self.sizer.Add(item = self.MakeLabel(_(
"Search in description:")),
864 flag = wx.ALIGN_LEFT |
865 wx.ALIGN_CENTER_VERTICAL |
866 wx.ALL, border = 5, pos = (2, 1))
867 self.sizer.Add(item = self.
searchb,
868 flag = wx.ALIGN_LEFT |
869 wx.ALIGN_CENTER_VERTICAL |
870 wx.ALL, border = 5, pos = (2, 2))
875 wx.ALL, border = 5, pos = (3, 1), span = (1, 4))
876 self.sizer.AddGrowableCol(4)
877 self.sizer.AddGrowableRow(3)
881 self.searchb.Bind(wx.EVT_TEXT_ENTER, self.
OnDSearch)
882 self.tdatum.Bind(wx.EVT_TEXT, self.
OnDText)
883 self.tdatum.Bind(wx.EVT_TEXT_ENTER, self.
OnDText)
885 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
892 proj = self.parent.projpage.p4proj
894 if event.GetDirection():
895 if self.
datum not in self.parent.datums:
903 datum =
'%s' % self.
datum,
910 dlg = SelectTransformDialog(self.parent.parent, transforms=ret)
912 if dlg.ShowModal() == wx.ID_OK:
913 dtrans = dlg.GetTransform()
917 return 'Datum transform is required.'
921 return 'Datum transform is required.'
923 self.parent.datumtrans = dtrans
925 self.GetNext().SetPrev(self)
926 self.parent.ellipsepage.ellipse = self.
ellipse
927 self.parent.ellipsepage.ellipseparams = self.parent.ellipsoids[self.
ellipse][1]
930 self.parent.datumtrans =
None
931 if event.GetDirection():
932 if len(self.
datum) == 0:
934 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
936 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
941 """!Datum code changed"""
942 self.
datum = event.GetString()
944 nextButton = wx.FindWindowById(wx.ID_FORWARD)
945 if len(self.
datum) == 0
or self.
datum not in self.parent.datums:
946 nextButton.Enable(
False)
952 self.datumparams.remove(
'dx=0.0')
956 self.datumparams.remove(
'dy=0.0')
960 self.datumparams.remove(
'dz=0.0')
964 nextButton.Enable(
True)
970 """!Search geodetic datum by desc"""
971 str = self.searchb.GetValue()
980 """!Datum selected"""
981 index = event.m_itemIndex
982 item = event.GetItem()
984 self.
datum = self.datumlist.GetItem(index, 0).GetText()
985 self.tdatum.SetValue(self.
datum)
990 """!Wizard page for selecting ellipsoid (select coordinate system option)"""
993 TitledPage.__init__(self, wizard, _(
"Specify ellipsoid"))
1006 self.
searchb = wx.SearchCtrl(self, size = (200,-1),
1007 style = wx.TE_PROCESS_ENTER)
1012 for key
in self.parent.ellipsoids.keys():
1013 data.append([key, self.parent.ellipsoids[key][0]])
1016 columns = [_(
'Code'), _(
'Description')])
1017 self.ellipselist.resizeLastColumn(30)
1020 self.sizer.Add(item = self.MakeLabel(_(
"Ellipsoid code:")),
1021 flag = wx.ALIGN_RIGHT |
1022 wx.ALIGN_CENTER_VERTICAL |
1023 wx.ALL, border = 5, pos = (1, 1))
1024 self.sizer.Add(item = self.
tellipse,
1025 flag = wx.ALIGN_LEFT |
1026 wx.ALIGN_CENTER_VERTICAL |
1027 wx.ALL, border = 5, pos = (1, 2))
1028 self.sizer.Add(item = self.MakeLabel(_(
"Search in description:")),
1029 flag = wx.ALIGN_RIGHT |
1030 wx.ALIGN_CENTER_VERTICAL |
1031 wx.ALL, border = 5, pos = (2, 1))
1032 self.sizer.Add(item = self.
searchb,
1033 flag = wx.ALIGN_LEFT |
1034 wx.ALIGN_CENTER_VERTICAL |
1035 wx.ALL, border = 5, pos = (2, 2))
1040 wx.ALL, border = 5, pos = (3, 1), span = (1, 4))
1041 self.sizer.AddGrowableCol(4)
1042 self.sizer.AddGrowableRow(3)
1045 self.ellipselist.Bind(wx.EVT_LIST_ITEM_SELECTED, self.
OnItemSelected)
1046 self.tellipse.Bind(wx.EVT_TEXT, self.
OnText)
1047 self.tellipse.Bind(wx.EVT_TEXT_ENTER, self.
OnText)
1048 self.searchb.Bind(wx.EVT_TEXT_ENTER, self.
OnSearch)
1049 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1055 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
1057 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
1062 if event.GetDirection()
and self.
ellipse not in self.parent.ellipsoids:
1066 self.GetNext().SetPrev(self)
1067 self.parent.datumpage.datumparams =
''
1071 """!Ellipspoid code changed"""
1072 self.
ellipse = event.GetString()
1073 nextButton = wx.FindWindowById(wx.ID_FORWARD)
1074 if len(self.
ellipse) == 0
or self.
ellipse not in self.parent.ellipsoids:
1075 nextButton.Enable(
False)
1079 elif self.
ellipse in self.parent.ellipsoids:
1082 nextButton.Enable(
True)
1085 """!Search ellipsoid by desc"""
1088 self.ellipselist.Search(index=[0,1], pattern=event.GetString())
1096 """!Ellipsoid selected"""
1097 index = event.m_itemIndex
1098 item = event.GetItem()
1100 self.
ellipse = self.ellipselist.GetItem(index, 0).GetText()
1101 self.tellipse.SetValue(self.
ellipse)
1106 """!Wizard page for selecting georeferenced file to use
1107 for setting coordinate system parameters"""
1110 TitledPage.__init__(self, wizard, _(
"Select georeferenced file"))
1115 self.
lfile= self.MakeLabel(_(
"Georeferenced file:"))
1116 self.
tfile = self.MakeTextCtrl(size = (300,-1))
1120 self.sizer.Add(item = self.
lfile, flag = wx.ALIGN_LEFT |
1121 wx.ALIGN_CENTRE_VERTICAL |
1122 wx.ALL, border = 5, pos = (1, 1))
1123 self.sizer.Add(item = self.
tfile, flag = wx.ALIGN_LEFT |
1124 wx.ALIGN_CENTRE_VERTICAL |
1125 wx.ALL, border = 5, pos = (1, 2))
1126 self.sizer.Add(item = self.
bbrowse, flag = wx.ALIGN_LEFT |
1127 wx.ALL, border = 5, pos = (1, 3))
1128 self.sizer.AddGrowableCol(3)
1130 self.bbrowse.Bind(wx.EVT_BUTTON, self.
OnBrowse)
1131 self.tfile.Bind(wx.EVT_TEXT, self.
OnText)
1133 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1141 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
1143 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
1148 if event.GetDirection()
and not os.path.isfile(self.
georeffile):
1150 self.GetNext().SetPrev(self)
1157 nextButton = wx.FindWindowById(wx.ID_FORWARD)
1159 if not nextButton.IsEnabled():
1160 nextButton.Enable(
True)
1162 if nextButton.IsEnabled():
1163 nextButton.Enable(
False)
1169 dlg = wx.FileDialog(self,
1170 _(
"Select georeferenced file"),
1171 os.getcwd(),
"",
"*.*", wx.OPEN)
1172 if dlg.ShowModal() == wx.ID_OK:
1173 path = dlg.GetPath()
1174 self.tfile.SetValue(path)
1180 """!Wizard page for selecting WKT file to use
1181 for setting coordinate system parameters"""
1184 TitledPage.__init__(self, wizard, _(
"Select Well Known Text (WKT) .prj file"))
1189 self.
lfile= self.MakeLabel(_(
"WKT .prj file:"))
1190 self.
tfile = self.MakeTextCtrl(size = (300,-1))
1194 self.sizer.Add(item = self.
lfile, flag = wx.ALIGN_LEFT |
1195 wx.ALIGN_CENTRE_VERTICAL |
1196 wx.ALL, border = 5, pos = (1, 1))
1197 self.sizer.Add(item = self.
tfile, flag = wx.ALIGN_LEFT |
1198 wx.ALIGN_CENTRE_VERTICAL |
1199 wx.ALL, border = 5, pos = (1, 2))
1200 self.sizer.Add(item = self.
bbrowse, flag = wx.ALIGN_LEFT |
1201 wx.ALL, border = 5, pos = (1, 3))
1202 self.sizer.AddGrowableCol(3)
1204 self.bbrowse.Bind(wx.EVT_BUTTON, self.
OnBrowse)
1205 self.tfile.Bind(wx.EVT_TEXT, self.
OnText)
1207 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1212 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
1214 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
1219 if event.GetDirection()
and not os.path.isfile(self.
wktfile):
1221 self.GetNext().SetPrev(self)
1227 self.
wktfile = event.GetString()
1228 nextButton = wx.FindWindowById(wx.ID_FORWARD)
1230 if not nextButton.IsEnabled():
1231 nextButton.Enable(
True)
1233 if nextButton.IsEnabled():
1234 nextButton.Enable(
False)
1240 dlg = wx.FileDialog(self,
1241 message = _(
"Select Well Known Text (WKT) .prj file"),
1242 defaultDir = os.getcwd(),
1243 wildcard =
"PRJ files (*.prj)|*.prj|Files (*.*)|*.*",
1246 if dlg.ShowModal() == wx.ID_OK:
1247 path = dlg.GetPath()
1248 self.tfile.SetValue(path)
1254 """!Wizard page for selecting EPSG code for
1255 setting coordinate system parameters"""
1258 TitledPage.__init__(self, wizard, _(
"Choose EPSG Code"))
1266 self.
lfile = self.MakeLabel(_(
"Path to the EPSG-codes file:"),
1267 style = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
1268 self.
lcode = self.MakeLabel(_(
"EPSG code:"),
1269 style = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
1272 self.
tfile = self.MakeTextCtrl(text = epsgdir, size = (200,-1),
1273 style = wx.TE_PROCESS_ENTER)
1274 self.
tcode = self.MakeTextCtrl(size = (200,-1))
1280 self.
searchb = wx.SearchCtrl(self, size = (200,-1),
1281 style = wx.TE_PROCESS_ENTER)
1284 columns = [_(
'Code'), _(
'Description'), _(
'Parameters')])
1287 self.sizer.Add(item = self.
lfile,
1288 flag = wx.ALIGN_LEFT |
1289 wx.ALIGN_CENTER_VERTICAL |
1290 wx.ALL, border = 5, pos = (1, 1), span = (1, 2))
1291 self.sizer.Add(item = self.
tfile,
1292 flag = wx.ALIGN_LEFT |
1293 wx.ALIGN_CENTER_VERTICAL |
1294 wx.ALL, border = 5, pos = (1, 3))
1295 self.sizer.Add(item = self.
bbrowse,
1296 flag = wx.ALIGN_LEFT |
1297 wx.ALIGN_CENTER_VERTICAL |
1298 wx.ALL, border = 5, pos = (1, 4))
1299 self.sizer.Add(item = self.
lcode,
1300 flag = wx.ALIGN_LEFT |
1301 wx.ALIGN_CENTER_VERTICAL |
1302 wx.ALL, border = 5, pos = (2, 1), span = (1, 2))
1303 self.sizer.Add(item = self.
tcode,
1304 flag = wx.ALIGN_LEFT |
1305 wx.ALIGN_CENTER_VERTICAL |
1306 wx.ALL, border = 5, pos = (2, 3))
1307 self.sizer.Add(item = self.
searchb,
1308 flag = wx.ALIGN_LEFT |
1309 wx.ALIGN_CENTER_VERTICAL |
1310 wx.ALL, border = 5, pos = (3, 3))
1312 self.sizer.Add(item = self.
epsglist,
1313 flag = wx.ALIGN_LEFT | wx.EXPAND, pos = (4, 1),
1315 self.sizer.AddGrowableCol(3)
1316 self.sizer.AddGrowableRow(4)
1319 self.bbrowse.Bind(wx.EVT_BUTTON, self.
OnBrowse)
1321 self.tcode.Bind(wx.EVT_TEXT, self.
OnText)
1322 self.tcode.Bind(wx.EVT_TEXT_ENTER, self.
OnText)
1323 self.epsglist.Bind(wx.EVT_LIST_ITEM_SELECTED, self.
OnItemSelected)
1324 self.searchb.Bind(wx.EVT_TEXT_ENTER, self.
OnSearch)
1326 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1329 self.parent.datumtrans =
None
1330 if event.GetDirection():
1333 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
1335 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
1343 if event.GetDirection():
1358 dlg = SelectTransformDialog(self.parent.parent, transforms = ret)
1360 if dlg.ShowModal() == wx.ID_OK:
1361 dtrans = dlg.GetTransform()
1365 return 'Datum transform is required.'
1369 return 'Datum transform is required.'
1371 self.parent.datumtrans = dtrans
1372 self.GetNext().SetPrev(self)
1381 nextButton = wx.FindWindowById(wx.ID_FORWARD)
1386 if not nextButton.IsEnabled():
1387 nextButton.Enable(
True)
1390 if nextButton.IsEnabled():
1391 nextButton.Enable(
False)
1395 value = self.searchb.GetValue()
1400 self.tcode.SetValue(
'')
1401 self.searchb.SetValue(
'')
1406 self.epsglist.Search(index=[0,1,2], pattern=value)
1407 except (IndexError, ValueError):
1410 self.tcode.SetValue(
'')
1411 self.searchb.SetValue(
'')
1416 """!Define path for EPSG code file"""
1417 path = os.path.dirname(self.tfile.GetValue())
1421 dlg = wx.FileDialog(parent = self, message = _(
"Choose EPSG codes file"),
1422 defaultDir = path, defaultFile =
"", wildcard =
"*", style = wx.OPEN)
1424 if dlg.ShowModal() == wx.ID_OK:
1425 path = dlg.GetPath()
1426 self.tfile.SetValue(path)
1434 """!EPSG code selected from the list"""
1435 index = event.m_itemIndex
1436 item = event.GetItem()
1438 self.
epsgcode = int(self.epsglist.GetItem(index, 0).GetText())
1439 self.
epsgdesc = self.epsglist.GetItem(index, 1).GetText()
1440 self.tcode.SetValue(str(self.
epsgcode))
1445 """!Browse EPSG codes"""
1449 wx.MessageBox(parent = self,
1450 message = _(
"Unable to read EPGS codes: %s") % self.
epsgCodeDict,
1451 caption = _(
"Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
1452 self.epsglist.Populate(list(), update =
True)
1456 for code, val
in self.epsgCodeDict.iteritems():
1457 if code
is not None:
1458 data.append((code, val[0], val[1]))
1460 self.epsglist.Populate(data, update =
True)
1463 """!Wizard page for entering custom PROJ.4 string
1464 for setting coordinate system parameters"""
1467 TitledPage.__init__(self, wizard,
1468 _(
"Choose method of specifying georeferencing parameters"))
1475 style = wx.TE_MULTILINE)
1480 flag = wx.ALIGN_LEFT | wx.ALL,
1481 border = 5, pos = (1, 1))
1483 flag = wx.ALIGN_LEFT | wx.ALL | wx.EXPAND,
1484 border = 5, pos = (2, 1), span = (1, 2))
1485 self.sizer.AddGrowableRow(2)
1486 self.sizer.AddGrowableCol(2)
1490 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1495 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
1497 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
1500 if event.GetDirection():
1503 if self.customstring.find(
'+datum=') < 0:
1504 self.GetNext().SetPrev(self)
1510 read =
True, getErrorMsg =
True,
1515 wx.MessageBox(parent = self,
1517 caption = _(
"Error"),
1518 style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
1525 dlg = SelectTransformDialog(self.parent.parent, transforms = out)
1526 if dlg.ShowModal() == wx.ID_OK:
1527 dtrans = dlg.GetTransform()
1531 return _(
'Datum transform is required.')
1535 return _(
'Datum transform is required.')
1537 self.parent.datumtrans = dtrans
1543 datumtrans = dtrans,
1547 for projterm
in projlabel.split(
' +'):
1548 if projterm.find(
"towgs84=") != -1
or projterm.find(
"nadgrids=") != -1:
1552 self.GetNext().SetPrev(self)
1555 """!Change proj string"""
1558 nextButton = wx.FindWindowById(wx.ID_FORWARD)
1560 if nextButton.IsEnabled():
1561 nextButton.Enable(
False)
1563 if not nextButton.IsEnabled():
1567 """!Shows summary result of choosing coordinate system parameters
1568 prior to creating location"""
1570 TitledPage.__init__(self, wizard, _(
"Summary"))
1573 self.
panelTitle = scrolled.ScrolledPanel(parent = self, id = wx.ID_ANY)
1575 self.
panelProj = scrolled.ScrolledPanel(parent = self, id = wx.ID_ANY)
1584 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1589 def _doLayout(self):
1590 """!Do page layout"""
1592 titleSizer = wx.BoxSizer(wx.VERTICAL)
1593 titleSizer.Add(item = self.
llocTitle, proportion = 1,
1594 flag = wx.EXPAND | wx.ALL, border = 5)
1595 self.panelTitle.SetSizer(titleSizer)
1597 projSizer = wx.BoxSizer(wx.VERTICAL)
1598 projSizer.Add(item = self.
lprojection, proportion = 1,
1599 flag = wx.EXPAND | wx.ALL, border = 5)
1600 self.panelProj.SetSizer(projSizer)
1602 proj4stringSizer = wx.BoxSizer(wx.VERTICAL)
1603 proj4stringSizer.Add(item = self.
lproj4string, proportion = 1,
1604 flag = wx.EXPAND | wx.ALL, border = 5)
1605 self.panelProj4string.SetSizer(proj4stringSizer)
1607 self.panelProj4string.SetupScrolling()
1608 self.panelProj.SetupScrolling(scroll_y =
False)
1609 self.panelTitle.SetupScrolling(scroll_y =
False)
1611 self.sizer.Add(item = self.MakeLabel(_(
"GRASS Database:")),
1612 flag = wx.ALIGN_LEFT | wx.ALL,
1613 border = 5, pos = (1, 0))
1615 flag = wx.ALIGN_LEFT | wx.ALL,
1616 border = 5, pos = (1, 1))
1617 self.sizer.Add(item = self.MakeLabel(_(
"Location Name:")),
1618 flag = wx.ALIGN_LEFT | wx.ALL,
1619 border = 5, pos = (2, 0))
1621 flag = wx.ALIGN_LEFT | wx.ALL,
1622 border = 5, pos = (2, 1))
1623 self.sizer.Add(item = self.MakeLabel(_(
"Location Title:")),
1624 flag = wx.ALIGN_LEFT | wx.ALL,
1625 border = 5, pos = (3, 0))
1627 flag = wx.ALIGN_LEFT | wx.ALL | wx.EXPAND,
1628 border = 0, pos = (3, 1))
1629 self.sizer.Add(item = self.MakeLabel(_(
"Projection:")),
1630 flag = wx.ALIGN_LEFT | wx.ALL,
1631 border = 5, pos = (4, 0))
1633 flag = wx.ALIGN_LEFT | wx.ALL | wx.EXPAND,
1634 border = 0, pos = (4, 1))
1635 self.sizer.Add(item = self.MakeLabel(_(
"PROJ.4 definition:\n (non-definitive)")),
1636 flag = wx.ALIGN_LEFT | wx.ALL,
1637 border = 5, pos = (5, 0))
1639 flag = wx.ALIGN_LEFT | wx.ALL | wx.EXPAND,
1640 border = 0, pos = (5, 1))
1641 self.sizer.AddGrowableCol(1)
1642 self.sizer.AddGrowableRow(3, 1)
1643 self.sizer.AddGrowableRow(4, 1)
1644 self.sizer.AddGrowableRow(5, 5)
1647 """!Insert values into text controls for summary of location
1650 database = self.parent.startpage.grassdatabase
1651 location = self.parent.startpage.location
1652 proj4string = self.parent.CreateProj4String()
1653 epsgcode = self.parent.epsgpage.epsgcode
1654 datum = self.parent.datumpage.datum
1655 dtrans = self.parent.datumtrans
1659 if coordsys
in (
'proj',
'epsg',
'wkt',
'file'):
1661 extra_opts[
'location'] =
'location'
1662 extra_opts[
'getErrorMsg'] =
True
1663 extra_opts[
'read'] =
True
1665 if coordsys ==
'proj':
1668 extra_opts[
'datum'] =
'%s' % datum
1669 extra_opts[
'datumtrans'] = dtrans
1673 proj4 = proj4string,
1675 elif coordsys ==
'epsg':
1679 datumtrans = dtrans,
1681 elif coordsys ==
'file':
1684 georef = self.parent.filepage.georeffile,
1686 elif coordsys ==
'wkt':
1689 wkt = self.parent.wktpage.wktfile,
1692 finishButton = wx.FindWindowById(wx.ID_FORWARD)
1695 projlabel = projlabel +
'+datum=%s' % datum
1696 self.lproj4string.SetLabel(projlabel.replace(
' +', os.linesep +
'+'))
1697 finishButton.Enable(
True)
1699 GError(err, parent = self)
1700 self.lproj4string.SetLabel(
'')
1701 finishButton.Enable(
False)
1703 projdesc = self.parent.projpage.projdesc
1704 ellipsedesc = self.parent.ellipsepage.ellipsedesc
1705 datumdesc = self.parent.datumpage.datumdesc
1706 self.ldatabase.SetLabel(database)
1707 self.llocation.SetLabel(location)
1708 self.llocTitle.SetLabel(self.parent.startpage.locTitle)
1711 if coordsys ==
'epsg':
1712 label =
'EPSG code %s (%s)' % (self.parent.epsgpage.epsgcode,
1713 self.parent.epsgpage.epsgdesc)
1715 elif coordsys ==
'file':
1716 label =
'matches file %s' % self.parent.filepage.georeffile
1718 elif coordsys ==
'wkt':
1719 label =
'matches file %s' % self.parent.wktpage.wktfile
1721 elif coordsys ==
'proj':
1722 label = (
'%s, %s %s' % (projdesc, datumdesc, ellipsedesc))
1724 elif coordsys ==
'xy':
1725 label = (
'XY coordinate system (not projected).')
1726 self.lproj4string.SetLabel(
"")
1728 elif coordsys ==
'custom':
1730 combo_str = self.parent.custompage.customstring + \
1731 self.parent.custompage.custom_dtrans_string
1732 self.lproj4string.SetLabel((
'%s' % combo_str.replace(
' +', os.linesep +
'+')))
1734 self.lprojection.SetLabel(label)
1738 dlg = wx.MessageDialog(parent = self.wizard,
1739 message = _(
"Do you want to create GRASS location <%s>?") % location,
1740 caption = _(
"Create new location?"),
1741 style = wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
1743 if dlg.ShowModal() == wx.ID_NO:
1751 """!Start wizard here and finish wizard here
1762 imagePath = os.path.join(globalvar.ETCIMGDIR,
"loc_wizard_qgis.png")
1763 wizbmp = wx.Image(imagePath, wx.BITMAP_TYPE_PNG)
1764 wizbmp = wizbmp.ConvertToBitmap()
1784 title = _(
"Define new GRASS Location"),
1786 self.wizard.Bind(wiz.EVT_WIZARD_HELP, self.
OnHelp)
1806 self.csystemspage.SetPrev(self.
startpage)
1807 self.csystemspage.SetNext(self.
sumpage)
1812 self.paramspage.SetPrev(self.
projpage)
1816 self.datumpage.SetNext(self.
sumpage)
1819 self.ellipsepage.SetNext(self.
sumpage)
1822 self.epsgpage.SetNext(self.
sumpage)
1825 self.filepage.SetNext(self.
sumpage)
1828 self.wktpage.SetNext(self.
sumpage)
1831 self.custompage.SetNext(self.
sumpage)
1838 self.startpage.DoLayout()
1839 self.csystemspage.DoLayout()
1840 self.projpage.DoLayout()
1841 self.datumpage.DoLayout()
1842 self.paramspage.DoLayout()
1843 self.epsgpage.DoLayout()
1844 self.filepage.DoLayout()
1845 self.wktpage.DoLayout()
1846 self.ellipsepage.DoLayout()
1847 self.custompage.DoLayout()
1848 self.sumpage.DoLayout()
1850 size = self.wizard.GetPageSize()
1851 self.wizard.SetPageSize((size[0], size[1] + 75))
1863 if self.wizard.RunWizard(self.
startpage):
1866 self.wizard.Destroy()
1867 self.
location = self.startpage.location
1874 self.wizard.Destroy()
1875 GError(parent = self.
parent,
1876 message =
"%s" % _(
"Unable to create new location. "
1877 "Location <%(loc)s> not created.\n\n"
1878 "Details: %(err)s") % \
1879 {
'loc' : self.startpage.location,
1882 self.wizard.Destroy()
1883 GMessage(parent = self.
parent,
1884 message = _(
"Location wizard canceled. "
1885 "Location not created."))
1889 def __cleanUp(self):
1905 transformlist = list()
1907 def __readData(self):
1908 """!Get georeferencing information from tables in $GISBASE/etc"""
1911 f = open(os.path.join(globalvar.ETCDIR,
"proj-parms.table"),
"r")
1914 for line
in f.readlines():
1917 proj, projdesc, params = line.split(
':')
1918 paramslist = params.split(
';')
1920 for p
in paramslist:
1921 if p ==
'':
continue
1922 p1, pdefault = p.split(
',')
1923 pterm, pask = p1.split(
'=')
1924 p = [pterm.strip(), pask.strip(), pdefault.strip()]
1926 self.
projections[proj.lower().strip()] = (projdesc.strip(), plist)
1927 self.
projdesc[proj.lower().strip()] = projdesc.strip()
1933 f = open(os.path.join(globalvar.ETCDIR,
"datum.table"),
"r")
1936 for line
in f.readlines():
1937 line = line.expandtabs(1)
1939 if line ==
'' or line[0] ==
"#":
1941 datum, info = line.split(
" ", 1)
1943 datumdesc, params = info.split(
" ", 1)
1944 datumdesc = datumdesc.strip(
'"')
1945 paramlist = params.split()
1946 ellipsoid = paramlist.pop(0)
1947 self.
datums[datum] = (ellipsoid, datumdesc.replace(
'_',
' '), paramlist)
1951 f = open(os.path.join(globalvar.ETCDIR,
"ellipse.table"),
"r")
1953 for line
in f.readlines():
1954 line = line.expandtabs(1)
1956 if line ==
'' or line[0] ==
"#":
1958 ellipse, rest = line.split(
" ", 1)
1959 rest = rest.strip(
'" ')
1960 desc, params = rest.split(
'"', 1)
1961 desc = desc.strip(
'" ')
1962 paramslist = params.split()
1963 self.
ellipsoids[ellipse] = (desc, paramslist)
1967 f = open(os.path.join(globalvar.ETCDIR,
"proj-desc.table"),
"r")
1969 for line
in f.readlines():
1972 pparam, datatype, proj4term, desc = line.split(
':')
1973 self.
paramdesc[pparam] = (datatype, proj4term, desc)
1979 """!Wizard finished, create new location
1981 @return error message on error
1982 @return None on success
1984 database = self.startpage.grassdatabase
1985 location = self.startpage.location
1988 if os.path.isdir(os.path.join(database,location)):
1989 GError(parent = self.
wizard,
1990 message =
"%s <%s>: %s" % \
1991 (_(
"Unable to create new location"),
1992 os.path.join(database, location),
1993 _(
"Location already exists in GRASS Database.")))
1997 current_gdb = grass.gisenv()[
'GISDBASE']
1998 if current_gdb != database:
2000 if os.path.isdir(database) !=
True:
2007 set =
'GISDBASE=%s' % database)
2009 wx.MessageBox(parent = self.
wizard,
2010 message = _(
"Location <%(loc)s> will be created "
2011 "in GIS data directory <%(dir)s>. "
2012 "You will need to change the default GIS "
2013 "data directory in the GRASS startup screen.") % \
2014 {
'loc' : location,
'dir' : database},
2015 caption = _(
"New GIS data directory"),
2016 style = wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
2023 if coordsys ==
"xy":
2024 grass.create_location(dbase = self.startpage.grassdatabase,
2025 location = self.startpage.location,
2026 desc = self.startpage.locTitle)
2027 elif coordsys ==
"proj":
2028 grass.create_location(dbase = self.startpage.grassdatabase,
2029 location = self.startpage.location,
2031 datum = self.datumpage.datum,
2033 desc = self.startpage.locTitle)
2034 elif coordsys ==
'custom':
2039 grass.create_location(dbase = self.startpage.grassdatabase,
2040 location = self.startpage.location,
2041 proj4 = self.custompage.customstring,
2042 desc = self.startpage.locTitle,
2044 elif coordsys ==
"epsg":
2045 if not self.epsgpage.epsgcode:
2046 return _(
'EPSG code missing.')
2048 grass.create_location(dbase = self.startpage.grassdatabase,
2049 location = self.startpage.location,
2050 epsg = self.epsgpage.epsgcode,
2051 datum = self.datumpage.datum,
2053 desc = self.startpage.locTitle)
2054 elif coordsys ==
"file":
2055 if not self.filepage.georeffile
or \
2056 not os.path.isfile(self.filepage.georeffile):
2057 return _(
"File <%s> not found." % self.filepage.georeffile)
2059 grass.create_location(dbase = self.startpage.grassdatabase,
2060 location = self.startpage.location,
2061 filename = self.filepage.georeffile,
2062 desc = self.startpage.locTitle)
2063 elif coordsys ==
"wkt":
2064 if not self.wktpage.wktfile
or \
2065 not os.path.isfile(self.wktpage.wktfile):
2066 return _(
"File <%s> not found." % self.wktpage.wktfile)
2068 grass.create_location(dbase = self.startpage.grassdatabase,
2069 location = self.startpage.location,
2070 wkt = self.wktpage.wktfile,
2071 desc = self.startpage.locTitle)
2073 except grass.ScriptError, e:
2079 """!Constract PROJ.4 string"""
2080 location = self.startpage.location
2081 proj = self.projpage.p4proj
2082 projdesc = self.projpage.projdesc
2083 proj4params = self.paramspage.p4projparams
2086 if self.datumpage.datumdesc:
2087 datumdesc = self.datumpage.datumdesc +
' - ' + self.datumpage.ellipse
2090 datumparams = self.datumpage.datumparams
2091 ellipse = self.ellipsepage.ellipse
2092 ellipsedesc = self.ellipsepage.ellipsedesc
2093 ellipseparams = self.ellipsepage.ellipseparams
2098 proj4string =
'%s %s' % (proj, proj4params)
2102 proj4string =
'%s +ellps=%s' % (proj4string, ellipse)
2103 for item
in ellipseparams:
2104 if item[:4] ==
'f=1/':
2105 item =
' +rf=' + item[4:]
2108 proj4string =
'%s %s' % (proj4string, item)
2112 for item
in datumparams:
2113 proj4string =
'%s +%s' % (proj4string,item)
2115 proj4string =
'%s +no_defs' % proj4string
2120 """'Help' button clicked"""
2123 filePath = os.path.join(os.getenv(
'GISBASE'),
"docs",
"html",
"helptext.html")
2124 webbrowser.open(filePath)
2129 pre = wiz.PreWizard()
2130 pre.SetExtraStyle(wx.wizard.WIZARD_EX_HELPBUTTON)
2131 pre.Create(parent = parent, id = id, title = title, bitmap = bitmap)
2132 self.PostCreate(pre)
Wizard page for selecting ellipsoid (select coordinate system option)
Wizard page for selecting projection (select coordinate system option)
Wizard page for setting GIS data directory and location name.
Location wizard - dialogs.
Generic list (for projections, ellipsoids, etc.)
def OnItemSelected
Projection selected.
def OnChangeName
Name for new location was changed.
def _nameValidationFailed
Wizard page for selecting datum (with associated ellipsoid) and datum transformation parameters (sele...
def CreateProj4String
Constract PROJ.4 string.
def OnPageChange
Go to next page.
Wizard page for selecting georeferenced file to use for setting coordinate system parameters...
def OnWizFinished
Wizard finished, create new location.
Wizard page for selecting EPSG code for setting coordinate system parameters.
Location wizard - base classes.
Shows summary result of choosing coordinate system parameters prior to creating location.
def OnEnterPage
Insert values into text controls for summary of location creation options.
def OnItemSelected
EPSG code selected from the list.
def OnSearch
Search ellipsoid by desc.
def OnEnterPage
Page entered.
def OnDSearch
Search geodetic datum by desc.
Start wizard here and finish wizard here.
def GetSortImages
Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py.
def OnText
Projection name changed.
Wizard page for entering custom PROJ.4 string for setting coordinate system parameters.
def OnBrowse
Define path for EPSG code file.
def ReadEpsgCodes
Read EPSG code from the file.
def OnItemSelected
Ellipsoid selected.
def OnText
Ellipspoid code changed.
def OnDatumSelected
Datum selected.
def OnParamEntry
Parameter value changed.
def GetProjstring
Change proj string.
Class to make wizard pages.
Wizard page for selecting WKT file to use for setting coordinate system parameters.
def GetListCtrl
Used by listmix.ColumnSorterMixin.
def OnGetItemText
Get item text.
def OnGetItemAttr
Get item attributes.
def PathJoin
Check path created by os.path.join.
def OnSearch
Search projection by desc.
Wizard page for selecting method of setting coordinate system parameters (select coordinate system op...
Wizard page for choosing method for location creation.
def OnBrowse
Choose GRASS data directory.
def OnBrowseCodes
Browse EPSG codes.
def Populate
Populate list.
def Search
Search projection by description Return first found item or None.
def _doLayout
Do page layout.
def OnColumnClick
Sort by column.
def OnDText
Datum code changed.
def __readData
Get georeferencing information from tables in $GISBASE/etc.
def DoLayout
Do page layout.
def RunCommand
Run GRASS command.