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)
80 self.pagesizer.Add(item = self.
title, proportion = 0,
81 flag = wx.ALIGN_CENTRE | wx.ALL,
83 self.pagesizer.Add(item = wx.StaticLine(self, -1), proportion = 0,
84 flag = wx.EXPAND | wx.ALL,
86 self.pagesizer.Add(item = self.
sizer, proportion = 1,
89 self.SetAutoLayout(
True)
94 """!Wizard page for setting GIS data directory and location name"""
95 def __init__(self, wizard, parent, grassdatabase):
96 TitledPage.__init__(self, wizard, _(
"Define GRASS Database and Location Name"))
106 self.
tgisdbase = self.MakeTextCtrl(grassdatabase, size = (300, -1))
107 self.
tlocation = self.MakeTextCtrl(
"newLocation", size = (300, -1))
112 self.sizer.Add(item = self.MakeLabel(_(
"GIS Data Directory:")),
113 flag = wx.ALIGN_RIGHT |
114 wx.ALIGN_CENTER_VERTICAL |
118 flag = wx.ALIGN_LEFT |
119 wx.ALIGN_CENTER_VERTICAL |
122 self.sizer.Add(item = self.
bbrowse,
123 flag = wx.ALIGN_LEFT |
124 wx.ALIGN_CENTER_VERTICAL |
128 self.sizer.Add(item = self.MakeLabel(
"%s:" % _(
"Project Location"),
129 tooltip = _(
"Name of location directory in GIS Data Directory")),
130 flag = wx.ALIGN_RIGHT |
131 wx.ALIGN_CENTER_VERTICAL |
135 flag = wx.ALIGN_LEFT |
136 wx.ALIGN_CENTER_VERTICAL |
140 self.sizer.Add(item = self.MakeLabel(
"%s:" % _(
"Location Title"),
141 tooltip = _(
"Optional location title, "
142 "you can leave this field blank.")),
143 flag = wx.ALIGN_RIGHT |
144 wx.ALIGN_TOP | wx.ALIGN_CENTER_VERTICAL |
148 flag = wx.ALIGN_LEFT |
149 wx.ALIGN_CENTER_VERTICAL |
151 pos = (3, 2), span = (1, 2))
152 self.sizer.AddGrowableCol(3)
160 def _nameValidationFailed(self, ctrl):
161 message = _(
"Name <%(name)s> is not a valid name for location. "
162 "Please use only ASCII characters excluding %(chars)s "
163 "and space.") % {
'name': ctrl.GetValue(),
'chars':
'/"\'@,=*~'}
164 GError(parent=self, message=message, caption=_(
"Invalid location name"))
167 """!Name for new location was changed"""
168 nextButton = wx.FindWindowById(wx.ID_FORWARD)
169 if len(event.GetString()) > 0:
170 if not nextButton.IsEnabled():
178 """!Choose GRASS data directory"""
179 dlg = wx.DirDialog(self, _(
"Choose GRASS data directory:"),
180 os.getcwd(), wx.DD_DEFAULT_STYLE)
181 if dlg.ShowModal() == wx.ID_OK:
189 if os.path.isdir(os.path.join(self.tgisdbase.GetValue(), self.tlocation.GetValue())):
190 error = _(
"Location already exists in GRASS Database.")
193 GError(parent = self,
194 message=
"%s <%s>.%s%s" % (_(
"Unable to create location"),
195 str(self.tlocation.GetValue()),
201 self.
location = self.tlocation.GetValue()
203 self.
locTitle = self.tlocTitle.GetValue()
206 GWarning(parent = self,
207 message = _(
"Title of the location is limited only to one line and "
208 "256 characters. The rest of the text will be ignored."))
209 self.
locTitle = self.locTitle.split(os.linesep)[0][:255]
212 """!Wizard page for choosing method for location creation"""
214 TitledPage.__init__(self, wizard, _(
"Choose method for creating a new location"))
220 self.
radio1 = wx.RadioButton(parent = self, id = wx.ID_ANY,
221 label = _(
"Select coordinate system parameters from a list"),
223 self.
radio2 = wx.RadioButton(parent = self, id = wx.ID_ANY,
224 label = _(
"Select EPSG code of spatial reference system"))
225 self.
radio3 = wx.RadioButton(parent = self, id = wx.ID_ANY,
226 label = _(
"Read projection and datum terms from a "
227 "georeferenced data file"))
228 self.
radio4 = wx.RadioButton(parent = self, id = wx.ID_ANY,
229 label = _(
"Read projection and datum terms from a "
230 "Well Known Text (WKT) .prj file"))
231 self.
radio5 = wx.RadioButton(parent = self, id = wx.ID_ANY,
232 label = _(
"Specify projection and datum terms using custom "
233 "PROJ.4 parameters"))
234 self.
radio6 = wx.RadioButton(parent = self, id = wx.ID_ANY,
235 label = _(
"Create a generic Cartesian coordinate system (XY)"))
238 self.sizer.SetVGap(10)
239 self.sizer.Add(item = self.
radio1,
240 flag = wx.ALIGN_LEFT, pos = (1, 1))
241 self.sizer.Add(item = self.
radio2,
242 flag = wx.ALIGN_LEFT, pos = (2, 1))
243 self.sizer.Add(item = self.
radio3,
244 flag = wx.ALIGN_LEFT, pos = (3, 1))
245 self.sizer.Add(item = self.
radio4,
246 flag = wx.ALIGN_LEFT, pos = (4, 1))
247 self.sizer.Add(item = self.
radio5,
248 flag = wx.ALIGN_LEFT, pos = (5, 1))
249 self.sizer.Add(item = self.
radio6,
250 flag = wx.ALIGN_LEFT, pos = (6, 1))
251 self.sizer.AddGrowableCol(1)
254 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio1.GetId())
255 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio2.GetId())
256 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio3.GetId())
257 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio4.GetId())
258 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio5.GetId())
259 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio6.GetId())
260 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
267 self.radio1.SetValue(
True)
269 if coordsys ==
'proj':
270 self.radio1.SetValue(
True)
271 if coordsys ==
"epsg":
272 self.radio2.SetValue(
True)
273 if coordsys ==
"file":
274 self.radio3.SetValue(
True)
275 if coordsys ==
"wkt":
276 self.radio4.SetValue(
True)
277 if coordsys ==
"custom":
278 self.radio5.SetValue(
True)
280 self.radio6.SetValue(
True)
282 if event.GetDirection():
283 if coordsys ==
'proj':
284 self.SetNext(self.parent.projpage)
285 self.parent.sumpage.SetPrev(self.parent.datumpage)
286 if coordsys ==
"epsg":
287 self.SetNext(self.parent.epsgpage)
288 self.parent.sumpage.SetPrev(self.parent.epsgpage)
289 if coordsys ==
"file":
290 self.SetNext(self.parent.filepage)
291 self.parent.sumpage.SetPrev(self.parent.filepage)
292 if coordsys ==
"wkt":
293 self.SetNext(self.parent.wktpage)
294 self.parent.sumpage.SetPrev(self.parent.wktpage)
295 if coordsys ==
"custom":
296 self.SetNext(self.parent.custompage)
297 self.parent.sumpage.SetPrev(self.parent.custompage)
299 self.SetNext(self.parent.sumpage)
300 self.parent.sumpage.SetPrev(self.parent.csystemspage)
302 if not wx.FindWindowById(wx.ID_FORWARD).IsEnabled():
303 wx.FindWindowById(wx.ID_FORWARD).Enable()
308 if event.GetId() == self.radio1.GetId():
310 self.SetNext(self.parent.projpage)
311 self.parent.sumpage.SetPrev(self.parent.datumpage)
312 elif event.GetId() == self.radio2.GetId():
314 self.SetNext(self.parent.epsgpage)
315 self.parent.sumpage.SetPrev(self.parent.epsgpage)
316 elif event.GetId() == self.radio3.GetId():
318 self.SetNext(self.parent.filepage)
319 self.parent.sumpage.SetPrev(self.parent.filepage)
320 elif event.GetId() == self.radio4.GetId():
322 self.SetNext(self.parent.wktpage)
323 self.parent.sumpage.SetPrev(self.parent.wktpage)
324 elif event.GetId() == self.radio5.GetId():
326 self.SetNext(self.parent.custompage)
327 self.parent.sumpage.SetPrev(self.parent.custompage)
328 elif event.GetId() == self.radio6.GetId():
330 self.SetNext(self.parent.sumpage)
331 self.parent.sumpage.SetPrev(self.parent.csystemspage)
334 """!Wizard page for selecting projection (select coordinate system option)"""
336 TitledPage.__init__(self, wizard, _(
"Choose projection"))
344 self.
tproj = self.MakeTextCtrl(
"", size = (200,-1))
347 self.
searchb = wx.SearchCtrl(self, size = (200,-1),
348 style = wx.TE_PROCESS_ENTER)
352 columns = [_(
'Code'), _(
'Description')])
353 self.projlist.resizeLastColumn(30)
356 self.sizer.Add(item = self.MakeLabel(_(
"Projection code:")),
357 flag = wx.ALIGN_LEFT |
358 wx.ALIGN_CENTER_VERTICAL |
359 wx.ALL, border = 5, pos = (1, 1))
360 self.sizer.Add(item = self.
tproj,
361 flag = wx.ALIGN_RIGHT | wx.EXPAND | wx.ALL,
362 border = 5, pos = (1, 2))
364 self.sizer.Add(item = self.MakeLabel(_(
"Search in description:")),
365 flag = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
366 border = 5, pos = (2, 1))
367 self.sizer.Add(item = self.
searchb,
368 flag = wx.ALIGN_RIGHT | wx.EXPAND | wx.ALL,
369 border = 5, pos = (2, 2))
371 self.sizer.Add(item = self.
projlist,
374 wx.ALL, border = 5, pos = (3, 1), span = (1, 3))
375 self.sizer.AddGrowableCol(3)
376 self.sizer.AddGrowableRow(3)
379 self.tproj.Bind(wx.EVT_TEXT, self.
OnText)
380 self.tproj.Bind(wx.EVT_TEXT_ENTER, self.
OnText)
381 self.searchb.Bind(wx.EVT_TEXT_ENTER, self.
OnSearch)
382 self.projlist.Bind(wx.EVT_LIST_ITEM_SELECTED, self.
OnItemSelected)
384 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
387 if event.GetDirection()
and self.
proj not in self.parent.projections.keys():
391 """!Projection name changed"""
392 self.
proj = event.GetString().lower()
394 nextButton = wx.FindWindowById(wx.ID_FORWARD)
395 if self.
proj not in self.parent.projections.keys()
and nextButton.IsEnabled():
396 nextButton.Enable(
False)
398 if self.
proj in self.parent.projections.keys():
399 if self.
proj ==
'stp':
400 wx.MessageBox(
'Currently State Plane projections must be selected using the '
401 'text-based setup (g.setproj), or entered by EPSG code or '
402 'custom PROJ.4 terms.',
403 'Warning', wx.ICON_WARNING)
405 self.tproj.SetValue(self.
proj)
406 nextButton.Enable(
False)
408 elif self.proj.lower() ==
'll':
409 self.
p4proj =
'+proj=longlat'
411 self.
p4proj =
'+proj=' + self.proj.lower()
416 if len(self.
proj) == 0:
418 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
420 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
425 """!Search projection by desc"""
426 str = event.GetString()
428 self.
proj, self.
projdesc = self.projlist.Search(index = [0,1], pattern = event.GetString())
435 """!Projection selected"""
436 index = event.m_itemIndex
439 self.
proj = self.projlist.GetItem(index, 0).GetText().lower()
440 self.tproj.SetValue(self.
proj)
445 listmix.ListCtrlAutoWidthMixin,
446 listmix.ColumnSorterMixin):
447 """!Generic list (for projections, ellipsoids, etc.)"""
450 wx.ListCtrl.__init__(self, parent = parent, id = wx.ID_ANY,
451 style = wx.LC_REPORT |
456 wx.LC_SORT_ASCENDING, size = (550, 125))
465 for column
in columns:
466 self.InsertColumn(i, column)
472 self.attr1.SetBackgroundColour(wx.Colour(238,238,238))
474 self.attr2.SetBackgroundColour(
"white")
479 for i
in range(self.GetColumnCount()):
480 self.SetColumnWidth(i, wx.LIST_AUTOSIZE_USEHEADER)
481 if self.GetColumnWidth(i) < 80:
482 self.SetColumnWidth(i, 80)
487 listmix.ListCtrlAutoWidthMixin.__init__(self)
488 listmix.ColumnSorterMixin.__init__(self, self.GetColumnCount())
490 self.
il = wx.ImageList(16, 16)
491 self.
sm_up = self.il.Add(wx.ArtProvider_GetBitmap(wx.ART_GO_UP, wx.ART_TOOLBAR,
493 self.
sm_dn = self.il.Add(wx.ArtProvider_GetBitmap(wx.ART_GO_DOWN, wx.ART_TOOLBAR,
495 self.SetImageList(self.
il, wx.IMAGE_LIST_SMALL)
501 self.SortListItems(col = 0, ascending =
True)
520 self.DeleteAllItems()
524 for i
in range(1, len(value)):
526 self.itemIndexMap.append(row)
529 self.SetItemCount(row)
532 self.SetColumnWidth(0, 80)
533 self.SetColumnWidth(1, 300)
537 except StandardError, e:
538 wx.MessageBox(parent = self,
539 message = _(
"Unable to read list: %s") % e,
540 caption = _(
"Error"), style = wx.OK | wx.ICON_ERROR)
543 """!Sort by column"""
544 self.
_col = event.GetColumn()
549 info.m_mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE
551 for column
in range(self.GetColumnCount()):
552 info.m_text = self.GetColumn(column).GetText()
553 self.SetColumn(column, info)
558 """!Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py"""
568 """!Get item attributes"""
570 if ( index % 2) == 0:
577 items = list(self.itemDataMap.keys())
585 colName = self.GetColumn(self.
_col).GetText()
586 ascending = self._colSortFlag[self.
_col]
592 cmpVal = locale.strcoll(str(item1), str(item2))
594 cmpVal = cmp(item1, item2)
599 cmpVal = apply(cmp, self.GetSecondarySortValues(self.
_col, key1, key2))
607 """!Used by listmix.ColumnSorterMixin"""
611 """!Search projection by description
612 Return first found item or None
619 pattern = pattern.lower()
627 except UnicodeDecodeError:
638 """!Wizard page for selecting method of setting coordinate system
639 parameters (select coordinate system option)
642 TitledPage.__init__(self, wizard, _(
"Choose projection parameters"))
655 radioSBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
656 label =
" %s " % _(
"Select datum or ellipsoid (next page)"))
657 radioSBSizer = wx.StaticBoxSizer(radioSBox)
658 self.sizer.Add(item = radioSBSizer, pos = (0, 1),
659 flag = wx.EXPAND | wx.ALIGN_TOP | wx.TOP, border = 10)
660 self.sizer.AddGrowableCol(1)
662 self.
radio1 = wx.RadioButton(parent = self, id = wx.ID_ANY,
663 label = _(
"Datum with associated ellipsoid"),
665 self.
radio2 = wx.RadioButton(parent = self, id = wx.ID_ANY,
666 label = _(
"Ellipsoid only"))
669 if self.radio1.GetValue() ==
False and self.radio2.GetValue() ==
False:
670 self.radio1.SetValue(
True)
671 self.SetNext(self.parent.datumpage)
674 radioSBSizer.Add(item = self.
radio1,
675 flag = wx.ALIGN_LEFT | wx.RIGHT, border = 20)
676 radioSBSizer.Add(item = self.
radio2,
677 flag = wx.ALIGN_LEFT)
680 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio1.GetId())
681 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio2.GetId())
682 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.
OnPageChange)
683 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
686 """!Parameter value changed"""
688 val = event.GetString()
695 win = self.FindWindowById(id)
696 if param[
'type'] ==
'zone':
703 if param[
'type'] ==
'bool':
704 param[
'value'] = event.GetSelection()
711 """!Go to next page"""
712 if event.GetDirection():
714 for id, param
in self.pparam.iteritems():
715 if param[
'type'] ==
'bool':
716 if param[
'value'] ==
False:
721 if param[
'value']
is None:
722 wx.MessageBox(parent = self,
723 message = _(
'You must enter a value for %s') % param[
'desc'],
724 caption = _(
'Error'), style = wx.ICON_ERROR | wx.CENTRE)
727 self.
p4projparams += (
' +' + param[
'proj4'] +
'=' + str(param[
'value']))
731 self.
projdesc = self.parent.projections[self.parent.projpage.proj][0]
734 self.
paramSBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
735 label = _(
" Enter parameters for %s projection ") % self.
projdesc)
736 paramSBSizer = wx.StaticBoxSizer(self.
paramSBox)
738 self.
panel = scrolled.ScrolledPanel(parent = self, id = wx.ID_ANY)
739 self.panel.SetupScrolling()
743 self.sizer.Add(item = paramSBSizer, pos = (1, 1),
745 paramSBSizer.Add(item = self.
panel, proportion = 1,
746 flag = wx.ALIGN_CENTER | wx.EXPAND)
748 paramSBSizer.Fit(self.
panel)
751 if event.GetDirection():
752 self.prjParamSizer.Clear(
True)
753 self.paramSBox.SetLabel(_(
" Enter parameters for %s projection ") % self.
projdesc)
756 for paramgrp
in self.parent.projections[self.parent.projpage.proj][1]:
759 param = self.
pparam[id] = {
'type' : self.parent.paramdesc[paramgrp[0]][0],
760 'proj4': self.parent.paramdesc[paramgrp[0]][1],
761 'desc' : self.parent.paramdesc[paramgrp[0]][2] }
764 if param[
'type'] ==
'bool':
766 elif param[
'type'] ==
'zone':
768 param[
'desc'] +=
' (1-60)'
770 param[
'value'] = paramgrp[2]
772 label = wx.StaticText(parent = self.
panel, id = wx.ID_ANY, label = param[
'desc'],
773 style = wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE)
774 if param[
'type'] ==
'bool':
775 win = wx.Choice(parent = self.
panel, id = id, size = (100,-1),
776 choices = [_(
'No'), _(
'Yes')])
777 win.SetSelection(param[
'value'])
779 elif param[
'type'] ==
'zone':
780 win = wx.SpinCtrl(parent = self.
panel, id = id,
782 style = wx.SP_ARROW_KEYS | wx.SP_WRAP,
784 win.SetValue(param[
'value'])
788 win = wx.TextCtrl(parent = self.
panel, id = id,
789 value = param[
'value'],
792 if paramgrp[1] ==
'noask':
795 self.prjParamSizer.Add(item = label, pos = (row, 1),
796 flag = wx.ALIGN_RIGHT |
797 wx.ALIGN_CENTER_VERTICAL |
798 wx.RIGHT, border = 5)
799 self.prjParamSizer.Add(item = win, pos = (row, 2),
800 flag = wx.ALIGN_LEFT |
801 wx.ALIGN_CENTER_VERTICAL |
804 self.sizer.AddGrowableRow(1)
805 self.panel.SetSize(self.panel.GetBestSize())
810 if not wx.FindWindowById(wx.ID_FORWARD).IsEnabled():
811 wx.FindWindowById(wx.ID_FORWARD).Enable()
817 if event.GetId() == self.radio1.GetId():
818 self.SetNext(self.parent.datumpage)
819 self.parent.sumpage.SetPrev(self.parent.datumpage)
820 elif event.GetId() == self.radio2.GetId():
821 self.SetNext(self.parent.ellipsepage)
822 self.parent.sumpage.SetPrev(self.parent.ellipsepage)
825 """!Wizard page for selecting datum (with associated ellipsoid)
826 and datum transformation parameters (select coordinate system option)
830 TitledPage.__init__(self, wizard, _(
"Specify geodetic datum"))
840 self.
tdatum = self.MakeTextCtrl(
"", size = (200,-1))
843 self.
searchb = wx.SearchCtrl(self, size = (200,-1),
844 style = wx.TE_PROCESS_ENTER)
848 for key
in self.parent.datums.keys():
849 data.append([key, self.parent.datums[key][0], self.parent.datums[key][1]])
852 columns = [_(
'Code'), _(
'Ellipsoid'), _(
'Description')])
853 self.datumlist.resizeLastColumn(10)
856 self.sizer.Add(item = self.MakeLabel(_(
"Datum code:")),
857 flag = wx.ALIGN_LEFT |
858 wx.ALIGN_CENTER_VERTICAL |
859 wx.ALL, border = 5, pos = (1, 1))
860 self.sizer.Add(item = self.
tdatum,
861 flag = wx.ALIGN_LEFT |
862 wx.ALIGN_CENTER_VERTICAL |
863 wx.ALL, border = 5, pos = (1, 2))
865 self.sizer.Add(item = self.MakeLabel(_(
"Search in description:")),
866 flag = wx.ALIGN_LEFT |
867 wx.ALIGN_CENTER_VERTICAL |
868 wx.ALL, border = 5, pos = (2, 1))
869 self.sizer.Add(item = self.
searchb,
870 flag = wx.ALIGN_LEFT |
871 wx.ALIGN_CENTER_VERTICAL |
872 wx.ALL, border = 5, pos = (2, 2))
877 wx.ALL, border = 5, pos = (3, 1), span = (1, 4))
878 self.sizer.AddGrowableCol(4)
879 self.sizer.AddGrowableRow(3)
883 self.searchb.Bind(wx.EVT_TEXT_ENTER, self.
OnDSearch)
884 self.tdatum.Bind(wx.EVT_TEXT, self.
OnDText)
885 self.tdatum.Bind(wx.EVT_TEXT_ENTER, self.
OnDText)
887 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
894 proj = self.parent.projpage.p4proj
896 if event.GetDirection():
897 if self.
datum not in self.parent.datums:
905 datum =
'%s' % self.
datum,
912 dlg = SelectTransformDialog(self.parent.parent, transforms=ret)
914 if dlg.ShowModal() == wx.ID_OK:
915 dtrans = dlg.GetTransform()
919 return 'Datum transform is required.'
923 return 'Datum transform is required.'
925 self.parent.datumtrans = dtrans
927 self.GetNext().SetPrev(self)
928 self.parent.ellipsepage.ellipse = self.
ellipse
929 self.parent.ellipsepage.ellipseparams = self.parent.ellipsoids[self.
ellipse][1]
932 self.parent.datumtrans =
None
933 if event.GetDirection():
934 if len(self.
datum) == 0:
936 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
938 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
943 """!Datum code changed"""
944 self.
datum = event.GetString()
946 nextButton = wx.FindWindowById(wx.ID_FORWARD)
947 if len(self.
datum) == 0
or self.
datum not in self.parent.datums:
948 nextButton.Enable(
False)
954 self.datumparams.remove(
'dx=0.0')
958 self.datumparams.remove(
'dy=0.0')
962 self.datumparams.remove(
'dz=0.0')
966 nextButton.Enable(
True)
972 """!Search geodetic datum by desc"""
973 str = self.searchb.GetValue()
982 """!Datum selected"""
983 index = event.m_itemIndex
984 item = event.GetItem()
986 self.
datum = self.datumlist.GetItem(index, 0).GetText()
987 self.tdatum.SetValue(self.
datum)
992 """!Wizard page for selecting ellipsoid (select coordinate system option)"""
995 TitledPage.__init__(self, wizard, _(
"Specify ellipsoid"))
1008 self.
searchb = wx.SearchCtrl(self, size = (200,-1),
1009 style = wx.TE_PROCESS_ENTER)
1014 for key
in self.parent.ellipsoids.keys():
1015 data.append([key, self.parent.ellipsoids[key][0]])
1018 columns = [_(
'Code'), _(
'Description')])
1019 self.ellipselist.resizeLastColumn(30)
1022 self.sizer.Add(item = self.MakeLabel(_(
"Ellipsoid code:")),
1023 flag = wx.ALIGN_RIGHT |
1024 wx.ALIGN_CENTER_VERTICAL |
1025 wx.ALL, border = 5, pos = (1, 1))
1026 self.sizer.Add(item = self.
tellipse,
1027 flag = wx.ALIGN_LEFT |
1028 wx.ALIGN_CENTER_VERTICAL |
1029 wx.ALL, border = 5, pos = (1, 2))
1030 self.sizer.Add(item = self.MakeLabel(_(
"Search in description:")),
1031 flag = wx.ALIGN_RIGHT |
1032 wx.ALIGN_CENTER_VERTICAL |
1033 wx.ALL, border = 5, pos = (2, 1))
1034 self.sizer.Add(item = self.
searchb,
1035 flag = wx.ALIGN_LEFT |
1036 wx.ALIGN_CENTER_VERTICAL |
1037 wx.ALL, border = 5, pos = (2, 2))
1042 wx.ALL, border = 5, pos = (3, 1), span = (1, 4))
1043 self.sizer.AddGrowableCol(4)
1044 self.sizer.AddGrowableRow(3)
1047 self.ellipselist.Bind(wx.EVT_LIST_ITEM_SELECTED, self.
OnItemSelected)
1048 self.tellipse.Bind(wx.EVT_TEXT, self.
OnText)
1049 self.tellipse.Bind(wx.EVT_TEXT_ENTER, self.
OnText)
1050 self.searchb.Bind(wx.EVT_TEXT_ENTER, self.
OnSearch)
1051 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1057 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
1059 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
1064 if event.GetDirection()
and self.
ellipse not in self.parent.ellipsoids:
1068 self.GetNext().SetPrev(self)
1069 self.parent.datumpage.datumparams =
''
1073 """!Ellipspoid code changed"""
1074 self.
ellipse = event.GetString()
1075 nextButton = wx.FindWindowById(wx.ID_FORWARD)
1076 if len(self.
ellipse) == 0
or self.
ellipse not in self.parent.ellipsoids:
1077 nextButton.Enable(
False)
1081 elif self.
ellipse in self.parent.ellipsoids:
1084 nextButton.Enable(
True)
1087 """!Search ellipsoid by desc"""
1090 self.ellipselist.Search(index=[0,1], pattern=event.GetString())
1098 """!Ellipsoid selected"""
1099 index = event.m_itemIndex
1100 item = event.GetItem()
1102 self.
ellipse = self.ellipselist.GetItem(index, 0).GetText()
1103 self.tellipse.SetValue(self.
ellipse)
1108 """!Wizard page for selecting georeferenced file to use
1109 for setting coordinate system parameters"""
1112 TitledPage.__init__(self, wizard, _(
"Select georeferenced file"))
1117 self.
lfile= self.MakeLabel(_(
"Georeferenced file:"))
1118 self.
tfile = self.MakeTextCtrl(size = (300,-1))
1122 self.sizer.Add(item = self.
lfile, flag = wx.ALIGN_LEFT |
1123 wx.ALIGN_CENTRE_VERTICAL |
1124 wx.ALL, border = 5, pos = (1, 1))
1125 self.sizer.Add(item = self.
tfile, flag = wx.ALIGN_LEFT |
1126 wx.ALIGN_CENTRE_VERTICAL |
1127 wx.ALL, border = 5, pos = (1, 2))
1128 self.sizer.Add(item = self.
bbrowse, flag = wx.ALIGN_LEFT |
1129 wx.ALL, border = 5, pos = (1, 3))
1130 self.sizer.AddGrowableCol(3)
1132 self.bbrowse.Bind(wx.EVT_BUTTON, self.
OnBrowse)
1133 self.tfile.Bind(wx.EVT_TEXT, self.
OnText)
1135 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1143 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
1145 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
1150 if event.GetDirection()
and not os.path.isfile(self.
georeffile):
1152 self.GetNext().SetPrev(self)
1159 nextButton = wx.FindWindowById(wx.ID_FORWARD)
1161 if not nextButton.IsEnabled():
1162 nextButton.Enable(
True)
1164 if nextButton.IsEnabled():
1165 nextButton.Enable(
False)
1171 dlg = wx.FileDialog(self,
1172 _(
"Select georeferenced file"),
1173 os.getcwd(),
"",
"*.*", wx.FD_OPEN)
1174 if dlg.ShowModal() == wx.ID_OK:
1175 path = dlg.GetPath()
1176 self.tfile.SetValue(path)
1182 """!Wizard page for selecting WKT file to use
1183 for setting coordinate system parameters"""
1186 TitledPage.__init__(self, wizard, _(
"Select Well Known Text (WKT) .prj file"))
1191 self.
lfile= self.MakeLabel(_(
"WKT .prj file:"))
1192 self.
tfile = self.MakeTextCtrl(size = (300,-1))
1196 self.sizer.Add(item = self.
lfile, flag = wx.ALIGN_LEFT |
1197 wx.ALIGN_CENTRE_VERTICAL |
1198 wx.ALL, border = 5, pos = (1, 1))
1199 self.sizer.Add(item = self.
tfile, flag = wx.ALIGN_LEFT |
1200 wx.ALIGN_CENTRE_VERTICAL |
1201 wx.ALL, border = 5, pos = (1, 2))
1202 self.sizer.Add(item = self.
bbrowse, flag = wx.ALIGN_LEFT |
1203 wx.ALL, border = 5, pos = (1, 3))
1204 self.sizer.AddGrowableCol(3)
1206 self.bbrowse.Bind(wx.EVT_BUTTON, self.
OnBrowse)
1207 self.tfile.Bind(wx.EVT_TEXT, self.
OnText)
1209 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1214 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
1216 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
1221 if event.GetDirection()
and not os.path.isfile(self.
wktfile):
1223 self.GetNext().SetPrev(self)
1229 self.
wktfile = event.GetString()
1230 nextButton = wx.FindWindowById(wx.ID_FORWARD)
1232 if not nextButton.IsEnabled():
1233 nextButton.Enable(
True)
1235 if nextButton.IsEnabled():
1236 nextButton.Enable(
False)
1242 dlg = wx.FileDialog(self,
1243 message = _(
"Select Well Known Text (WKT) .prj file"),
1244 defaultDir = os.getcwd(),
1245 wildcard =
"PRJ files (*.prj)|*.prj|Files (*.*)|*.*",
1248 if dlg.ShowModal() == wx.ID_OK:
1249 path = dlg.GetPath()
1250 self.tfile.SetValue(path)
1256 """!Wizard page for selecting EPSG code for
1257 setting coordinate system parameters"""
1260 TitledPage.__init__(self, wizard, _(
"Choose EPSG Code"))
1268 self.
lfile = self.MakeLabel(_(
"Path to the EPSG-codes file:"),
1269 style = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
1270 self.
lcode = self.MakeLabel(_(
"EPSG code:"),
1271 style = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
1274 self.
tfile = self.MakeTextCtrl(text = epsgdir, size = (200,-1),
1275 style = wx.TE_PROCESS_ENTER)
1276 self.
tcode = self.MakeTextCtrl(size = (200,-1))
1282 self.
searchb = wx.SearchCtrl(self, size = (200,-1),
1283 style = wx.TE_PROCESS_ENTER)
1286 columns = [_(
'Code'), _(
'Description'), _(
'Parameters')])
1289 self.sizer.Add(item = self.
lfile,
1290 flag = wx.ALIGN_LEFT |
1291 wx.ALIGN_CENTER_VERTICAL |
1292 wx.ALL, border = 5, pos = (1, 1), span = (1, 2))
1293 self.sizer.Add(item = self.
tfile,
1294 flag = wx.ALIGN_LEFT |
1295 wx.ALIGN_CENTER_VERTICAL |
1296 wx.ALL, border = 5, pos = (1, 3))
1297 self.sizer.Add(item = self.
bbrowse,
1298 flag = wx.ALIGN_LEFT |
1299 wx.ALIGN_CENTER_VERTICAL |
1300 wx.ALL, border = 5, pos = (1, 4))
1301 self.sizer.Add(item = self.
lcode,
1302 flag = wx.ALIGN_LEFT |
1303 wx.ALIGN_CENTER_VERTICAL |
1304 wx.ALL, border = 5, pos = (2, 1), span = (1, 2))
1305 self.sizer.Add(item = self.
tcode,
1306 flag = wx.ALIGN_LEFT |
1307 wx.ALIGN_CENTER_VERTICAL |
1308 wx.ALL, border = 5, pos = (2, 3))
1309 self.sizer.Add(item = self.
searchb,
1310 flag = wx.ALIGN_LEFT |
1311 wx.ALIGN_CENTER_VERTICAL |
1312 wx.ALL, border = 5, pos = (3, 3))
1314 self.sizer.Add(item = self.
epsglist,
1315 flag = wx.ALIGN_LEFT | wx.EXPAND, pos = (4, 1),
1317 self.sizer.AddGrowableCol(3)
1318 self.sizer.AddGrowableRow(4)
1321 self.bbrowse.Bind(wx.EVT_BUTTON, self.
OnBrowse)
1323 self.tcode.Bind(wx.EVT_TEXT, self.
OnText)
1324 self.tcode.Bind(wx.EVT_TEXT_ENTER, self.
OnText)
1325 self.epsglist.Bind(wx.EVT_LIST_ITEM_SELECTED, self.
OnItemSelected)
1326 self.searchb.Bind(wx.EVT_TEXT_ENTER, self.
OnSearch)
1328 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1331 self.parent.datumtrans =
None
1332 if event.GetDirection():
1335 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
1337 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
1345 if event.GetDirection():
1360 dlg = SelectTransformDialog(self.parent.parent, transforms = ret)
1362 if dlg.ShowModal() == wx.ID_OK:
1363 dtrans = dlg.GetTransform()
1367 return 'Datum transform is required.'
1371 return 'Datum transform is required.'
1373 self.parent.datumtrans = dtrans
1374 self.GetNext().SetPrev(self)
1383 nextButton = wx.FindWindowById(wx.ID_FORWARD)
1388 if not nextButton.IsEnabled():
1389 nextButton.Enable(
True)
1392 if nextButton.IsEnabled():
1393 nextButton.Enable(
False)
1397 value = self.searchb.GetValue()
1402 self.tcode.SetValue(
'')
1403 self.searchb.SetValue(
'')
1408 self.epsglist.Search(index=[0,1,2], pattern=value)
1409 except (IndexError, ValueError):
1412 self.tcode.SetValue(
'')
1413 self.searchb.SetValue(
'')
1418 """!Define path for EPSG code file"""
1419 path = os.path.dirname(self.tfile.GetValue())
1423 dlg = wx.FileDialog(parent = self, message = _(
"Choose EPSG codes file"),
1424 defaultDir = path, defaultFile =
"", wildcard =
"*", style = wx.FD_OPEN)
1426 if dlg.ShowModal() == wx.ID_OK:
1427 path = dlg.GetPath()
1428 self.tfile.SetValue(path)
1436 """!EPSG code selected from the list"""
1437 index = event.m_itemIndex
1438 item = event.GetItem()
1440 self.
epsgcode = int(self.epsglist.GetItem(index, 0).GetText())
1441 self.
epsgdesc = self.epsglist.GetItem(index, 1).GetText()
1442 self.tcode.SetValue(str(self.
epsgcode))
1447 """!Browse EPSG codes"""
1451 wx.MessageBox(parent = self,
1452 message = _(
"Unable to read EPGS codes: %s") % self.
epsgCodeDict,
1453 caption = _(
"Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
1454 self.epsglist.Populate(list(), update =
True)
1458 for code, val
in self.epsgCodeDict.iteritems():
1459 if code
is not None:
1460 data.append((code, val[0], val[1]))
1462 self.epsglist.Populate(data, update =
True)
1465 """!Wizard page for entering custom PROJ.4 string
1466 for setting coordinate system parameters"""
1469 TitledPage.__init__(self, wizard,
1470 _(
"Choose method of specifying georeferencing parameters"))
1477 style = wx.TE_MULTILINE)
1482 flag = wx.ALIGN_LEFT | wx.ALL,
1483 border = 5, pos = (1, 1))
1485 flag = wx.ALIGN_LEFT | wx.ALL | wx.EXPAND,
1486 border = 5, pos = (2, 1), span = (1, 2))
1487 self.sizer.AddGrowableRow(2)
1488 self.sizer.AddGrowableCol(2)
1492 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1497 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
1499 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
1502 if event.GetDirection():
1505 if self.customstring.find(
'+datum=') < 0:
1506 self.GetNext().SetPrev(self)
1512 read =
True, getErrorMsg =
True,
1517 wx.MessageBox(parent = self,
1519 caption = _(
"Error"),
1520 style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
1527 dlg = SelectTransformDialog(self.parent.parent, transforms = out)
1528 if dlg.ShowModal() == wx.ID_OK:
1529 dtrans = dlg.GetTransform()
1533 return _(
'Datum transform is required.')
1537 return _(
'Datum transform is required.')
1539 self.parent.datumtrans = dtrans
1545 datumtrans = dtrans,
1549 for projterm
in projlabel.split(
' +'):
1550 if projterm.find(
"towgs84=") != -1
or projterm.find(
"nadgrids=") != -1:
1554 self.GetNext().SetPrev(self)
1557 """!Change proj string"""
1560 nextButton = wx.FindWindowById(wx.ID_FORWARD)
1562 if nextButton.IsEnabled():
1563 nextButton.Enable(
False)
1565 if not nextButton.IsEnabled():
1569 """!Shows summary result of choosing coordinate system parameters
1570 prior to creating location"""
1572 TitledPage.__init__(self, wizard, _(
"Summary"))
1575 self.
panelTitle = scrolled.ScrolledPanel(parent = self, id = wx.ID_ANY)
1577 self.
panelProj = scrolled.ScrolledPanel(parent = self, id = wx.ID_ANY)
1586 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1591 def _doLayout(self):
1592 """!Do page layout"""
1594 titleSizer = wx.BoxSizer(wx.VERTICAL)
1595 titleSizer.Add(item = self.
llocTitle, proportion = 1,
1596 flag = wx.EXPAND | wx.ALL, border = 5)
1597 self.panelTitle.SetSizer(titleSizer)
1599 projSizer = wx.BoxSizer(wx.VERTICAL)
1600 projSizer.Add(item = self.
lprojection, proportion = 1,
1601 flag = wx.EXPAND | wx.ALL, border = 5)
1602 self.panelProj.SetSizer(projSizer)
1604 proj4stringSizer = wx.BoxSizer(wx.VERTICAL)
1605 proj4stringSizer.Add(item = self.
lproj4string, proportion = 1,
1606 flag = wx.EXPAND | wx.ALL, border = 5)
1607 self.panelProj4string.SetSizer(proj4stringSizer)
1609 self.panelProj4string.SetupScrolling()
1610 self.panelProj.SetupScrolling(scroll_y =
False)
1611 self.panelTitle.SetupScrolling(scroll_y =
False)
1613 self.sizer.Add(item = self.MakeLabel(_(
"GRASS Database:")),
1614 flag = wx.ALIGN_LEFT | wx.ALL,
1615 border = 5, pos = (1, 0))
1617 flag = wx.ALIGN_LEFT | wx.ALL,
1618 border = 5, pos = (1, 1))
1619 self.sizer.Add(item = self.MakeLabel(_(
"Location Name:")),
1620 flag = wx.ALIGN_LEFT | wx.ALL,
1621 border = 5, pos = (2, 0))
1623 flag = wx.ALIGN_LEFT | wx.ALL,
1624 border = 5, pos = (2, 1))
1625 self.sizer.Add(item = self.MakeLabel(_(
"Location Title:")),
1626 flag = wx.ALIGN_LEFT | wx.ALL,
1627 border = 5, pos = (3, 0))
1629 flag = wx.ALIGN_LEFT | wx.ALL | wx.EXPAND,
1630 border = 0, pos = (3, 1))
1631 self.sizer.Add(item = self.MakeLabel(_(
"Projection:")),
1632 flag = wx.ALIGN_LEFT | wx.ALL,
1633 border = 5, pos = (4, 0))
1635 flag = wx.ALIGN_LEFT | wx.ALL | wx.EXPAND,
1636 border = 0, pos = (4, 1))
1637 self.sizer.Add(item = self.MakeLabel(_(
"PROJ.4 definition:\n (non-definitive)")),
1638 flag = wx.ALIGN_LEFT | wx.ALL,
1639 border = 5, pos = (5, 0))
1641 flag = wx.ALIGN_LEFT | wx.ALL | wx.EXPAND,
1642 border = 0, pos = (5, 1))
1643 self.sizer.AddGrowableCol(1)
1644 self.sizer.AddGrowableRow(3, 1)
1645 self.sizer.AddGrowableRow(4, 1)
1646 self.sizer.AddGrowableRow(5, 5)
1649 """!Insert values into text controls for summary of location
1652 database = self.parent.startpage.grassdatabase
1653 location = self.parent.startpage.location
1654 proj4string = self.parent.CreateProj4String()
1655 epsgcode = self.parent.epsgpage.epsgcode
1656 datum = self.parent.datumpage.datum
1657 dtrans = self.parent.datumtrans
1661 if coordsys
in (
'proj',
'epsg',
'wkt',
'file'):
1663 extra_opts[
'location'] =
'location'
1664 extra_opts[
'getErrorMsg'] =
True
1665 extra_opts[
'read'] =
True
1667 if coordsys ==
'proj':
1670 extra_opts[
'datum'] =
'%s' % datum
1671 extra_opts[
'datumtrans'] = dtrans
1675 proj4 = proj4string,
1677 elif coordsys ==
'epsg':
1681 datumtrans = dtrans,
1683 elif coordsys ==
'file':
1686 georef = self.parent.filepage.georeffile,
1688 elif coordsys ==
'wkt':
1691 wkt = self.parent.wktpage.wktfile,
1694 finishButton = wx.FindWindowById(wx.ID_FORWARD)
1697 projlabel = projlabel +
'+datum=%s' % datum
1698 self.lproj4string.SetLabel(projlabel.replace(
' +', os.linesep +
'+'))
1699 finishButton.Enable(
True)
1701 GError(err, parent = self)
1702 self.lproj4string.SetLabel(
'')
1703 finishButton.Enable(
False)
1705 projdesc = self.parent.projpage.projdesc
1706 ellipsedesc = self.parent.ellipsepage.ellipsedesc
1707 datumdesc = self.parent.datumpage.datumdesc
1708 self.ldatabase.SetLabel(database)
1709 self.llocation.SetLabel(location)
1710 self.llocTitle.SetLabel(self.parent.startpage.locTitle)
1713 if coordsys ==
'epsg':
1714 label =
'EPSG code %s (%s)' % (self.parent.epsgpage.epsgcode,
1715 self.parent.epsgpage.epsgdesc)
1717 elif coordsys ==
'file':
1718 label =
'matches file %s' % self.parent.filepage.georeffile
1720 elif coordsys ==
'wkt':
1721 label =
'matches file %s' % self.parent.wktpage.wktfile
1723 elif coordsys ==
'proj':
1724 label = (
'%s, %s %s' % (projdesc, datumdesc, ellipsedesc))
1726 elif coordsys ==
'xy':
1727 label = (
'XY coordinate system (not projected).')
1728 self.lproj4string.SetLabel(
"")
1730 elif coordsys ==
'custom':
1732 combo_str = self.parent.custompage.customstring + \
1733 self.parent.custompage.custom_dtrans_string
1734 self.lproj4string.SetLabel((
'%s' % combo_str.replace(
' +', os.linesep +
'+')))
1736 self.lprojection.SetLabel(label)
1740 dlg = wx.MessageDialog(parent = self.wizard,
1741 message = _(
"Do you want to create GRASS location <%s>?") % location,
1742 caption = _(
"Create new location?"),
1743 style = wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
1745 if dlg.ShowModal() == wx.ID_NO:
1753 """!Start wizard here and finish wizard here
1764 imagePath = os.path.join(globalvar.ETCIMGDIR,
"loc_wizard_qgis.png")
1765 wizbmp = wx.Image(imagePath, wx.BITMAP_TYPE_PNG)
1766 wizbmp = wizbmp.ConvertToBitmap()
1786 title = _(
"Define new GRASS Location"),
1788 self.wizard.Bind(wiz.EVT_WIZARD_HELP, self.
OnHelp)
1808 self.csystemspage.SetPrev(self.
startpage)
1809 self.csystemspage.SetNext(self.
sumpage)
1814 self.paramspage.SetPrev(self.
projpage)
1818 self.datumpage.SetNext(self.
sumpage)
1821 self.ellipsepage.SetNext(self.
sumpage)
1824 self.epsgpage.SetNext(self.
sumpage)
1827 self.filepage.SetNext(self.
sumpage)
1830 self.wktpage.SetNext(self.
sumpage)
1833 self.custompage.SetNext(self.
sumpage)
1840 self.startpage.DoLayout()
1841 self.csystemspage.DoLayout()
1842 self.projpage.DoLayout()
1843 self.datumpage.DoLayout()
1844 self.paramspage.DoLayout()
1845 self.epsgpage.DoLayout()
1846 self.filepage.DoLayout()
1847 self.wktpage.DoLayout()
1848 self.ellipsepage.DoLayout()
1849 self.custompage.DoLayout()
1850 self.sumpage.DoLayout()
1852 size = self.wizard.GetPageSize()
1853 self.wizard.SetPageSize((size[0], size[1] + 75))
1865 if self.wizard.RunWizard(self.
startpage):
1868 self.wizard.Destroy()
1869 self.
location = self.startpage.location
1876 self.wizard.Destroy()
1877 GError(parent = self.
parent,
1878 message =
"%s" % _(
"Unable to create new location. "
1879 "Location <%(loc)s> not created.\n\n"
1880 "Details: %(err)s") % \
1881 {
'loc' : self.startpage.location,
1884 self.wizard.Destroy()
1885 GMessage(parent = self.
parent,
1886 message = _(
"Location wizard canceled. "
1887 "Location not created."))
1891 def __cleanUp(self):
1907 transformlist = list()
1909 def __readData(self):
1910 """!Get georeferencing information from tables in $GISBASE/etc"""
1913 f = open(os.path.join(globalvar.ETCDIR,
"proj-parms.table"),
"r")
1916 for line
in f.readlines():
1919 proj, projdesc, params = line.split(
':')
1920 paramslist = params.split(
';')
1922 for p
in paramslist:
1923 if p ==
'':
continue
1924 p1, pdefault = p.split(
',')
1925 pterm, pask = p1.split(
'=')
1926 p = [pterm.strip(), pask.strip(), pdefault.strip()]
1928 self.
projections[proj.lower().strip()] = (projdesc.strip(), plist)
1929 self.
projdesc[proj.lower().strip()] = projdesc.strip()
1935 f = open(os.path.join(globalvar.ETCDIR,
"datum.table"),
"r")
1938 for line
in f.readlines():
1939 line = line.expandtabs(1)
1941 if line ==
'' or line[0] ==
"#":
1943 datum, info = line.split(
" ", 1)
1945 datumdesc, params = info.split(
" ", 1)
1946 datumdesc = datumdesc.strip(
'"')
1947 paramlist = params.split()
1948 ellipsoid = paramlist.pop(0)
1949 self.
datums[datum] = (ellipsoid, datumdesc.replace(
'_',
' '), paramlist)
1953 f = open(os.path.join(globalvar.ETCDIR,
"ellipse.table"),
"r")
1955 for line
in f.readlines():
1956 line = line.expandtabs(1)
1958 if line ==
'' or line[0] ==
"#":
1960 ellipse, rest = line.split(
" ", 1)
1961 rest = rest.strip(
'" ')
1962 desc, params = rest.split(
'"', 1)
1963 desc = desc.strip(
'" ')
1964 paramslist = params.split()
1965 self.
ellipsoids[ellipse] = (desc, paramslist)
1969 f = open(os.path.join(globalvar.ETCDIR,
"proj-desc.table"),
"r")
1971 for line
in f.readlines():
1974 pparam, datatype, proj4term, desc = line.split(
':')
1975 self.
paramdesc[pparam] = (datatype, proj4term, desc)
1981 """!Wizard finished, create new location
1983 @return error message on error
1984 @return None on success
1986 database = self.startpage.grassdatabase
1987 location = self.startpage.location
1990 if os.path.isdir(os.path.join(database,location)):
1991 GError(parent = self.
wizard,
1992 message =
"%s <%s>: %s" % \
1993 (_(
"Unable to create new location"),
1994 os.path.join(database, location),
1995 _(
"Location already exists in GRASS Database.")))
1999 current_gdb = grass.gisenv()[
'GISDBASE']
2000 if current_gdb != database:
2002 if os.path.isdir(database) !=
True:
2009 set =
'GISDBASE=%s' % database)
2011 wx.MessageBox(parent = self.
wizard,
2012 message = _(
"Location <%(loc)s> will be created "
2013 "in GIS data directory <%(dir)s>. "
2014 "You will need to change the default GIS "
2015 "data directory in the GRASS startup screen.") % \
2016 {
'loc' : location,
'dir' : database},
2017 caption = _(
"New GIS data directory"),
2018 style = wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
2025 if coordsys ==
"xy":
2026 grass.create_location(dbase = self.startpage.grassdatabase,
2027 location = self.startpage.location,
2028 desc = self.startpage.locTitle)
2029 elif coordsys ==
"proj":
2030 grass.create_location(dbase = self.startpage.grassdatabase,
2031 location = self.startpage.location,
2033 datum = self.datumpage.datum,
2035 desc = self.startpage.locTitle)
2036 elif coordsys ==
'custom':
2041 grass.create_location(dbase = self.startpage.grassdatabase,
2042 location = self.startpage.location,
2043 proj4 = self.custompage.customstring,
2044 desc = self.startpage.locTitle,
2046 elif coordsys ==
"epsg":
2047 if not self.epsgpage.epsgcode:
2048 return _(
'EPSG code missing.')
2050 grass.create_location(dbase = self.startpage.grassdatabase,
2051 location = self.startpage.location,
2052 epsg = self.epsgpage.epsgcode,
2053 datum = self.datumpage.datum,
2055 desc = self.startpage.locTitle)
2056 elif coordsys ==
"file":
2057 if not self.filepage.georeffile
or \
2058 not os.path.isfile(self.filepage.georeffile):
2059 return _(
"File <%s> not found." % self.filepage.georeffile)
2061 grass.create_location(dbase = self.startpage.grassdatabase,
2062 location = self.startpage.location,
2063 filename = self.filepage.georeffile,
2064 desc = self.startpage.locTitle)
2065 elif coordsys ==
"wkt":
2066 if not self.wktpage.wktfile
or \
2067 not os.path.isfile(self.wktpage.wktfile):
2068 return _(
"File <%s> not found." % self.wktpage.wktfile)
2070 grass.create_location(dbase = self.startpage.grassdatabase,
2071 location = self.startpage.location,
2072 wkt = self.wktpage.wktfile,
2073 desc = self.startpage.locTitle)
2075 except grass.ScriptError, e:
2081 """!Constract PROJ.4 string"""
2082 location = self.startpage.location
2083 proj = self.projpage.p4proj
2084 projdesc = self.projpage.projdesc
2085 proj4params = self.paramspage.p4projparams
2088 if self.datumpage.datumdesc:
2089 datumdesc = self.datumpage.datumdesc +
' - ' + self.datumpage.ellipse
2092 datumparams = self.datumpage.datumparams
2093 ellipse = self.ellipsepage.ellipse
2094 ellipsedesc = self.ellipsepage.ellipsedesc
2095 ellipseparams = self.ellipsepage.ellipseparams
2100 proj4string =
'%s %s' % (proj, proj4params)
2104 proj4string =
'%s +ellps=%s' % (proj4string, ellipse)
2105 for item
in ellipseparams:
2106 if item[:4] ==
'f=1/':
2107 item =
' +rf=' + item[4:]
2110 proj4string =
'%s %s' % (proj4string, item)
2114 for item
in datumparams:
2115 proj4string =
'%s +%s' % (proj4string,item)
2117 proj4string =
'%s +no_defs' % proj4string
2122 """'Help' button clicked"""
2125 filePath = os.path.join(os.getenv(
'GISBASE'),
"docs",
"html",
"helptext.html")
2126 webbrowser.open(filePath)
2131 pre = wiz.PreWizard()
2132 pre.SetExtraStyle(wx.wizard.WIZARD_EX_HELPBUTTON)
2133 pre.Create(parent = parent, id = id, title = title, bitmap = bitmap)
2134 self.PostCreate(pre)
def OnColumnClick(self, event)
Sort by column.
Wizard page for selecting ellipsoid (select coordinate system option)
def OnText(self, event)
Ellipspoid code changed.
def OnPageChanging(self, event)
def __init__(self, wizard, parent)
def OnDText(self, event)
Datum code changed.
def OnEnterPage(self, event)
Page entered.
def _doLayout(self)
Do page layout.
def OnItemSelected(self, event)
EPSG code selected from the list.
def PathJoin(args)
Check path created by os.path.join.
Wizard page for selecting projection (select coordinate system option)
def __init__(self, wizard, parent)
def __init__(self, wizard, parent, grassdatabase)
Wizard page for setting GIS data directory and location name.
Location wizard - dialogs.
def GetListCtrl(self)
Used by listmix.ColumnSorterMixin.
Generic list (for projections, ellipsoids, etc.)
def CreateProj4String(self)
Constract PROJ.4 string.
def __readData(self)
Get georeferencing information from tables in $GISBASE/etc.
def __init__(self, wizard, parent)
def OnPageChanging(self, event)
def OnPageChanging(self, event)
def __init__(self, parent, grassdatabase)
def OnPageChanging(self, event)
def __init__(self, wizard, parent)
def __init__(self, wizard, parent)
Wizard page for selecting datum (with associated ellipsoid) and datum transformation parameters (sele...
def OnDSearch(self, event)
Search geodetic datum by desc.
def OnPageChange
Go to next page.
Wizard page for selecting georeferenced file to use for setting coordinate system parameters...
def SetVal(self, event)
Set value.
Wizard page for selecting EPSG code for setting coordinate system parameters.
def OnPageChanging(self, event)
Location wizard - base classes.
def OnFinish(self, event)
def __init__(self, wizard, parent)
def OnPageChanging(self, event)
Shows summary result of choosing coordinate system parameters prior to creating location.
def Search(self, index, pattern)
Search projection by description Return first found item or None.
def OnText(self, event)
File changed.
def OnEnterPage(self, event)
def OnItemSelected(self, event)
Projection selected.
def ReadEpsgCodes(path)
Read EPSG code from the file.
Start wizard here and finish wizard here.
def OnEnterPage(self, event)
def __init__(self, wizard, parent)
def __init__(self, parent, title)
Wizard page for entering custom PROJ.4 string for setting coordinate system parameters.
def OnSearch(self, event)
def OnText(self, event)
Projection name changed.
def OnItemSelected(self, event)
Ellipsoid selected.
def OnWizFinished(self)
Wizard finished, create new location.
def OnEnterPage(self, event)
def OnEnterPage(self, event)
def OnParamEntry(self, event)
Parameter value changed.
def OnEnterPage(self, event)
def OnGetItemText(self, item, col)
Get item text.
def OnEnterPage(self, event)
Insert values into text controls for summary of location creation options.
def OnPageChanging(self, event)
def DoLayout(self)
Do page layout.
Class to make wizard pages.
Wizard page for selecting WKT file to use for setting coordinate system parameters.
def OnChangeName(self, event)
Name for new location was changed.
def OnEnterPage(self, event)
def SetVal(self, event)
Choose method.
Wizard page for selecting method of setting coordinate system parameters (select coordinate system op...
def RunCommand(prog, flags="", overwrite=False, quiet=False, verbose=False, parent=None, read=False, stdin=None, getErrorMsg=False, kwargs)
Run GRASS command.
def OnGetItemAttr(self, item)
Get item attributes.
def __init__(self, wizard, parent)
def OnBrowse(self, event)
Choose file.
Wizard page for choosing method for location creation.
def OnBrowseCodes
Browse EPSG codes.
def OnBrowse(self, event)
Choose file.
def Populate
Populate list.
def OnText(self, event)
File changed.
def OnEnterPage(self, event)
def __init__(self, wizard, parent)
def _nameValidationFailed(self, ctrl)
def OnSearch(self, event)
Search projection by desc.
def OnBrowse(self, event)
Define path for EPSG code file.
def GetSortImages(self)
Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py.
def GetProjstring(self, event)
Change proj string.
def OnSearch(self, event)
Search ellipsoid by desc.
def OnDatumSelected(self, event)
Datum selected.
def OnBrowse(self, event)
Choose GRASS data directory.
def OnEnterPage(self, event)
def Sorter(self, key1, key2)
def __init__(self, wizard, parent)