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.AddGrowableCol(3)
111 self.sizer.Add(item = self.MakeLabel(_(
"GIS Data Directory:")),
112 flag = wx.ALIGN_RIGHT |
113 wx.ALIGN_CENTER_VERTICAL |
117 flag = wx.ALIGN_LEFT |
118 wx.ALIGN_CENTER_VERTICAL |
121 self.sizer.Add(item = self.
bbrowse,
122 flag = wx.ALIGN_LEFT |
123 wx.ALIGN_CENTER_VERTICAL |
127 self.sizer.Add(item = self.MakeLabel(
"%s:" % _(
"Project Location"),
128 tooltip = _(
"Name of location directory in GIS Data Directory")),
129 flag = wx.ALIGN_RIGHT |
130 wx.ALIGN_CENTER_VERTICAL |
134 flag = wx.ALIGN_LEFT |
135 wx.ALIGN_CENTER_VERTICAL |
139 self.sizer.Add(item = self.MakeLabel(
"%s:" % _(
"Location Title"),
140 tooltip = _(
"Optional location title, "
141 "you can leave this field blank.")),
142 flag = wx.ALIGN_RIGHT |
143 wx.ALIGN_TOP | wx.ALIGN_CENTER_VERTICAL |
147 flag = wx.ALIGN_LEFT |
148 wx.ALIGN_CENTER_VERTICAL |
150 pos = (3, 2), span = (1, 2))
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.AddGrowableCol(1)
237 self.sizer.SetVGap(10)
238 self.sizer.Add(item = self.
radio1,
239 flag = wx.ALIGN_LEFT, pos = (1, 1))
240 self.sizer.Add(item = self.
radio2,
241 flag = wx.ALIGN_LEFT, pos = (2, 1))
242 self.sizer.Add(item = self.
radio3,
243 flag = wx.ALIGN_LEFT, pos = (3, 1))
244 self.sizer.Add(item = self.
radio4,
245 flag = wx.ALIGN_LEFT, pos = (4, 1))
246 self.sizer.Add(item = self.
radio5,
247 flag = wx.ALIGN_LEFT, pos = (5, 1))
248 self.sizer.Add(item = self.
radio6,
249 flag = wx.ALIGN_LEFT, pos = (6, 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.AddGrowableCol(3)
355 self.sizer.Add(item = self.MakeLabel(_(
"Projection code:")),
356 flag = wx.ALIGN_LEFT |
357 wx.ALIGN_CENTER_VERTICAL |
358 wx.ALL, border = 5, pos = (1, 1))
359 self.sizer.Add(item = self.
tproj,
360 flag = wx.ALIGN_RIGHT | wx.EXPAND | wx.ALL,
361 border = 5, pos = (1, 2))
363 self.sizer.Add(item = self.MakeLabel(_(
"Search in description:")),
364 flag = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
365 border = 5, pos = (2, 1))
366 self.sizer.Add(item = self.
searchb,
367 flag = wx.ALIGN_RIGHT | wx.EXPAND | wx.ALL,
368 border = 5, pos = (2, 2))
370 self.sizer.AddGrowableRow(3)
371 self.sizer.Add(item = self.
projlist,
374 wx.ALL, border = 5, pos = (3, 1), span = (1, 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"))
652 self.sizer.AddGrowableCol(1)
653 self.sizer.AddGrowableRow(1)
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)
661 self.
radio1 = wx.RadioButton(parent = self, id = wx.ID_ANY,
662 label = _(
"Datum with associated ellipsoid"),
664 self.
radio2 = wx.RadioButton(parent = self, id = wx.ID_ANY,
665 label = _(
"Ellipsoid only"))
668 if self.radio1.GetValue() ==
False and self.radio2.GetValue() ==
False:
669 self.radio1.SetValue(
True)
670 self.SetNext(self.parent.datumpage)
673 radioSBSizer.Add(item = self.
radio1,
674 flag = wx.ALIGN_LEFT | wx.RIGHT, border = 20)
675 radioSBSizer.Add(item = self.
radio2,
676 flag = wx.ALIGN_LEFT)
679 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio1.GetId())
680 self.Bind(wx.EVT_RADIOBUTTON, self.
SetVal, id = self.radio2.GetId())
681 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.
OnPageChange)
682 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
685 """!Parameter value changed"""
687 val = event.GetString()
694 win = self.FindWindowById(id)
695 if param[
'type'] ==
'zone':
702 if param[
'type'] ==
'bool':
703 param[
'value'] = event.GetSelection()
710 """!Go to next page"""
711 if event.GetDirection():
713 for id, param
in self.pparam.iteritems():
714 if param[
'type'] ==
'bool':
715 if param[
'value'] ==
False:
720 if param[
'value']
is None:
721 wx.MessageBox(parent = self,
722 message = _(
'You must enter a value for %s') % param[
'desc'],
723 caption = _(
'Error'), style = wx.ICON_ERROR | wx.CENTRE)
726 self.
p4projparams += (
' +' + param[
'proj4'] +
'=' + str(param[
'value']))
730 self.
projdesc = self.parent.projections[self.parent.projpage.proj][0]
733 self.
paramSBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
734 label = _(
" Enter parameters for %s projection ") % self.
projdesc)
735 paramSBSizer = wx.StaticBoxSizer(self.
paramSBox)
737 self.
panel = scrolled.ScrolledPanel(parent = self, id = wx.ID_ANY)
738 self.panel.SetupScrolling()
742 self.sizer.Add(item = paramSBSizer, pos = (1, 1),
744 paramSBSizer.Add(item = self.
panel, proportion = 1,
745 flag = wx.ALIGN_CENTER | wx.EXPAND)
747 paramSBSizer.Fit(self.
panel)
750 if event.GetDirection():
751 self.prjParamSizer.Clear(
True)
752 self.paramSBox.SetLabel(_(
" Enter parameters for %s projection ") % self.
projdesc)
755 for paramgrp
in self.parent.projections[self.parent.projpage.proj][1]:
758 param = self.
pparam[id] = {
'type' : self.parent.paramdesc[paramgrp[0]][0],
759 'proj4': self.parent.paramdesc[paramgrp[0]][1],
760 'desc' : self.parent.paramdesc[paramgrp[0]][2] }
763 if param[
'type'] ==
'bool':
765 elif param[
'type'] ==
'zone':
767 param[
'desc'] +=
' (1-60)'
769 param[
'value'] = paramgrp[2]
771 label = wx.StaticText(parent = self.
panel, id = wx.ID_ANY, label = param[
'desc'],
772 style = wx.ALIGN_RIGHT | wx.ST_NO_AUTORESIZE)
773 if param[
'type'] ==
'bool':
774 win = wx.Choice(parent = self.
panel, id = id, size = (100,-1),
775 choices = [_(
'No'), _(
'Yes')])
776 win.SetSelection(param[
'value'])
778 elif param[
'type'] ==
'zone':
779 win = wx.SpinCtrl(parent = self.
panel, id = id,
781 style = wx.SP_ARROW_KEYS | wx.SP_WRAP,
783 win.SetValue(param[
'value'])
787 win = wx.TextCtrl(parent = self.
panel, id = id,
788 value = param[
'value'],
791 if paramgrp[1] ==
'noask':
794 self.prjParamSizer.Add(item = label, pos = (row, 1),
795 flag = wx.ALIGN_RIGHT |
796 wx.ALIGN_CENTER_VERTICAL |
797 wx.RIGHT, border = 5)
798 self.prjParamSizer.Add(item = win, pos = (row, 2),
799 flag = wx.ALIGN_LEFT |
800 wx.ALIGN_CENTER_VERTICAL |
804 self.panel.SetSize(self.panel.GetBestSize())
809 if not wx.FindWindowById(wx.ID_FORWARD).IsEnabled():
810 wx.FindWindowById(wx.ID_FORWARD).Enable()
816 if event.GetId() == self.radio1.GetId():
817 self.SetNext(self.parent.datumpage)
818 self.parent.sumpage.SetPrev(self.parent.datumpage)
819 elif event.GetId() == self.radio2.GetId():
820 self.SetNext(self.parent.ellipsepage)
821 self.parent.sumpage.SetPrev(self.parent.ellipsepage)
824 """!Wizard page for selecting datum (with associated ellipsoid)
825 and datum transformation parameters (select coordinate system option)
829 TitledPage.__init__(self, wizard, _(
"Specify geodetic datum"))
839 self.
tdatum = self.MakeTextCtrl(
"", size = (200,-1))
842 self.
searchb = wx.SearchCtrl(self, size = (200,-1),
843 style = wx.TE_PROCESS_ENTER)
847 for key
in self.parent.datums.keys():
848 data.append([key, self.parent.datums[key][0], self.parent.datums[key][1]])
851 columns = [_(
'Code'), _(
'Ellipsoid'), _(
'Description')])
852 self.datumlist.resizeLastColumn(10)
855 self.sizer.AddGrowableCol(4)
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))
874 self.sizer.AddGrowableRow(3)
878 wx.ALL, border = 5, pos = (3, 1), span = (1, 4))
882 self.searchb.Bind(wx.EVT_TEXT_ENTER, self.
OnDSearch)
883 self.tdatum.Bind(wx.EVT_TEXT, self.
OnDText)
884 self.tdatum.Bind(wx.EVT_TEXT_ENTER, self.
OnDText)
886 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
893 proj = self.parent.projpage.p4proj
895 if event.GetDirection():
896 if self.
datum not in self.parent.datums:
904 datum =
'%s' % self.
datum,
911 dlg = SelectTransformDialog(self.parent.parent, transforms=ret)
913 if dlg.ShowModal() == wx.ID_OK:
914 dtrans = dlg.GetTransform()
918 return 'Datum transform is required.'
922 return 'Datum transform is required.'
924 self.parent.datumtrans = dtrans
926 self.GetNext().SetPrev(self)
927 self.parent.ellipsepage.ellipse = self.
ellipse
928 self.parent.ellipsepage.ellipseparams = self.parent.ellipsoids[self.
ellipse][1]
931 self.parent.datumtrans =
None
932 if event.GetDirection():
933 if len(self.
datum) == 0:
935 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
937 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
942 """!Datum code changed"""
943 self.
datum = event.GetString()
945 nextButton = wx.FindWindowById(wx.ID_FORWARD)
946 if len(self.
datum) == 0
or self.
datum not in self.parent.datums:
947 nextButton.Enable(
False)
953 self.datumparams.remove(
'dx=0.0')
957 self.datumparams.remove(
'dy=0.0')
961 self.datumparams.remove(
'dz=0.0')
965 nextButton.Enable(
True)
971 """!Search geodetic datum by desc"""
972 str = self.searchb.GetValue()
981 """!Datum selected"""
982 index = event.m_itemIndex
983 item = event.GetItem()
985 self.
datum = self.datumlist.GetItem(index, 0).GetText()
986 self.tdatum.SetValue(self.
datum)
991 """!Wizard page for selecting ellipsoid (select coordinate system option)"""
994 TitledPage.__init__(self, wizard, _(
"Specify ellipsoid"))
1007 self.
searchb = wx.SearchCtrl(self, size = (200,-1),
1008 style = wx.TE_PROCESS_ENTER)
1013 for key
in self.parent.ellipsoids.keys():
1014 data.append([key, self.parent.ellipsoids[key][0]])
1017 columns = [_(
'Code'), _(
'Description')])
1018 self.ellipselist.resizeLastColumn(30)
1021 self.sizer.AddGrowableCol(4)
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))
1039 self.sizer.AddGrowableRow(3)
1043 wx.ALL, border = 5, pos = (3, 1), span = (1, 4))
1046 self.ellipselist.Bind(wx.EVT_LIST_ITEM_SELECTED, self.
OnItemSelected)
1047 self.tellipse.Bind(wx.EVT_TEXT, self.
OnText)
1048 self.tellipse.Bind(wx.EVT_TEXT_ENTER, self.
OnText)
1049 self.searchb.Bind(wx.EVT_TEXT_ENTER, self.
OnSearch)
1050 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1056 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
1058 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
1063 if event.GetDirection()
and self.
ellipse not in self.parent.ellipsoids:
1067 self.GetNext().SetPrev(self)
1068 self.parent.datumpage.datumparams =
''
1072 """!Ellipspoid code changed"""
1073 self.
ellipse = event.GetString()
1074 nextButton = wx.FindWindowById(wx.ID_FORWARD)
1075 if len(self.
ellipse) == 0
or self.
ellipse not in self.parent.ellipsoids:
1076 nextButton.Enable(
False)
1080 elif self.
ellipse in self.parent.ellipsoids:
1083 nextButton.Enable(
True)
1086 """!Search ellipsoid by desc"""
1089 self.ellipselist.Search(index=[0,1], pattern=event.GetString())
1097 """!Ellipsoid selected"""
1098 index = event.m_itemIndex
1099 item = event.GetItem()
1101 self.
ellipse = self.ellipselist.GetItem(index, 0).GetText()
1102 self.tellipse.SetValue(self.
ellipse)
1107 """!Wizard page for selecting georeferenced file to use
1108 for setting coordinate system parameters"""
1111 TitledPage.__init__(self, wizard, _(
"Select georeferenced file"))
1116 self.
lfile= self.MakeLabel(_(
"Georeferenced file:"))
1117 self.
tfile = self.MakeTextCtrl(size = (300,-1))
1121 self.sizer.AddGrowableCol(3)
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))
1131 self.bbrowse.Bind(wx.EVT_BUTTON, self.
OnBrowse)
1132 self.tfile.Bind(wx.EVT_TEXT, self.
OnText)
1134 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1142 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
1144 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
1149 if event.GetDirection()
and not os.path.isfile(self.
georeffile):
1151 self.GetNext().SetPrev(self)
1158 nextButton = wx.FindWindowById(wx.ID_FORWARD)
1160 if not nextButton.IsEnabled():
1161 nextButton.Enable(
True)
1163 if nextButton.IsEnabled():
1164 nextButton.Enable(
False)
1170 dlg = wx.FileDialog(self,
1171 _(
"Select georeferenced file"),
1172 os.getcwd(),
"",
"*.*", wx.OPEN)
1173 if dlg.ShowModal() == wx.ID_OK:
1174 path = dlg.GetPath()
1175 self.tfile.SetValue(path)
1181 """!Wizard page for selecting WKT file to use
1182 for setting coordinate system parameters"""
1185 TitledPage.__init__(self, wizard, _(
"Select Well Known Text (WKT) .prj file"))
1190 self.
lfile= self.MakeLabel(_(
"WKT .prj file:"))
1191 self.
tfile = self.MakeTextCtrl(size = (300,-1))
1195 self.sizer.AddGrowableCol(3)
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))
1205 self.bbrowse.Bind(wx.EVT_BUTTON, self.
OnBrowse)
1206 self.tfile.Bind(wx.EVT_TEXT, self.
OnText)
1208 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1213 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
1215 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
1220 if event.GetDirection()
and not os.path.isfile(self.
wktfile):
1222 self.GetNext().SetPrev(self)
1228 self.
wktfile = event.GetString()
1229 nextButton = wx.FindWindowById(wx.ID_FORWARD)
1231 if not nextButton.IsEnabled():
1232 nextButton.Enable(
True)
1234 if nextButton.IsEnabled():
1235 nextButton.Enable(
False)
1241 dlg = wx.FileDialog(self,
1242 message = _(
"Select Well Known Text (WKT) .prj file"),
1243 defaultDir = os.getcwd(),
1244 wildcard =
"PRJ files (*.prj)|*.prj|Files (*.*)|*.*",
1247 if dlg.ShowModal() == wx.ID_OK:
1248 path = dlg.GetPath()
1249 self.tfile.SetValue(path)
1255 """!Wizard page for selecting EPSG code for
1256 setting coordinate system parameters"""
1259 TitledPage.__init__(self, wizard, _(
"Choose EPSG Code"))
1267 self.
lfile = self.MakeLabel(_(
"Path to the EPSG-codes file:"),
1268 style = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
1269 self.
lcode = self.MakeLabel(_(
"EPSG code:"),
1270 style = wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
1273 self.
tfile = self.MakeTextCtrl(text = epsgdir, size = (200,-1),
1274 style = wx.TE_PROCESS_ENTER)
1275 self.
tcode = self.MakeTextCtrl(size = (200,-1))
1281 self.
searchb = wx.SearchCtrl(self, size = (200,-1),
1282 style = wx.TE_PROCESS_ENTER)
1285 columns = [_(
'Code'), _(
'Description'), _(
'Parameters')])
1288 self.sizer.AddGrowableCol(3)
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.AddGrowableRow(4)
1315 self.sizer.Add(item = self.
epsglist,
1316 flag = wx.ALIGN_LEFT | wx.EXPAND, pos = (4, 1),
1320 self.bbrowse.Bind(wx.EVT_BUTTON, self.
OnBrowse)
1322 self.tcode.Bind(wx.EVT_TEXT, self.
OnText)
1323 self.tcode.Bind(wx.EVT_TEXT_ENTER, self.
OnText)
1324 self.epsglist.Bind(wx.EVT_LIST_ITEM_SELECTED, self.
OnItemSelected)
1325 self.searchb.Bind(wx.EVT_TEXT_ENTER, self.
OnSearch)
1327 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1330 self.parent.datumtrans =
None
1331 if event.GetDirection():
1334 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
1336 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
1344 if event.GetDirection():
1359 dlg = SelectTransformDialog(self.parent.parent, transforms = ret)
1361 if dlg.ShowModal() == wx.ID_OK:
1362 dtrans = dlg.GetTransform()
1366 return 'Datum transform is required.'
1370 return 'Datum transform is required.'
1372 self.parent.datumtrans = dtrans
1373 self.GetNext().SetPrev(self)
1382 nextButton = wx.FindWindowById(wx.ID_FORWARD)
1387 if not nextButton.IsEnabled():
1388 nextButton.Enable(
True)
1391 if nextButton.IsEnabled():
1392 nextButton.Enable(
False)
1396 value = self.searchb.GetValue()
1401 self.tcode.SetValue(
'')
1402 self.searchb.SetValue(
'')
1407 self.epsglist.Search(index=[0,1,2], pattern=value)
1408 except (IndexError, ValueError):
1411 self.tcode.SetValue(
'')
1412 self.searchb.SetValue(
'')
1417 """!Define path for EPSG code file"""
1418 path = os.path.dirname(self.tfile.GetValue())
1422 dlg = wx.FileDialog(parent = self, message = _(
"Choose EPSG codes file"),
1423 defaultDir = path, defaultFile =
"", wildcard =
"*", style = wx.OPEN)
1425 if dlg.ShowModal() == wx.ID_OK:
1426 path = dlg.GetPath()
1427 self.tfile.SetValue(path)
1435 """!EPSG code selected from the list"""
1436 index = event.m_itemIndex
1437 item = event.GetItem()
1439 self.
epsgcode = int(self.epsglist.GetItem(index, 0).GetText())
1440 self.
epsgdesc = self.epsglist.GetItem(index, 1).GetText()
1441 self.tcode.SetValue(str(self.
epsgcode))
1446 """!Browse EPSG codes"""
1450 wx.MessageBox(parent = self,
1451 message = _(
"Unable to read EPGS codes: %s") % self.
epsgCodeDict,
1452 caption = _(
"Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
1453 self.epsglist.Populate(list(), update =
True)
1457 for code, val
in self.epsgCodeDict.iteritems():
1458 if code
is not None:
1459 data.append((code, val[0], val[1]))
1461 self.epsglist.Populate(data, update =
True)
1464 """!Wizard page for entering custom PROJ.4 string
1465 for setting coordinate system parameters"""
1468 TitledPage.__init__(self, wizard,
1469 _(
"Choose method of specifying georeferencing parameters"))
1476 style = wx.TE_MULTILINE)
1480 self.sizer.AddGrowableCol(2)
1482 flag = wx.ALIGN_LEFT | wx.ALL,
1483 border = 5, pos = (1, 1))
1484 self.sizer.AddGrowableRow(2)
1486 flag = wx.ALIGN_LEFT | wx.ALL | wx.EXPAND,
1487 border = 5, pos = (2, 1), span = (1, 2))
1491 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1496 wx.FindWindowById(wx.ID_FORWARD).Enable(
False)
1498 wx.FindWindowById(wx.ID_FORWARD).Enable(
True)
1501 if event.GetDirection():
1504 if self.customstring.find(
'+datum=') < 0:
1505 self.GetNext().SetPrev(self)
1511 read =
True, getErrorMsg =
True,
1516 wx.MessageBox(parent = self,
1518 caption = _(
"Error"),
1519 style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
1526 dlg = SelectTransformDialog(self.parent.parent, transforms = out)
1527 if dlg.ShowModal() == wx.ID_OK:
1528 dtrans = dlg.GetTransform()
1532 return _(
'Datum transform is required.')
1536 return _(
'Datum transform is required.')
1538 self.parent.datumtrans = dtrans
1544 datumtrans = dtrans,
1548 for projterm
in projlabel.split(
' +'):
1549 if projterm.find(
"towgs84=") != -1
or projterm.find(
"nadgrids=") != -1:
1553 self.GetNext().SetPrev(self)
1556 """!Change proj string"""
1559 nextButton = wx.FindWindowById(wx.ID_FORWARD)
1561 if nextButton.IsEnabled():
1562 nextButton.Enable(
False)
1564 if not nextButton.IsEnabled():
1568 """!Shows summary result of choosing coordinate system parameters
1569 prior to creating location"""
1571 TitledPage.__init__(self, wizard, _(
"Summary"))
1574 self.
panelTitle = scrolled.ScrolledPanel(parent = self, id = wx.ID_ANY)
1576 self.
panelProj = scrolled.ScrolledPanel(parent = self, id = wx.ID_ANY)
1585 self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.
OnEnterPage)
1590 def _doLayout(self):
1591 """!Do page layout"""
1592 self.sizer.AddGrowableCol(1)
1593 self.sizer.AddGrowableRow(3, 1)
1594 self.sizer.AddGrowableRow(4, 1)
1595 self.sizer.AddGrowableRow(5, 5)
1597 titleSizer = wx.BoxSizer(wx.VERTICAL)
1598 titleSizer.Add(item = self.
llocTitle, proportion = 1,
1599 flag = wx.EXPAND | wx.ALL, border = 5)
1600 self.panelTitle.SetSizer(titleSizer)
1602 projSizer = wx.BoxSizer(wx.VERTICAL)
1603 projSizer.Add(item = self.
lprojection, proportion = 1,
1604 flag = wx.EXPAND | wx.ALL, border = 5)
1605 self.panelProj.SetSizer(projSizer)
1607 proj4stringSizer = wx.BoxSizer(wx.VERTICAL)
1608 proj4stringSizer.Add(item = self.
lproj4string, proportion = 1,
1609 flag = wx.EXPAND | wx.ALL, border = 5)
1610 self.panelProj4string.SetSizer(proj4stringSizer)
1612 self.panelProj4string.SetupScrolling()
1613 self.panelProj.SetupScrolling(scroll_y =
False)
1614 self.panelTitle.SetupScrolling(scroll_y =
False)
1616 self.sizer.Add(item = self.MakeLabel(_(
"GRASS Database:")),
1617 flag = wx.ALIGN_LEFT | wx.ALL,
1618 border = 5, pos = (1, 0))
1620 flag = wx.ALIGN_LEFT | wx.ALL,
1621 border = 5, pos = (1, 1))
1622 self.sizer.Add(item = self.MakeLabel(_(
"Location Name:")),
1623 flag = wx.ALIGN_LEFT | wx.ALL,
1624 border = 5, pos = (2, 0))
1626 flag = wx.ALIGN_LEFT | wx.ALL,
1627 border = 5, pos = (2, 1))
1628 self.sizer.Add(item = self.MakeLabel(_(
"Location Title:")),
1629 flag = wx.ALIGN_LEFT | wx.ALL,
1630 border = 5, pos = (3, 0))
1632 flag = wx.ALIGN_LEFT | wx.ALL | wx.EXPAND,
1633 border = 0, pos = (3, 1))
1634 self.sizer.Add(item = self.MakeLabel(_(
"Projection:")),
1635 flag = wx.ALIGN_LEFT | wx.ALL,
1636 border = 5, pos = (4, 0))
1638 flag = wx.ALIGN_LEFT | wx.ALL | wx.EXPAND,
1639 border = 0, pos = (4, 1))
1640 self.sizer.Add(item = self.MakeLabel(_(
"PROJ.4 definition:\n (non-definitive)")),
1641 flag = wx.ALIGN_LEFT | wx.ALL,
1642 border = 5, pos = (5, 0))
1644 flag = wx.ALIGN_LEFT | wx.ALL | wx.EXPAND,
1645 border = 0, pos = (5, 1))
1648 """!Insert values into text controls for summary of location
1651 database = self.parent.startpage.grassdatabase
1652 location = self.parent.startpage.location
1653 proj4string = self.parent.CreateProj4String()
1654 epsgcode = self.parent.epsgpage.epsgcode
1655 datum = self.parent.datumpage.datum
1656 dtrans = self.parent.datumtrans
1660 if coordsys
in (
'proj',
'epsg',
'wkt',
'file'):
1662 extra_opts[
'location'] =
'location'
1663 extra_opts[
'getErrorMsg'] =
True
1664 extra_opts[
'read'] =
True
1666 if coordsys ==
'proj':
1669 extra_opts[
'datum'] =
'%s' % datum
1670 extra_opts[
'datumtrans'] = dtrans
1674 proj4 = proj4string,
1676 elif coordsys ==
'epsg':
1680 datumtrans = dtrans,
1682 elif coordsys ==
'file':
1685 georef = self.parent.filepage.georeffile,
1687 elif coordsys ==
'wkt':
1690 wkt = self.parent.wktpage.wktfile,
1693 finishButton = wx.FindWindowById(wx.ID_FORWARD)
1696 projlabel = projlabel +
'+datum=%s' % datum
1697 self.lproj4string.SetLabel(projlabel.replace(
' +', os.linesep +
'+'))
1698 finishButton.Enable(
True)
1700 GError(err, parent = self)
1701 self.lproj4string.SetLabel(
'')
1702 finishButton.Enable(
False)
1704 projdesc = self.parent.projpage.projdesc
1705 ellipsedesc = self.parent.ellipsepage.ellipsedesc
1706 datumdesc = self.parent.datumpage.datumdesc
1707 self.ldatabase.SetLabel(database)
1708 self.llocation.SetLabel(location)
1709 self.llocTitle.SetLabel(self.parent.startpage.locTitle)
1712 if coordsys ==
'epsg':
1713 label =
'EPSG code %s (%s)' % (self.parent.epsgpage.epsgcode,
1714 self.parent.epsgpage.epsgdesc)
1716 elif coordsys ==
'file':
1717 label =
'matches file %s' % self.parent.filepage.georeffile
1719 elif coordsys ==
'wkt':
1720 label =
'matches file %s' % self.parent.wktpage.wktfile
1722 elif coordsys ==
'proj':
1723 label = (
'%s, %s %s' % (projdesc, datumdesc, ellipsedesc))
1725 elif coordsys ==
'xy':
1726 label = (
'XY coordinate system (not projected).')
1727 self.lproj4string.SetLabel(
"")
1729 elif coordsys ==
'custom':
1731 combo_str = self.parent.custompage.customstring + \
1732 self.parent.custompage.custom_dtrans_string
1733 self.lproj4string.SetLabel((
'%s' % combo_str.replace(
' +', os.linesep +
'+')))
1735 self.lprojection.SetLabel(label)
1739 dlg = wx.MessageDialog(parent = self.wizard,
1740 message = _(
"Do you want to create GRASS location <%s>?") % location,
1741 caption = _(
"Create new location?"),
1742 style = wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
1744 if dlg.ShowModal() == wx.ID_NO:
1752 """!Start wizard here and finish wizard here
1763 imagePath = os.path.join(globalvar.ETCIMGDIR,
"loc_wizard_qgis.png")
1764 wizbmp = wx.Image(imagePath, wx.BITMAP_TYPE_PNG)
1765 wizbmp = wizbmp.ConvertToBitmap()
1785 title = _(
"Define new GRASS Location"),
1787 self.wizard.Bind(wiz.EVT_WIZARD_HELP, self.
OnHelp)
1807 self.csystemspage.SetPrev(self.
startpage)
1808 self.csystemspage.SetNext(self.
sumpage)
1813 self.paramspage.SetPrev(self.
projpage)
1817 self.datumpage.SetNext(self.
sumpage)
1820 self.ellipsepage.SetNext(self.
sumpage)
1823 self.epsgpage.SetNext(self.
sumpage)
1826 self.filepage.SetNext(self.
sumpage)
1829 self.wktpage.SetNext(self.
sumpage)
1832 self.custompage.SetNext(self.
sumpage)
1839 self.startpage.DoLayout()
1840 self.csystemspage.DoLayout()
1841 self.projpage.DoLayout()
1842 self.datumpage.DoLayout()
1843 self.paramspage.DoLayout()
1844 self.epsgpage.DoLayout()
1845 self.filepage.DoLayout()
1846 self.wktpage.DoLayout()
1847 self.ellipsepage.DoLayout()
1848 self.custompage.DoLayout()
1849 self.sumpage.DoLayout()
1851 size = self.wizard.GetPageSize()
1852 self.wizard.SetPageSize((size[0], size[1] + 75))
1864 if self.wizard.RunWizard(self.
startpage):
1867 self.wizard.Destroy()
1868 self.
location = self.startpage.location
1875 self.wizard.Destroy()
1876 GError(parent = self.
parent,
1877 message =
"%s" % _(
"Unable to create new location. "
1878 "Location <%(loc)s> not created.\n\n"
1879 "Details: %(err)s") % \
1880 {
'loc' : self.startpage.location,
1883 self.wizard.Destroy()
1884 GMessage(parent = self.
parent,
1885 message = _(
"Location wizard canceled. "
1886 "Location not created."))
1890 def __cleanUp(self):
1906 transformlist = list()
1908 def __readData(self):
1909 """!Get georeferencing information from tables in $GISBASE/etc"""
1912 f = open(os.path.join(globalvar.ETCDIR,
"proj-parms.table"),
"r")
1915 for line
in f.readlines():
1918 proj, projdesc, params = line.split(
':')
1919 paramslist = params.split(
';')
1921 for p
in paramslist:
1922 if p ==
'':
continue
1923 p1, pdefault = p.split(
',')
1924 pterm, pask = p1.split(
'=')
1925 p = [pterm.strip(), pask.strip(), pdefault.strip()]
1927 self.
projections[proj.lower().strip()] = (projdesc.strip(), plist)
1928 self.
projdesc[proj.lower().strip()] = projdesc.strip()
1934 f = open(os.path.join(globalvar.ETCDIR,
"datum.table"),
"r")
1937 for line
in f.readlines():
1938 line = line.expandtabs(1)
1940 if line ==
'' or line[0] ==
"#":
1942 datum, info = line.split(
" ", 1)
1944 datumdesc, params = info.split(
" ", 1)
1945 datumdesc = datumdesc.strip(
'"')
1946 paramlist = params.split()
1947 ellipsoid = paramlist.pop(0)
1948 self.
datums[datum] = (ellipsoid, datumdesc.replace(
'_',
' '), paramlist)
1952 f = open(os.path.join(globalvar.ETCDIR,
"ellipse.table"),
"r")
1954 for line
in f.readlines():
1955 line = line.expandtabs(1)
1957 if line ==
'' or line[0] ==
"#":
1959 ellipse, rest = line.split(
" ", 1)
1960 rest = rest.strip(
'" ')
1961 desc, params = rest.split(
'"', 1)
1962 desc = desc.strip(
'" ')
1963 paramslist = params.split()
1964 self.
ellipsoids[ellipse] = (desc, paramslist)
1968 f = open(os.path.join(globalvar.ETCDIR,
"proj-desc.table"),
"r")
1970 for line
in f.readlines():
1973 pparam, datatype, proj4term, desc = line.split(
':')
1974 self.
paramdesc[pparam] = (datatype, proj4term, desc)
1980 """!Wizard finished, create new location
1982 @return error message on error
1983 @return None on success
1985 database = self.startpage.grassdatabase
1986 location = self.startpage.location
1989 if os.path.isdir(os.path.join(database,location)):
1990 GError(parent = self.
wizard,
1991 message =
"%s <%s>: %s" % \
1992 (_(
"Unable to create new location"),
1993 os.path.join(database, location),
1994 _(
"Location already exists in GRASS Database.")))
1998 current_gdb = grass.gisenv()[
'GISDBASE']
1999 if current_gdb != database:
2001 if os.path.isdir(database) !=
True:
2008 set =
'GISDBASE=%s' % database)
2010 wx.MessageBox(parent = self.
wizard,
2011 message = _(
"Location <%(loc)s> will be created "
2012 "in GIS data directory <%(dir)s>. "
2013 "You will need to change the default GIS "
2014 "data directory in the GRASS startup screen.") % \
2015 {
'loc' : location,
'dir' : database},
2016 caption = _(
"New GIS data directory"),
2017 style = wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
2024 if coordsys ==
"xy":
2025 grass.create_location(dbase = self.startpage.grassdatabase,
2026 location = self.startpage.location,
2027 desc = self.startpage.locTitle)
2028 elif coordsys ==
"proj":
2029 grass.create_location(dbase = self.startpage.grassdatabase,
2030 location = self.startpage.location,
2032 datum = self.datumpage.datum,
2034 desc = self.startpage.locTitle)
2035 elif coordsys ==
'custom':
2040 grass.create_location(dbase = self.startpage.grassdatabase,
2041 location = self.startpage.location,
2042 proj4 = self.custompage.customstring,
2043 desc = self.startpage.locTitle,
2045 elif coordsys ==
"epsg":
2046 if not self.epsgpage.epsgcode:
2047 return _(
'EPSG code missing.')
2049 grass.create_location(dbase = self.startpage.grassdatabase,
2050 location = self.startpage.location,
2051 epsg = self.epsgpage.epsgcode,
2052 datum = self.datumpage.datum,
2054 desc = self.startpage.locTitle)
2055 elif coordsys ==
"file":
2056 if not self.filepage.georeffile
or \
2057 not os.path.isfile(self.filepage.georeffile):
2058 return _(
"File <%s> not found." % self.filepage.georeffile)
2060 grass.create_location(dbase = self.startpage.grassdatabase,
2061 location = self.startpage.location,
2062 filename = self.filepage.georeffile,
2063 desc = self.startpage.locTitle)
2064 elif coordsys ==
"wkt":
2065 if not self.wktpage.wktfile
or \
2066 not os.path.isfile(self.wktpage.wktfile):
2067 return _(
"File <%s> not found." % self.wktpage.wktfile)
2069 grass.create_location(dbase = self.startpage.grassdatabase,
2070 location = self.startpage.location,
2071 wkt = self.wktpage.wktfile,
2072 desc = self.startpage.locTitle)
2074 except grass.ScriptError, e:
2080 """!Constract PROJ.4 string"""
2081 location = self.startpage.location
2082 proj = self.projpage.p4proj
2083 projdesc = self.projpage.projdesc
2084 proj4params = self.paramspage.p4projparams
2087 if self.datumpage.datumdesc:
2088 datumdesc = self.datumpage.datumdesc +
' - ' + self.datumpage.ellipse
2091 datumparams = self.datumpage.datumparams
2092 ellipse = self.ellipsepage.ellipse
2093 ellipsedesc = self.ellipsepage.ellipsedesc
2094 ellipseparams = self.ellipsepage.ellipseparams
2099 proj4string =
'%s %s' % (proj, proj4params)
2103 proj4string =
'%s +ellps=%s' % (proj4string, ellipse)
2104 for item
in ellipseparams:
2105 if item[:4] ==
'f=1/':
2106 item =
' +rf=' + item[4:]
2109 proj4string =
'%s %s' % (proj4string, item)
2113 for item
in datumparams:
2114 proj4string =
'%s +%s' % (proj4string,item)
2116 proj4string =
'%s +no_defs' % proj4string
2121 """'Help' button clicked"""
2124 filePath = os.path.join(os.getenv(
'GISBASE'),
"docs",
"html",
"helptext.html")
2125 webbrowser.open(filePath)
2130 pre = wiz.PreWizard()
2131 pre.SetExtraStyle(wx.wizard.WIZARD_EX_HELPBUTTON)
2132 pre.Create(parent = parent, id = id, title = title, bitmap = bitmap)
2133 self.PostCreate(pre)