From barton at grass.itc.it Wed Aug 1 08:06:49 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Aug 1 08:06:54 2007 Subject: [grass-addons] r988 - trunk/grassaddons/gui Message-ID: <200708010606.l7166nuP004276@grass.itc.it> Author: barton Date: 2007-08-01 08:06:25 +0200 (Wed, 01 Aug 2007) New Revision: 988 Modified: trunk/grassaddons/gui/location_wizard.py Log: Setting region extents disabled. Will be moved to intro screen button. Added location variable (if new location creation successful) for use in intro panel. Modified: trunk/grassaddons/gui/location_wizard.py =================================================================== --- trunk/grassaddons/gui/location_wizard.py 2007-07-30 17:59:30 UTC (rev 987) +++ trunk/grassaddons/gui/location_wizard.py 2007-08-01 06:06:25 UTC (rev 988) @@ -240,10 +240,10 @@ wx.MessageBox('You must select a coordinate system') event.Veto() - if coordsys == "xy": - self.parent.bboxpage.cstate.Enable(False) - else: - self.parent.bboxpage.cstate.Enable(True) +# if coordsys == "xy": +# self.parent.bboxpage.cstate.Enable(False) +# else: +# self.parent.bboxpage.cstate.Enable(True) def SetVal(self,event): global coordsys @@ -954,7 +954,7 @@ self.GetNext().SetPrev(self) def OnText(self, event): - self.epsgcode = self.GetString() + self.epsgcode = event.GetString() def OnDoSearch(self,event): str = self.searchb.GetValue() @@ -1673,7 +1673,7 @@ self.projpage = ProjectionsPage(self.wizard, self) self.projtypepage = ProjTypePage(self.wizard,self) self.epsgpage = EPSGPage(self.wizard, self) - self.bboxpage = BBoxPage(self.wizard, self) +# self.bboxpage = BBoxPage(self.wizard, self) self.filepage = GeoreferencedFilePage(self.wizard, self) self.datumpage = DatumPage(self.wizard, self) self.ellipsepage = EllipsePage(self.wizard, self) @@ -1686,35 +1686,37 @@ self.startpage.SetNext(self.csystemspage) self.csystemspage.SetPrev(self.startpage) - self.csystemspage.SetNext(self.bboxpage) + self.csystemspage.SetNext(self.sumpage) self.projtypepage.SetPrev(self.projpage) self.projtypepage.SetNext(self.datumpage) self.datumpage.SetPrev(self.projtypepage) - self.datumpage.SetNext(self.bboxpage) + self.datumpage.SetNext(self.sumpage) self.ellipsepage.SetPrev(self.projtypepage) - self.ellipsepage.SetNext(self.bboxpage) + self.ellipsepage.SetNext(self.sumpage) self.projpage.SetPrev(self.csystemspage) - self.projpage.SetNext(self.projtypepage) + self.projpage.SetNext(self.sumpage) self.epsgpage.SetPrev(self.csystemspage) - self.epsgpage.SetNext(self.bboxpage) + self.epsgpage.SetNext(self.sumpage) self.filepage.SetPrev(self.csystemspage) - self.filepage.SetNext(self.bboxpage) + self.filepage.SetNext(self.sumpage) self.custompage.SetPrev(self.csystemspage) - self.custompage.SetNext(self.bboxpage) + self.custompage.SetNext(self.sumpage) - self.bboxpage.SetPrev(self.csystemspage) - self.bboxpage.SetNext(self.sumpage) +# self.bboxpage.SetPrev(self.csystemspage) +# self.bboxpage.SetNext(self.sumpage) - self.sumpage.SetPrev(self.bboxpage) +# self.sumpage.SetPrev(self.bboxpage) +# + self.wizard.FitToPage(self.datumpage) - self.wizard.FitToPage(self.bboxpage) + self.location = None #New location created success = False @@ -1722,12 +1724,13 @@ success = self.onWizFinished() if success == True: wx.MessageBox("New location created.") + self.location = self.startpage.location else: wx.MessageBox("Unable to create new location.") else: wx.MessageBox("Location wizard canceled. New location not created.") - self.wizard.Destroy() +# self.wizard.Destroy() def onWizFinished(self): database = self.startpage.grassdatabase @@ -1852,6 +1855,7 @@ def CustomCreate(self): proj4string = self.custompage.proj4string + location = self.startpage.location dlg = wx.MessageDialog(self.wizard, "New location '%s' will be created using PROJ.4 string: %s" % (location,proj4string), From barton at grass.itc.it Wed Aug 1 08:08:25 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Aug 1 08:08:30 2007 Subject: [grass-addons] r989 - trunk/grassaddons/gui Message-ID: <200708010608.l7168P8A004296@grass.itc.it> Author: barton Date: 2007-08-01 08:07:35 +0200 (Wed, 01 Aug 2007) New Revision: 989 Modified: trunk/grassaddons/gui/gis_set.py Log: When new location created in wizard, it is automatically selected along with the new PERMANENT mapset. EPSG and Georeferenced file classes removed from gis_set.py because they are now in location wizard. Modified: trunk/grassaddons/gui/gis_set.py =================================================================== --- trunk/grassaddons/gui/gis_set.py 2007-08-01 06:06:25 UTC (rev 988) +++ trunk/grassaddons/gui/gis_set.py 2007-08-01 06:07:35 UTC (rev 989) @@ -24,371 +24,6 @@ return grassrc -class EpsgCode(wx.Frame): - def __init__(self, parent, id, title, ): - wx.Frame.__init__(self,parent, id , title, size=(50,600)) - - self.parent = parent - - # sizers - self.vsizer= wx.BoxSizer(wx.VERTICAL) - self.sizer = wx.FlexGridSizer(5,4,5,5) - - # labels - self.lname= wx.StaticText(self, -1, "Name of new Location: ", - style=wx.ALIGN_RIGHT) - self.lfile= wx.StaticText(self, -1, "Path to the EPSG-codes file: ", - style=wx.ALIGN_RIGHT) - self.lcode= wx.StaticText(self, -1, "EPSG code: ", - style=wx.ALIGN_RIGHT) - self.lsearch= wx.StaticText(self, -1, "Search in code description: ", - style=wx.ALIGN_RIGHT) - - # text input - self.tname = wx.TextCtrl(self,-1, "newLocation", size=(200,20)) - epsgdir = os.path.join(os.environ["GRASS_PROJSHARE"], 'epsg') - self.tfile = wx.TextCtrl(self,-1, epsgdir, size=(200,20)) - - self.tcode = wx.TextCtrl(self,-1, "", size=(200,20)) - - # buttons - self.bbrowse = wx.Button(self, -1, "Browse ...", size=(100,-1)) - self.bbcodes = wx.Button(self, -1, "Browse Codes") - self.bcancel = wx.Button(self, -1, "Cancel", size=(100,-1)) - self.bcreate = wx.Button(self, -1, "Create", size=(100,-1)) - - # empty panels - self.epanel1 = wx.Panel(self,-1) - self.epanel2 = wx.Panel(self,-1) - self.epanel3 = wx.Panel(self,-1) - self.epanel4 = wx.Panel(self,-1) - - # search box - self.searchb = wx.SearchCtrl(self, size=(200,-1), style=wx.TE_PROCESS_ENTER) - - # table - self.tablewidth=600 - self.epsgs = wx.ListCtrl(self, id=wx.ID_ANY, - size=(750,200), - style=wx.LC_REPORT| - wx.LC_HRULES| - wx.EXPAND) - self.epsgs.InsertColumn(0, 'EPSG', wx.LIST_FORMAT_CENTRE) - self.epsgs.InsertColumn(1, 'Description', wx.LIST_FORMAT_LEFT) - self.epsgs.InsertColumn(2, 'Parameters', wx.LIST_FORMAT_LEFT) - self.epsgs.SetColumnWidth(0, 50) - self.epsgs.SetColumnWidth(1, 300) - self.epsgs.SetColumnWidth(2, 400) - - # layout - self.sizer.Add(self.lname, 0, wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP, 10) - self.sizer.Add(self.tname, 0, wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP, 10) - self.sizer.Add(self.epanel1, 0, wx.ALIGN_LEFT, 1) - self.sizer.Add(self.epanel2, 0, wx.ALIGN_LEFT, 1) - - self.sizer.Add(self.lfile, 0 , wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP, 5) - self.sizer.Add(self.tfile, 0 , wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP, 5) - self.sizer.Add(self.bbrowse, 0 , wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP|wx.LEFT, 5) - self.sizer.Add(self.epanel3, 0, wx.ALIGN_LEFT, 1) - - self.sizer.Add(self.lcode, 0, wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP, 5) - self.sizer.Add(self.tcode, 0, wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP, 5) - self.sizer.Add(self.bcreate, 0 , wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP|wx.LEFT, 5) - self.sizer.Add(self.bcancel, 0 , wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP|wx.RIGHT, 5) - - self.sizer.Add(self.lsearch, 0, wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP|wx.BOTTOM, 5) - self.sizer.Add(self.searchb, 0, wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP|wx.BOTTOM, 5) - self.sizer.Add(self.bbcodes, 0 , wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.TOP|wx.LEFT|wx.BOTTOM, 5) - self.sizer.Add(self.epanel4, 0, wx.ALIGN_LEFT, 1) - - self.vsizer.Add(self.sizer,0, wx.ADJUST_MINSIZE, 1) - self.vsizer.Add(self.epsgs, wx.ALIGN_LEFT|wx.EXPAND, 0) - - self.SetAutoLayout(True) - self.SetSizer(self.vsizer) - self.vsizer.Fit(self) - self.vsizer.SetSizeHints(self) - self.Layout() - - # events - wx.EVT_BUTTON(self, self.bbrowse.GetId(), self.OnBrowse) - wx.EVT_BUTTON(self, self.bcancel.GetId(), self.OnCancel) - wx.EVT_BUTTON(self, self.bcreate.GetId(), self.OnCreate) - wx.EVT_BUTTON(self, self.bbcodes.GetId(), self.OnBrowseCodes) - self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self.epsgs) - self.searchb.Bind(wx.EVT_TEXT_ENTER, self.OnDoSearch, self.searchb) - - def OnDoSearch(self,event): - str = self.searchb.GetValue() - listItem = self.epsgs.GetColumn(1) - - for i in range(self.epsgs.GetItemCount()): - listItem = self.epsgs.GetItem(i,1) - if listItem.GetText().find(str) > -1: - epsgcode = self.epsgs.GetItem(i, 0) - self.tcode.SetValue(epsgcode.GetText()) - break - - self.OnBrowseCodes(None,str) - - - def OnBrowse(self, event): - - dlg = wx.FileDialog(self, "Locate EPSG codes file:", - "/", "", "*.*", wx.OPEN) - if dlg.ShowModal() == wx.ID_OK: - path = dlg.GetPath() - self.tfile.SetValue(path) - dlg.Destroy() - - def OnCancel(self, event): - self.Destroy() - - def OnItemSelected(self,event): - item = event.GetItem() - self.tcode.SetValue(str(item.GetText())) - - - def OnBrowseCodes(self,event,search=None): - try: - self.epsgs.DeleteAllItems() - f = open(self.tfile.GetValue(),"r") - i=1 - j = 0 - descr = None - code = None - params = "" - #self.epsgs.ClearAll() - for line in f.readlines(): - line = line.strip() - if line.find("#") == 0: - descr = line[1:].strip() - elif line.find("<") == 0: - code = line.split(" ")[0] - for par in line.split(" ")[1:]: - params += par + " " - code = code[1:-1] - if code == None: code = 'no code' - if descr == None: descr = 'no description' - if params == None: params = 'no parameters' - if i%2 == 0: - if search and descr.lower().find(search.lower()) > -1 or\ - not search: - index = self.epsgs.InsertStringItem(j, code) - self.epsgs.SetStringItem(index, 1, descr) - self.epsgs.SetStringItem(index, 2, params) - j += 1 - # reset - descr = None; code = None; params = "" -# if i%2 == 0: -# self.epsgs.SetItemBackgroundColour(i, "grey") - i += 1 - f.close() - self.epsgs.SetColumnWidth(1, wx.LIST_AUTOSIZE) - self.epsgs.SetColumnWidth(2, wx.LIST_AUTOSIZE) - self.SendSizeEvent() - except StandardError, e: - dlg = wx.MessageDialog(self, "Could not read EPGS codes: %s " - % e,"Can not read file", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - - def OnChange(self,event): - self.item = event.GetItem() - - def OnCreate(self, event): - if not self.tcode.GetValue(): - dlg = wx.MessageDialog(self, "Could not create new location: EPSG Code value missing", - "Can not create location", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - return - - number = -1 - try: - code = self.tcode.GetValue() - except: - dlg = wx.MessageDialog(self, "Could not create new location: '%s' is not a valid EPSG code" % code, - "Can not create location", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - return - - if os.path.isdir(os.path.join(self.parent.gisdbase,self.tname.GetValue())): - dlg = wx.MessageDialog(self, "Could not create new location: %s already exists" - % os.path.join(self.parent.gisdbase,self.tname.GetValue()),"Can not create location", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - return - - # creating location - # all credit to Michael Barton and his file_option.tcl and - # Markus Neteler - try: - dtoptions = os.popen3(" g.proj epsg=%s datumtrans=-1" % (code))[1].read() - if dtoptions != None: - # open a dialog to select datum transform number - dtoptions = 'Select the number of a datum transformation to use: \n'+dtoptions - dlg = wx.TextEntryDialog(self, dtoptions) - dlg.SetValue('1') - - if dlg.ShowModal() == wx.ID_OK: - dtrans = dlg.GetValue() - - dlg.Destroy() - - cmd = os.system("g.proj -c epsg=%s location=%s datumtrans=%s" % (code, self.tname.GetValue(), dtrans)) - else: - os.system("g.proj -c epsg=%s location=%s datumtrans=1" % (code, self.tname.GetValue())) - - self.Destroy() - self.parent.OnSetDatabase(None) - - except StandardError, e: - dlg = wx.MessageDialog(self, "Could not create new location: %s " - % str(e),"Can not create location", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - return - - def OnDoubleClick(self, event): - print self.epsgs.GetValue() - pass - - -class GeoreferencedFile(wx.Frame): - def __init__(self, parent, id, title, ): - wx.Frame.__init__(self,parent, id , title) - - self.parent = parent - - self.sizer = wx.FlexGridSizer(3,3,5,5) - - self.lname= wx.StaticText(self, -1, "Name of new Location: ", - style=wx.ALIGN_RIGHT) - - self.lfile= wx.StaticText(self, -1, "Georeferenced file: ", - style=wx.ALIGN_RIGHT) - - self.tname = wx.TextCtrl(self,-1, "newLocation", size=(200,20)) - self.tfile = wx.TextCtrl(self,-1, "", size=(200,20)) - - self.bbrowse = wx.Button(self, -1, "Browse ...", size=(100,-1)) - self.bcancel = wx.Button(self, -1, "Cancel", size=(100,-1)) - self.bcreate = wx.Button(self, -1, "Create", size=(100,-1)) - - self.gpanel1 = wx.Panel(self,-1) - self.gpanel2 = wx.Panel(self,-1) - - self.sizer.Add(self.lname, 0, wx.ALIGN_RIGHT | - wx.ALIGN_CENTRE_VERTICAL | - wx.TOP|wx.LEFT , 10) - self.sizer.Add(self.tname, 0, wx.ALIGN_LEFT | - wx.ALIGN_CENTRE_VERTICAL | - wx.TOP , 10) - self.sizer.Add(self.gpanel1, 0, wx.ALIGN_LEFT | - wx.ALIGN_CENTRE, 5) - - self.sizer.Add(self.lfile, 0 , wx.ALIGN_RIGHT | - wx.ALIGN_CENTRE_VERTICAL | - wx.TOP , 5) - self.sizer.Add(self.tfile, 0 , wx.ALIGN_LEFT | - wx.ALIGN_CENTRE_VERTICAL | - wx.TOP , 5) - self.sizer.Add(self.bbrowse, 0 , wx.ALIGN_CENTER, 10) - - self.sizer.Add(self.bcreate, 0 , wx.ALIGN_CENTER | - wx.ALL, 10) - self.sizer.Add(self.gpanel2, 0 , wx.ALIGN_CENTER | - wx.ALL, 10) - - self.sizer.Add(self.bcancel, 0 , wx.ALIGN_CENTER | - wx.ALL, 10) - - self.SetAutoLayout(True) - self.SetSizer(self.sizer) - self.sizer.Fit(self) - self.sizer.SetSizeHints(self) - self.Layout() - - - wx.EVT_BUTTON(self, self.bbrowse.GetId(), self.OnBrowse) - wx.EVT_BUTTON(self, self.bcancel.GetId(), self.OnCancel) - wx.EVT_BUTTON(self, self.bcreate.GetId(), self.OnCreate) - - def OnBrowse(self, event): - - dlg = wx.FileDialog(self, "Choose a georeferenced file:", os.getcwd(), "", "*.*", wx.OPEN) - if dlg.ShowModal() == wx.ID_OK: - path = dlg.GetPath() - self.tfile.SetValue(path) - dlg.Destroy() - - def OnCancel(self, event): - self.Destroy() - - def OnCreate(self, event): - if not os.path.isfile(self.tfile.GetValue()): - dlg = wx.MessageDialog(self, "Could not create new location: %s not file" - % self.tfile.GetValue(),"Can not create location", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - return - - if not self.tname.GetValue(): - dlg = wx.MessageDialog(self, "Could not create new location: name not set", - "Can not create location", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - return - - if os.path.isdir(os.path.join(self.parent.gisdbase,self.tname.GetValue())): - dlg = wx.MessageDialog(self, "Could not create new location: %s exists" - % os.path.join(self.parent.gisdbase,self.tname.GetValue()),"Can not create location", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - return - - # creating location - # all credit to Michael Barton and his file_option.tcl and - # Markus Neteler - try: - # FIXME: this does not need to work on windows - os.system("g.proj -c georef=%s location=%s >&2" % (self.tfile.GetValue(), self.tname.GetValue())) - - self.parent.OnSetDatabase(None) - self.Destroy() - - except StandardError, e: - dlg = wx.MessageDialog(self, "Could not create new location: %s " - % str(e),"Can not create location", wx.OK|wx.ICON_INFORMATION) - dlg.ShowModal() - dlg.Destroy() - class GRASSStartup(wx.Frame): def __init__(self, *args, **kwds): kwds["style"] = wx.DEFAULT_FRAME_STYLE @@ -612,10 +247,14 @@ def OnWizard(self,event): import location_wizard reload(location_wizard) - gWizard = location_wizard.GWizard(self, self.tgisdbase.GetValue()) - self.OnSetDatabase(event) + gWizard = location_wizard.GWizard(self, self.tgisdbase.GetValue()) + if gWizard.location != None: + self.OnSetDatabase(event) + self.UpdateMapsets(os.path.join( + self.gisbase,gWizard.location)) + self.lblocations.SetSelection(self.listOfLocations.index(gWizard.location)) + self.lbmapsets.SetSelection(0) - def UpdateLocations(self,dbase): self.listOfLocations = [] @@ -733,7 +372,6 @@ event.Skip() - class StartUp(wx.App): def OnInit(self): wx.InitAllImageHandlers() From barton at grass.itc.it Wed Aug 1 08:34:27 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Aug 1 08:34:32 2007 Subject: [grass-addons] r990 - trunk/grassaddons/gui Message-ID: <200708010634.l716YRRW004413@grass.itc.it> Author: barton Date: 2007-08-01 08:34:12 +0200 (Wed, 01 Aug 2007) New Revision: 990 Modified: trunk/grassaddons/gui/gis_set.py Log: Initial layout and code for new region setting frame. Modified: trunk/grassaddons/gui/gis_set.py =================================================================== --- trunk/grassaddons/gui/gis_set.py 2007-08-01 06:07:35 UTC (rev 989) +++ trunk/grassaddons/gui/gis_set.py 2007-08-01 06:34:12 UTC (rev 990) @@ -6,8 +6,8 @@ import os import glob import shutil +import wx.lib.rcsizer as rcs - def read_grassrc(): """ Read variables from $HOME/.grassrc6 file @@ -61,6 +61,7 @@ self.lmapset = wx.StaticText(self, -1, "Accessible Mapsets\n(directories of GIS files)", style=wx.ALIGN_CENTRE) self.lcreate = wx.StaticText(self, -1, "Create new mapset\nin selected location", style=wx.ALIGN_CENTRE) self.ldefine = wx.StaticText(self, -1, "Define new location...", style=wx.ALIGN_CENTRE) + self.lregion = wx.StaticText(self, -1, "Define default region...", style=wx.ALIGN_CENTRE) # buttons buttonsize1 = (150,-1) @@ -75,6 +76,7 @@ # self.bgeoreferenced = wx.Button(self, -1, "Georeferenced file", size=buttonsize1) # self.bepsg = wx.Button(self, -1, "EPSG codes", size=buttonsize1) self.bwizard = wx.Button(self, -1, "Location wizard", size=buttonsize1) + self.bregion = wx.Button(self, -1, "Define region", size=buttonsize1) # textinputs @@ -99,24 +101,16 @@ self.__do_layout() # events -# wx.EVT_BUTTON(self, self.bbrowse.GetId(), self.OnBrowse) self.bbrowse.Bind(wx.EVT_BUTTON, self.OnBrowse) -# wx.EVT_BUTTON(self, self.bstart.GetId(), self.OnStart) self.bstart.Bind(wx.EVT_BUTTON, self.OnStart) -# wx.EVT_BUTTON(self, self.bexit.GetId(), self.OnExit) self.bexit.Bind(wx.EVT_BUTTON, self.OnExit) -# wx.EVT_BUTTON(self, self.bhelp.GetId(), self.OnHelp) self.bhelp.Bind(wx.EVT_BUTTON, self.OnHelp) -# wx.EVT_BUTTON(self, self.bmapset.GetId(), self.OnCreateMapset) self.bmapset.Bind(wx.EVT_BUTTON, self.OnCreateMapset) -# wx.EVT_BUTTON(self, self.bgeoreferenced.GetId(), self.OnGeoreferenced) -# wx.EVT_BUTTON(self, self.bepsg.GetId(), self.OnEpsg) self.bwizard.Bind(wx.EVT_BUTTON, self.OnWizard) + self.bregion.Bind(wx.EVT_BUTTON, self.OnRegion) self.lblocations.Bind(wx.EVT_LISTBOX, self.OnSelectLocation) self.lbmapsets.Bind(wx.EVT_LISTBOX, self.OnSelectMapset) -# wx.EVT_KEY_DOWN(self.tgisdbase, self.OnKeyPressedInDbase) self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressedInDbase, self.tgisdbase) -# wx.EVT_KEY_DOWN(self.tnewmapset, self.OnKeyPressedInMapset) self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressedInMapset, self.tnewmapset) self.Bind(wx.EVT_CLOSE, self.onCloseWindow) @@ -173,9 +167,9 @@ mapset_sizer.Add(self.tnewmapset, 0, label_style|wx.BOTTOM, 5) mapset_sizer.Add(self.bmapset, 0, label_style|wx.BOTTOM, 10) mapset_sizer.Add(self.ldefine, 0, label_style|wx.RIGHT|wx.LEFT, 5) -# mapset_sizer.Add(self.bgeoreferenced, 0, label_style|wx.TOP, 5) -# mapset_sizer.Add(self.bepsg, 0, label_style|wx.TOP, 5) mapset_sizer.Add(self.bwizard, 0, label_style|wx.TOP, 5) + mapset_sizer.Add(self.lregion, 0, label_style|wx.TOP|wx.RIGHT|wx.LEFT, 5) + mapset_sizer.Add(self.bregion, 0, label_style|wx.TOP, 5) mapset_sizer.Add((5,0)) grid_sizer.Add(self.llocation, 0,label_style|wx.ALL, 5) @@ -255,6 +249,9 @@ self.lblocations.SetSelection(self.listOfLocations.index(gWizard.location)) self.lbmapsets.SetSelection(0) + def OnRegion(self,event): + RegionDef(self) + def UpdateLocations(self,dbase): self.listOfLocations = [] @@ -344,15 +341,6 @@ #self.bmapset.Enable(True) event.Skip() - def OnGeoreferenced(self,event): - NewLocation = GeoreferencedFile(self, -1, "Define new Location") - NewLocation.Show() - - def OnEpsg(self,event): - NewLocation = EpsgCode(self, -1, "Define new Location") - NewLocation.Show() - - def OnStart(self, event): print "g.gisenv set=GISDBASE='%s';" % self.tgisdbase.GetValue() print "g.gisenv set=LOCATION_NAME='%s';" % self.listOfLocations[self.lblocations.GetSelection()] @@ -371,7 +359,424 @@ print "exit" event.Skip() +class RegionDef(wx.Frame): + """ + Page for setting default region extents and resolution + """ + def __init__(self,parent,id=wx.ID_ANY, title="Set default region values"): + wx.Frame.__init__(self, parent, id, title, size=(300,300)) + + self.parent = parent + # inputs + self.ttop = self.MakeTextCtrl("1", size=(150, -1)) + self.tbottom = self.MakeTextCtrl("0", size=(150, -1)) + self.tleft = self.MakeTextCtrl("0", size=(150, -1)) + self.tright = self.MakeTextCtrl("1", size=(150, -1)) + self.tres = self.MakeTextCtrl("1", size=(150, -1)) + + self.tgdal = self.MakeTextCtrl("", size=(250, -1)) + self.tdsn = self.MakeTextCtrl("", size=(250, -1)) + # list of layers + self.layers = [] + self.llayers = wx.ComboBox(self, -1, + choices=self.layers, + size=(250,-1), + style=wx.CB_DROPDOWN) + + # labels + self.lmessage = wx.StaticText(self,-1, "", size=(300,50)) + + # buttons + self.bbrowsegdal = self.MakeButton("Browse...", size=(150,-1)) + self.bbrowseogr = self.MakeButton("Browse...", size=(150,-1)) + self.bgetlayers = self.MakeButton("Get Layers", size=(150,-1)) + self.bset = self.MakeButton("Set coordinates", size=(150,-1)) + + # list of states + self.states = [] + self.coords = [] + try: + f = open(os.path.join(os.getenv("GISBASE"),"etc","wx","states.txt"),"r") + for line in f.readlines(): + if line[0] == "#": + continue + state,coord = line.split(";") + coord = coord.replace(","," ") + self.states.append(state) + self.coords.append(coord.split()) + f.close() + except: + pass + # NOTE: ComboCtcl should come here, but nobody knows, how to + # implement it + # self.stateslist = wx.ListCtrl(self, + # style=wx.LC_LIST|wx.LC_SINGLE_SEL|wx.SIMPLE_BORDER) + # self.cstate = wx.combo.ComboCtrl(self, -1, pos=(50, 170), size=(150, -1), + # style=wx.CB_READONLY) + + self.cstate = wx.ComboBox(self, -1, + size=(250,-1), + choices=self.states, + style=wx.CB_DROPDOWN) + + # layout + self.sizer = rcs.RowColSizer() +# tmpsizer = wx.BoxSizer(wx.VERTICAL) +# +# tmpsizer.Add(self.title, 0, wx.ALIGN_CENTRE|wx.ALL, 5) +# tmpsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 0) +# tmpsizer.Add(self.sizer, wx.EXPAND) +# +# self.SetSizer(tmpsizer) + self.SetSizer(self.sizer) + self.SetAutoLayout(True) + + + + self.sizer.Add(self.MakeRLabel("North"), 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 0, row=1,col=2) + self.sizer.Add(self.ttop, 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=2,col=2) + + self.sizer.Add(self.MakeRLabel("West"), 0, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 0, row=3,col=0) + self.sizer.Add(self.tleft, 0, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=3,col=1) + + self.sizer.Add(self.tright, 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=3,col=3) + self.sizer.Add(self.MakeRLabel("East"), 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 0, row=3,col=4) + + self.sizer.Add(self.tbottom, 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=4,col=2) + self.sizer.Add(self.MakeRLabel("South"), 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 0, row=5,col=2) + + self.sizer.Add(self.MakeRLabel("Initial resolution"), 0, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=6,col=1) + self.sizer.Add(self.tres, 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=6,col=2) + self.sizer.Add(self.bset, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=6, col=3 ) + + self.sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 0, row=7, col=0, colspan=6) + + self.sizer.Add(self.MakeRLabel("Match extents of georeferenced raster map or image"), 3, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=8,col=0, colspan=3) + + self.sizer.Add(self.MakeRLabel("File:"), 0, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=9,col=0, colspan=1) + self.sizer.Add(self.tgdal, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=9,col=1, colspan=2) + self.sizer.Add(self.bbrowsegdal, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=9,col=3) + + self.sizer.Add(wx.StaticLine(self, -1), 0, + wx.EXPAND|wx.ALL, 0, + row=10, col=0, colspan=6) + + self.sizer.Add(self.MakeRLabel("Match extents of georeferenced vector map"), 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=11,col=0, colspan=3 ) + + self.sizer.Add(self.MakeRLabel("Data source/directory:"), 0, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=12,col=0, colspan=1) + self.sizer.Add(self.tdsn, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=12, col=1, colspan=2) + self.sizer.Add(self.bbrowseogr, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=12, col=3) + + self.sizer.Add(self.MakeRLabel("Layer/file:"), 0, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=13,col=0, colspan=1) + self.sizer.Add(self.llayers, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=13,col=1, colspan=2) + self.sizer.Add(self.bgetlayers, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=13,col=3) + + self.sizer.Add(wx.StaticLine(self, -1), 0, + wx.EXPAND|wx.ALL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, + row=14, col=0, colspan=6) + self.sizer.Add(self.MakeRLabel("Match extents of selected country"), 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=15,col=0, colspan=3) + self.sizer.Add(self.cstate, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=16,col=1, colspan=2) + + self.sizer.Add(self.lmessage, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, + row=17,col=1, colspan=3) + + self.Bind(wx.EVT_COMBOBOX, self.OnItemSelected, self.cstate) + self.Bind(wx.EVT_TEXT, self.OnStateText, self.cstate) + self.Bind(wx.EVT_BUTTON, self.OnSetButton, self.bset) + self.Bind(wx.EVT_BUTTON, self.OnBrowseGdal, self.bbrowsegdal) + self.Bind(wx.EVT_BUTTON, self.OnBrowseOGR, self.bbrowseogr) + self.Bind(wx.EVT_BUTTON, self.OnGetOGRLayers, self.bgetlayers) + + def MakeRLabel(self, text=""): + """Make right-aligned label""" + try: + if text[-1] != " ": + text += " " + except: + pass + return wx.StaticText(self, -1, text, style=wx.ALIGN_RIGHT) + + def MakeLLabel(self, text=""): + """Make left-aligned label""" + try: + if text[-1] != " ": + text += " " + except: + pass + return wx.StaticText(self, -1, text, style=wx.ALIGN_LEFT) + + def MakeTextCtrl(self,text='', size=(100,-1)): + """Generic text control""" + return wx.TextCtrl(self,-1, text, size=size) + + def MakeButton(self,text, size=(75,25)): + """Generic button""" + return wx.Button(self, -1, text, + style=wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, + size=size) + + def OnBrowseGdal(self, event): + dlg = wx.FileDialog(self, "Choose a raster file:", os.getcwd(), "", "*.*", wx.OPEN) + path = "" + if dlg.ShowModal() == wx.ID_OK: + path = dlg.GetPath() + self.tgdal.SetValue(path) + dlg.Destroy() + + self.OnSetButton() + + def OnBrowseOGR(self, event): + dlg = wx.FileDialog(self, "Choose a data source name:", os.getcwd(), "", "*.*", wx.OPEN) + path = "" + if dlg.ShowModal() == wx.ID_OK: + path = dlg.GetPath() + self.tdsn.SetValue(path) + dlg.Destroy() + self.OnGetOGRLayers(None) + + def OnSetButton(self,event=None): + if self.tgdal.GetValue(): + self.__setGDAL() + if self.tdsn.GetValue() and self.llayers.GetSelection()>-1: + self.__setOGR() + elif self.cstate.GetSelection() > -1: + sys.stderr.write("##############"+str(self.cstate.GetSelection())+"\n") + self.OnItemSelected(None) + + def OnGetOGRLayers(self, event): + path = self.tdsn.GetValue() + line = "" + + sys.stderr.write(path+"####\n") + self.layers = [] + self.llayers.Clear() + cmd = os.popen("ogrinfo -so %s\n" % (path)) + line = cmd.readline() + # 1: cr (Polygon) + rex = re.compile("^(\d+):\s+(.+)\s+\(.*\)") + while 1: + if not line or line == "": + break + try: + sys.stderr.write("#####"+line+"####\n") + number, name = rex.findall(line)[0] + self.layers.append(name) + except: + pass + line = cmd.readline() + self.llayers.AppendItems(self.layers) + #sys.stderr.write(str( self.layers)+"\n") + #self.sizer.Remove(self.llayers) + #self.llayers = wx.ComboBox(self, -1, choices=self.layers, size=(100,-1), + # style=wx.CB_DROPDOWN) + #self.sizer.Add(self.llayers, 0, wx.ALIGN_CENTER_VERTICAL, row=12,col=3) + #self.sizer.ShowItems(True) + self.OnSetButton() + pass + + def __setOGR(self): + layer = self.layers[self.llayers.GetSelection()] + path = self.tdsn.GetValue() + number="-?\d+\.\d+" + line = "" + + #test values + self.ttop.SetValue(500) + self.tleft.SetValue(500) + + #Extent: (-146.976217, -55.985484) - (72.774632, 80.594358) + rex = re.compile("\((%s),\s*(%s)\)\s*-\s*\((%s),\s*(%s)\)" %(number, number, number, number)) + cmd = os.popen("ogrinfo -so %s %s" % (path ,layer)) + line = cmd.readline() + while 1: + if not line or line == "": + break + sys.stderr.write(line+"\n") + if line.find("Extent")>-1: + sys.stderr.write(line[0]+"#####\n") + x1,y1,x2,y2 = rex.findall(line)[0] + self.tbottom.SetValue(y1) + self.tleft.SetValue(x1) + self.ttop.SetValue(y2) + self.tright.SetValue(x2) + break + line = cmd.readline() + return + + def __setGDAL(self): + path = self.tgdal.GetValue() + line = "" + number="-?\d+\.\d+" + + #test values + self.ttop.SetValue(500) + self.tleft.SetValue(500) + + # Upper Left ( 0.0, 0.0) + rex=re.compile("\(\s*(%s)\s*,\s*(%s)\)" % (number, number)) + obj = os.popen("gdalinfo %s | grep \"Upper\|Lower\"" % path) + + line = obj.readline() + while 1: + sys.stderr.write(line+"\n") + if not line: + break + if line.find("Upper Left")>-1: + x,y = rex.findall(line)[0] + self.ttop.SetValue(y) + self.tleft.SetValue(x) + if line.find("Lower Right")>-1: + x,y = rex.findall(line)[0] + self.tbottom.SetValue(y) + self.tright.SetValue(x) + line = obj.readline() + return + + def OnStateText(self,event): + item = self.llayers.FindString(event.GetString()) + self.llayers.SetSelection(item) + self.llayers.SetValue(self.llayers.GetStringSelection()) + pass + #.log.WriteText('EvtTextEnter: %s' % event.GetString()) + #sys.stderr.write(event.GetString()+"\n") + #text=event.GetString().lower() + #for idx in range(len(self.states)): + # if self.states[idx].lower() == text: + # self.cstate.Select(idx) + # break + + def OnPageChange(self, event): + self.GetNext().FillVars() + self.GetNext().SetPrev(self) + + global north + north = self.ttop.GetValue() + global south + south = self.tbottom.GetValue() + global east + east = self.tright.GetValue() + global west + west = self.tleft.GetValue() + global resolution + resolution = self.tres.GetValue() + + def OnItemSelected(self, event): + item = self.cstate.GetSelection() + w,s,e,n = self.coords[item] + # 4 + # 1 3 + # 2 + + if self.parent.csystemspage.cs == "latlong": + pass + if self.parent.csystemspage.cs == "xy": + pass + else: + if self.parent.csystemspage.cs == "epsg": + to="+init=epsg:%d" % (int(self.parent.epsgpage.tcode.GetValue())) + elif self.parent.csystemspage.cs == "proj": + to="+proj=%s" % (self.parent.projpage.tproj.GetValue()) + elif self.parent.csystemspage.cs == "utm": + to="+proj=utm" + else: + sys.stderr.write(self.parent.csystemspage.cs+"\n") + + try: + sin, sout = os.popen2("cs2cs +proj=latlong +datum=WGS84 +to %s" % (to)) + sin.write("%s %s\n" % (w,s)) + sin.write("%s %s\n" % (e,n)) + sin.close() + w,s,t = sout.readline().split() + e,n,t = sout.readline().split() + self.lmessage.SetLabel("") + except: + n = s = w = e="NULL" + self.lmessage.SetLabel("Unable to calculate country extends:\n cs2cs +proj=latlong +datum=WGS84 +to %s"% to) + + self.ttop.SetValue( str(n) ) + self.tbottom.SetValue( str(s) ) + self.tright.SetValue( str(e) ) + self.tleft.SetValue( str(w) ) + + class StartUp(wx.App): def OnInit(self): wx.InitAllImageHandlers() From barton at grass.itc.it Wed Aug 1 18:01:24 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Wed Aug 1 18:01:26 2007 Subject: [grass-addons] r991 - trunk/grassaddons/gui Message-ID: <200708011601.l71G1OCk014952@grass.itc.it> Author: barton Date: 2007-08-01 18:01:12 +0200 (Wed, 01 Aug 2007) New Revision: 991 Modified: trunk/grassaddons/gui/gis_set.py Log: Basic layout for default region setting done. Note that I've deactivated functions that require external programs that do not come with GRASS and may not be present on all systems. Modified: trunk/grassaddons/gui/gis_set.py =================================================================== --- trunk/grassaddons/gui/gis_set.py 2007-08-01 06:34:12 UTC (rev 990) +++ trunk/grassaddons/gui/gis_set.py 2007-08-01 16:01:12 UTC (rev 991) @@ -250,7 +250,8 @@ self.lbmapsets.SetSelection(0) def OnRegion(self,event): - RegionDef(self) + defineRegion = RegionDef(self) + defineRegion.Show() def UpdateLocations(self,dbase): @@ -365,7 +366,7 @@ """ def __init__(self,parent,id=wx.ID_ANY, title="Set default region values"): - wx.Frame.__init__(self, parent, id, title, size=(300,300)) + wx.Frame.__init__(self, parent, id, title, size=(650,300)) self.parent = parent # inputs @@ -375,23 +376,24 @@ self.tright = self.MakeTextCtrl("1", size=(150, -1)) self.tres = self.MakeTextCtrl("1", size=(150, -1)) - self.tgdal = self.MakeTextCtrl("", size=(250, -1)) - self.tdsn = self.MakeTextCtrl("", size=(250, -1)) +# self.tgdal = self.MakeTextCtrl("", size=(250, -1)) +# self.tdsn = self.MakeTextCtrl("", size=(250, -1)) # list of layers self.layers = [] - self.llayers = wx.ComboBox(self, -1, - choices=self.layers, - size=(250,-1), - style=wx.CB_DROPDOWN) +# self.llayers = wx.ComboBox(self, -1, +# choices=self.layers, +# size=(250,-1), +# style=wx.CB_DROPDOWN) # labels self.lmessage = wx.StaticText(self,-1, "", size=(300,50)) # buttons - self.bbrowsegdal = self.MakeButton("Browse...", size=(150,-1)) - self.bbrowseogr = self.MakeButton("Browse...", size=(150,-1)) - self.bgetlayers = self.MakeButton("Get Layers", size=(150,-1)) +# self.bbrowsegdal = self.MakeButton("Browse...", size=(150,-1)) +# self.bbrowseogr = self.MakeButton("Browse...", size=(150,-1)) +# self.bgetlayers = self.MakeButton("Get Layers", size=(150,-1)) self.bset = self.MakeButton("Set coordinates", size=(150,-1)) + self.bcancel = self.MakeButton("Cancel", size=(150,-1)) # list of states self.states = [] @@ -415,10 +417,10 @@ # self.cstate = wx.combo.ComboCtrl(self, -1, pos=(50, 170), size=(150, -1), # style=wx.CB_READONLY) - self.cstate = wx.ComboBox(self, -1, - size=(250,-1), - choices=self.states, - style=wx.CB_DROPDOWN) +# self.cstate = wx.ComboBox(self, -1, +# size=(250,-1), +# choices=self.states, +# style=wx.CB_DROPDOWN) # layout self.sizer = rcs.RowColSizer() @@ -429,11 +431,12 @@ # tmpsizer.Add(self.sizer, wx.EXPAND) # # self.SetSizer(tmpsizer) - self.SetSizer(self.sizer) - self.SetAutoLayout(True) + self.sizer.Add(self.MakeLLabel("Region extents and resolution:"), 3, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 10, row=0,col=0, colspan=2) - self.sizer.Add(self.MakeRLabel("North"), 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | @@ -470,7 +473,7 @@ wx.ALIGN_CENTER_VERTICAL | wx.ALL, 0, row=5,col=2) - self.sizer.Add(self.MakeRLabel("Initial resolution"), 0, + self.sizer.Add(self.MakeRLabel("Resolution"), 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5, row=6,col=1) @@ -478,92 +481,103 @@ wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5, row=6,col=2) - self.sizer.Add(self.bset, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=6, col=3 ) self.sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 0, row=7, col=0, colspan=6) - self.sizer.Add(self.MakeRLabel("Match extents of georeferenced raster map or image"), 3, + self.sizer.Add(self.bset, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=8,col=0, colspan=3) + wx.ALL, 5, row=8, col=3 ) - self.sizer.Add(self.MakeRLabel("File:"), 0, - wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=9,col=0, colspan=1) - self.sizer.Add(self.tgdal, 0, + self.sizer.Add(self.bcancel, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=9,col=1, colspan=2) - self.sizer.Add(self.bbrowsegdal, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=9,col=3) + wx.ALL, 5, row=8, col=1 ) - self.sizer.Add(wx.StaticLine(self, -1), 0, - wx.EXPAND|wx.ALL, 0, - row=10, col=0, colspan=6) +# self.sizer.Add(self.MakeRLabel("Match extents of georeferenced raster map or image"), 3, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=8,col=0, colspan=3) +# +# self.sizer.Add(self.MakeRLabel("File:"), 0, +# wx.ALIGN_RIGHT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=9,col=0, colspan=1) +# self.sizer.Add(self.tgdal, 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=9,col=1, colspan=2) +# self.sizer.Add(self.bbrowsegdal, 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=9,col=3) +# +# self.sizer.Add(wx.StaticLine(self, -1), 0, +# wx.EXPAND|wx.ALL, 0, +# row=10, col=0, colspan=6) +# +# self.sizer.Add(self.MakeRLabel("Match extents of georeferenced vector map"), 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=11,col=0, colspan=3 ) +# +# self.sizer.Add(self.MakeRLabel("Data source/directory:"), 0, +# wx.ALIGN_RIGHT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=12,col=0, colspan=1) +# self.sizer.Add(self.tdsn, 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=12, col=1, colspan=2) +# self.sizer.Add(self.bbrowseogr, 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=12, col=3) +# +# self.sizer.Add(self.MakeRLabel("Layer/file:"), 0, +# wx.ALIGN_RIGHT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=13,col=0, colspan=1) +# self.sizer.Add(self.llayers, 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=13,col=1, colspan=2) +# self.sizer.Add(self.bgetlayers, 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=13,col=3) +# +# self.sizer.Add(wx.StaticLine(self, -1), 0, +# wx.EXPAND|wx.ALL | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, +# row=14, col=0, colspan=6) +# self.sizer.Add(self.MakeRLabel("Match extents of selected country"), 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=15,col=0, colspan=3) +# self.sizer.Add(self.cstate, 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, row=16,col=1, colspan=2) +# +# self.sizer.Add(self.lmessage, 0, +# wx.ALIGN_LEFT | +# wx.ALIGN_CENTER_VERTICAL | +# wx.ALL, 5, +# row=17,col=1, colspan=3) - self.sizer.Add(self.MakeRLabel("Match extents of georeferenced vector map"), 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=11,col=0, colspan=3 ) + self.SetSizer(self.sizer) + self.SetAutoLayout(True) + self.Layout() - self.sizer.Add(self.MakeRLabel("Data source/directory:"), 0, - wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=12,col=0, colspan=1) - self.sizer.Add(self.tdsn, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=12, col=1, colspan=2) - self.sizer.Add(self.bbrowseogr, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=12, col=3) - - self.sizer.Add(self.MakeRLabel("Layer/file:"), 0, - wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=13,col=0, colspan=1) - self.sizer.Add(self.llayers, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=13,col=1, colspan=2) - self.sizer.Add(self.bgetlayers, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=13,col=3) - - self.sizer.Add(wx.StaticLine(self, -1), 0, - wx.EXPAND|wx.ALL | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, - row=14, col=0, colspan=6) - self.sizer.Add(self.MakeRLabel("Match extents of selected country"), 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=15,col=0, colspan=3) - self.sizer.Add(self.cstate, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=16,col=1, colspan=2) - - self.sizer.Add(self.lmessage, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, - row=17,col=1, colspan=3) - - self.Bind(wx.EVT_COMBOBOX, self.OnItemSelected, self.cstate) - self.Bind(wx.EVT_TEXT, self.OnStateText, self.cstate) +# self.Bind(wx.EVT_COMBOBOX, self.OnItemSelected, self.cstate) +# self.Bind(wx.EVT_TEXT, self.OnStateText, self.cstate) self.Bind(wx.EVT_BUTTON, self.OnSetButton, self.bset) - self.Bind(wx.EVT_BUTTON, self.OnBrowseGdal, self.bbrowsegdal) - self.Bind(wx.EVT_BUTTON, self.OnBrowseOGR, self.bbrowseogr) - self.Bind(wx.EVT_BUTTON, self.OnGetOGRLayers, self.bgetlayers) + self.Bind(wx.EVT_BUTTON, self.OnCancel, self.bcancel) +# self.Bind(wx.EVT_BUTTON, self.OnBrowseGdal, self.bbrowsegdal) +# self.Bind(wx.EVT_BUTTON, self.OnBrowseOGR, self.bbrowseogr) +# self.Bind(wx.EVT_BUTTON, self.OnGetOGRLayers, self.bgetlayers) def MakeRLabel(self, text=""): """Make right-aligned label""" @@ -621,6 +635,9 @@ sys.stderr.write("##############"+str(self.cstate.GetSelection())+"\n") self.OnItemSelected(None) + def OnCancel(self, event): + self.Destroy() + def OnGetOGRLayers(self, event): path = self.tdsn.GetValue() line = "" From bundala at grass.itc.it Wed Aug 1 20:42:13 2007 From: bundala at grass.itc.it (bundala@grass.itc.it) Date: Wed Aug 1 20:42:16 2007 Subject: [grass-addons] r992 - trunk/grassaddons/v.generalize Message-ID: <200708011842.l71IgD9c019992@grass.itc.it> Author: bundala Date: 2007-08-01 20:42:10 +0200 (Wed, 01 Aug 2007) New Revision: 992 Modified: trunk/grassaddons/v.generalize/description.html trunk/grassaddons/v.generalize/main.c Log: Added and documented r flag-remove small areas and lines Modified: trunk/grassaddons/v.generalize/description.html =================================================================== --- trunk/grassaddons/v.generalize/description.html 2007-08-01 16:01:12 UTC (rev 991) +++ trunk/grassaddons/v.generalize/description.html 2007-08-01 18:42:10 UTC (rev 992) @@ -34,17 +34,12 @@
@@ -159,4 +154,4 @@
Wolf Bergenheim, Mentor
-
Last changed: $Date: 2007/13/07 23:58:37 $ +
Last changed: $Date: 2007/01/08 19:38:17 $ Modified: trunk/grassaddons/v.generalize/main.c =================================================================== --- trunk/grassaddons/v.generalize/main.c 2007-08-01 16:01:12 UTC (rev 991) +++ trunk/grassaddons/v.generalize/main.c 2007-08-01 18:42:10 UTC (rev 992) @@ -50,7 +50,7 @@ struct Option *field_opt, *where_opt, *reduction_opt, *slide_opt; struct Option *angle_thresh_opt, *degree_thresh_opt, *closeness_thresh_opt; struct Option *betweeness_thresh_opt; - struct Flag *ca_flag; + struct Flag *ca_flag, *rs_flag; int with_z; int total_input, total_output; /* Number of points in the input/output map respectively */ double thresh, alfa, beta, reduction, slide, angle_thresh; @@ -204,6 +204,10 @@ ca_flag->key = 'c'; ca_flag->description = _("Copy attributes"); + rs_flag = G_define_flag(); + rs_flag->key = 'r'; + rs_flag->description = _("Remove lines and areas smaller than threshold"); + /* options and flags parser */ if (G_parser(argc, argv)) exit(EXIT_FAILURE); @@ -400,7 +404,7 @@ /* remove "oversimplified" lines */ - if (simplification && type == GV_LINE && + if (rs_flag->answer && simplification && type == GV_LINE && Vect_line_length(Points) < thresh) continue; @@ -456,7 +460,7 @@ }; /* remove small areas */ - if (simplification && (mask_type & GV_AREA)) { + if (rs_flag->answer && simplification && (mask_type & GV_AREA)) { Vect_build_partial(&Out, GV_BUILD_CENTROIDS, NULL); Vect_remove_small_areas(&Out, thresh, NULL, NULL, &slide); }; From barton at grass.itc.it Thu Aug 2 08:43:18 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Thu Aug 2 08:43:21 2007 Subject: [grass-addons] r993 - trunk/grassaddons/gui Message-ID: <200708020643.l726hIoA027482@grass.itc.it> Author: barton Date: 2007-08-02 08:43:09 +0200 (Thu, 02 Aug 2007) New Revision: 993 Modified: trunk/grassaddons/gui/gis_set.py Log: Default region setting tool completed. Works for any location, new or old. Modified: trunk/grassaddons/gui/gis_set.py =================================================================== --- trunk/grassaddons/gui/gis_set.py 2007-08-01 18:42:10 UTC (rev 992) +++ trunk/grassaddons/gui/gis_set.py 2007-08-02 06:43:09 UTC (rev 993) @@ -7,6 +7,7 @@ import glob import shutil import wx.lib.rcsizer as rcs +import gui_modules.cmd as cmd def read_grassrc(): """ @@ -167,7 +168,7 @@ mapset_sizer.Add(self.tnewmapset, 0, label_style|wx.BOTTOM, 5) mapset_sizer.Add(self.bmapset, 0, label_style|wx.BOTTOM, 10) mapset_sizer.Add(self.ldefine, 0, label_style|wx.RIGHT|wx.LEFT, 5) - mapset_sizer.Add(self.bwizard, 0, label_style|wx.TOP, 5) + mapset_sizer.Add(self.bwizard, 0, label_style|wx.TOP|wx.BOTTOM, 5) mapset_sizer.Add(self.lregion, 0, label_style|wx.TOP|wx.RIGHT|wx.LEFT, 5) mapset_sizer.Add(self.bregion, 0, label_style|wx.TOP, 5) mapset_sizer.Add((5,0)) @@ -250,7 +251,7 @@ self.lbmapsets.SetSelection(0) def OnRegion(self,event): - defineRegion = RegionDef(self) + defineRegion = RegionDef(self, location=self.listOfLocations[self.lblocations.GetSelection()]) defineRegion.Show() def UpdateLocations(self,dbase): @@ -365,10 +366,12 @@ Page for setting default region extents and resolution """ - def __init__(self,parent,id=wx.ID_ANY, title="Set default region values"): + def __init__(self,parent,id=wx.ID_ANY, title="Set default region values", location=None): wx.Frame.__init__(self, parent, id, title, size=(650,300)) self.parent = parent + self.location = location + # inputs self.ttop = self.MakeTextCtrl("1", size=(150, -1)) self.tbottom = self.MakeTextCtrl("0", size=(150, -1)) @@ -376,61 +379,69 @@ self.tright = self.MakeTextCtrl("1", size=(150, -1)) self.tres = self.MakeTextCtrl("1", size=(150, -1)) -# self.tgdal = self.MakeTextCtrl("", size=(250, -1)) -# self.tdsn = self.MakeTextCtrl("", size=(250, -1)) - # list of layers - self.layers = [] -# self.llayers = wx.ComboBox(self, -1, -# choices=self.layers, -# size=(250,-1), -# style=wx.CB_DROPDOWN) + self.north = 1.0 + self.south = 0.0 + self.east = 1.0 + self.west = 0.0 + self.res = 1.0 # labels self.lmessage = wx.StaticText(self,-1, "", size=(300,50)) # buttons -# self.bbrowsegdal = self.MakeButton("Browse...", size=(150,-1)) -# self.bbrowseogr = self.MakeButton("Browse...", size=(150,-1)) -# self.bgetlayers = self.MakeButton("Get Layers", size=(150,-1)) self.bset = self.MakeButton("Set coordinates", size=(150,-1)) self.bcancel = self.MakeButton("Cancel", size=(150,-1)) - # list of states - self.states = [] - self.coords = [] - try: - f = open(os.path.join(os.getenv("GISBASE"),"etc","wx","states.txt"),"r") - for line in f.readlines(): - if line[0] == "#": - continue - state,coord = line.split(";") - coord = coord.replace(","," ") - self.states.append(state) - self.coords.append(coord.split()) - f.close() - except: - pass - # NOTE: ComboCtcl should come here, but nobody knows, how to - # implement it - # self.stateslist = wx.ListCtrl(self, - # style=wx.LC_LIST|wx.LC_SINGLE_SEL|wx.SIMPLE_BORDER) - # self.cstate = wx.combo.ComboCtrl(self, -1, pos=(50, 170), size=(150, -1), - # style=wx.CB_READONLY) + #Set current working environment to PERMANENT mapset in selected location in order to set default region (WIND) + envval = {} + cmdlist = ['g.gisenv'] + p = cmd.Command(cmdlist) + if p.returncode == 0: + output = p.module_stdout.read().strip("'").split(';\n') + for line in output: + line = line.strip() + if '=' in line: key,val = line.split('=') + envval[key] = val + self.currlocation = envval['LOCATION_NAME'].strip("';") + self.currmapset = envval['MAPSET'].strip("';") + if self.currlocation == self.location and self.currmapset == 'PERMANENT': + pass + else: + cmdlist = ['g.mapset', 'location=%s' % self.location, 'mapset=PERMANENT'] + cmd.Command(cmdlist) + else: + wx.MessageBox('A valid location must be selected') + return -# self.cstate = wx.ComboBox(self, -1, -# size=(250,-1), -# choices=self.states, -# style=wx.CB_DROPDOWN) + #Get current region settings + region = {} + cmdlist = ['g.region', '-gp'] + p = cmd.Command(cmdlist) + if p.returncode == 0: + output = p.module_stdout.read().split('\n') + for line in output: + line = line.strip() + if '=' in line: key,val = line.split('=') + region[key] = float(val) + else: + wx.MessageBox('Invalid region') + return + self.north = region['n'] + self.south = region['s'] + self.east = region['e'] + self.west = region['w'] + self.res = region['ewres'] + + # Insert current region settings into text controls + self.ttop.SetValue(str(self.north)) + self.tbottom.SetValue(str(self.south)) + self.tleft.SetValue(str(self.west)) + self.tright.SetValue(str(self.east)) + self.tres.SetValue(str(self.res)) + # layout self.sizer = rcs.RowColSizer() -# tmpsizer = wx.BoxSizer(wx.VERTICAL) -# -# tmpsizer.Add(self.title, 0, wx.ALIGN_CENTRE|wx.ALL, 5) -# tmpsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 0) -# tmpsizer.Add(self.sizer, wx.EXPAND) -# -# self.SetSizer(tmpsizer) self.sizer.Add(self.MakeLLabel("Region extents and resolution:"), 3, wx.ALIGN_RIGHT | @@ -494,90 +505,18 @@ wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5, row=8, col=1 ) -# self.sizer.Add(self.MakeRLabel("Match extents of georeferenced raster map or image"), 3, -# wx.ALIGN_LEFT | -# wx.ALIGN_CENTER_VERTICAL | -# wx.ALL, 5, row=8,col=0, colspan=3) -# -# self.sizer.Add(self.MakeRLabel("File:"), 0, -# wx.ALIGN_RIGHT | -# wx.ALIGN_CENTER_VERTICAL | -# wx.ALL, 5, row=9,col=0, colspan=1) -# self.sizer.Add(self.tgdal, 0, -# wx.ALIGN_LEFT | -# wx.ALIGN_CENTER_VERTICAL | -# wx.ALL, 5, row=9,col=1, colspan=2) -# self.sizer.Add(self.bbrowsegdal, 0, -# wx.ALIGN_LEFT | -# wx.ALIGN_CENTER_VERTICAL | -# wx.ALL, 5, row=9,col=3) -# -# self.sizer.Add(wx.StaticLine(self, -1), 0, -# wx.EXPAND|wx.ALL, 0, -# row=10, col=0, colspan=6) -# -# self.sizer.Add(self.MakeRLabel("Match extents of georeferenced vector map"), 0, -# wx.ALIGN_LEFT | -# wx.ALIGN_CENTER_VERTICAL | -# wx.ALL, 5, row=11,col=0, colspan=3 ) -# -# self.sizer.Add(self.MakeRLabel("Data source/directory:"), 0, -# wx.ALIGN_RIGHT | -# wx.ALIGN_CENTER_VERTICAL | -# wx.ALL, 5, row=12,col=0, colspan=1) -# self.sizer.Add(self.tdsn, 0, -# wx.ALIGN_LEFT | -# wx.ALIGN_CENTER_VERTICAL | -# wx.ALL, 5, row=12, col=1, colspan=2) -# self.sizer.Add(self.bbrowseogr, 0, -# wx.ALIGN_LEFT | -# wx.ALIGN_CENTER_VERTICAL | -# wx.ALL, 5, row=12, col=3) -# -# self.sizer.Add(self.MakeRLabel("Layer/file:"), 0, -# wx.ALIGN_RIGHT | -# wx.ALIGN_CENTER_VERTICAL | -# wx.ALL, 5, row=13,col=0, colspan=1) -# self.sizer.Add(self.llayers, 0, -# wx.ALIGN_LEFT | -# wx.ALIGN_CENTER_VERTICAL | -# wx.ALL, 5, row=13,col=1, colspan=2) -# self.sizer.Add(self.bgetlayers, 0, -# wx.ALIGN_LEFT | -# wx.ALIGN_CENTER_VERTICAL | -# wx.ALL, 5, row=13,col=3) -# -# self.sizer.Add(wx.StaticLine(self, -1), 0, -# wx.EXPAND|wx.ALL | -# wx.ALIGN_CENTER_VERTICAL | -# wx.ALL, 5, -# row=14, col=0, colspan=6) -# self.sizer.Add(self.MakeRLabel("Match extents of selected country"), 0, -# wx.ALIGN_LEFT | -# wx.ALIGN_CENTER_VERTICAL | -# wx.ALL, 5, row=15,col=0, colspan=3) -# self.sizer.Add(self.cstate, 0, -# wx.ALIGN_LEFT | -# wx.ALIGN_CENTER_VERTICAL | -# wx.ALL, 5, row=16,col=1, colspan=2) -# -# self.sizer.Add(self.lmessage, 0, -# wx.ALIGN_LEFT | -# wx.ALIGN_CENTER_VERTICAL | -# wx.ALL, 5, -# row=17,col=1, colspan=3) self.SetSizer(self.sizer) self.SetAutoLayout(True) self.Layout() -# self.Bind(wx.EVT_COMBOBOX, self.OnItemSelected, self.cstate) -# self.Bind(wx.EVT_TEXT, self.OnStateText, self.cstate) self.Bind(wx.EVT_BUTTON, self.OnSetButton, self.bset) self.Bind(wx.EVT_BUTTON, self.OnCancel, self.bcancel) -# self.Bind(wx.EVT_BUTTON, self.OnBrowseGdal, self.bbrowsegdal) -# self.Bind(wx.EVT_BUTTON, self.OnBrowseOGR, self.bbrowseogr) -# self.Bind(wx.EVT_BUTTON, self.OnGetOGRLayers, self.bgetlayers) + self.Bind(wx.EVT_TEXT, self.OnNorth, self.ttop) + self.Bind(wx.EVT_TEXT, self.OnSouth, self.tbottom) + self.Bind(wx.EVT_TEXT, self.OnEast, self.tright) + self.Bind(wx.EVT_TEXT, self.OnWest, self.tleft) + self.Bind(wx.EVT_TEXT, self.OnRes, self.tres) def MakeRLabel(self, text=""): """Make right-aligned label""" @@ -607,193 +546,36 @@ style=wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, size=size) - def OnBrowseGdal(self, event): - dlg = wx.FileDialog(self, "Choose a raster file:", os.getcwd(), "", "*.*", wx.OPEN) - path = "" - if dlg.ShowModal() == wx.ID_OK: - path = dlg.GetPath() - self.tgdal.SetValue(path) - dlg.Destroy() + def OnNorth(self,event): + self.north = event.GetString() - self.OnSetButton() + def OnSouth(self, event): + self.south = event.GetString() - def OnBrowseOGR(self, event): - dlg = wx.FileDialog(self, "Choose a data source name:", os.getcwd(), "", "*.*", wx.OPEN) - path = "" - if dlg.ShowModal() == wx.ID_OK: - path = dlg.GetPath() - self.tdsn.SetValue(path) - dlg.Destroy() - self.OnGetOGRLayers(None) + def OnEast(self,event): + self.east = event.GetString() + def OnWest(self,event): + self.west = event.GetString() + + def OnRes(self,event): + self.res = event.GetString() + def OnSetButton(self,event=None): - if self.tgdal.GetValue(): - self.__setGDAL() - if self.tdsn.GetValue() and self.llayers.GetSelection()>-1: - self.__setOGR() - elif self.cstate.GetSelection() > -1: - sys.stderr.write("##############"+str(self.cstate.GetSelection())+"\n") - self.OnItemSelected(None) + cmdlist = ['g.region', '-sgpa', 'n=%s' % self.north, 's=%s' % self.south, \ + 'e=%s' % self.east, 'w=%s' % self.west, 'res=%s' % self.res] + p = cmd.Command(cmdlist) + if p.returncode == 0: + output = p.module_stdout.read() + wx.MessageBox('New default region:\n%s' % output) + else: + wx.MessageBox('Setting default region failed\n%s %s' % \ + (p.module_stderr.read(),p.module_stdout.read())) + self.Destroy() def OnCancel(self, event): self.Destroy() - def OnGetOGRLayers(self, event): - path = self.tdsn.GetValue() - line = "" - - sys.stderr.write(path+"####\n") - self.layers = [] - self.llayers.Clear() - cmd = os.popen("ogrinfo -so %s\n" % (path)) - line = cmd.readline() - # 1: cr (Polygon) - rex = re.compile("^(\d+):\s+(.+)\s+\(.*\)") - while 1: - if not line or line == "": - break - try: - sys.stderr.write("#####"+line+"####\n") - number, name = rex.findall(line)[0] - self.layers.append(name) - except: - pass - line = cmd.readline() - self.llayers.AppendItems(self.layers) - #sys.stderr.write(str( self.layers)+"\n") - #self.sizer.Remove(self.llayers) - #self.llayers = wx.ComboBox(self, -1, choices=self.layers, size=(100,-1), - # style=wx.CB_DROPDOWN) - #self.sizer.Add(self.llayers, 0, wx.ALIGN_CENTER_VERTICAL, row=12,col=3) - #self.sizer.ShowItems(True) - self.OnSetButton() - pass - - def __setOGR(self): - layer = self.layers[self.llayers.GetSelection()] - path = self.tdsn.GetValue() - number="-?\d+\.\d+" - line = "" - - #test values - self.ttop.SetValue(500) - self.tleft.SetValue(500) - - #Extent: (-146.976217, -55.985484) - (72.774632, 80.594358) - rex = re.compile("\((%s),\s*(%s)\)\s*-\s*\((%s),\s*(%s)\)" %(number, number, number, number)) - cmd = os.popen("ogrinfo -so %s %s" % (path ,layer)) - line = cmd.readline() - while 1: - if not line or line == "": - break - sys.stderr.write(line+"\n") - if line.find("Extent")>-1: - sys.stderr.write(line[0]+"#####\n") - x1,y1,x2,y2 = rex.findall(line)[0] - self.tbottom.SetValue(y1) - self.tleft.SetValue(x1) - self.ttop.SetValue(y2) - self.tright.SetValue(x2) - break - line = cmd.readline() - return - - def __setGDAL(self): - path = self.tgdal.GetValue() - line = "" - number="-?\d+\.\d+" - - #test values - self.ttop.SetValue(500) - self.tleft.SetValue(500) - - # Upper Left ( 0.0, 0.0) - rex=re.compile("\(\s*(%s)\s*,\s*(%s)\)" % (number, number)) - obj = os.popen("gdalinfo %s | grep \"Upper\|Lower\"" % path) - - line = obj.readline() - while 1: - sys.stderr.write(line+"\n") - if not line: - break - if line.find("Upper Left")>-1: - x,y = rex.findall(line)[0] - self.ttop.SetValue(y) - self.tleft.SetValue(x) - if line.find("Lower Right")>-1: - x,y = rex.findall(line)[0] - self.tbottom.SetValue(y) - self.tright.SetValue(x) - line = obj.readline() - return - - def OnStateText(self,event): - item = self.llayers.FindString(event.GetString()) - self.llayers.SetSelection(item) - self.llayers.SetValue(self.llayers.GetStringSelection()) - pass - #.log.WriteText('EvtTextEnter: %s' % event.GetString()) - #sys.stderr.write(event.GetString()+"\n") - #text=event.GetString().lower() - #for idx in range(len(self.states)): - # if self.states[idx].lower() == text: - # self.cstate.Select(idx) - # break - - def OnPageChange(self, event): - self.GetNext().FillVars() - self.GetNext().SetPrev(self) - - global north - north = self.ttop.GetValue() - global south - south = self.tbottom.GetValue() - global east - east = self.tright.GetValue() - global west - west = self.tleft.GetValue() - global resolution - resolution = self.tres.GetValue() - - def OnItemSelected(self, event): - item = self.cstate.GetSelection() - w,s,e,n = self.coords[item] - # 4 - # 1 3 - # 2 - - if self.parent.csystemspage.cs == "latlong": - pass - if self.parent.csystemspage.cs == "xy": - pass - else: - if self.parent.csystemspage.cs == "epsg": - to="+init=epsg:%d" % (int(self.parent.epsgpage.tcode.GetValue())) - elif self.parent.csystemspage.cs == "proj": - to="+proj=%s" % (self.parent.projpage.tproj.GetValue()) - elif self.parent.csystemspage.cs == "utm": - to="+proj=utm" - else: - sys.stderr.write(self.parent.csystemspage.cs+"\n") - - try: - sin, sout = os.popen2("cs2cs +proj=latlong +datum=WGS84 +to %s" % (to)) - sin.write("%s %s\n" % (w,s)) - sin.write("%s %s\n" % (e,n)) - sin.close() - w,s,t = sout.readline().split() - e,n,t = sout.readline().split() - self.lmessage.SetLabel("") - except: - n = s = w = e="NULL" - self.lmessage.SetLabel("Unable to calculate country extends:\n cs2cs +proj=latlong +datum=WGS84 +to %s"% to) - - self.ttop.SetValue( str(n) ) - self.tbottom.SetValue( str(s) ) - self.tright.SetValue( str(e) ) - self.tleft.SetValue( str(w) ) - - class StartUp(wx.App): def OnInit(self): wx.InitAllImageHandlers() From barton at grass.itc.it Thu Aug 2 09:11:52 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Thu Aug 2 09:11:53 2007 Subject: [grass-addons] r994 - trunk/grassaddons/gui Message-ID: <200708020711.l727Bqeh027573@grass.itc.it> Author: barton Date: 2007-08-02 09:11:44 +0200 (Thu, 02 Aug 2007) New Revision: 994 Modified: trunk/grassaddons/gui/location_wizard.py Log: Code cleanup. TODO: fix summary page so that it shows selected values and finish code for XY location. Modified: trunk/grassaddons/gui/location_wizard.py =================================================================== --- trunk/grassaddons/gui/location_wizard.py 2007-08-02 06:43:09 UTC (rev 993) +++ trunk/grassaddons/gui/location_wizard.py 2007-08-02 07:11:44 UTC (rev 994) @@ -13,7 +13,6 @@ * EPSGPage * CustomPage * SummaryPage - * BBoxPage * GWizard PURPOSE: Create a new GRASS location. User can choose from multiple methods @@ -241,9 +240,7 @@ event.Veto() # if coordsys == "xy": -# self.parent.bboxpage.cstate.Enable(False) -# else: -# self.parent.bboxpage.cstate.Enable(True) +# pass def SetVal(self,event): global coordsys @@ -251,7 +248,6 @@ coordsys = "proj" self.SetNext(self.parent.projpage) self.parent.datumpage.SetPrev(self.parent.projpage) - self.parent.bboxpage.SetPrev(self.parent.datumpage) elif event.GetId() == self.radio2.GetId(): coordsys = "epsg" self.SetNext(self.parent.epsgpage) @@ -266,10 +262,8 @@ self.parent.sumpage.SetPrev(self.parent.custompage) elif event.GetId() == self.radio5.GetId(): coordsys = "xy" - self.SetNext(self.parent.bboxpage) - self.parent.bboxpage.cstate.Enable(False) + self.SetNext(self.parent.sumpage) - class ProjectionsPage(TitledPage): """ Wizard page for selecting projection (select coordinate system option) @@ -1076,77 +1070,14 @@ self.parent = parent - self.sizer.Add(self.MakeRLabel("GRASS database:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=1, col=0) - self.sizer.Add(self.MakeRLabel("Location name:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=2, col=0) - self.sizer.Add(wx.StaticLine(self, -1), 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL, 0, row=3, col=0, colspan=2) - self.sizer.Add((10,10), 1, flag=wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, border=5, row=4, col=0) - self.sizer.Add(self.MakeRLabel("Projection:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=5, col=0) - self.sizer.Add(self.MakeRLabel("North:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=6, col=0) - self.sizer.Add(self.MakeRLabel("South:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=7, col=0) - self.sizer.Add(self.MakeRLabel("East:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=8, col=0) - self.sizer.Add(self.MakeRLabel("West:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=9, col=0) - self.sizer.Add(self.MakeRLabel("Resolution:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=10, col=0) - self.sizer.Add(self.MakeRLabel("Rows:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=12, col=0) - self.sizer.Add(self.MakeRLabel("Columns:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=13, col=0) - self.sizer.Add(self.MakeRLabel("Cells:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=14, col=0) - self.sizer.Add(self.MakeRLabel("PROJ.4 string:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=16, col=0) - - # labels - self.ldatabase = self.MakeLLabel("") - self.llocation = self.MakeLLabel("") - self.lprojection = self.MakeLLabel("") - self.lnorth = self.MakeLLabel("") - self.lsouth = self.MakeLLabel("") - self.least = self.MakeLLabel("") - self.lwest = self.MakeLLabel("") - self.lres = self.MakeLLabel("") - self.lrows = self.MakeLLabel("") - self.lcols = self.MakeLLabel("") - self.lcells = self.MakeLLabel("") - self.lproj4 = self.MakeLLabel("") - - self.sizer.Add(self.ldatabase, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=1, col=1) - self.sizer.Add(self.llocation, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=2, col=1) - self.sizer.Add(self.lprojection, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=5, col=1) - self.sizer.Add(self.lnorth, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=6, col=1) - self.sizer.Add(self.lsouth, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=7, col=1) - self.sizer.Add(self.least, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=8, col=1) - self.sizer.Add(self.lwest, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=9, col=1) - self.sizer.Add(self.lres, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=10, col=1) - self.sizer.Add(self.lrows, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=12, col=1) - self.sizer.Add(self.lcols, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=13, col=1) - self.sizer.Add(self.lcells, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=14, col=1) - self.sizer.Add(self.lproj4, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=16, col=1) - - def FillVars(self,event=None): database = self.parent.startpage.grassdatabase location = self.parent.startpage.location + global coordsys - global north - global south - global east - global west - global resolution - global proj4string if not coordsys: coordsys = 0 - if not north: - north = 0 - if not south: - south = 0 - if not east: - east = 0 - if not west: - west = 0 - if not resolution: - resolution = 1 - #if projection != "latlong": - rows = int(round((float(north)-float(south))/float(resolution))) - cols = int(round((float(east)-float(west))/float(resolution))) - cells = int(rows*cols) - projection = self.parent.projpage.proj projdesc = self.parent.projpage.projdesc utmzone = self.parent.projtypepage.utmzone @@ -1161,416 +1092,48 @@ transregion = self.parent.datumpage.transregion transparams = self.parent.datumpage.transparams + # labels + self.ldatabase = self.MakeLLabel("") + self.llocation = self.MakeLLabel("") + self.lprojection = self.MakeLLabel("") + self.ldatabase.SetLabel(str(database)) self.llocation.SetLabel(str(location)) label = '' if coordsys == 'epsg': - label = 'EPSG code %s: %s' % (self.parent.epsgpage.epsgcode,self.parent.epsgpage.epsgdesc) + label = 'EPSG code %s (%s)' % (self.parent.epsgpage.epsgcode,self.parent.epsgpage.epsgdesc) self.lprojection.SetLabel(label) elif coordsys == 'file': - label = 'Matches file: %s' % self.parent.filepage.georeffile + label = 'matches file %s' % self.parent.filepage.georeffile self.lprojection.SetLabel(label) elif coordsys == 'proj': - label = ('Projection: %s, %s%s' % (projdesc, datumdesc, ellipsedesc)) + label = ('%s, %s%s' % (projdesc, datumdesc, ellipsedesc)) self.lprojection.SetLabel(label) elif coordsys == 'xy': label = ('XY coordinate system. Not projected') self.lprojection.SetLabel(label) elif coordsys == 'custom': - label = ('Custom PROJ.4 string') - self.lprojection.Wrap(500) + label = ('%s' % self.custompage.proj4string) + self.lprojection.SetLabel(label) - self.lnorth.SetLabel(str(north)) - self.lsouth.SetLabel(str(south)) - self.least.SetLabel(str(east)) - self.lwest.SetLabel(str(west)) - self.lres.SetLabel(str(resolution)) - self.lrows.SetLabel(str(rows)) - self.lcols.SetLabel(str(cols)) - self.lcells.SetLabel(str(cells)) - self.lproj4.SetLabel(proj4string) + wx.MessageBox('label=%s' % label) + self.lprojection.Wrap(500) -class BBoxPage(TitledPage): - """ - Wizard page for setting default region extents and resolution - """ + self.sizer.Add(self.MakeRLabel("GRASS database:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=1, col=0) + self.sizer.Add(self.ldatabase, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=1, col=1) + self.sizer.Add(self.MakeRLabel("Location name:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=2, col=0) + self.sizer.Add(self.llocation, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=2, col=1) + self.sizer.Add(wx.StaticLine(self, -1), 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL, 0, row=3, col=0, colspan=2) + self.sizer.Add((10,10), 1, flag=wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, border=5, row=4, col=0) + self.sizer.Add(self.MakeRLabel("Projection: "), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=5, col=0) + self.sizer.Add(self.lprojection, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=5, col=1) + self.sizer.Add((10,20), 1, flag=wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, border=5, row=6, col=0) + self.sizer.Add(self.MakeLLabel("You can set the default extents and resolution after creating a new location"), \ + 1, flag=wx.ALIGN_CENTRE|wx.ALL, border=5, row=7, col=0, colspan=2) - def __init__(self, wizard, parent): - TitledPage.__init__(self, wizard, "Set default region extents and resolution") - self.parent = parent - # inputs - self.ttop = self.MakeTextCtrl("1", size=(150, -1)) - self.tbottom = self.MakeTextCtrl("0", size=(150, -1)) - self.tleft = self.MakeTextCtrl("0", size=(150, -1)) - self.tright = self.MakeTextCtrl("1", size=(150, -1)) - self.tres = self.MakeTextCtrl("1", size=(150, -1)) - - self.tgdal = self.MakeTextCtrl("", size=(250, -1)) - self.tdsn = self.MakeTextCtrl("", size=(250, -1)) - # list of layers - self.layers = [] - self.llayers = wx.ComboBox(self, -1, - choices=self.layers, - size=(250,-1), - style=wx.CB_DROPDOWN) - - # labels - self.lmessage = wx.StaticText(self,-1, "", size=(300,50)) - - # buttons - self.bbrowsegdal = self.MakeButton("Browse...", size=(150,-1)) - self.bbrowseogr = self.MakeButton("Browse...", size=(150,-1)) - self.bgetlayers = self.MakeButton("Get Layers", size=(150,-1)) - self.bset = self.MakeButton("Set coordinates", size=(150,-1)) - - # list of states - self.states = [] - self.coords = [] - try: - f = open(os.path.join(os.getenv("GISBASE"),"etc","wx","states.txt"),"r") - for line in f.readlines(): - if line[0] == "#": - continue - state,coord = line.split(";") - coord = coord.replace(","," ") - self.states.append(state) - self.coords.append(coord.split()) - f.close() - except: - pass - # NOTE: ComboCtcl should come here, but nobody knows, how to - # implement it - # self.stateslist = wx.ListCtrl(self, - # style=wx.LC_LIST|wx.LC_SINGLE_SEL|wx.SIMPLE_BORDER) - # self.cstate = wx.combo.ComboCtrl(self, -1, pos=(50, 170), size=(150, -1), - # style=wx.CB_READONLY) - - self.cstate = wx.ComboBox(self, -1, - size=(250,-1), - choices=self.states, - style=wx.CB_DROPDOWN) - - # layout - self.sizer.Add(self.MakeRLabel("North"), 0, - wx.ALIGN_CENTER_HORIZONTAL | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 0, row=1,col=2) - self.sizer.Add(self.ttop, 0, - wx.ALIGN_CENTER_HORIZONTAL | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=2,col=2) - - self.sizer.Add(self.MakeRLabel("West"), 0, - wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 0, row=3,col=0) - self.sizer.Add(self.tleft, 0, - wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=3,col=1) - - self.sizer.Add(self.tright, 0, - wx.ALIGN_CENTER_HORIZONTAL | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=3,col=3) - self.sizer.Add(self.MakeRLabel("East"), 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 0, row=3,col=4) - - self.sizer.Add(self.tbottom, 0, - wx.ALIGN_CENTER_HORIZONTAL | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=4,col=2) - self.sizer.Add(self.MakeRLabel("South"), 0, - wx.ALIGN_CENTER_HORIZONTAL | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 0, row=5,col=2) - - self.sizer.Add(self.MakeRLabel("Initial resolution"), 0, - wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=6,col=1) - self.sizer.Add(self.tres, 0, - wx.ALIGN_CENTER_HORIZONTAL | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=6,col=2) - self.sizer.Add(self.bset, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=6, col=3 ) - - self.sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 0, row=7, col=0, colspan=6) - - self.sizer.Add(self.MakeRLabel("Match extents of georeferenced raster map or image"), 3, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=8,col=0, colspan=3) - - self.sizer.Add(self.MakeRLabel("File:"), 0, - wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=9,col=0, colspan=1) - self.sizer.Add(self.tgdal, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=9,col=1, colspan=2) - self.sizer.Add(self.bbrowsegdal, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=9,col=3) - - self.sizer.Add(wx.StaticLine(self, -1), 0, - wx.EXPAND|wx.ALL, 0, - row=10, col=0, colspan=6) - - self.sizer.Add(self.MakeRLabel("Match extents of georeferenced vector map"), 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=11,col=0, colspan=3 ) - - self.sizer.Add(self.MakeRLabel("Data source/directory:"), 0, - wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=12,col=0, colspan=1) - self.sizer.Add(self.tdsn, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=12, col=1, colspan=2) - self.sizer.Add(self.bbrowseogr, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=12, col=3) - - self.sizer.Add(self.MakeRLabel("Layer/file:"), 0, - wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=13,col=0, colspan=1) - self.sizer.Add(self.llayers, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=13,col=1, colspan=2) - self.sizer.Add(self.bgetlayers, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=13,col=3) - - self.sizer.Add(wx.StaticLine(self, -1), 0, - wx.EXPAND|wx.ALL | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, - row=14, col=0, colspan=6) - self.sizer.Add(self.MakeRLabel("Match extents of selected country"), 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=15,col=0, colspan=3) - self.sizer.Add(self.cstate, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=16,col=1, colspan=2) - - self.sizer.Add(self.lmessage, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, - row=17,col=1, colspan=3) - - self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnPageChange) - self.Bind(wx.EVT_COMBOBOX, self.OnItemSelected, self.cstate) - self.Bind(wx.EVT_TEXT, self.OnStateText, self.cstate) - self.Bind(wx.EVT_BUTTON, self.OnSetButton, self.bset) - self.Bind(wx.EVT_BUTTON, self.OnBrowseGdal, self.bbrowsegdal) - self.Bind(wx.EVT_BUTTON, self.OnBrowseOGR, self.bbrowseogr) - self.Bind(wx.EVT_BUTTON, self.OnGetOGRLayers, self.bgetlayers) - - def OnBrowseGdal(self, event): - dlg = wx.FileDialog(self, "Choose a raster file:", os.getcwd(), "", "*.*", wx.OPEN) - path = "" - if dlg.ShowModal() == wx.ID_OK: - path = dlg.GetPath() - self.tgdal.SetValue(path) - dlg.Destroy() - - self.OnSetButton() - - def OnBrowseOGR(self, event): - dlg = wx.FileDialog(self, "Choose a data source name:", os.getcwd(), "", "*.*", wx.OPEN) - path = "" - if dlg.ShowModal() == wx.ID_OK: - path = dlg.GetPath() - self.tdsn.SetValue(path) - dlg.Destroy() - self.OnGetOGRLayers(None) - - def OnSetButton(self,event=None): - if self.tgdal.GetValue(): - self.__setGDAL() - if self.tdsn.GetValue() and self.llayers.GetSelection()>-1: - self.__setOGR() - elif self.cstate.GetSelection() > -1: - sys.stderr.write("##############"+str(self.cstate.GetSelection())+"\n") - self.OnItemSelected(None) - - def OnGetOGRLayers(self, event): - path = self.tdsn.GetValue() - line = "" - - sys.stderr.write(path+"####\n") - self.layers = [] - self.llayers.Clear() - cmd = os.popen("ogrinfo -so %s\n" % (path)) - line = cmd.readline() - # 1: cr (Polygon) - rex = re.compile("^(\d+):\s+(.+)\s+\(.*\)") - while 1: - if not line or line == "": - break - try: - sys.stderr.write("#####"+line+"####\n") - number, name = rex.findall(line)[0] - self.layers.append(name) - except: - pass - line = cmd.readline() - self.llayers.AppendItems(self.layers) - #sys.stderr.write(str( self.layers)+"\n") - #self.sizer.Remove(self.llayers) - #self.llayers = wx.ComboBox(self, -1, choices=self.layers, size=(100,-1), - # style=wx.CB_DROPDOWN) - #self.sizer.Add(self.llayers, 0, wx.ALIGN_CENTER_VERTICAL, row=12,col=3) - #self.sizer.ShowItems(True) - self.OnSetButton() - pass - - def __setOGR(self): - layer = self.layers[self.llayers.GetSelection()] - path = self.tdsn.GetValue() - number="-?\d+\.\d+" - line = "" - - #test values - self.ttop.SetValue(500) - self.tleft.SetValue(500) - - #Extent: (-146.976217, -55.985484) - (72.774632, 80.594358) - rex = re.compile("\((%s),\s*(%s)\)\s*-\s*\((%s),\s*(%s)\)" %(number, number, number, number)) - cmd = os.popen("ogrinfo -so %s %s" % (path ,layer)) - line = cmd.readline() - while 1: - if not line or line == "": - break - sys.stderr.write(line+"\n") - if line.find("Extent")>-1: - sys.stderr.write(line[0]+"#####\n") - x1,y1,x2,y2 = rex.findall(line)[0] - self.tbottom.SetValue(y1) - self.tleft.SetValue(x1) - self.ttop.SetValue(y2) - self.tright.SetValue(x2) - break - line = cmd.readline() - return - - def __setGDAL(self): - path = self.tgdal.GetValue() - line = "" - number="-?\d+\.\d+" - - #test values - self.ttop.SetValue(500) - self.tleft.SetValue(500) - - # Upper Left ( 0.0, 0.0) - rex=re.compile("\(\s*(%s)\s*,\s*(%s)\)" % (number, number)) - obj = os.popen("gdalinfo %s | grep \"Upper\|Lower\"" % path) - - line = obj.readline() - while 1: - sys.stderr.write(line+"\n") - if not line: - break - if line.find("Upper Left")>-1: - x,y = rex.findall(line)[0] - self.ttop.SetValue(y) - self.tleft.SetValue(x) - if line.find("Lower Right")>-1: - x,y = rex.findall(line)[0] - self.tbottom.SetValue(y) - self.tright.SetValue(x) - line = obj.readline() - return - - def OnStateText(self,event): - item = self.llayers.FindString(event.GetString()) - self.llayers.SetSelection(item) - self.llayers.SetValue(self.llayers.GetStringSelection()) - pass - #.log.WriteText('EvtTextEnter: %s' % event.GetString()) - #sys.stderr.write(event.GetString()+"\n") - #text=event.GetString().lower() - #for idx in range(len(self.states)): - # if self.states[idx].lower() == text: - # self.cstate.Select(idx) - # break - - def OnPageChange(self, event): - self.GetNext().FillVars() - self.GetNext().SetPrev(self) - - global north - north = self.ttop.GetValue() - global south - south = self.tbottom.GetValue() - global east - east = self.tright.GetValue() - global west - west = self.tleft.GetValue() - global resolution - resolution = self.tres.GetValue() - - def OnItemSelected(self, event): - item = self.cstate.GetSelection() - w,s,e,n = self.coords[item] - # 4 - # 1 3 - # 2 - - if self.parent.csystemspage.cs == "latlong": - pass - if self.parent.csystemspage.cs == "xy": - pass - else: - if self.parent.csystemspage.cs == "epsg": - to="+init=epsg:%d" % (int(self.parent.epsgpage.tcode.GetValue())) - elif self.parent.csystemspage.cs == "proj": - to="+proj=%s" % (self.parent.projpage.tproj.GetValue()) - elif self.parent.csystemspage.cs == "utm": - to="+proj=utm" - else: - sys.stderr.write(self.parent.csystemspage.cs+"\n") - - try: - sin, sout = os.popen2("cs2cs +proj=latlong +datum=WGS84 +to %s" % (to)) - sin.write("%s %s\n" % (w,s)) - sin.write("%s %s\n" % (e,n)) - sin.close() - w,s,t = sout.readline().split() - e,n,t = sout.readline().split() - self.lmessage.SetLabel("") - except: - n = s = w = e="NULL" - self.lmessage.SetLabel("Unable to calculate country extends:\n cs2cs +proj=latlong +datum=WGS84 +to %s"% to) - - self.ttop.SetValue( str(n) ) - self.tbottom.SetValue( str(s) ) - self.tright.SetValue( str(e) ) - self.tleft.SetValue( str(w) ) - - - class GWizard: """ Start wizard here and finish wizard here @@ -1673,7 +1236,6 @@ self.projpage = ProjectionsPage(self.wizard, self) self.projtypepage = ProjTypePage(self.wizard,self) self.epsgpage = EPSGPage(self.wizard, self) -# self.bboxpage = BBoxPage(self.wizard, self) self.filepage = GeoreferencedFilePage(self.wizard, self) self.datumpage = DatumPage(self.wizard, self) self.ellipsepage = EllipsePage(self.wizard, self) @@ -1709,11 +1271,6 @@ self.custompage.SetPrev(self.csystemspage) self.custompage.SetNext(self.sumpage) -# self.bboxpage.SetPrev(self.csystemspage) -# self.bboxpage.SetNext(self.sumpage) - -# self.sumpage.SetPrev(self.bboxpage) -# self.wizard.FitToPage(self.datumpage) self.location = None #New location created From barton at grass.itc.it Fri Aug 3 08:53:50 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Fri Aug 3 08:53:52 2007 Subject: [grass-addons] r995 - trunk/grassaddons/gui Message-ID: <200708030653.l736roMr012052@grass.itc.it> Author: barton Date: 2007-08-03 08:53:32 +0200 (Fri, 03 Aug 2007) New Revision: 995 Modified: trunk/grassaddons/gui/location_wizard.py Log: Summary page working and XY location creation working. Location wizard finished (although some enhancements still possible). Modified: trunk/grassaddons/gui/location_wizard.py =================================================================== --- trunk/grassaddons/gui/location_wizard.py 2007-08-02 07:11:44 UTC (rev 994) +++ trunk/grassaddons/gui/location_wizard.py 2007-08-03 06:53:32 UTC (rev 995) @@ -29,6 +29,7 @@ import gui_modules import gui_modules.cmd as cmd import os +import shutil import re import string import sys @@ -1070,11 +1071,36 @@ self.parent = parent + # labels + self.ldatabase = self.MakeLLabel("") + self.llocation = self.MakeLLabel("") + self.lprojection = self.MakeLLabel("") + + self.lprojection.Wrap(500) + + self.sizer.Add(self.MakeRLabel("GRASS database:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=1, col=0) + self.sizer.Add(self.ldatabase, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=1, col=1) + self.sizer.Add(self.MakeRLabel("Location name:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=2, col=0) + self.sizer.Add(self.llocation, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=2, col=1) + self.sizer.Add(wx.StaticLine(self, -1), 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL, 0, row=3, col=0, colspan=2) + self.sizer.Add((10,10), 1, flag=wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, border=5, row=4, col=0) + self.sizer.Add(self.MakeRLabel("Projection: "), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=5, col=0) + self.sizer.Add(self.lprojection, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=5, col=1) + self.sizer.Add((10,20), 1, flag=wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, border=5, row=6, col=0) + self.sizer.Add(self.MakeLLabel("You can set the default extents and resolution after creating a new location"), \ + 1, flag=wx.ALIGN_CENTRE|wx.ALL, border=5, row=7, col=0, colspan=2) + + self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnPageChange) + + def OnPageChange(self,event): + """ + Insert values into text controls for summary of location creation options + """ + database = self.parent.startpage.grassdatabase location = self.parent.startpage.location global coordsys - if not coordsys: coordsys = 0 @@ -1092,14 +1118,8 @@ transregion = self.parent.datumpage.transregion transparams = self.parent.datumpage.transparams - # labels - self.ldatabase = self.MakeLLabel("") - self.llocation = self.MakeLLabel("") - self.lprojection = self.MakeLLabel("") - self.ldatabase.SetLabel(str(database)) self.llocation.SetLabel(str(location)) - label = '' if coordsys == 'epsg': label = 'EPSG code %s (%s)' % (self.parent.epsgpage.epsgcode,self.parent.epsgpage.epsgdesc) @@ -1117,23 +1137,6 @@ label = ('%s' % self.custompage.proj4string) self.lprojection.SetLabel(label) - wx.MessageBox('label=%s' % label) - - self.lprojection.Wrap(500) - - self.sizer.Add(self.MakeRLabel("GRASS database:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=1, col=0) - self.sizer.Add(self.ldatabase, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=1, col=1) - self.sizer.Add(self.MakeRLabel("Location name:"), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=2, col=0) - self.sizer.Add(self.llocation, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=2, col=1) - self.sizer.Add(wx.StaticLine(self, -1), 0, wx.ALIGN_RIGHT|wx.EXPAND|wx.ALL, 0, row=3, col=0, colspan=2) - self.sizer.Add((10,10), 1, flag=wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, border=5, row=4, col=0) - self.sizer.Add(self.MakeRLabel("Projection: "), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=5, col=0) - self.sizer.Add(self.lprojection, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=5, col=1) - self.sizer.Add((10,20), 1, flag=wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, border=5, row=6, col=0) - self.sizer.Add(self.MakeLLabel("You can set the default extents and resolution after creating a new location"), \ - 1, flag=wx.ALIGN_CENTRE|wx.ALL, border=5, row=7, col=0, colspan=2) - - class GWizard: """ Start wizard here and finish wizard here @@ -1326,9 +1329,57 @@ """ Create an XY location """ - wx.MessageBox('Not implemented: Create xy location') + database = self.startpage.grassdatabase + location = self.startpage.location + dlg = wx.MessageDialog(self.wizard, "New XY location '%s' will be created (not projected or georeferenced)" + % location, + "Create new XY location?", + wx.YES_NO|wx.YES_DEFAULT|wx.ICON_QUESTION) + if dlg.ShowModal() == wx.ID_NO: + dlg.Destroy() + return False + else: + dlg.Destroy() + #Make location folder and PERMANT mapset + os.mkdir(os.path.join(database,location)) + os.mkdir(os.path.join(database,location,'PERMANENT')) + + #Make DEFAULT_WIND and WIND files + regioninfo = ['proj: 0', + 'zone: 0', + 'north: 1', + 'south: 0', + 'east: 1', + 'west: 0', + 'cols: 1', + 'rows: 1', + 'e-w resol: 1', + 'n-s resol: 1', + 'top: 1', + 'bottom: 0', + 'cols3: 1', + 'rows3: 1', + 'depths: 1', + 'e-w resol3: 1', + 'n-s resol3: 1', + 't-b resol: 1'] + + defwind = open(os.path.join(database,location,"PERMANENT","DEFAULT_WIND"),'w') + for param in regioninfo: + defwind.write(param+'\n') + defwind.close() + shutil.copy(os.path.join(database,location,"PERMANENT","DEFAULT_WIND"),\ + os.path.join(database,location,"PERMANENT","WIND")) + + #Make MYNAME file + myname = open(os.path.join(database,location,"PERMANENT","MYNAME"),'w') + myname.write('') + myname.close() + return True + + def Proj4Create(self): """ Create a new location for selected projection From bundala at grass.itc.it Fri Aug 3 17:52:21 2007 From: bundala at grass.itc.it (bundala@grass.itc.it) Date: Fri Aug 3 17:52:23 2007 Subject: [grass-addons] r996 - trunk/grassaddons/v.generalize Message-ID: <200708031552.l73FqLG8021171@grass.itc.it> Author: bundala Date: 2007-08-03 17:52:18 +0200 (Fri, 03 Aug 2007) New Revision: 996 Modified: trunk/grassaddons/v.generalize/description.html trunk/grassaddons/v.generalize/main.c Log: documentation of displacement and network generalization methods Modified: trunk/grassaddons/v.generalize/description.html =================================================================== --- trunk/grassaddons/v.generalize/description.html 2007-08-03 06:53:32 UTC (rev 995) +++ trunk/grassaddons/v.generalize/description.html 2007-08-03 15:52:18 UTC (rev 996) @@ -1,14 +1,15 @@
On the other hand, (line) smoothing is a "reverse" process which takes as an @@ -18,10 +19,12 @@ When this situation occurs, it is always a good idea to simplify the line after smoothing.
+-All the algorithms implemented in this module work line by line. i.e simplification/smoothing -of one line does not affect the other lines. The first and the last point of -each line is never translated and/or deleted. +Smoothing and simplification algorithms implemented in this module work line by +line. i.e simplification/smoothing of one line does not affect the other lines. +They are treated separately. Also, the first and the last point of each line is +never translated and/or deleted.
The following smoothing algorithms are implemented in v.generalize +
One of the key advantages of Hermite Interpolation is the fact that the computed line always passes throught the points of the original line whereas the lines produced by the @@ -137,11 +140,92 @@ translate the points, they do not insert any new points.
-Snakes Algorithm is the slowest among the algorithms presented here. Also, +Snakes Algorithm is (asymptotically) the slowest among the algorithms presented above. Also, it requires quite a lot of memory. This means, that it is not very efficient for maps with the lines consisting of many segments.
++The displacement is used when the lines (linear +features) interact (overlap and/or are close to each other) at the current +level of detail. In general, displacement methods, as name suggests, move the +conflicting features apart so that they do not interact and can be distinguished. +
++This module implements algorithm for displacement of linear features based on +the Snakes approach. This method has very good results. However, it +requires a lot of memory and is not very efficient. +
++Displacement is selected by method=displacement. It uses following parameters: +
++The lines affected by the algorithm can be specified by the layer, +cats and where parameters. +
+ + ++Is used for selecting "the most important" part of the network. This is based +on the graph algorithms. Network generalization is applied if method=network. +The algorithm calculates three centrality measures for each line in the +network and only the lines with the values greater than thresholds are selected. +The behaviour of algorithm can be altered by the following parameters: +
+ ++All three parameters above can be presented at the same time. In that case, +the algorithm selects only the lines which meet each criterion. +
++Also, the outputed network may not be connected if the value of betweeness_thresh +is too large. +
+Last changed: $Date: 2007/01/08 19:38:17 $ Modified: trunk/grassaddons/v.generalize/main.c =================================================================== --- trunk/grassaddons/v.generalize/main.c 2007-08-03 06:53:32 UTC (rev 995) +++ trunk/grassaddons/v.generalize/main.c 2007-08-03 15:52:18 UTC (rev 996) @@ -71,8 +71,10 @@ /* initialize module */ module = G_define_module(); - module->keywords = _("vector, generalization, simplification, smoothing"); - module->description = _("Line simplification and smoothing"); + module->keywords = + _ + ("vector, generalization, simplification, smoothing, displacement, network generalization"); + module->description = _("Vector based generalization"); /* Define the different options as defined in gis.h */ map_in = G_define_standard_option(G_OPT_V_INPUT); @@ -104,7 +106,7 @@ "network;Network generalization;" "displacement;Displacement of lines close to each other;"); - method_opt->description = _("Line simplification/smoothing algorithm"); + method_opt->description = _("Generalization algorithm"); thresh_opt = G_define_option(); thresh_opt->key = "threshold"; From ullah at grass.itc.it Fri Aug 3 22:35:55 2007 From: ullah at grass.itc.it (ullah@grass.itc.it) Date: Fri Aug 3 22:35:57 2007 Subject: [grass-addons] r997 - in trunk/grassaddons/LandDyn: r.landscape.evol r.landscape.evol.itr Message-ID: <200708032035.l73KZtdE024227@grass.itc.it> Author: ullah Date: 2007-08-03 22:35:46 +0200 (Fri, 03 Aug 2007) New Revision: 997 Modified: trunk/grassaddons/LandDyn/r.landscape.evol.itr/r.landscape.evol.itr trunk/grassaddons/LandDyn/r.landscape.evol/r.landscape.evol Log: Major modification of the smoothing routine for both r.landscape.evol and r.landscape.evol.itr . eliminated cutoff-based smoothing in favor of simple "despeckling"-type median smoothing. The input option "sigma" was consequently removed, and the default smoothing set to a 7x7 window for median smoothng with r.neighbors. Also updated the script so that r.flow is run on a depressionless map created by r.fill.dir every iteration. Modified: trunk/grassaddons/LandDyn/r.landscape.evol/r.landscape.evol =================================================================== --- trunk/grassaddons/LandDyn/r.landscape.evol/r.landscape.evol 2007-08-03 15:52:18 UTC (rev 996) +++ trunk/grassaddons/LandDyn/r.landscape.evol/r.landscape.evol 2007-08-03 20:35:46 UTC (rev 997) @@ -194,20 +194,20 @@ #% required : yes #% guisection: Smoothing_Filter #%end +# #%option +# #% key: sigma +# #% type: string +# #% description: Band-pass filter threshold value, sigma (meters) +# #% answer: 0.10 +# #% required : yes +# #% guisection: Smoothing_Filter +# #%end #%option -#% key: sigma -#% type: string -#% description: Band-pass filter threshold value, sigma (meters) -#% answer: 0.10 -#% required : yes -#% guisection: Smoothing_Filter -#%end -#%option #% key: method #% type: string #% description: Neighborhood smoothing method #% answer: median -#% options: median,mode,average +#% options: average,median,mode #% required : yes #% guisection: Smoothing_Filter #%end @@ -322,8 +322,6 @@ echo "The following temporary files will be created:" echo "" -neighbors=$prefx"neighbors"$num -echo "neighbors=$neighbors" tempsmoothdz=$prefx"tempsmoothdz"$num echo "tempsmoothdz=$tempsmoothdz" tempsmoothdz=$prefx"tempsmoothdz"$num @@ -388,7 +386,7 @@ # we must set the region to the map being used. otherwise r.flow will not work echo "" echo "Setting region to $elev" -g.region rast=$elev +g.region -a rast=$elev #now lets show before: echo "" @@ -435,6 +433,9 @@ echo "" + + + r.slope.aspect --q $elev slope=$slope aspect=$aspect pcurv=$pc tcurv=$tc @@ -468,26 +469,35 @@ echo "Amount of free RAM being allocated for this step: $mem Megabites" -r.terraflow --q elev=$elev filled=$prefx".filled" direction=$prefx".direct" swatershed=$prefx".sink" accumulation=temp.flowacc tci=$prefx".tci" d8cut=infinity memory=$mem STREAM_DIR=/var/tmp +tmpflacc=$prefx".tmpflacc" -r.mapcalc "$flowacc=temp.flowacc/$res" +r.terraflow --q elev=$elev filled=$prefx".filled" direction=$prefx".direct" swatershed=$prefx".sink" accumulation=$tmpflacc tci=$prefx".tci" d8cut=infinity memory=$mem STREAM_DIR=/var/tmp +r.mapcalc "$flowacc=$tmpflacc/$res" -g.remove --q rast=$prefx".filled",$prefx".direct",$prefx".sink",$prefx".tci",temp.flowacc + +g.remove --quiet rast=$prefx".filled",$prefx".direct",$prefx".sink",$prefx".tci",$tmpflacc,$tmpdirection rm -f /var/tmp/STREAM* else echo "using r.flow to calculate overland flow accumulation per cell (number of cells uplsope from each cell)" -tmpflacc=$prefx".tmpflacc" +tmpfilled=$prefx"tmpfilled"$num +tmpdirection=$prefx"tmpdirection" -r.flow -3 --quiet elevin=$elev aspin=$aspect dsout=$tmpflacc +tmpflacc=$prefx"tmpflacc" +r.fill.dir --quiet input=$elev elevation=$tmpfilled direction=$tmpdirection type=grass + +r.flow -3 --quiet elevin=$tmpfilled aspin=$aspect dsout=$tmpflacc + r.mapcalc "$flowacc=$tmpflacc*$res" -g.remove --quiet rast=$tmpflacc +g.remove --quiet rast=$tmpflacc,$tmpdirection + + fi echo "" @@ -629,6 +639,9 @@ echo "*************************" echo "" + + + if [ "$GIS_FLAG_y" -eq 1 ]; then echo ""echo "You have selected not to smooth your files... Oh Well!" @@ -636,15 +649,19 @@ r.mapcalc "$smoothdz=if((-1 * $erdep) >= $initsoil, (-1 * $initsoil), $erdep)" + else +#commenting out the sigma-based truncation because it was causeing deletarious amplification of cell edges. Leaving it commented for posterity only... +#r.mapcalc "$smoothdz=if((abs($tempsmoothdz-$neighbors)) > $GIS_OPT_sigma , $neighbors , $tempsmoothdz)" - -r.neighbors --q input=$erdep output=$neighbors method=$GIS_OPT_method size=$GIS_OPT_nbhood r.mapcalc "$tempsmoothdz=if((-1 * $erdep) >= $initsoil, (-1 * $initsoil), $erdep)" -r.mapcalc "$smoothdz=if((abs($tempsmoothdz-$neighbors)) > $GIS_OPT_sigma , $neighbors , $tempsmoothdz)" +r.neighbors --q input=$tempsmoothdz output=$smoothdz method=$GIS_OPT_method size=$GIS_OPT_nbhood + fi + + #checking to see if we should keep the initial soil depths map @@ -686,6 +703,7 @@ echo "*************************" echo "" + if [ $number -eq 1 ] ; then temp_dem=$prfx"temp_dem" @@ -734,6 +752,7 @@ #rate is actually the net change in bedrock elevation due to soil production, so lets use it to find the new bedrock elev, and the new soil depth! r.mapcalc "$new_bdrk=$initbdrk - $rate" + r.mapcalc "$new_soil=if (($new_dem - $new_bdrk) < 0, 0, ($new_dem - $new_bdrk))" fi @@ -824,8 +843,6 @@ echo "The following temporary files will be created:" echo "" -neighbors=$prefx"neighbors"$step -echo "neighbors=$neighbors" tempsmoothdz=$prefx"tempsmoothdz"$step echo "tempsmoothdz=$tempsmoothdz" temp2smoothdz=$prefx"temp2smoothdz"$step @@ -901,6 +918,10 @@ echo "*************************" echo "" + + + + r.slope.aspect --q elevation=$old_dem slope=$slope aspect=$aspect pcurv=$pc tcurv=$tc @@ -936,23 +957,32 @@ echo "Amount of free RAM being allocated for this step: $mem Megabites" -r.terraflow --q elev=$elev filled=$prefx".filled" direction=$prefx".direct" swatershed=$prefx".sink" accumulation=$prefx".tmpflacc" tci=$prefx".tci" d8cut=infinity memory=$mem STREAM_DIR=/var/tmp +tmpflacc=$prefx".tmpflacc" -r.mapcalc "$flowacc=$prefx".tmpflacc"/$res" +r.terraflow --q elev=$old_dem filled=$prefx".filled" direction=$prefx".direct" swatershed=$prefx".sink" accumulation=$tmpflacc tci=$prefx".tci" d8cut=infinity memory=$mem STREAM_DIR=/var/tmp -g.remove --q rast=$prefx".filled",$prefx".direct",$prefx".sink",$prefx".tci",$prefx".tmpflacc" +r.mapcalc "$flowacc=$tmpflacc/$res" + + +g.remove --quiet rast=$prefx".filled",$prefx".direct",$prefx".sink",$prefx".tci",$tmpflacc,$tmpdirection rm -f /var/tmp/STREAM* else echo "using r.flow to calculate overland flow accumulation per cell (number of cells uplsope from each cell)" -tmpflacc=$prefx".tmpflacc" -r.flow -3 --quiet elevin=$elev aspin=$aspect dsout=$tmpflacc +tmpfilled=$prefx"tmpfilled"$step +tmpdirection=$prefx"tmpdirection" +tmpflacc=$prefx"tmpflacc" + +r.fill.dir --quiet input=$old_dem elevation=$tmpfilled direction=$tmpdirection type=grass + +r.flow -3 --quiet elevin=$tmpfilled aspin=$aspect dsout=$tmpflacc + r.mapcalc "$flowacc=$tmpflacc*$res" -g.remove --quiet rast=$tmpflacc +g.remove --quiet rast=$tmpflacc,$tmpdirection fi @@ -1095,10 +1125,14 @@ else -r.neighbors --q input=$erdep output=$neighbors method=$GIS_OPT_method size=$GIS_OPT_nbhood +#commenting out the sigma-based truncation because it was causeing deletarious amplification of cell edges. Leaving it commented for posterity only... +#r.mapcalc "$temp2smoothdz=if((abs($tempsmoothdz-$neighbors)) > $GIS_OPT_sigma , $neighbors , $tempsmoothdz)" + r.mapcalc "$tempsmoothdz=if((-1 * $erdep) >= $old_soil, (-1 * $old_soil), $erdep)" -r.mapcalc "$temp2smoothdz=if((abs($tempsmoothdz-$neighbors)) > $GIS_OPT_sigma , $neighbors , $tempsmoothdz)" +r.neighbors --q input=$tempsmoothdz output=$temp2smoothdz method=$GIS_OPT_method size=$GIS_OPT_nbhood + + fi #now we must correct for the incredible edge shrinking effect by patching the last smoothdz underneath the new smoothdz @@ -1146,8 +1180,7 @@ echo "Calculating new soil depths keeping bedrock elevations static" -new_bdrk=$initbdrk -r.mapcalc "$new_soil=if (($new_dem - $new_bdrk) < 0, 0, ($new_dem - $new_bdrk))" +r.mapcalc "$new_soil=if (($new_dem - $initbdrk) < 0, 0, ($new_dem - $initbdrk))" else @@ -1321,7 +1354,8 @@ echo "" echo "Cleaning up..." -g.mremove -f --q rast=$prefx"neighbors*" + +g.mremove -f --q rast=$prefx"tmpfilled*" g.mremove -f --q rast=$prefx"flowacc*" g.mremove -f --q rast=$prefx"slope*" g.mremove -f --q rast=$prefx"aspect*" Modified: trunk/grassaddons/LandDyn/r.landscape.evol.itr/r.landscape.evol.itr =================================================================== --- trunk/grassaddons/LandDyn/r.landscape.evol.itr/r.landscape.evol.itr 2007-08-03 15:52:18 UTC (rev 996) +++ trunk/grassaddons/LandDyn/r.landscape.evol.itr/r.landscape.evol.itr 2007-08-03 20:35:46 UTC (rev 997) @@ -183,24 +183,25 @@ #% required : yes #% guisection: Smoothing_Filter #%end +# #%option +# #% key: sigma +# #% type: string +# #% description: Band-pass filter threshold value, sigma (meters) +# #% answer: 0.10 +# #% required : yes +# #% guisection: Smoothing_Filter +# #%end #%option -#% key: sigma -#% type: string -#% description: Band-pass filter threshold value, sigma (meters) -#% answer: 0.10 -#% required : yes -#% guisection: Smoothing_Filter -#%end -#%option #% key: method #% type: string #% description: Neighborhood smoothing method #% answer: median -#% options: median,mode,average +#% options: average,median,mode #% required : yes #% guisection: Smoothing_Filter #%end + #%flag #% key: c #% description: -c Output cumulative erosion/depostition map from data for all iterations @@ -283,8 +284,9 @@ elev=$GIS_OPT_elev initbdrk=$GIS_OPT_initbdrk R=$GIS_OPT_R -echo "R prefix = $Rprfx" +echo "R = $R" K=$GIS_OPT_K +echo "K = $K" Cprfx=$GIS_OPT_C echo "C prefix = $Cprfx" kappa=$GIS_OPT_kappa @@ -296,8 +298,6 @@ cutoff=$GIS_OPT_cutoff echo "The following temporary files will be created:" echo "" -neighbors=$prefx".neighbors1" -echo "neighbors=$neighbors" tempsmoothdz=$prefx".tempsmoothdz1" echo "tempsmoothdz=$tempsmoothdz" smoothdz=$prefx"_smoothdz1" @@ -361,9 +361,9 @@ res1=`eval g.region -p -m | grep "nsres:" | cut -d : -f 2` # we must set the region to the map being used. otherwise r.flow will not work -echo "" +#echo "" echo "Setting region to $elev" -g.region rast=$elev +g.region -a rast=$elev #now lets show before: echo "" @@ -437,24 +437,30 @@ echo "Amount of free RAM being allocated for this step: $mem Megabites" -r.terraflow --q elev=$elev filled=$prefx".filled" direction=$prefx".direct" swatershed=$prefx".sink" accumulation=$prefx".tmpflacc" tci=$prefx".tci" d8cut=infinity memory=$mem STREAM_DIR=/var/tmp +tmpflacc=$prefx".tmpflacc" -r.mapcalc "$flowacc=$prefx".tmpflacc"/$res" +r.terraflow --q elev=$elev filled=$prefx".filled" direction=$prefx".direct" swatershed=$prefx".sink" accumulation=$tmpflacc tci=$prefx".tci" d8cut=infinity memory=$mem STREAM_DIR=/var/tmp -g.remove --q rast=$prefx".filled",$prefx".direct",$prefx".sink",$prefx".tci",$prefx".tmpflacc" +r.mapcalc "$flowacc=$tmpflacc/$res" + + +g.remove --quiet rast=$prefx".filled",$prefx".direct",$prefx".sink",$prefx".tci",$tmpflacc,$tmpdirection rm -f /var/tmp/STREAM* else echo "using r.flow to calculate overland flow accumulation per cell (number of cells uplsope from each cell)" -tmpflacc=$prefx".tmpflacc" +tmpflacc=$prefx"tmpflacc" +tmpdirection=$prefx"tmpdirection" +tmpfilled=$prefx"tmpfilled1" -r.flow -3 --quiet elevin=$elev aspin=$aspect dsout=$tmpflacc +r.fill.dir --quiet input=$elev elevation=$tmpfilled direction=$tmpdirection type=grass +r.flow -3 --quiet elevin=$tmpfilled aspin=$aspect dsout=$tmpflacc r.mapcalc "$flowacc=$tmpflacc*$res" -g.remove --quiet rast=$tmpflacc +g.remove --quiet rast=$tmpflacc,$tmpdirection fi @@ -607,11 +613,15 @@ else +#commenting out the sigma-based truncation because it was causeing deletarious amplification of cell edges. Leaving it commented for posterity only... +#r.mapcalc "$smoothdz=if((abs($tempsmoothdz-$neighbors)) > $GIS_OPT_sigma , $neighbors , $tempsmoothdz)" -r.neighbors --quiet input=$erdep output=$neighbors method=$GIS_OPT_method size=$GIS_OPT_nbhood + r.mapcalc "$tempsmoothdz=if((-1 * $erdep) >= $initsoil, (-1 * $initsoil), $erdep)" -r.mapcalc "$smoothdz=if((abs($tempsmoothdz-$neighbors)) > $GIS_OPT_sigma , $neighbors , $tempsmoothdz)" +r.neighbors --quiet input=$tempsmoothdz output=$smoothdz method=$GIS_OPT_method size=$GIS_OPT_nbhood + + fi # create temporary file to code colors for $smoothdz @@ -742,25 +752,7 @@ echo "" -#This is replaced by the large g.mremove process at the end of the script. I leave it commented because one might like to have the files for each iteration cleaned up as the process runs instead of one batch process at the end. -#if [ "$GIS_FLAG_k" -eq 1 ]; then -# echo "" -# echo "Done" -# echo "" -#else -# echo "" -# echo "Cleaning up..." -# g.remove rast=$flowacc,$slope,$aspect,$sflowtopo,$qsx,$qsy,$qsxdx,$qsydy,$erdep,$neighbors -# echo "" -# echo "Done" -#fi - -#remove the temp files to avoid confusion...\rm -f $TMP1 $TMP1.sort - - - - # now we must go into a loop to get the rest of the dem's while [ "$step" -lt "$maxyrs" ] @@ -773,8 +765,6 @@ echo "The following temporary files will be created:" echo "" -neighbors=$prefx".neighbors"$step -echo "neighbors=$neighbors" tempsmoothdz=$prefx".tempsmoothdz"$step echo "tempsmoothdz=$tempsmoothdz" temp2smoothdz=$prefx".temp2smoothdz"$step @@ -850,9 +840,15 @@ echo "*************************" echo "" -r.slope.aspect --q elevation=$old_dem slope=$slope aspect=$aspect pcurv=$pc tcurv=$tc + +r.slope.aspect --q elevation=$elev slope=$slope aspect=$aspect pcurv=$pc tcurv=$tc + + + + + echo "" echo "*************************" echo "step 2 of 8: calculating upslope accumulated flow" @@ -885,24 +881,31 @@ echo "Amount of free RAM being allocated for this step: $mem Megabites" -r.terraflow --q elev=$elev filled=$prefx".filled" direction=$prefx".direct" swatershed=$prefx".sink" accumulation=$prefx".tmpflacc" tci=$prefx".tci" d8cut=infinity memory=$mem STREAM_DIR=/var/tmp +tmpflacc=$prefx".tmpflacc" -r.mapcalc "$flowacc=$prefx".tmpflacc"/$res" +r.terraflow --q elev=$elev filled=$prefx".filled" direction=$prefx".direct" swatershed=$prefx".sink" accumulation=$tmpflacc tci=$prefx".tci" d8cut=infinity memory=$mem STREAM_DIR=/var/tmp -g.remove --q rast=$prefx".filled",$prefx".direct",$prefx".sink",$prefx".tci",$prefx".tmpflacc" +r.mapcalc "$flowacc=$tmpflacc/$res" + + +g.remove --quiet rast=$prefx".filled",$prefx".direct",$prefx".sink",$prefx".tci",$tmpflacc,$tmpdirection rm -f /var/tmp/STREAM* else echo "using r.flow to calculate overland flow accumulation per cell (number of cells uplsope from each cell)" -tmpflacc=$prefx".tmpflacc" +tmpflacc=$prefx"tmpflacc" +tmpfilled=$prefx"tmpfilled"$step +tmpdirection=$prefx"tmpdirection" -r.flow -3 --quiet elevin=$elev aspin=$aspect dsout=$tmpflacc +r.fill.dir --quiet input=$old_dem elevation=$tmpfilled direction=$tmpdirection type=grass +r.flow -3 --quiet elevin=$old_dem aspin=$aspect dsout=$tmpflacc + r.mapcalc "$flowacc=$tmpflacc*$res" -g.remove --quiet rast=$tmpflacc +g.remove --quiet rast=$tmpflacc,$tmpdirection fi @@ -1047,10 +1050,14 @@ else -r.neighbors --q input=$erdep output=$neighbors method=$GIS_OPT_method size=$GIS_OPT_nbhood +#commenting out the sigma-based truncation because it was causeing deletarious amplification of cell edges. Leaving it commented for posterity only... +#r.mapcalc "$temp2smoothdz=if((abs($tempsmoothdz-$neighbors)) > $GIS_OPT_sigma , $neighbors , $tempsmoothdz)" + r.mapcalc "$tempsmoothdz=if((-1 * $erdep) >= $old_soil, (-1 * $old_soil), $erdep)" -r.mapcalc "$temp2smoothdz=if((abs($tempsmoothdz-$neighbors)) > $GIS_OPT_sigma , $neighbors , $tempsmoothdz)" +r.neighbors --q input=$tempsmoothdz output=$temp2smoothdz method=$GIS_OPT_method size=$GIS_OPT_nbhood + + fi #now we must correct for the incredible edge shrinking effect by patching the last smoothdz underneath the new smoothdz @@ -1099,8 +1106,7 @@ echo "Calculating new soil depths keeping bedrock elevations static" -new_bdrk=$initbdrk -r.mapcalc "$new_soil=if (($new_dem - $new_bdrk) < 0, 0, ($new_dem - $new_bdrk))" +r.mapcalc "$new_soil=if (($new_dem - $initbdrk) < 0, 0, ($new_dem - $initbdrk))" else @@ -1276,8 +1282,7 @@ else echo "" echo "Cleaning up..." -g.mremove -f --q rast=$prefx".neighbors*" -g.mremove -f --q rast=$prefx".smoothdz*" +g.mremove -f --q rast=$prefx"tmpfilled*" g.mremove -f --q rast=$prefx".flowacc*" g.mremove -f --q rast=$prefx".slope*" g.mremove -f --q rast=$prefx".aspect*" From ullah at grass.itc.it Fri Aug 3 22:46:41 2007 From: ullah at grass.itc.it (ullah@grass.itc.it) Date: Fri Aug 3 22:46:42 2007 Subject: [grass-addons] r998 - in trunk/grassaddons/LandDyn: r.landscape.evol r.landscape.evol.itr Message-ID: <200708032046.l73KkfSW024279@grass.itc.it> Author: ullah Date: 2007-08-03 22:46:32 +0200 (Fri, 03 Aug 2007) New Revision: 998 Modified: trunk/grassaddons/LandDyn/r.landscape.evol.itr/r.landscape.evol.itr trunk/grassaddons/LandDyn/r.landscape.evol/r.landscape.evol Log: changed color rules slightly Modified: trunk/grassaddons/LandDyn/r.landscape.evol/r.landscape.evol =================================================================== --- trunk/grassaddons/LandDyn/r.landscape.evol/r.landscape.evol 2007-08-03 20:35:46 UTC (rev 997) +++ trunk/grassaddons/LandDyn/r.landscape.evol/r.landscape.evol 2007-08-03 20:46:32 UTC (rev 998) @@ -681,7 +681,7 @@ fi -echo "100% 255 000 255" > $TMP1 +echo "100% 104 034 139" > $TMP1 echo "5 violet" >> $TMP1 echo "3 aqua" >> $TMP1 echo "1 cyan" >> $TMP1 @@ -691,7 +691,7 @@ echo "-1 orange" >> $TMP1 echo "-3 red" >> $TMP1 echo "-5 255 000 255" $TMP1 -echo "0% 104 034 139" >> $TMP1 +echo "-0% 255 000 255" >> $TMP1 echo "end" >> $TMP1 @@ -1138,31 +1138,8 @@ #now we must correct for the incredible edge shrinking effect by patching the last smoothdz underneath the new smoothdz r.patch input=$temp2smoothdz,$lastsmooth output=$smoothdz +#set the colors to our rules -# create temporary file to code colors for $smoothdz -TMP1=`g.tempfile pid=$$` - -if [ $? -ne 0 ] || [ -z "$TMP1" ] ; then - echo "ERROR: unable to create temporary file for colors" 1>&2 - exit 1 -else - echo "creating temporary file to code colors" - -fi -echo "100% 255 000 255" > $TMP1 -echo "5 violet" >> $TMP1 -echo "3 aqua" >> $TMP1 -echo "1 cyan" >> $TMP1 -echo "0.5 green" >> $TMP1 -echo "0 white" >> $TMP1 -echo "-0.5 yellow" >> $TMP1 -echo "-1 orange" >> $TMP1 -echo "-3 red" >> $TMP1 -echo "-5 255 000 255" $TMP1 -echo "0% 104 034 139" >> $TMP1 -echo "end" >> $TMP1 - - cat $TMP1 | r.colors --q map=$smoothdz color=rules echo "" Modified: trunk/grassaddons/LandDyn/r.landscape.evol.itr/r.landscape.evol.itr =================================================================== --- trunk/grassaddons/LandDyn/r.landscape.evol.itr/r.landscape.evol.itr 2007-08-03 20:35:46 UTC (rev 997) +++ trunk/grassaddons/LandDyn/r.landscape.evol.itr/r.landscape.evol.itr 2007-08-03 20:46:32 UTC (rev 998) @@ -637,17 +637,17 @@ fi -echo "0% 104 034 139" > $TMP1 -echo "-5 violet" >> $TMP1 -echo "-3 aqua" >> $TMP1 -echo "-1 cyan" >> $TMP1 -echo "-0.5 green" >> $TMP1 +echo "100% 104 034 139" > $TMP1 +echo "5 violet" >> $TMP1 +echo "3 aqua" >> $TMP1 +echo "1 cyan" >> $TMP1 +echo "0.5 green" >> $TMP1 echo "0 white" >> $TMP1 -echo "0.5 yellow" >> $TMP1 -echo "1 orange" >> $TMP1 -echo "3 red" >> $TMP1 -echo "5 255 000 255" $TMP1 -echo "100% 255 000 255" >> $TMP1 +echo "-0.5 yellow" >> $TMP1 +echo "-1 orange" >> $TMP1 +echo "-3 red" >> $TMP1 +echo "-5 255 000 255" $TMP1 +echo "-0% 255 000 255" >> $TMP1 echo "end" >> $TMP1 @@ -1063,32 +1063,7 @@ #now we must correct for the incredible edge shrinking effect by patching the last smoothdz underneath the new smoothdz r.patch input=$temp2smoothdz,$lastsmooth output=$smoothdz - -# create temporary file to code colors for $smoothdz -TMP1=`g.tempfile pid=$$` - -if [ $? -ne 0 ] || [ -z "$TMP1" ] ; then - echo "ERROR: unable to create temporary file for colors" 1>&2 - exit 1 -else - echo "creating temporary file to code colors" - -fi - -echo "0% 104 034 139" > $TMP1 -echo "-5 violet" >> $TMP1 -echo "-3 aqua" >> $TMP1 -echo "-1 cyan" >> $TMP1 -echo "-0.5 green" >> $TMP1 -echo "0 white" >> $TMP1 -echo "0.5 yellow" >> $TMP1 -echo "1 orange" >> $TMP1 -echo "3 red" >> $TMP1 -echo "5 255 000 255" $TMP1 -echo "100% 255 000 255" >> $TMP1 -echo "end" >> $TMP1 - - +# set the colors to our rules cat $TMP1 | r.colors --q map=$smoothdz color=rules echo "" From barton at grass.itc.it Sat Aug 4 08:00:07 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sat Aug 4 08:00:10 2007 Subject: [grass-addons] r999 - trunk/grassaddons/gui Message-ID: <200708040600.l7460750012059@grass.itc.it> Author: barton Date: 2007-08-04 07:59:55 +0200 (Sat, 04 Aug 2007) New Revision: 999 Modified: trunk/grassaddons/gui/location_wizard.py Log: Added option to create default extents and resolution back into wizard. Modified: trunk/grassaddons/gui/location_wizard.py =================================================================== --- trunk/grassaddons/gui/location_wizard.py 2007-08-03 20:46:32 UTC (rev 998) +++ trunk/grassaddons/gui/location_wizard.py 2007-08-04 05:59:55 UTC (rev 999) @@ -1087,8 +1087,10 @@ self.sizer.Add(self.MakeRLabel("Projection: "), 1, flag=wx.ALIGN_RIGHT|wx.ALL, border=5, row=5, col=0) self.sizer.Add(self.lprojection, 1, flag=wx.ALIGN_LEFT|wx.ALL, border=5, row=5, col=1) self.sizer.Add((10,20), 1, flag=wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, border=5, row=6, col=0) - self.sizer.Add(self.MakeLLabel("You can set the default extents and resolution after creating a new location"), \ + self.sizer.Add(self.MakeLLabel("You can set the default extents and resolution after creating new location"), \ 1, flag=wx.ALIGN_CENTRE|wx.ALL, border=5, row=7, col=0, colspan=2) + self.sizer.Add(self.MakeLLabel("or you can set them during a working session."), \ + 1, flag=wx.ALIGN_CENTRE|wx.ALL, border=5, row=7, col=0, colspan=2) self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnPageChange) @@ -1137,6 +1139,221 @@ label = ('%s' % self.custompage.proj4string) self.lprojection.SetLabel(label) +class RegionDef(wx.Frame): + """ + Page for setting default region extents and resolution + """ + + def __init__(self,parent,id=wx.ID_ANY, title="Set default region values", location=None): + wx.Frame.__init__(self, parent, id, title, size=(650,300)) + + self.parent = parent + self.location = location + + # inputs + self.ttop = self.MakeTextCtrl("1", size=(150, -1)) + self.tbottom = self.MakeTextCtrl("0", size=(150, -1)) + self.tleft = self.MakeTextCtrl("0", size=(150, -1)) + self.tright = self.MakeTextCtrl("1", size=(150, -1)) + self.tres = self.MakeTextCtrl("1", size=(150, -1)) + + self.north = 1.0 + self.south = 0.0 + self.east = 1.0 + self.west = 0.0 + self.res = 1.0 + + # labels + self.lmessage = wx.StaticText(self,-1, "", size=(300,50)) + + # buttons + self.bset = self.MakeButton("Set coordinates", size=(150,-1)) + self.bcancel = self.MakeButton("Cancel", size=(150,-1)) + + #Set current working environment to PERMANENT mapset in selected location in order to set default region (WIND) + envval = {} + cmdlist = ['g.gisenv'] + p = cmd.Command(cmdlist) + if p.returncode == 0: + output = p.module_stdout.read().strip("'").split(';\n') + for line in output: + line = line.strip() + if '=' in line: key,val = line.split('=') + envval[key] = val + self.currlocation = envval['LOCATION_NAME'].strip("';") + self.currmapset = envval['MAPSET'].strip("';") + if self.currlocation == self.location and self.currmapset == 'PERMANENT': + pass + else: + cmdlist = ['g.mapset', 'location=%s' % self.location, 'mapset=PERMANENT'] + cmd.Command(cmdlist) + else: + wx.MessageBox('A valid location must be selected') + return + + #Get current region settings + region = {} + cmdlist = ['g.region', '-gp'] + p = cmd.Command(cmdlist) + if p.returncode == 0: + output = p.module_stdout.read().split('\n') + for line in output: + line = line.strip() + if '=' in line: key,val = line.split('=') + region[key] = float(val) + else: + wx.MessageBox('Invalid region') + return + + self.north = region['n'] + self.south = region['s'] + self.east = region['e'] + self.west = region['w'] + self.res = region['ewres'] + + # Insert current region settings into text controls + self.ttop.SetValue(str(self.north)) + self.tbottom.SetValue(str(self.south)) + self.tleft.SetValue(str(self.west)) + self.tright.SetValue(str(self.east)) + self.tres.SetValue(str(self.res)) + + # layout + self.sizer = rcs.RowColSizer() + + self.sizer.Add(self.MakeLLabel("Region extents and resolution:"), 3, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 10, row=0,col=0, colspan=2) + + self.sizer.Add(self.MakeRLabel("North"), 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 0, row=1,col=2) + self.sizer.Add(self.ttop, 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=2,col=2) + + self.sizer.Add(self.MakeRLabel("West"), 0, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 0, row=3,col=0) + self.sizer.Add(self.tleft, 0, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=3,col=1) + + self.sizer.Add(self.tright, 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=3,col=3) + self.sizer.Add(self.MakeRLabel("East"), 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 0, row=3,col=4) + + self.sizer.Add(self.tbottom, 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=4,col=2) + self.sizer.Add(self.MakeRLabel("South"), 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 0, row=5,col=2) + + self.sizer.Add(self.MakeRLabel("Resolution"), 0, + wx.ALIGN_RIGHT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=6,col=1) + self.sizer.Add(self.tres, 0, + wx.ALIGN_CENTER_HORIZONTAL | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=6,col=2) + + self.sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 0, row=7, col=0, colspan=6) + + self.sizer.Add(self.bset, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=8, col=3 ) + + self.sizer.Add(self.bcancel, 0, + wx.ALIGN_LEFT | + wx.ALIGN_CENTER_VERTICAL | + wx.ALL, 5, row=8, col=1 ) + + + self.SetSizer(self.sizer) + self.SetAutoLayout(True) + self.Layout() + + self.Bind(wx.EVT_BUTTON, self.OnSetButton, self.bset) + self.Bind(wx.EVT_BUTTON, self.OnCancel, self.bcancel) + self.Bind(wx.EVT_TEXT, self.OnNorth, self.ttop) + self.Bind(wx.EVT_TEXT, self.OnSouth, self.tbottom) + self.Bind(wx.EVT_TEXT, self.OnEast, self.tright) + self.Bind(wx.EVT_TEXT, self.OnWest, self.tleft) + self.Bind(wx.EVT_TEXT, self.OnRes, self.tres) + + def MakeRLabel(self, text=""): + """Make right-aligned label""" + try: + if text[-1] != " ": + text += " " + except: + pass + return wx.StaticText(self, -1, text, style=wx.ALIGN_RIGHT) + + def MakeLLabel(self, text=""): + """Make left-aligned label""" + try: + if text[-1] != " ": + text += " " + except: + pass + return wx.StaticText(self, -1, text, style=wx.ALIGN_LEFT) + + def MakeTextCtrl(self,text='', size=(100,-1)): + """Generic text control""" + return wx.TextCtrl(self,-1, text, size=size) + + def MakeButton(self,text, size=(75,25)): + """Generic button""" + return wx.Button(self, -1, text, + style=wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, + size=size) + + def OnNorth(self,event): + self.north = event.GetString() + + def OnSouth(self, event): + self.south = event.GetString() + + def OnEast(self,event): + self.east = event.GetString() + + def OnWest(self,event): + self.west = event.GetString() + + def OnRes(self,event): + self.res = event.GetString() + + def OnSetButton(self,event=None): + cmdlist = ['g.region', '-sgpa', 'n=%s' % self.north, 's=%s' % self.south, \ + 'e=%s' % self.east, 'w=%s' % self.west, 'res=%s' % self.res] + p = cmd.Command(cmdlist) + if p.returncode == 0: + output = p.module_stdout.read() + wx.MessageBox('New default region:\n%s' % output) + else: + wx.MessageBox('Setting default region failed\n%s %s' % \ + (p.module_stderr.read(),p.module_stdout.read())) + self.Destroy() + + def OnCancel(self, event): + self.Destroy() + class GWizard: """ Start wizard here and finish wizard here @@ -1148,7 +1365,7 @@ wizbmp = wizbmp.ConvertToBitmap() global coordsys - + self.parent = parent # get georeferencing information from tables in $GISBASE/etc # make projections dictionary @@ -1283,8 +1500,18 @@ if self.wizard.RunWizard(self.startpage): success = self.onWizFinished() if success == True: - wx.MessageBox("New location created.") self.location = self.startpage.location + dlg = wx.MessageDialog(self.wizard, + "Do you want to set the default region extents and resolution now?", + "New location '%s' created"% self.location, + wx.YES_NO|wx.YES_DEFAULT|wx.ICON_QUESTION) + if dlg.ShowModal() == wx.ID_YES: + dlg.Destroy() + defineRegion = RegionDef(None, location=self.location) + defineRegion.Show() + else: + dlg.Destroy() + else: wx.MessageBox("Unable to create new location.") else: From barton at grass.itc.it Sat Aug 4 08:02:33 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sat Aug 4 08:02:34 2007 Subject: [grass-addons] r1000 - trunk/grassaddons/gui Message-ID: <200708040602.l7462XcH012083@grass.itc.it> Author: barton Date: 2007-08-04 08:02:24 +0200 (Sat, 04 Aug 2007) New Revision: 1000 Modified: trunk/grassaddons/gui/gis_set.py Log: Removed region defaults button (not settable when location created or within working session via g.region). Added new location management choice control: rename and delete mapsets and locations. Modified: trunk/grassaddons/gui/gis_set.py =================================================================== --- trunk/grassaddons/gui/gis_set.py 2007-08-04 05:59:55 UTC (rev 999) +++ trunk/grassaddons/gui/gis_set.py 2007-08-04 06:02:24 UTC (rev 1000) @@ -8,6 +8,7 @@ import shutil import wx.lib.rcsizer as rcs import gui_modules.cmd as cmd +import shutil def read_grassrc(): """ @@ -61,8 +62,8 @@ self.llocation = wx.StaticText(self, -1, "Project Location\n(projection/coordinate system)", style=wx.ALIGN_CENTRE) self.lmapset = wx.StaticText(self, -1, "Accessible Mapsets\n(directories of GIS files)", style=wx.ALIGN_CENTRE) self.lcreate = wx.StaticText(self, -1, "Create new mapset\nin selected location", style=wx.ALIGN_CENTRE) - self.ldefine = wx.StaticText(self, -1, "Define new location...", style=wx.ALIGN_CENTRE) - self.lregion = wx.StaticText(self, -1, "Define default region...", style=wx.ALIGN_CENTRE) + self.ldefine = wx.StaticText(self, -1, "Define new location", style=wx.ALIGN_CENTRE) + self.lmanageloc = wx.StaticText(self, -1, "Manage location", style=wx.ALIGN_CENTRE) # buttons buttonsize1 = (150,-1) @@ -74,12 +75,10 @@ self.bhelp = wx.Button(self, -1, "Help", size=buttonsize2) self.bbrowse = wx.Button(self, -1, "Browse ...", size=(-1,-1)) self.bmapset = wx.Button(self, -1, "Create new mapset", size=buttonsize1) -# self.bgeoreferenced = wx.Button(self, -1, "Georeferenced file", size=buttonsize1) -# self.bepsg = wx.Button(self, -1, "EPSG codes", size=buttonsize1) self.bwizard = wx.Button(self, -1, "Location wizard", size=buttonsize1) - self.bregion = wx.Button(self, -1, "Define region", size=buttonsize1) + choicelist = ['Rename selected mapset','Rename selected location', 'Delete selected mapset', 'Delete selected location'] + self.manageloc = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choices=choicelist) - # textinputs self.tgisdbase = wx.TextCtrl(self, -1, "", size=(300, 20), style=wx.TE_LEFT) @@ -108,7 +107,7 @@ self.bhelp.Bind(wx.EVT_BUTTON, self.OnHelp) self.bmapset.Bind(wx.EVT_BUTTON, self.OnCreateMapset) self.bwizard.Bind(wx.EVT_BUTTON, self.OnWizard) - self.bregion.Bind(wx.EVT_BUTTON, self.OnRegion) + self.manageloc.Bind(wx.EVT_CHOICE, self.OnManageLoc) self.lblocations.Bind(wx.EVT_LISTBOX, self.OnSelectLocation) self.lbmapsets.Bind(wx.EVT_LISTBOX, self.OnSelectMapset) self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressedInDbase, self.tgisdbase) @@ -169,8 +168,8 @@ mapset_sizer.Add(self.bmapset, 0, label_style|wx.BOTTOM, 10) mapset_sizer.Add(self.ldefine, 0, label_style|wx.RIGHT|wx.LEFT, 5) mapset_sizer.Add(self.bwizard, 0, label_style|wx.TOP|wx.BOTTOM, 5) - mapset_sizer.Add(self.lregion, 0, label_style|wx.TOP|wx.RIGHT|wx.LEFT, 5) - mapset_sizer.Add(self.bregion, 0, label_style|wx.TOP, 5) + mapset_sizer.Add(self.lmanageloc, 0, label_style|wx.TOP|wx.RIGHT|wx.LEFT, 5) + mapset_sizer.Add(self.manageloc, 0, label_style|wx.TOP|wx.RIGHT|wx.LEFT, 5) mapset_sizer.Add((5,0)) grid_sizer.Add(self.llocation, 0,label_style|wx.ALL, 5) @@ -246,14 +245,82 @@ if gWizard.location != None: self.OnSetDatabase(event) self.UpdateMapsets(os.path.join( - self.gisbase,gWizard.location)) + self.gisdbase,gWizard.location)) self.lblocations.SetSelection(self.listOfLocations.index(gWizard.location)) self.lbmapsets.SetSelection(0) - def OnRegion(self,event): - defineRegion = RegionDef(self, location=self.listOfLocations[self.lblocations.GetSelection()]) - defineRegion.Show() + def OnManageLoc(self,event): + if event.GetString() == 'Rename selected mapset': + self.RenameMapset() + elif event.GetString() == 'Rename selected location': + self.RenameLocation() + elif event.GetString() == 'Delete selected mapset': + self.DeleteMapset() + elif event.GetString() == 'Delete selected location': + self.DeleteLocation() + def RenameMapset(self): + location = location=self.listOfLocations[self.lblocations.GetSelection()] + mapset = self.listOfMapsets[self.lbmapsets.GetSelection()] + dlg = wx.TextEntryDialog( + self, 'Current name: %s\nEnter new name:' % mapset, + 'Rename selected mapset') + + if dlg.ShowModal() == wx.ID_OK: + newmapset = dlg.GetValue() + try: + os.rename(os.path.join(self.gisdbase,location,mapset),\ + os.path.join(self.gisdbase,location,newmapset)) + self.OnSelectLocation(None) + self.lbmapsets.SetSelection(self.listOfMapsets.index(newmapset)) + except: + wx.MessageBox('Mapset could not be renamed') + + dlg.Destroy() + + def RenameLocation(self): + location = location=self.listOfLocations[self.lblocations.GetSelection()] + dlg = wx.TextEntryDialog( + self, 'Current name: %s\nEnter new name:' % location, + 'Rename selected location') + + if dlg.ShowModal() == wx.ID_OK: + newlocation = dlg.GetValue() + mapset = self.listOfMapsets[self.lbmapsets.GetSelection()] + try: + os.rename(os.path.join(self.gisdbase,location),\ + os.path.join(self.gisdbase,newlocation)) + self.UpdateLocations(self.gisdbase) + self.lblocations.SetSelection(self.listOfLocations.index(newlocation)) + + except: + wx.MessageBox('Location could not be renamed') + + dlg.Destroy() + + def DeleteMapset(self): + location = location=self.listOfLocations[self.lblocations.GetSelection()] + mapset = self.listOfMapsets[self.lbmapsets.GetSelection()] + dlg = wx.MessageDialog(self, "Do you want to continue with deleting the mapset?", + "WARNING! Mapset '%s', and ALL MAPS it contains will be PERMANENTLY DELETED!" + % mapset,wx.YES_NO|wx.NO_DEFAULT|wx.ICON_EXCLAMATION) + if dlg.ShowModal() == wx.ID_YES: + pass + #delete the mapset + + dlg.Destroy() + + def DeleteLocation(self): + location = location=self.listOfLocations[self.lblocations.GetSelection()] + dlg = wx.MessageDialog(self, "Do you want to continue with deleting the location?", + "WARNING! Location '%s', and ALL MAPSETS and MAPS it contains will be PERMANENTLY DELETED!" + % location,wx.YES_NO|wx.NO_DEFAULT|wx.ICON_EXCLAMATION) + if dlg.ShowModal() == wx.ID_YES: + pass + #delete the mapset + + dlg.Destroy() + def UpdateLocations(self,dbase): self.listOfLocations = [] @@ -280,7 +347,7 @@ def OnSelectLocation(self,event): if self.lblocations.GetSelection() > -1: self.UpdateMapsets(os.path.join( - self.gisbase,self.listOfLocations[self.lblocations.GetSelection()])) + self.gisdbase,self.listOfLocations[self.lblocations.GetSelection()])) else: self.listOfMapsets = [] self.lbmapsets.Clear() @@ -291,8 +358,8 @@ pass def OnSetDatabase(self,event): - self.gisbase = self.tgisdbase.GetValue() - self.UpdateLocations(self.gisbase) + self.gisdbase = self.tgisdbase.GetValue() + self.UpdateLocations(self.gisdbase) self.lblocations.Clear() self.lblocations.InsertItems(self.listOfLocations,0) if self.listOfLocations != []: self.lblocations.SetSelection(0) @@ -305,8 +372,8 @@ dlg = wx.DirDialog(self, "Choose a GRASS directory:", style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON) if dlg.ShowModal() == wx.ID_OK: - self.gisbase = dlg.GetPath() - self.tgisdbase.SetValue(self.gisbase) + self.gisdbase = dlg.GetPath() + self.tgisdbase.SetValue(self.gisdbase) dlg.Destroy() self.OnSetDatabase(event) @@ -318,15 +385,15 @@ event.Skip() def OnCreateMapset(self,event): - self.gisbase = self.tgisdbase.GetValue() + self.gisdbase = self.tgisdbase.GetValue() location = self.listOfLocations[self.lblocations.GetSelection()] try: mapset = self.tnewmapset.GetValue() - os.mkdir(os.path.join(self.gisbase,location,mapset)) + os.mkdir(os.path.join(self.gisdbase,location,mapset)) # copy WIND file and its permissions from PERMANENT and set permissions to u+rw,go+r - shutil.copy(os.path.join(self.gisbase,location,'PERMANENT','WIND'), - os.path.join(self.gisbase,location,mapset)) + shutil.copy(os.path.join(self.gisdbase,location,'PERMANENT','WIND'), + os.path.join(self.gisdbase,location,mapset)) # os.chmod(os.path.join(database,location,mapset,'WIND'), 0644) self.OnSelectLocation(None) self.lbmapsets.SetSelection(self.listOfMapsets.index(mapset)) @@ -361,221 +428,6 @@ print "exit" event.Skip() -class RegionDef(wx.Frame): - """ - Page for setting default region extents and resolution - """ - - def __init__(self,parent,id=wx.ID_ANY, title="Set default region values", location=None): - wx.Frame.__init__(self, parent, id, title, size=(650,300)) - - self.parent = parent - self.location = location - - # inputs - self.ttop = self.MakeTextCtrl("1", size=(150, -1)) - self.tbottom = self.MakeTextCtrl("0", size=(150, -1)) - self.tleft = self.MakeTextCtrl("0", size=(150, -1)) - self.tright = self.MakeTextCtrl("1", size=(150, -1)) - self.tres = self.MakeTextCtrl("1", size=(150, -1)) - - self.north = 1.0 - self.south = 0.0 - self.east = 1.0 - self.west = 0.0 - self.res = 1.0 - - # labels - self.lmessage = wx.StaticText(self,-1, "", size=(300,50)) - - # buttons - self.bset = self.MakeButton("Set coordinates", size=(150,-1)) - self.bcancel = self.MakeButton("Cancel", size=(150,-1)) - - #Set current working environment to PERMANENT mapset in selected location in order to set default region (WIND) - envval = {} - cmdlist = ['g.gisenv'] - p = cmd.Command(cmdlist) - if p.returncode == 0: - output = p.module_stdout.read().strip("'").split(';\n') - for line in output: - line = line.strip() - if '=' in line: key,val = line.split('=') - envval[key] = val - self.currlocation = envval['LOCATION_NAME'].strip("';") - self.currmapset = envval['MAPSET'].strip("';") - if self.currlocation == self.location and self.currmapset == 'PERMANENT': - pass - else: - cmdlist = ['g.mapset', 'location=%s' % self.location, 'mapset=PERMANENT'] - cmd.Command(cmdlist) - else: - wx.MessageBox('A valid location must be selected') - return - - #Get current region settings - region = {} - cmdlist = ['g.region', '-gp'] - p = cmd.Command(cmdlist) - if p.returncode == 0: - output = p.module_stdout.read().split('\n') - for line in output: - line = line.strip() - if '=' in line: key,val = line.split('=') - region[key] = float(val) - else: - wx.MessageBox('Invalid region') - return - - self.north = region['n'] - self.south = region['s'] - self.east = region['e'] - self.west = region['w'] - self.res = region['ewres'] - - # Insert current region settings into text controls - self.ttop.SetValue(str(self.north)) - self.tbottom.SetValue(str(self.south)) - self.tleft.SetValue(str(self.west)) - self.tright.SetValue(str(self.east)) - self.tres.SetValue(str(self.res)) - - # layout - self.sizer = rcs.RowColSizer() - - self.sizer.Add(self.MakeLLabel("Region extents and resolution:"), 3, - wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 10, row=0,col=0, colspan=2) - - self.sizer.Add(self.MakeRLabel("North"), 0, - wx.ALIGN_CENTER_HORIZONTAL | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 0, row=1,col=2) - self.sizer.Add(self.ttop, 0, - wx.ALIGN_CENTER_HORIZONTAL | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=2,col=2) - - self.sizer.Add(self.MakeRLabel("West"), 0, - wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 0, row=3,col=0) - self.sizer.Add(self.tleft, 0, - wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=3,col=1) - - self.sizer.Add(self.tright, 0, - wx.ALIGN_CENTER_HORIZONTAL | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=3,col=3) - self.sizer.Add(self.MakeRLabel("East"), 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 0, row=3,col=4) - - self.sizer.Add(self.tbottom, 0, - wx.ALIGN_CENTER_HORIZONTAL | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=4,col=2) - self.sizer.Add(self.MakeRLabel("South"), 0, - wx.ALIGN_CENTER_HORIZONTAL | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 0, row=5,col=2) - - self.sizer.Add(self.MakeRLabel("Resolution"), 0, - wx.ALIGN_RIGHT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=6,col=1) - self.sizer.Add(self.tres, 0, - wx.ALIGN_CENTER_HORIZONTAL | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=6,col=2) - - self.sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 0, row=7, col=0, colspan=6) - - self.sizer.Add(self.bset, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=8, col=3 ) - - self.sizer.Add(self.bcancel, 0, - wx.ALIGN_LEFT | - wx.ALIGN_CENTER_VERTICAL | - wx.ALL, 5, row=8, col=1 ) - - - self.SetSizer(self.sizer) - self.SetAutoLayout(True) - self.Layout() - - self.Bind(wx.EVT_BUTTON, self.OnSetButton, self.bset) - self.Bind(wx.EVT_BUTTON, self.OnCancel, self.bcancel) - self.Bind(wx.EVT_TEXT, self.OnNorth, self.ttop) - self.Bind(wx.EVT_TEXT, self.OnSouth, self.tbottom) - self.Bind(wx.EVT_TEXT, self.OnEast, self.tright) - self.Bind(wx.EVT_TEXT, self.OnWest, self.tleft) - self.Bind(wx.EVT_TEXT, self.OnRes, self.tres) - - def MakeRLabel(self, text=""): - """Make right-aligned label""" - try: - if text[-1] != " ": - text += " " - except: - pass - return wx.StaticText(self, -1, text, style=wx.ALIGN_RIGHT) - - def MakeLLabel(self, text=""): - """Make left-aligned label""" - try: - if text[-1] != " ": - text += " " - except: - pass - return wx.StaticText(self, -1, text, style=wx.ALIGN_LEFT) - - def MakeTextCtrl(self,text='', size=(100,-1)): - """Generic text control""" - return wx.TextCtrl(self,-1, text, size=size) - - def MakeButton(self,text, size=(75,25)): - """Generic button""" - return wx.Button(self, -1, text, - style=wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, - size=size) - - def OnNorth(self,event): - self.north = event.GetString() - - def OnSouth(self, event): - self.south = event.GetString() - - def OnEast(self,event): - self.east = event.GetString() - - def OnWest(self,event): - self.west = event.GetString() - - def OnRes(self,event): - self.res = event.GetString() - - def OnSetButton(self,event=None): - cmdlist = ['g.region', '-sgpa', 'n=%s' % self.north, 's=%s' % self.south, \ - 'e=%s' % self.east, 'w=%s' % self.west, 'res=%s' % self.res] - p = cmd.Command(cmdlist) - if p.returncode == 0: - output = p.module_stdout.read() - wx.MessageBox('New default region:\n%s' % output) - else: - wx.MessageBox('Setting default region failed\n%s %s' % \ - (p.module_stderr.read(),p.module_stdout.read())) - self.Destroy() - - def OnCancel(self, event): - self.Destroy() - class StartUp(wx.App): def OnInit(self): wx.InitAllImageHandlers() From barton at grass.itc.it Sat Aug 4 08:41:50 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sat Aug 4 08:41:50 2007 Subject: [grass-addons] r1001 - trunk/grassaddons/gui Message-ID: <200708040641.l746fo1r012127@grass.itc.it> Author: barton Date: 2007-08-04 08:41:42 +0200 (Sat, 04 Aug 2007) New Revision: 1001 Modified: trunk/grassaddons/gui/location_wizard.py Log: Header string update Modified: trunk/grassaddons/gui/location_wizard.py =================================================================== --- trunk/grassaddons/gui/location_wizard.py 2007-08-04 06:02:24 UTC (rev 1000) +++ trunk/grassaddons/gui/location_wizard.py 2007-08-04 06:41:42 UTC (rev 1001) @@ -13,6 +13,7 @@ * EPSGPage * CustomPage * SummaryPage + * RegionDef * GWizard PURPOSE: Create a new GRASS location. User can choose from multiple methods From barton at grass.itc.it Sat Aug 4 08:42:23 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sat Aug 4 08:42:24 2007 Subject: [grass-addons] r1002 - trunk/grassaddons/gui Message-ID: <200708040642.l746gNFe012147@grass.itc.it> Author: barton Date: 2007-08-04 08:42:15 +0200 (Sat, 04 Aug 2007) New Revision: 1002 Modified: trunk/grassaddons/gui/gis_set.py Log: Completed location/mapset management functions. Added header string. Modified: trunk/grassaddons/gui/gis_set.py =================================================================== --- trunk/grassaddons/gui/gis_set.py 2007-08-04 06:41:42 UTC (rev 1001) +++ trunk/grassaddons/gui/gis_set.py 2007-08-04 06:42:15 UTC (rev 1002) @@ -2,6 +2,31 @@ # -*- coding: UTF-8 -*- # generated by wxGlade 0.4.1 on Mon Feb 26 18:29:42 2007 +""" +MODULE: gis_set.py + +CLASSES: + * GRASSStartup + * StartUp + +PURPOSE: Initialization module for wxPython GUI for GRASS GIS. Includes + location/mapset selection, location/mapset creation, + location/mapset management. + + Usage: + python "$GISBASE/etc/wx/wxgui.py" -name wxgui_py + +AUTHORS: The GRASS Development Team + Michael Barton + Jachym Cepicky + +COPYRIGHT: (C) 2006-2007 by the GRASS Development Team + This program is free software under the GNU General Public + License (>=v2). Read the file COPYING that comes with GRASS + for details. +""" + + import wx import os import glob @@ -61,9 +86,10 @@ self.ldbase = wx.StaticText(self, -1, "GIS Data Directory:") self.llocation = wx.StaticText(self, -1, "Project Location\n(projection/coordinate system)", style=wx.ALIGN_CENTRE) self.lmapset = wx.StaticText(self, -1, "Accessible Mapsets\n(directories of GIS files)", style=wx.ALIGN_CENTRE) + self.lmanage = wx.StaticText(self, -1, "Manage Locations\nand Mapsets", style=wx.ALIGN_CENTRE) self.lcreate = wx.StaticText(self, -1, "Create new mapset\nin selected location", style=wx.ALIGN_CENTRE) self.ldefine = wx.StaticText(self, -1, "Define new location", style=wx.ALIGN_CENTRE) - self.lmanageloc = wx.StaticText(self, -1, "Manage location", style=wx.ALIGN_CENTRE) + self.lmanageloc = wx.StaticText(self, -1, "Rename/delete selected\nmapset or location", style=wx.ALIGN_CENTRE) # buttons buttonsize1 = (150,-1) @@ -74,9 +100,9 @@ self.bexit = wx.Button(self, -1, "Exit", size=buttonsize2) self.bhelp = wx.Button(self, -1, "Help", size=buttonsize2) self.bbrowse = wx.Button(self, -1, "Browse ...", size=(-1,-1)) - self.bmapset = wx.Button(self, -1, "Create new mapset", size=buttonsize1) + self.bmapset = wx.Button(self, -1, "Create mapset", size=buttonsize1) self.bwizard = wx.Button(self, -1, "Location wizard", size=buttonsize1) - choicelist = ['Rename selected mapset','Rename selected location', 'Delete selected mapset', 'Delete selected location'] + choicelist = ['Rename mapset','Rename location', 'Delete mapset', 'Delete location'] self.manageloc = wx.Choice(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, choices=choicelist) # textinputs @@ -164,17 +190,18 @@ dbase_sizer.Add(self.bbrowse, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5) - mapset_sizer.Add(self.tnewmapset, 0, label_style|wx.BOTTOM, 5) - mapset_sizer.Add(self.bmapset, 0, label_style|wx.BOTTOM, 10) - mapset_sizer.Add(self.ldefine, 0, label_style|wx.RIGHT|wx.LEFT, 5) - mapset_sizer.Add(self.bwizard, 0, label_style|wx.TOP|wx.BOTTOM, 5) + mapset_sizer.Add(self.ldefine, 0, label_style|wx.RIGHT|wx.LEFT|wx.BOTTOM, 5) + mapset_sizer.Add(self.bwizard, 0, label_style|wx.BOTTOM, 8) + mapset_sizer.Add(self.lcreate, 0, label_style|wx.TOP|wx.RIGHT|wx.LEFT, 5) + mapset_sizer.Add(self.tnewmapset, 0, label_style|wx.ALL, 5) + mapset_sizer.Add(self.bmapset, 0, label_style|wx.BOTTOM, 8) mapset_sizer.Add(self.lmanageloc, 0, label_style|wx.TOP|wx.RIGHT|wx.LEFT, 5) - mapset_sizer.Add(self.manageloc, 0, label_style|wx.TOP|wx.RIGHT|wx.LEFT, 5) + mapset_sizer.Add(self.manageloc, 0, label_style|wx.ALL, 5) mapset_sizer.Add((5,0)) grid_sizer.Add(self.llocation, 0,label_style|wx.ALL, 5) grid_sizer.Add(self.lmapset, 0,label_style|wx.ALL, 5) - grid_sizer.Add(self.lcreate, 0,label_style|wx.ALL, 5) + grid_sizer.Add(self.lmanage, 0,label_style|wx.ALL, 5) grid_sizer.Add(self.lpanel, 0, wx.ADJUST_MINSIZE| wx.ALIGN_CENTER_VERTICAL| @@ -250,6 +277,10 @@ self.lbmapsets.SetSelection(0) def OnManageLoc(self,event): + """ + Location management choice control handler + """ + if event.GetString() == 'Rename selected mapset': self.RenameMapset() elif event.GetString() == 'Rename selected location': @@ -260,6 +291,10 @@ self.DeleteLocation() def RenameMapset(self): + """ + Renames selected mapset + """ + location = location=self.listOfLocations[self.lblocations.GetSelection()] mapset = self.listOfMapsets[self.lbmapsets.GetSelection()] dlg = wx.TextEntryDialog( @@ -279,6 +314,10 @@ dlg.Destroy() def RenameLocation(self): + """ + Renames selected location + """ + location = location=self.listOfLocations[self.lblocations.GetSelection()] dlg = wx.TextEntryDialog( self, 'Current name: %s\nEnter new name:' % location, @@ -299,25 +338,40 @@ dlg.Destroy() def DeleteMapset(self): + """ + Deletes selected mapset + """ + location = location=self.listOfLocations[self.lblocations.GetSelection()] mapset = self.listOfMapsets[self.lbmapsets.GetSelection()] dlg = wx.MessageDialog(self, "Do you want to continue with deleting the mapset?", "WARNING! Mapset '%s', and ALL MAPS it contains will be PERMANENTLY DELETED!" % mapset,wx.YES_NO|wx.NO_DEFAULT|wx.ICON_EXCLAMATION) if dlg.ShowModal() == wx.ID_YES: - pass - #delete the mapset + try: + shutil.rmtree(os.path.join(self.gisdbase,location,mapset)) + self.OnSelectLocation(None) + self.lbmapsets.SetSelection(0) + except: + wx.MessageBox('Mapset could not be deleted') dlg.Destroy() def DeleteLocation(self): + """ + Deletes selected location + """ + location = location=self.listOfLocations[self.lblocations.GetSelection()] dlg = wx.MessageDialog(self, "Do you want to continue with deleting the location?", "WARNING! Location '%s', and ALL MAPSETS and MAPS it contains will be PERMANENTLY DELETED!" % location,wx.YES_NO|wx.NO_DEFAULT|wx.ICON_EXCLAMATION) if dlg.ShowModal() == wx.ID_YES: - pass - #delete the mapset + try: + shutil.rmtree(os.path.join(self.gisdbase,location)) + self.UpdateLocations(self.gisdbase) + except: + wx.MessageBox('Location could not be deleted') dlg.Destroy() From barton at grass.itc.it Sat Aug 4 23:39:40 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sat Aug 4 23:39:42 2007 Subject: [grass-addons] r1003 - trunk/grassaddons/gui Message-ID: <200708042139.l74Ldeob025707@grass.itc.it> Author: barton Date: 2007-08-04 23:39:32 +0200 (Sat, 04 Aug 2007) New Revision: 1003 Modified: trunk/grassaddons/gui/location_wizard.py Log: Bug fix for coordinate setting pages Modified: trunk/grassaddons/gui/location_wizard.py =================================================================== --- trunk/grassaddons/gui/location_wizard.py 2007-08-04 06:42:15 UTC (rev 1002) +++ trunk/grassaddons/gui/location_wizard.py 2007-08-04 21:39:32 UTC (rev 1003) @@ -1091,7 +1091,7 @@ self.sizer.Add(self.MakeLLabel("You can set the default extents and resolution after creating new location"), \ 1, flag=wx.ALIGN_CENTRE|wx.ALL, border=5, row=7, col=0, colspan=2) self.sizer.Add(self.MakeLLabel("or you can set them during a working session."), \ - 1, flag=wx.ALIGN_CENTRE|wx.ALL, border=5, row=7, col=0, colspan=2) + 1, flag=wx.ALIGN_CENTRE|wx.ALL, border=5, row=8, col=0, colspan=2) self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnPageChange) @@ -1481,7 +1481,7 @@ self.ellipsepage.SetNext(self.sumpage) self.projpage.SetPrev(self.csystemspage) - self.projpage.SetNext(self.sumpage) + self.projpage.SetNext(self.projtypepage) self.epsgpage.SetPrev(self.csystemspage) self.epsgpage.SetNext(self.sumpage) From barton at grass.itc.it Sun Aug 5 01:58:09 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sun Aug 5 01:58:10 2007 Subject: [grass-addons] r1004 - trunk/grassaddons/gui Message-ID: <200708042358.l74Nw9RT026733@grass.itc.it> Author: barton Date: 2007-08-05 01:58:01 +0200 (Sun, 05 Aug 2007) New Revision: 1004 Modified: trunk/grassaddons/gui/gis_set.py Log: Fixed small bug in rename/delete control Modified: trunk/grassaddons/gui/gis_set.py =================================================================== --- trunk/grassaddons/gui/gis_set.py 2007-08-04 21:39:32 UTC (rev 1003) +++ trunk/grassaddons/gui/gis_set.py 2007-08-04 23:58:01 UTC (rev 1004) @@ -281,13 +281,13 @@ Location management choice control handler """ - if event.GetString() == 'Rename selected mapset': + if event.GetString() == 'Rename mapset': self.RenameMapset() - elif event.GetString() == 'Rename selected location': + elif event.GetString() == 'Rename location': self.RenameLocation() - elif event.GetString() == 'Delete selected mapset': + elif event.GetString() == 'Delete mapset': self.DeleteMapset() - elif event.GetString() == 'Delete selected location': + elif event.GetString() == 'Delete location': self.DeleteLocation() def RenameMapset(self): From barton at grass.itc.it Sun Aug 5 19:48:52 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sun Aug 5 19:48:54 2007 Subject: [grass-addons] r1005 - in trunk/grassaddons/gui: . gui_modules icons Message-ID: <200708051748.l75Hmq6Z019360@grass.itc.it> Author: barton Date: 2007-08-05 19:48:36 +0200 (Sun, 05 Aug 2007) New Revision: 1005 Modified: trunk/grassaddons/gui/gui_modules/render.py trunk/grassaddons/gui/gui_modules/wxgui_utils.py trunk/grassaddons/gui/icons/icon.py trunk/grassaddons/gui/wxgui.py Log: Added new layer types to layer manager: shaded map, rhumbline, and geodesic line Modified: trunk/grassaddons/gui/gui_modules/render.py =================================================================== --- trunk/grassaddons/gui/gui_modules/render.py 2007-08-04 23:58:01 UTC (rev 1004) +++ trunk/grassaddons/gui/gui_modules/render.py 2007-08-05 17:48:36 UTC (rev 1005) @@ -102,7 +102,8 @@ # # prepare command for each layer # - layertypes = ['raster','rgb','his','vector','thememap','themechart','grid','labels','command','overlay'] + layertypes = ['raster','rgb','his','shaded','vector','thememap','themechart',\ + 'grid','geodesic','rhumb','labels','command','overlay'] if self.type in layertypes: self.__renderLayer() elif self.type == "wms": Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-08-04 23:58:01 UTC (rev 1004) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-08-05 17:48:36 UTC (rev 1005) @@ -163,6 +163,9 @@ trgif = Icons["addhis"].GetBitmap(bmpsize) self.his_icon = il.Add(trgif) + trgif = Icons["addshaded"].GetBitmap(bmpsize) + self.shaded_icon = il.Add(trgif) + trgif = Icons["addrarrow"].GetBitmap(bmpsize) self.rarrow_icon = il.Add(trgif) @@ -181,6 +184,12 @@ trgif = Icons["addgrid"].GetBitmap(bmpsize) self.grid_icon = il.Add(trgif) + trgif = Icons["addgeodesic"].GetBitmap(bmpsize) + self.geodesic_icon = il.Add(trgif) + + trgif = Icons["addrhumb"].GetBitmap(bmpsize) + self.rhumb_icon = il.Add(trgif) + trgif = Icons["addlabels"].GetBitmap(bmpsize) self.labels_icon = il.Add(trgif) @@ -425,6 +434,9 @@ elif ltype == 'his': self.SetItemImage(layer, self.his_icon) self.SetItemText(layer, 'HIS (double click to set properties)') + elif ltype == 'shaded': + self.SetItemImage(layer, self.shaded_icon) + self.SetItemText(layer, 'Shaded relief (double click to set properties)') elif ltype == 'rastnum': self.SetItemImage(layer, self.rnum_icon) self.SetItemText(layer, 'raster cell numbers (double click to set properties)') @@ -443,6 +455,12 @@ elif ltype == 'grid': self.SetItemImage(layer, self.grid_icon) self.SetItemText(layer, 'grid (double click to set properties)') + elif ltype == 'geodesic': + self.SetItemImage(layer, self.geodesic_icon) + self.SetItemText(layer, 'geodesic line (double click to set properties)') + elif ltype == 'rhumb': + self.SetItemImage(layer, self.rhumb_icon) + self.SetItemText(layer, 'rhumbline (double click to set properties)') elif ltype == 'labels': self.SetItemImage(layer, self.labels_icon) self.SetItemText(layer, 'vector labels (double click to set properties)') @@ -475,6 +493,8 @@ menuform.GUI().ParseCommand('d.rgb', gmpath, completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'his': menuform.GUI().ParseCommand('d.his', gmpath, completed=(self.getOptData,layer,params), parentframe=self) + elif ltype == 'shaded': + menuform.GUI().ParseCommand('d.shadedmap', gmpath, completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'rastarrow': menuform.GUI().ParseCommand('d.rast.arrow', gmpath, completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'rastnum': @@ -487,6 +507,10 @@ menuform.GUI().ParseCommand('d.vect.chart', gmpath, completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'grid': menuform.GUI().ParseCommand('d.grid', gmpath, completed=(self.getOptData,layer,params), parentframe=self) + elif ltype == 'geodesic': + menuform.GUI().ParseCommand('d.geodesic', gmpath, completed=(self.getOptData,layer,params), parentframe=self) + elif ltype == 'rhumb': + menuform.GUI().ParseCommand('d.rhumbline', gmpath, completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'labels': menuform.GUI().ParseCommand('d.labels', gmpath, completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'cmdlayer': @@ -763,8 +787,14 @@ mapname = item.split('=')[1] elif 'h_map=' in item: mapname = item.split('=')[1] + elif 'reliefmap' in item: + mapname = item.split('=')[1] elif 'd.grid' in item: mapname = 'grid' + elif 'd.geodesic' in item: + mapname = 'geodesic' + elif 'd.rhumbline' in item: + mapname = 'rhumb' elif 'labels=' in item: mapname = item.split('=')[1]+' labels' @@ -956,6 +986,7 @@ layertype = {'d.rast' : 'raster', 'd.rgb' : 'rgb', 'd.his' : 'his', + 'd.shaded' : 'shaded', 'd.legend' : 'rastleg', 'd.rast.arrow' : 'rastarrow', 'd.rast.num' : 'rastnum', @@ -963,6 +994,8 @@ 'd.vect.thematic': 'thememap', 'd.vect.chart' : 'themechart', 'd.grid' : 'grid', + 'd.geodesic' : 'geodesic', + 'd.rhumbline' : 'rhumb', 'd.labels' : 'labels'}[command] except KeyError: print _('Command type not yet implemented') Modified: trunk/grassaddons/gui/icons/icon.py =================================================================== --- trunk/grassaddons/gui/icons/icon.py 2007-08-04 23:58:01 UTC (rev 1004) +++ trunk/grassaddons/gui/icons/icon.py 2007-08-05 17:48:36 UTC (rev 1005) @@ -67,12 +67,15 @@ "attrtable" : 'db-values.gif', "addrgb" : 'module-d.rgb.gif', "addhis" : 'channel-his.gif', + "addshaded" : 'module-d.shadedmap.gif', "addrarrow" : 'module-d.rast.arrow.gif', "addrnum" : 'module-d.rast.num.gif', "elvect" : 'element-vector.gif', "addthematic": 'module-d.vect.thematic.gif', "addchart" : 'module-d.vect.chart.gif', "addgrid" : 'module-d.grid.gif', + "addgeodesic": 'module-d.geodesic.gif', + "addrhumb" : 'module-d.rhumbline.gif', "addlabels" : 'module-d.labels.gif', "addtext" : 'module-d.text.gif', "addbarscale": 'module-d.barscale.gif', @@ -205,12 +208,15 @@ "attrtable" : MetaIcon (img=icons_img["attrtable"], label="Show attribute table"), "addrgb" : MetaIcon (img=icons_img["addrgb"], label="Add RGB layer"), "addhis" : MetaIcon (img=icons_img["addhis"], label="Add HIS layer"), + "addshaded" : MetaIcon (img=icons_img["addshaded"], label="Add shaded relief map layer"), "addrarrow" : MetaIcon (img=icons_img["addrarrow"], label="Add raster flow arrows"), "addrnum" : MetaIcon (img=icons_img["addrnum"], label="Add raster cell numbers"), "elvect" : MetaIcon (img=icons_img["elvect"], label=""), "addthematic": MetaIcon (img=icons_img["addthematic"], label="Add thematic layer"), "addchart" : MetaIcon (img=icons_img["addchart"], label="Add thematic chart layer"), "addgrid" : MetaIcon (img=icons_img["addgrid"], label="Add grid layer"), + "addgeodesic": MetaIcon (img=icons_img["addgeodesic"], label="Add geodesic line layer"), + "addrhumb" : MetaIcon (img=icons_img["addrhumb"], label="Add rhumbline layer"), "addlabels" : MetaIcon (img=icons_img["addlabels"], label="Add labels"), "addtext" : MetaIcon (img=icons_img["addtext"], label="Add text layer"), # digit Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-08-04 23:58:01 UTC (rev 1004) +++ trunk/grassaddons/gui/wxgui.py 2007-08-05 17:48:36 UTC (rev 1005) @@ -516,6 +516,7 @@ ('addcmd', Icons["addcmd"].GetBitmap(), Icons["addcmd"].GetLabel(), self.AddCommand), ('addgrp', wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_TOOLBAR, (16,16)), Icons["addgrp"].GetLabel(), self.AddGroup), ('addovl', Icons["addovl"].GetBitmap(), Icons["addovl"].GetLabel(), self.OnOverlay), + ('addlabels', Icons["addlabels"].GetBitmap(), Icons["addlabels"].GetLabel(), self.AddLabels), ('delcmd', wx.ArtProvider.GetBitmap(wx.ART_DELETE, wx.ART_TOOLBAR, (16,16)), 'Delete selected layer', self.DeleteLayer), ('', '', '', ''), ('attrtable', Icons["attrtable"].GetBitmap(), Icons["attrtable"].GetLabel(), self.ShowAttributeTable) @@ -612,6 +613,11 @@ rastmenu.AppendItem(addrast) self.Bind(wx.EVT_MENU, self.AddRaster, addrast) + addshaded = wx.MenuItem(rastmenu, -1, Icons ["addshaded"].GetLabel()) + addshaded.SetBitmap(Icons["addshaded"].GetBitmap (self.iconsize)) + rastmenu.AppendItem(addshaded) + self.Bind(wx.EVT_MENU, self.AddShaded, addshaded) + addrgb = wx.MenuItem(rastmenu, -1, Icons["addrgb"].GetLabel()) addrgb.SetBitmap(Icons["addrgb"].GetBitmap(self.iconsize)) rastmenu.AppendItem(addrgb) @@ -671,17 +677,21 @@ ovlmenu.AppendItem(addgrid) self.Bind(wx.EVT_MENU, self.AddGrid, addgrid) - addlbl = wx.MenuItem(ovlmenu, -1, Icons["addlabels"].GetLabel()) - addlbl.SetBitmap(Icons["addlabels"].GetBitmap(self.iconsize)) - ovlmenu.AppendItem(addlbl) - self.Bind(wx.EVT_MENU, self.AddLabels, addlbl) + addgeodesic = wx.MenuItem(ovlmenu, -1, Icons["addgeodesic"].GetLabel()) + addgeodesic.SetBitmap(Icons["addgeodesic"].GetBitmap(self.iconsize)) + ovlmenu.AppendItem(addgeodesic) + self.Bind(wx.EVT_MENU, self.AddGeodesic, addgeodesic) + addrhumb = wx.MenuItem(ovlmenu, -1, Icons["addrhumb"].GetLabel()) + addrhumb.SetBitmap(Icons["addrhumb"].GetBitmap(self.iconsize)) + ovlmenu.AppendItem(addrhumb) + self.Bind(wx.EVT_MENU, self.AddRhumb, addrhumb) + # Popup the menu. If an item is selected then its handler # will be called before PopupMenu returns. self.PopupMenu(ovlmenu) ovlmenu.Destroy() - def AddRaster(self, event): self.notebook.SetSelection(0) self.curr_page.maptree.AddLayer('raster') @@ -696,6 +706,11 @@ self.notebook.SetSelection(0) self.curr_page.maptree.AddLayer('his') + def AddShaded(self, event): + """Add shaded relief map layer""" + self.notebook.SetSelection(0) + self.curr_page.maptree.AddLayer('shaded') + def AddRastarrow(self, event): """Add raster flow arrows map""" self.notebook.SetSelection(0) @@ -736,6 +751,16 @@ self.notebook.SetSelection(0) self.curr_page.maptree.AddLayer('grid') + def AddGeodesic(self, event): + """Add layer geodesic""" + self.notebook.SetSelection(0) + self.curr_page.maptree.AddLayer('geodesic') + + def AddRhumb(self, event): + """Add layer rhumb""" + self.notebook.SetSelection(0) + self.curr_page.maptree.AddLayer('rhumb') + def AddLabels(self, event): """Add layer vector labels""" self.notebook.SetSelection(0) From barton at grass.itc.it Sun Aug 5 20:56:07 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Sun Aug 5 20:56:09 2007 Subject: [grass-addons] r1006 - in trunk/grassaddons/gui: . gui_modules Message-ID: <200708051856.l75Iu7fd020797@grass.itc.it> Author: barton Date: 2007-08-05 20:55:56 +0200 (Sun, 05 Aug 2007) New Revision: 1006 Modified: trunk/grassaddons/gui/gui_modules/render.py trunk/grassaddons/gui/wxgui.py Log: Added raster arrows (d.rast.arrow) layer to layer manager Modified: trunk/grassaddons/gui/gui_modules/render.py =================================================================== --- trunk/grassaddons/gui/gui_modules/render.py 2007-08-05 17:48:36 UTC (rev 1005) +++ trunk/grassaddons/gui/gui_modules/render.py 2007-08-05 18:55:56 UTC (rev 1006) @@ -102,7 +102,7 @@ # # prepare command for each layer # - layertypes = ['raster','rgb','his','shaded','vector','thememap','themechart',\ + layertypes = ['raster','rgb','his','shaded','rastarrow','vector','thememap','themechart',\ 'grid','geodesic','rhumb','labels','command','overlay'] if self.type in layertypes: self.__renderLayer() Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-08-05 17:48:36 UTC (rev 1005) +++ trunk/grassaddons/gui/wxgui.py 2007-08-05 18:55:56 UTC (rev 1006) @@ -628,11 +628,11 @@ rastmenu.AppendItem(addhis) self.Bind(wx.EVT_MENU, self.AddHIS, addhis) - # addrastarrow = wx.MenuItem(rastmenu, -1, Icons ["addrarrow"].GetLabel()) - # addrastarrow.SetBitmap(Icons["addrarrow"].GetBitmap (self.iconsize)) - # rastmenu.AppendItem(addrastarrow) - # self.Bind(wx.EVT_MENU, self.AddRastarrow, addrastarrow) - # + addrastarrow = wx.MenuItem(rastmenu, -1, Icons ["addrarrow"].GetLabel()) + addrastarrow.SetBitmap(Icons["addrarrow"].GetBitmap (self.iconsize)) + rastmenu.AppendItem(addrastarrow) + self.Bind(wx.EVT_MENU, self.AddRastarrow, addrastarrow) + # addrastnums = wx.MenuItem(rastmenu, -1, Icons ["addrnum"].GetLabel()) # addrastnums.SetBitmap(Icons["addrnum"].GetBitmap (self.iconsize)) # rastmenu.AppendItem(addrastnums) From neteler at grass.itc.it Sun Aug 5 22:17:53 2007 From: neteler at grass.itc.it (neteler@grass.itc.it) Date: Sun Aug 5 22:17:55 2007 Subject: [grass-addons] r1007 - trunk/grassaddons/gui Message-ID: <200708052017.l75KHrgm010361@grass.itc.it> Author: neteler Date: 2007-08-05 22:17:50 +0200 (Sun, 05 Aug 2007) New Revision: 1007 Modified: trunk/grassaddons/gui/README Log: Mandriva 2007.1 wxPython package Modified: trunk/grassaddons/gui/README =================================================================== --- trunk/grassaddons/gui/README 2007-08-05 18:55:56 UTC (rev 1006) +++ trunk/grassaddons/gui/README 2007-08-05 20:17:50 UTC (rev 1007) @@ -11,7 +11,9 @@ Get wxPython 2.8.x packages from: * Debian: http://www.bitpim.org/developer.html -> "Install wxPython" * Fedora: - * Mandriva 2007: http://mpa.itc.it/markus/wxpython_rpms/ + * Mandriva 2007.0: http://mpa.itc.it/markus/wxpython_rpms/ + * Mandriva 2007.1 (spring): available from main/backports (see + http://club.mandriva.com/xwiki/bin/view/Downloads/MirrorFinder2 ) * MS-Windows: * SuSe: * Ubuntu: deb http://wxpython.wxcommunity.com/apt/ubuntu/dapper / From barton at grass.itc.it Mon Aug 6 04:44:21 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Mon Aug 6 04:44:24 2007 Subject: [grass-addons] r1008 - trunk/grassaddons/gui Message-ID: <200708060244.l762iLJJ024216@grass.itc.it> Author: barton Date: 2007-08-06 04:44:13 +0200 (Mon, 06 Aug 2007) New Revision: 1008 Modified: trunk/grassaddons/gui/location_wizard.py Log: Improved wizard control and error checking. Bugfix for custom projstring location Modified: trunk/grassaddons/gui/location_wizard.py =================================================================== --- trunk/grassaddons/gui/location_wizard.py 2007-08-05 20:17:50 UTC (rev 1007) +++ trunk/grassaddons/gui/location_wizard.py 2007-08-06 02:44:13 UTC (rev 1008) @@ -56,7 +56,6 @@ global west global resolution global wizerror -global proj4string coordsys = '' north = '' @@ -64,7 +63,6 @@ east = '' west = '' resolution = '' -proj4string = '' class TitledPage(wiz.WizardPageSimple): """ @@ -241,15 +239,11 @@ wx.MessageBox('You must select a coordinate system') event.Veto() -# if coordsys == "xy": -# pass - def SetVal(self,event): global coordsys if event.GetId() == self.radio1.GetId(): coordsys = "proj" self.SetNext(self.parent.projpage) - self.parent.datumpage.SetPrev(self.parent.projpage) elif event.GetId() == self.radio2.GetId(): coordsys = "epsg" self.SetNext(self.parent.epsgpage) @@ -265,6 +259,7 @@ elif event.GetId() == self.radio5.GetId(): coordsys = "xy" self.SetNext(self.parent.sumpage) + set.parent.sumpage.SetPrev(self.parent.csystemspage) class ProjectionsPage(TitledPage): """ @@ -327,8 +322,8 @@ self._onBrowseProj(None, None) def OnPageChange(self,event): - if not self.proj: - wx.MessageBox('You must select a projection') + if event.GetDirection() and self.proj not in self.parent.projections: + wx.MessageBox('You must select a valid projection in order to continue') event.Veto() if self.proj == 'utm': self.parent.projtypepage.text_utm.SetEditable(True) @@ -404,41 +399,62 @@ self.radio1 = wx.RadioButton( self, -1, " Select datum with associated ellipsoid", style = wx.RB_GROUP ) self.radio2 = wx.RadioButton( self, -1, " Select ellipsoid" ) - - # layout - self.sizer.Add(self.radio1, 0, wx.ALIGN_LEFT, row=1, col=2) - self.sizer.Add(self.radio2, 0, wx.ALIGN_LEFT, row=2, col=2) - self.title_utm = self.MakeLLabel("Set zone for UTM projection") self.text_utm = self.MakeTextCtrl(size=(100,-1)) self.label_utm = self.MakeRLabel("Zone: ") self.hemisphere = wx.Choice(self, -1, (100, 50), choices = self.hemischoices) self.label_hemisphere = self.MakeRLabel("Hemisphere for zone: ") + # layout + self.sizer.Add(self.radio1, 0, wx.ALIGN_LEFT, row=1, col=2) + self.sizer.Add(self.radio2, 0, wx.ALIGN_LEFT, row=2, col=2) self.sizer.Add(self.title_utm, 0, wx.ALIGN_LEFT|wx.ALL, 5, row=4,col=2) self.sizer.Add(self.label_utm, 0, wx.ALIGN_RIGHT|wx.ALL, 5, row=5,col=1) self.sizer.Add(self.text_utm, 0, wx.ALIGN_LEFT|wx.ALL, 5, row=5,col=2) self.sizer.Add(self.label_hemisphere, 0, wx.ALIGN_RIGHT|wx.ALL, 5, row=6,col=1) self.sizer.Add(self.hemisphere, 0, wx.ALIGN_LEFT|wx.ALL, 5, row=6,col=2) + self.title_utm.Hide() + self.text_utm.Hide() + self.label_utm.Hide() + self.hemisphere.Hide() + self.label_hemisphere.Hide() + # bindings self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.radio1.GetId()) self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.radio2.GetId()) - self.Bind(wx.EVT_CHOICE, self.OnHemisphere, self.hemisphere) - self.Bind(wx.EVT_TEXT, self.GetUTM, self.text_utm) self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnPageChange) + self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage) def OnPageChange(self,event=None): - if self.parent.projpage.proj == 'utm' and self.utmzone == '': + if event.GetDirection() and self.parent.projpage.proj == 'utm' and self.utmzone == '': wx.MessageBox('You must set a zone for a UTM projection') event.Veto() + self.title_utm.Hide() + self.text_utm.Hide() + self.label_utm.Hide() + self.hemisphere.Hide() + self.label_hemisphere.Hide() + def OnEnterPage(self,event): + if self.parent.projpage.proj == 'utm': + self.title_utm.Show() + self.text_utm.Show() + self.label_utm.Show() + self.hemisphere.Show() + self.label_hemisphere.Show() + + self.Bind(wx.EVT_CHOICE, self.OnHemisphere, self.hemisphere) + self.Bind(wx.EVT_TEXT, self.GetUTM, self.text_utm) + def SetVal(self, event): global coordsys if event.GetId() == self.radio1.GetId(): self.SetNext(self.parent.datumpage) + self.parent.sumpage.SetPrev(self.parent.datumpage) elif event.GetId() == self.radio2.GetId(): self.SetNext(self.parent.ellipsepage) + self.parent.sumpage.SetPrev(self.parent.ellipsepage) def GetUTM(self, event): self.utmzone = event.GetString() @@ -558,17 +574,16 @@ def OnPageChange(self,event): self.proj4params = '' - if not self.datum: - wx.MessageBox('You must select a datum') + if event.GetDirection() and self.datum not in self.parent.datums: + wx.MessageBox('You must select a valid datum in order to continue') event.Veto() # if self.hastransform == True and self.transform == '': # wx.MessageBox('You must select a datum transform') # event.Veto() self.GetNext().SetPrev(self) self.parent.ellipsepage.ellipseparams = self.parent.ellipsoids[self.ellipsoid][1] + self.GetNext().SetPrev(self) - global proj4string - def OnDText(self, event): self.datum = event.GetString() if self.datum in self.parent.datums: @@ -745,16 +760,17 @@ def OnPageChange(self,event): self.proj4params = '' - if not self.ellipse: - wx.MessageBox('You must select an ellipse') + if event.GetDirection() and self.ellipse not in self.parent.ellipsoids: + wx.MessageBox('You must select a valid ellipsoid in order to continue') event.Veto() self.GetNext().SetPrev(self) self.parent.datumpage.datumparams = '' self.parent.datumpage.transparams = '' + self.GetNext().SetPrev(self) def OnText(self, event): self.ellipse = event.GetString() - if self.ellipse in self.parent.ellipseoids: + if self.ellipse in self.parent.ellipsoids: self.ellipsedesc = self.parent.ellipsoids[self.ellipse][0] self.ellipseparams = self.parent.ellipsoids[self.ellipse][1] @@ -840,8 +856,8 @@ self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnPageChange) def OnPageChange(self, event): - if self.georeffile == '': - wx.MessageBox('You must select a file') + if event.GetDirection() and self.georeffile == '': + wx.MessageBox('You must select a georeferenced file in order to continue') event.Veto() self.GetNext().SetPrev(self) @@ -944,7 +960,7 @@ self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnPageChange) def OnPageChange(self, event): - if not self.epsgcode: + if event.GetDirection() and not self.epsgcode: wx.MessageBox('You must select an EPSG code') event.Veto() self.GetNext().SetPrev(self) @@ -965,7 +981,6 @@ self.OnBrowseCodes(None,str) - def OnBrowse(self, event): dlg = wx.FileDialog(self, "Choose EPSG codes file:", @@ -1037,14 +1052,11 @@ def __init__(self, wizard, parent): TitledPage.__init__(self, wizard, "Choose method of specifying georeferencing parameters") global coordsys - self.proj4string = '' + self.customstring = '' self.parent = parent self.text_proj4string = self.MakeTextCtrl(size=(400,100)) self.label_proj4string = self.MakeRLabel("Enter PROJ.4 parameters string: ") - if proj4string: - self.text_proj4string.SetValue(proj4string) - self.sizer.Add(self.label_proj4string, 0, wx.ALIGN_RIGHT|wx.ALL, 5, row=5,col=1) self.sizer.Add(self.text_proj4string, 0, wx.ALIGN_LEFT|wx.ALL, 5, row=5,col=2) @@ -1052,14 +1064,13 @@ self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnPageChange) def OnPageChange(self, event): - if not self.proj4string: + if event.GetDirection() and not self.customstring: wx.MessageBox('You must enter a PROJ.4 string') event.Veto() self.GetNext().SetPrev(self) def GetProjstring(self, event): - proj4string - self.proj4string = event.GetString() + self.customstring = event.GetString() class SummaryPage(TitledPage): @@ -1137,7 +1148,7 @@ label = ('XY coordinate system. Not projected') self.lprojection.SetLabel(label) elif coordsys == 'custom': - label = ('%s' % self.custompage.proj4string) + label = ('%s' % self.parent.custompage.customstring) self.lprojection.SetLabel(label) class RegionDef(wx.Frame): @@ -1469,10 +1480,11 @@ self.startpage.SetNext(self.csystemspage) self.csystemspage.SetPrev(self.startpage) - self.csystemspage.SetNext(self.sumpage) + self.projpage.SetPrev(self.csystemspage) + self.projpage.SetNext(self.projtypepage) + self.projtypepage.SetPrev(self.projpage) - self.projtypepage.SetNext(self.datumpage) self.datumpage.SetPrev(self.projtypepage) self.datumpage.SetNext(self.sumpage) @@ -1480,9 +1492,6 @@ self.ellipsepage.SetPrev(self.projtypepage) self.ellipsepage.SetNext(self.sumpage) - self.projpage.SetPrev(self.csystemspage) - self.projpage.SetNext(self.projtypepage) - self.epsgpage.SetPrev(self.csystemspage) self.epsgpage.SetNext(self.sumpage) @@ -1524,7 +1533,7 @@ database = self.startpage.grassdatabase location = self.startpage.location global coordsys - success = '' + success = False # wx.MessageBox("finished database: %s, location: %s, coordsys: %s" % (database, location, coordsys)) if os.path.isdir(os.path.join(database,location)): @@ -1545,7 +1554,7 @@ elif coordsys == "proj": success = self.Proj4Create() elif coordsys == 'custom': - success - self.CustomCreate + success = self.CustomCreate() elif coordsys == "epsg": success = self.EPSGCreate() elif coordsys == "file": @@ -1679,8 +1688,9 @@ # Creating location from PROJ.4 string passed to g.proj try: cmdlist = ['g.proj', '-c', 'proj4=%s' % proj4string, 'location=%s' % location] - cmd.Command(cmdlist) - return True + p = cmd.Command(cmdlist) + if p == 0: + return True except StandardError, e: dlg = wx.MessageDialog(self.wizard, "Could not create new location: %s " % str(e), @@ -1690,7 +1700,7 @@ return False def CustomCreate(self): - proj4string = self.custompage.proj4string + proj4string = self.custompage.customstring location = self.startpage.location dlg = wx.MessageDialog(self.wizard, "New location '%s' will be created using PROJ.4 string: %s" @@ -1705,8 +1715,9 @@ try: cmdlist = ['g.proj','-c','proj4=%s' % proj4string,'location=%s' % location] - cmd.Command(cmdlist) - return True + p = cmd.Command(cmdlist) + if p == 0: + return True except StandardError, e: dlg = wx.MessageDialog(self.wizard, "Could not create new location: %s " % str(e), @@ -1772,8 +1783,9 @@ else: cmdlist = ['g.proj','-c','epsg=%s' % epsgcode,'location=%s' % location,'datumtrans=1'] - cmd.Command(cmdlist) - return True + p = cmd.Command(cmdlist) + if p == 0: + return True except StandardError, e: dlg = wx.MessageDialog(self.wizard, "Could not create new location: %s " % str(e), @@ -1817,8 +1829,9 @@ # creating location try: cmdlist = ['g.proj','-c','georef=%s' % georeffile,'location=%s' % location] - cmd.Command(cmdlist) - return True + p = cmd.Command(cmdlist) + if p == 0: + return True except StandardError, e: dlg = wx.MessageDialog(self.wizard, "Could not create new location: %s " % str(e), From barton at grass.itc.it Mon Aug 6 06:00:10 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Mon Aug 6 06:00:12 2007 Subject: [grass-addons] r1009 - trunk/grassaddons/gui Message-ID: <200708060400.l7640AGb026472@grass.itc.it> Author: barton Date: 2007-08-06 06:00:02 +0200 (Mon, 06 Aug 2007) New Revision: 1009 Modified: trunk/grassaddons/gui/location_wizard.py Log: Fix for bugs introduced in last update. Also, now behaves properly if g.proj fails or if "No" is pressed in the final dialog. Modified: trunk/grassaddons/gui/location_wizard.py =================================================================== --- trunk/grassaddons/gui/location_wizard.py 2007-08-06 02:44:13 UTC (rev 1008) +++ trunk/grassaddons/gui/location_wizard.py 2007-08-06 04:00:02 UTC (rev 1009) @@ -235,7 +235,7 @@ def OnPageChange(self,event=None): global coordsys - if not coordsys: + if event.GetDirection() and not coordsys: wx.MessageBox('You must select a coordinate system') event.Veto() @@ -244,6 +244,7 @@ if event.GetId() == self.radio1.GetId(): coordsys = "proj" self.SetNext(self.parent.projpage) + self.parent.sumpage.SetPrev(self.parent.datumpage) elif event.GetId() == self.radio2.GetId(): coordsys = "epsg" self.SetNext(self.parent.epsgpage) @@ -1480,11 +1481,13 @@ self.startpage.SetNext(self.csystemspage) self.csystemspage.SetPrev(self.startpage) + self.csystemspage.SetNext(self.sumpage) self.projpage.SetPrev(self.csystemspage) self.projpage.SetNext(self.projtypepage) self.projtypepage.SetPrev(self.projpage) + self.projtypepage.SetNext(self.datumpage) self.datumpage.SetPrev(self.projtypepage) self.datumpage.SetNext(self.sumpage) @@ -1501,6 +1504,8 @@ self.custompage.SetPrev(self.csystemspage) self.custompage.SetNext(self.sumpage) + self.sumpage.SetPrev(self.csystemspage) + self.wizard.FitToPage(self.datumpage) self.location = None #New location created @@ -1603,20 +1608,22 @@ 'n-s resol3: 1', 't-b resol: 1'] - defwind = open(os.path.join(database,location,"PERMANENT","DEFAULT_WIND"),'w') - for param in regioninfo: - defwind.write(param+'\n') - defwind.close() - shutil.copy(os.path.join(database,location,"PERMANENT","DEFAULT_WIND"),\ - os.path.join(database,location,"PERMANENT","WIND")) + try: + defwind = open(os.path.join(database,location,"PERMANENT","DEFAULT_WIND"),'w') + for param in regioninfo: + defwind.write(param+'\n') + defwind.close() + shutil.copy(os.path.join(database,location,"PERMANENT","DEFAULT_WIND"),\ + os.path.join(database,location,"PERMANENT","WIND")) - #Make MYNAME file - myname = open(os.path.join(database,location,"PERMANENT","MYNAME"),'w') - myname.write('') - myname.close() - return True + #Make MYNAME file + myname = open(os.path.join(database,location,"PERMANENT","MYNAME"),'w') + myname.write('') + myname.close() + return True + except: + return False - def Proj4Create(self): """ Create a new location for selected projection @@ -1689,8 +1696,10 @@ try: cmdlist = ['g.proj', '-c', 'proj4=%s' % proj4string, 'location=%s' % location] p = cmd.Command(cmdlist) - if p == 0: + if p.module.returncode == 0: return True + else: + return False except StandardError, e: dlg = wx.MessageDialog(self.wizard, "Could not create new location: %s " % str(e), @@ -1716,8 +1725,10 @@ try: cmdlist = ['g.proj','-c','proj4=%s' % proj4string,'location=%s' % location] p = cmd.Command(cmdlist) - if p == 0: + if p.module.returncode == 0: return True + else: + return False except StandardError, e: dlg = wx.MessageDialog(self.wizard, "Could not create new location: %s " % str(e), @@ -1784,8 +1795,10 @@ cmdlist = ['g.proj','-c','epsg=%s' % epsgcode,'location=%s' % location,'datumtrans=1'] p = cmd.Command(cmdlist) - if p == 0: + if p.module.returncode == 0: return True + else: + return False except StandardError, e: dlg = wx.MessageDialog(self.wizard, "Could not create new location: %s " % str(e), @@ -1830,8 +1843,10 @@ try: cmdlist = ['g.proj','-c','georef=%s' % georeffile,'location=%s' % location] p = cmd.Command(cmdlist) - if p == 0: + if p.module.returncode == 0: return True + else: + return False except StandardError, e: dlg = wx.MessageDialog(self.wizard, "Could not create new location: %s " % str(e), From barton at grass.itc.it Mon Aug 6 06:41:30 2007 From: barton at grass.itc.it (barton@grass.itc.it) Date: Mon Aug 6 06:41:31 2007 Subject: [grass-addons] r1010 - in trunk/grassaddons/gui: . gui_modules Message-ID: <200708060441.l764fUPr026614@grass.itc.it> Author: barton Date: 2007-08-06 06:41:16 +0200 (Mon, 06 Aug 2007) New Revision: 1010 Modified: trunk/grassaddons/gui/gui_modules/menuform.py trunk/grassaddons/gui/gui_modules/wxgui_utils.py trunk/grassaddons/gui/wxgui.py Log: gmpath argument no longer used by menuform. Removed. Modified: trunk/grassaddons/gui/gui_modules/menuform.py =================================================================== --- trunk/grassaddons/gui/gui_modules/menuform.py 2007-08-06 04:00:02 UTC (rev 1009) +++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-08-06 04:41:16 UTC (rev 1010) @@ -549,8 +549,8 @@ except ValueError: self.SetStatusText( status_text ) - - + + # buttons btnsizer = wx.BoxSizer(orient=wx.HORIZONTAL) # cancel @@ -1081,7 +1081,7 @@ def __init__(self, parent=-1): self.parent = parent - def ParseCommand(self, cmd, gmpath, completed=None, parentframe=-1, modal=False): + def ParseCommand(self, cmd, gmpath=None, completed=None, parentframe=-1, modal=False): """ Parse command @@ -1115,7 +1115,7 @@ self.grass_task.params = dcmd_params['params'] if 'flags' in dcmd_params: self.grass_task.flags = dcmd_params['flags'] - + self.mf = mainFrame(parent=self.parent, ID=wx.ID_ANY, task_description=self.grass_task, get_dcmd=get_dcmd, layer=layer) self.mf.Show(True) self.mf.MakeModal(modal) Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py =================================================================== --- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-08-06 04:00:02 UTC (rev 1009) +++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-08-06 04:41:16 UTC (rev 1010) @@ -488,31 +488,31 @@ ltype) if ltype == 'raster': - menuform.GUI().ParseCommand('d.rast', gmpath, completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.rast', completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'rgb': - menuform.GUI().ParseCommand('d.rgb', gmpath, completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.rgb', completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'his': - menuform.GUI().ParseCommand('d.his', gmpath, completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.his', completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'shaded': - menuform.GUI().ParseCommand('d.shadedmap', gmpath, completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.shadedmap', completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'rastarrow': - menuform.GUI().ParseCommand('d.rast.arrow', gmpath, completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.rast.arrow', completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'rastnum': - menuform.GUI().ParseCommand('d.rast.num', gmpath, completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.rast.num', completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'vector': - menuform.GUI().ParseCommand('d.vect', gmpath, completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.vect', completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'thememap': - menuform.GUI().ParseCommand('d.vect.thematic', gmpath, completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.vect.thematic', completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'themechart': - menuform.GUI().ParseCommand('d.vect.chart', gmpath, completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.vect.chart', completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'grid': - menuform.GUI().ParseCommand('d.grid', gmpath, completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.grid', completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'geodesic': - menuform.GUI().ParseCommand('d.geodesic', gmpath, completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.geodesic', completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'rhumb': - menuform.GUI().ParseCommand('d.rhumbline', gmpath, completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.rhumbline', completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'labels': - menuform.GUI().ParseCommand('d.labels', gmpath, completed=(self.getOptData,layer,params), parentframe=self) + menuform.GUI().ParseCommand('d.labels', completed=(self.getOptData,layer,params), parentframe=self) elif ltype == 'cmdlayer': pass elif ltype == 'group': @@ -1005,7 +1005,7 @@ self.Parent.Parent.curr_page.maptree.AddLayer(layertype) else: - menuform.GUI().ParseCommand(string.join(cmdlist), gmpath, parentframe=None) + menuform.GUI().ParseCommand(string.join(cmdlist), parentframe=None) self.cmd_output.write(string.join(cmdlist) + "\n----------\n") elif command[0:2] == "d." and len(cmdlist) > 1: Modified: trunk/grassaddons/gui/wxgui.py =================================================================== --- trunk/grassaddons/gui/wxgui.py 2007-08-06 04:00:02 UTC (rev 1009) +++ trunk/grassaddons/gui/wxgui.py 2007-08-06 04:41:16 UTC (rev 1010) @@ -139,7 +139,7 @@ # self.cmdsizer = wx.BoxSizer(wx.HORIZONTAL) # do layout - self.SetTitle(_("GRASS GIS Manager - wxPython Prototype")) + self.SetTitle(_("GRASS Layer Manager")) self.SetMinSize((500, 400)) self.SetIcon(wx.Icon(os.path.join(imagepath,'grass.smlogo.gif'), wx.BITMAP_TYPE_ANY)) @@ -372,7 +372,7 @@ """Run menu command""" cmd = self.GetMenuCmd(event) global gmpath - menuform.GUI().ParseCommand(cmd,gmpath, parentframe=self) + menuform.GUI().ParseCommand(cmd, parentframe=self) def RulesCmd(self, event): """ From ullah at grass.itc.it Mon Aug 6 19:32:13 2007 From: ullah at grass.itc.it (ullah@grass.itc.it) Date: Mon Aug 6 19:32:15 2007 Subject: [grass-addons] r1011 - in trunk/grassaddons/LandDyn: r.landscape.evol r.landscape.evol.itr Message-ID: <200708061732.l76HWDuq004175@grass.itc.it> Author: ullah Date: 2007-08-06 19:32:05 +0200 (Mon, 06 Aug 2007) New Revision: 1011 Modified: trunk/grassaddons/LandDyn/r.landscape.evol.itr/r.landscape.evol.itr trunk/grassaddons/LandDyn/r.landscape.evol/r.landscape.evol Log: Updated color rules for smoothdz maps again to make them more clear. Modified: trunk/grassaddons/LandDyn/r.landscape.evol/r.landscape.evol =================================================================== --- trunk/grassaddons/LandDyn/r.landscape.evol/r.landscape.evol 2007-08-06 04:41:16 UTC (rev 1010) +++ trunk/grassaddons/LandDyn/r.landscape.evol/r.landscape.evol 2007-08-06 17:32:05 UTC (rev 1011) @@ -681,17 +681,15 @@ fi -echo "100% 104 034 139" > $TMP1 -echo "5 violet" >> $TMP1 -echo "3 aqua" >> $TMP1 -echo "1 cyan" >> $TMP1 +echo "100% 0 0 100" > $TMP1 +echo "3 blue" >> $TMP1 +echo "1 indigo" >> $TMP1 echo "0.5 green" >> $TMP1 echo "0 white" >> $TMP1 echo "-0.5 yellow" >> $TMP1 echo "-1 orange" >> $TMP1 echo "-3 red" >> $TMP1 -echo "-5 255 000 255" $TMP1 -echo "-0% 255 000 255" >> $TMP1 +echo "0% 150 0 50" >> $TMP1 echo "end" >> $TMP1 Modified: trunk/grassaddons/LandDyn/r.landscape.evol.itr/r.landscape.evol.itr =================================================================== --- trunk/grassaddons/LandDyn/r.landscape.evol.itr/r.landscape.evol.itr 2007-08-06 04:41:16 UTC (rev 1010) +++ trunk/grassaddons/LandDyn/r.landscape.evol.itr/r.landscape.evol.itr 2007-08-06 17:32:05 UTC (rev 1011) @@ -637,17 +637,15 @@ fi -echo "100% 104 034 139" > $TMP1 -echo "5 violet" >> $TMP1 -echo "3 aqua" >> $TMP1 -echo "1 cyan" >> $TMP1 +echo "100% 0 0 100" > $TMP1 +echo "3 blue" >> $TMP1 +echo "1 indigo" >> $TMP1 echo "0.5 green" >> $TMP1 echo "0 white" >> $TMP1 echo "-0.5 yellow" >> $TMP1 echo "-1 orange" >> $TMP1 echo "-3 red" >> $TMP1 -echo "-5 255 000 255" $TMP1 -echo "-0% 255 000 255" >> $TMP1 +echo "0% 150 0 50" >> $TMP1 echo "end" >> $TMP1 From bundala at grass.itc.it Mon Aug 6 20:54:39 2007 From: bundala at grass.itc.it (bundala@grass.itc.it) Date: Mon Aug 6 20:54:41 2007 Subject: [grass-addons] r1012 - trunk/grassaddons/v.generalize Message-ID: <200708061854.l76IsdXl005775@grass.itc.it> Author: bundala Date: 2007-08-06 20:54:32 +0200 (Mon, 06 Aug 2007) New Revision: 1012 Added: trunk/grassaddons/v.generalize/operators.h Modified: trunk/grassaddons/v.generalize/description.html trunk/grassaddons/v.generalize/displacement.c trunk/grassaddons/v.generalize/main.c trunk/grassaddons/v.generalize/misc.c trunk/grassaddons/v.generalize/pq.c trunk/grassaddons/v.generalize/simplification.c trunk/grassaddons/v.generalize/smoothing.c Log: fix in priority queue, declarations of operators are stored in operators.h, more proper naming conventions Modified: trunk/grassaddons/v.generalize/description.html =================================================================== --- trunk/grassaddons/v.generalize/description.html 2007-08-06 17:32:05 UTC (rev 1011) +++ trunk/grassaddons/v.generalize/description.html 2007-08-06 18:54:32 UTC (rev 1012) @@ -115,8 +115,8 @@ Angle_thresh is used for reducing the number of the outputed points. It denotes the minimal angle (in degrees) between two consecutive segements of line.
@@ -166,12 +166,12 @@ closer than threshold appart.
Modified: trunk/grassaddons/v.generalize/main.c
===================================================================
--- trunk/grassaddons/v.generalize/main.c 2007-08-10 05:15:56 UTC (rev 1020)
+++ trunk/grassaddons/v.generalize/main.c 2007-08-10 12:36:27 UTC (rev 1021)
@@ -35,6 +35,7 @@
#define SNAKES 8
#define DOUGLAS_REDUCTION 9
#define SLIDING_AVERAGING 10
+#define REMOVE_SMALL 11
#define NETWORK 100
#define DISPLACEMENT 101
@@ -91,13 +92,14 @@
method_opt->required = YES;
method_opt->multiple = NO;
method_opt->options =
- "douglas,douglas_reduction,lang,reduction,reumann,boyle,sliding_averaging,distance_weighting,chaiken,hermite,snakes,network,displacement";
+ "douglas,douglas_reduction,lang,reduction,reumann,remove_small,boyle,sliding_averaging,distance_weighting,chaiken,hermite,snakes,network,displacement";
method_opt->answer = "douglas";
method_opt->descriptions = _("douglas;Douglas-Peucker Algorithm;"
"douglas_reduction;Douglas-Peucker Algorithm with reduction parameter;"
"lang;Lang Simplification Algorithm;"
"reduction;Vertex Reduction Algorithm eliminates points close to each other;"
"reumann;Reumann-Witkam Algorithm;"
+ "remove_small;Removes lines shorter than threshold and areas of area less than threshold;"
"boyle;Boyle's Forward-Looking Algorithm;"
"sliding_averaging;McMaster's Sliding Averaging Algorithm;"
"distance_weighting;McMaster's Distance-Weighting Algorithm;"
@@ -258,6 +260,11 @@
method = NETWORK;
else if (strcmp(s, "displacement") == 0)
method = DISPLACEMENT;
+ else if (strcmp(s, "remove_small") == 0) {
+ method = REMOVE_SMALL;
+ /* switch -r flag on */
+ rs_flag->answer = 1;
+ }
else {
G_fatal_error(_("Unknown method"));
exit(EXIT_FAILURE);
@@ -271,6 +278,7 @@
case LANG:
case VERTEX_REDUCTION:
case REUMANN:
+ case REMOVE_SMALL:
simplification = 1;
break;
default:
From barton at grass.itc.it Sat Aug 11 00:17:05 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Sat Aug 11 00:17:07 2007
Subject: [grass-addons] r1022 - trunk/grassaddons/gui/gui_modules
Message-ID: <200708102217.l7AMH55W024860@grass.itc.it>
Author: barton
Date: 2007-08-11 00:16:58 +0200 (Sat, 11 Aug 2007)
New Revision: 1022
Modified:
trunk/grassaddons/gui/gui_modules/render.py
Log:
Remove debugging code.
Modified: trunk/grassaddons/gui/gui_modules/render.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/render.py 2007-08-10 12:36:27 UTC (rev 1021)
+++ trunk/grassaddons/gui/gui_modules/render.py 2007-08-10 22:16:58 UTC (rev 1022)
@@ -413,8 +413,6 @@
string usable for GRASS_REGION variable or None
"""
- print "in setregion"
-
grass_region = ""
self.region = self.__adjustRegion()
From bundala at grass.itc.it Tue Aug 14 00:20:21 2007
From: bundala at grass.itc.it (bundala@grass.itc.it)
Date: Tue Aug 14 00:20:24 2007
Subject: [grass-addons] r1023 - trunk/grassaddons/v.generalize
Message-ID: <200708132220.l7DMKLG7010324@grass.itc.it>
Author: bundala
Date: 2007-08-14 00:20:17 +0200 (Tue, 14 Aug 2007)
New Revision: 1023
Modified:
trunk/grassaddons/v.generalize/main.c
Log:
fixed: bug in displacement
Modified: trunk/grassaddons/v.generalize/main.c
===================================================================
--- trunk/grassaddons/v.generalize/main.c 2007-08-10 22:16:58 UTC (rev 1022)
+++ trunk/grassaddons/v.generalize/main.c 2007-08-13 22:20:17 UTC (rev 1023)
@@ -258,8 +258,11 @@
method = SLIDING_AVERAGING;
else if (strcmp(s, "network") == 0)
method = NETWORK;
- else if (strcmp(s, "displacement") == 0)
+ else if (strcmp(s, "displacement") == 0) {
method = DISPLACEMENT;
+ /* we can displace only the lines */
+ mask_type = GV_LINE;
+ }
else if (strcmp(s, "remove_small") == 0) {
method = REMOVE_SMALL;
/* switch -r flag on */
From neteler at grass.itc.it Tue Aug 14 10:37:46 2007
From: neteler at grass.itc.it (neteler@grass.itc.it)
Date: Tue Aug 14 10:37:49 2007
Subject: [grass-addons] r1024 - trunk/grassaddons/gui
Message-ID: <200708140837.l7E8bkx3018368@grass.itc.it>
Author: neteler
Date: 2007-08-14 10:37:46 +0200 (Tue, 14 Aug 2007)
New Revision: 1024
Modified:
trunk/grassaddons/gui/README
Log:
new Fedora RPMs from Brad
Modified: trunk/grassaddons/gui/README
===================================================================
--- trunk/grassaddons/gui/README 2007-08-13 22:20:17 UTC (rev 1023)
+++ trunk/grassaddons/gui/README 2007-08-14 08:37:46 UTC (rev 1024)
@@ -12,7 +12,8 @@
* Source: : http://www.wxpython.org/download.php
* Debian: http://www.bitpim.org/developer.html -> "Install wxPython"
* Fedora: http://www.wxpython.org/download.php
- * Mandriva 2007.0: http://mpa.itc.it/markus/wxpython_rpms/
+ http://mpa.itc.it/markus/wxpython_rpms/fedora/
+ * Mandriva 2007.0: http://mpa.itc.it/markus/wxpython_rpms/mandriva2007.0/
* Mandriva 2007.1 (spring): available from main/backports (see
http://club.mandriva.com/xwiki/bin/view/Downloads/MirrorFinder2 )
Also http://www.wxpython.org/download.php
From barton at grass.itc.it Thu Aug 16 07:45:25 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Thu Aug 16 07:45:26 2007
Subject: [grass-addons] r1025 - trunk/grassaddons/gui/gui_modules
Message-ID: <200708160545.l7G5jPX3017099@grass.itc.it>
Author: barton
Date: 2007-08-16 07:45:16 +0200 (Thu, 16 Aug 2007)
New Revision: 1025
Modified:
trunk/grassaddons/gui/gui_modules/render.py
Log:
removed more temporary debugging code
Modified: trunk/grassaddons/gui/gui_modules/render.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/render.py 2007-08-14 08:37:46 UTC (rev 1024)
+++ trunk/grassaddons/gui/gui_modules/render.py 2007-08-16 05:45:16 UTC (rev 1025)
@@ -235,7 +235,6 @@
"""
Reads current region settings from g.region command
"""
- print "in initregion"
#
# setting region
@@ -382,7 +381,6 @@
Example:
{"n":"4928010", "s":"4913700", "w":"589980",...}
"""
- print "in getregion"
region = {}
@@ -404,13 +402,15 @@
return region
- def SetRegion(self):
+ def SetRegion(self, windres=False):
"""
Render string for GRASS_REGION env. variable, so that the images will be rendered
from desired zoom level.
Returns:
string usable for GRASS_REGION variable or None
+ If windres set to True, uses resolution from WIND file rather than display
+ (for modules that require set resolution like d.rast.num)
"""
grass_region = ""
From landa at grass.itc.it Thu Aug 16 09:50:01 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Thu Aug 16 09:50:03 2007
Subject: [grass-addons] r1026 - trunk/grassaddons/gui
Message-ID: <200708160750.l7G7o1C7018147@grass.itc.it>
Author: landa
Date: 2007-08-16 09:49:42 +0200 (Thu, 16 Aug 2007)
New Revision: 1026
Modified:
trunk/grassaddons/gui/README
Log:
Debian GNU/Linux installation notes updated
Modified: trunk/grassaddons/gui/README
===================================================================
--- trunk/grassaddons/gui/README 2007-08-16 05:45:16 UTC (rev 1025)
+++ trunk/grassaddons/gui/README 2007-08-16 07:49:42 UTC (rev 1026)
@@ -1,7 +1,8 @@
GRASS graphical user interface
==============================
-AUTHORS: Jachym, Michael, MartinL
+AUTHORS: Michael Barton, Jachym Cepicky, Martin Landa
+
$LastChangedDate$
---------------------------------------------------------------------
@@ -9,8 +10,10 @@
Python >=2.4 and wxPython >=2.8.1.1
Get wxPython 2.8.x packages from:
- * Source: : http://www.wxpython.org/download.php
- * Debian: http://www.bitpim.org/developer.html -> "Install wxPython"
+ * Source: http://www.wxpython.org/download.php
+ * Debian GNU/Linux: http://wiki.wxpython.org/InstallingOnUbuntuOrDebian
+ [ deb http://apt.wxwidgets.org/ etch-wx main ]
+ http://www.bitpim.org/developer.html -> "Install wxPython"
* Fedora: http://www.wxpython.org/download.php
http://mpa.itc.it/markus/wxpython_rpms/fedora/
* Mandriva 2007.0: http://mpa.itc.it/markus/wxpython_rpms/mandriva2007.0/
From barton at grass.itc.it Thu Aug 16 18:15:01 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Thu Aug 16 18:15:03 2007
Subject: [grass-addons] r1027 - trunk/grassaddons/gui/gui_modules
Message-ID: <200708161615.l7GGF138024776@grass.itc.it>
Author: barton
Date: 2007-08-16 18:14:52 +0200 (Thu, 16 Aug 2007)
New Revision: 1027
Modified:
trunk/grassaddons/gui/gui_modules/render.py
Log:
Code cleanup. Classes changed to new style for Python 2.4+
Modified: trunk/grassaddons/gui/gui_modules/render.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/render.py 2007-08-16 07:49:42 UTC (rev 1026)
+++ trunk/grassaddons/gui/gui_modules/render.py 2007-08-16 16:14:52 UTC (rev 1027)
@@ -22,7 +22,7 @@
import cmd
from debug import Debug as Debug
-class MapLayer:
+class MapLayer(object):
"""
This class serves for storing map layers to be displayed
@@ -166,7 +166,7 @@
else:
return int (self.opacity * 100)
-class Map:
+class Map(object):
"""
This class serves for rendering of output images.
@@ -489,7 +489,7 @@
projinfo['proj'] = "xy"
return projinfo
else:
- return
+ return None
def GetListOfLayers(self, l_type=None, l_mapset=None, l_active=None, l_hidden=None):
"""
From barton at grass.itc.it Thu Aug 16 18:16:36 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Thu Aug 16 18:16:38 2007
Subject: [grass-addons] r1028 - trunk/grassaddons/gui/gui_modules
Message-ID: <200708161616.l7GGGaWk024797@grass.itc.it>
Author: barton
Date: 2007-08-16 18:16:28 +0200 (Thu, 16 Aug 2007)
New Revision: 1028
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
Barscale and legend overlay code improved. Overlay layers not added
until user selects overlay from menubar. Barscale (north arrow only) and
legend now work in latlon locations.
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-08-16 16:14:52 UTC (rev 1027)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-08-16 16:16:28 UTC (rev 1028)
@@ -1494,12 +1494,6 @@
for i in range(len(map_frame_statusbar_fields)):
self.statusbar.SetStatusText(map_frame_statusbar_fields[i], i)
-
- # d.barscale overlay added to rendering overlay list
- self.Map.AddOverlay(0, type='overlay', command=['d.barscale'], l_active=False, l_render=False)
- # d.barscale overlay added to rendering overlay list as placeholder for d.legend
- self.Map.AddOverlay(1, type='overlay', command=['d.barscale'], l_active=False, l_render=False)
-
#
# Init map display
#
@@ -2087,29 +2081,18 @@
ovltype = id = 0 # index for overlay layer in render
- if ovltype not in self.Map.ovlookup:
- self.Map.AddOverlay(ovltype, type='overlay', command='d.barscale', l_active=False, l_render=False)
-
if ovltype in self.params:
params = self.params[ovltype]
else:
params = ''
- # get overlay images (overlay must be active)
- if not self.Map.ovlookup[ovltype].active:
- self.Map.ovlookup[ovltype].active = True
- self.Map.Render(force=True)
+ # If location is latlon, only display north arrow (scale won't work)
+# proj = self.projinfo['proj']
+# if proj == 'll':
+# barcmd = 'd.barscale -n'
+# else:
+# barcmd = 'd.barscale'
- ovldict = self.MapWindow.GetOverlay()
-
- if id not in ovldict:
- return
-
- img = ovldict[id]
-
- if id not in self.ovlcoords:
- self.ovlcoords[id] = [10,10]
-
# decoration overlay control dialog
dlg = DecDialog(self, wx.ID_ANY, _('Scale and North arrow'), size=(350, 200),
style=wx.DEFAULT_DIALOG_STYLE,
@@ -2122,16 +2105,34 @@
dlg.CenterOnScreen()
+# if ovltype not in self.Map.ovlookup:
+# self.Map.AddOverlay(ovltype, type='overlay', command=['d.barscale'], l_active=False, l_render=False)
+
+
# if OK button pressed in decoration control dialog
if dlg.ShowModal() == wx.ID_OK:
if self.ovlchk[id] == True:
+ # get overlay images (overlay must be active)
+ if not self.Map.ovlookup[ovltype].active:
+ self.Map.ovlookup[ovltype].active = True
+ self.Map.Render(force=True)
+
+ ovldict = self.MapWindow.GetOverlay()
+
+ if id not in ovldict:
+ self.MapWindow.UpdateMap()
+ return
+
+ img = ovldict[id]
+
+ if id not in self.ovlcoords:
+ self.ovlcoords[id] = [10,10]
+
self.MapWindow.Draw(self.MapWindow.pdc, drawid=id,
img=img, pdctype='image',
coords=self.ovlcoords[id])
- # update the map canvas
self.MapWindow.UpdateMap()
-
dlg.Destroy()
# close properties dialog if open
@@ -2146,29 +2147,11 @@
"""
ovltype = id = 1 # index for overlay layer in render
- if ovltype not in self.Map.ovlookup:
- self.Map.AddOverlay(ovltype, type='overlay', command='d.barscale', l_active=False, l_render=False)
-
if ovltype in self.params:
params = self.params[ovltype]
else:
params = ''
- # get overlay images (overlay must be active)
- if not self.Map.ovlookup[ovltype].active:
- self.Map.ovlookup[ovltype].active = True
- self.Map.Render(force=True)
-
- ovldict = self.MapWindow.GetOverlay()
-
- if id not in ovldict:
- return
-
- img = ovldict[id]
-
- if id not in self.ovlcoords:
- self.ovlcoords[id] = [10,10]
-
# Decoration overlay control dialog
dlg = DecDialog(self, wx.ID_ANY, 'Legend', size=(350, 200),
style=wx.DEFAULT_DIALOG_STYLE,
@@ -2184,10 +2167,27 @@
# If OK button pressed in decoration control dialog
val = dlg.ShowModal()
if val == wx.ID_OK:
+
if self.ovlchk[id] == True:
+ # get overlay images (overlay must be active)
+ if not self.Map.ovlookup[ovltype].active:
+ self.Map.ovlookup[ovltype].active = True
+ self.Map.Render(force=True)
+
+ ovldict = self.MapWindow.GetOverlay()
+
+ if id not in ovldict:
+ self.MapWindow.UpdateMap()
+ return
+
+ img = ovldict[id]
+
+ if id not in self.ovlcoords:
+ self.ovlcoords[id] = [10,10]
+
self.MapWindow.Draw(self.MapWindow.pdc, drawid=id,
- img=img, pdctype='image',
- coords=self.ovlcoords[id])
+ img=img, pdctype='image',
+ coords=self.ovlcoords[id])
self.MapWindow.UpdateMap()
dlg.Destroy()
@@ -2234,10 +2234,13 @@
# delete object if if it has no text
if maptext == '':
- self.MapWindow.pdc.ClearId(id)
- self.MapWindow.pdc.RemoveId(id)
- del self.MapWindow.textdict[id]
- del self.ovlcoords[id]
+ try:
+ self.MapWindow.pdc.ClearId(id)
+ self.MapWindow.pdc.RemoveId(id)
+ del self.MapWindow.textdict[id]
+ del self.ovlcoords[id]
+ except:
+ pass
return
self.MapWindow.pdc.ClearId(id)
@@ -2310,6 +2313,9 @@
self.ovlchk = self.parent.MapWindow.ovlchk
self.params = params #previously set decoration options to pass back to options dialog
+ if self.ovltype not in self.parent.Map.ovlookup:
+ self.parent.Map.AddOverlay(self.ovltype, type='overlay', command=[self.ovlcmd], l_active=False, l_render=False)
+
#self.MakeModal(True)
sizer = wx.BoxSizer(wx.VERTICAL)
@@ -2364,6 +2370,7 @@
"""
Sets option for decoration map overlays
"""
+
# display properties dialog (modal mode)
menuform.GUI().ParseCommand(self.ovlcmd, gmpath,
completed=(self.parent.GetOptData, self.ovltype, self.params),
From barton at grass.itc.it Thu Aug 16 19:18:55 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Thu Aug 16 19:18:57 2007
Subject: [grass-addons] r1029 - trunk/grassaddons/gui
Message-ID: <200708161718.l7GHItro025368@grass.itc.it>
Author: barton
Date: 2007-08-16 19:18:47 +0200 (Thu, 16 Aug 2007)
New Revision: 1029
Modified:
trunk/grassaddons/gui/wxgrass
Log:
Updated wxgrass startup script so that it runs non-modally
Modified: trunk/grassaddons/gui/wxgrass
===================================================================
--- trunk/grassaddons/gui/wxgrass 2007-08-16 16:16:28 UTC (rev 1028)
+++ trunk/grassaddons/gui/wxgrass 2007-08-16 17:18:47 UTC (rev 1029)
@@ -5,12 +5,12 @@
exit 1
fi
-SYSTEM=`uname -s`
+#SYSTEM=`uname -s`
-if [ "$SYSTEM" = "Darwin" ] ; then
- pythonw "$GISBASE/etc/wx/wxgui.py" -name wxgui_py
-else
- python "$GISBASE/etc/wx/wxgui.py" -name wxgui_py
-fi
+#if [ "$SYSTEM" = "Darwin" ] ; then
+# pythonw "$GISBASE/etc/wx/wxgui.py" -name wxgui_py
+#else
+ python "$GISBASE/etc/wx/wxgui.py" -name wxgui_py &
+#fi
exit 0
From bundala at grass.itc.it Fri Aug 17 00:01:12 2007
From: bundala at grass.itc.it (bundala@grass.itc.it)
Date: Fri Aug 17 00:01:14 2007
Subject: [grass-addons] r1030 - trunk/grassaddons/v.generalize
Message-ID: <200708162201.l7GM1CRA027822@grass.itc.it>
Author: bundala
Date: 2007-08-17 00:01:10 +0200 (Fri, 17 Aug 2007)
New Revision: 1030
Modified:
trunk/grassaddons/v.generalize/smoothing.c
Log:
fixed bug in distance_weighting
Modified: trunk/grassaddons/v.generalize/smoothing.c
===================================================================
--- trunk/grassaddons/v.generalize/smoothing.c 2007-08-16 17:18:47 UTC (rev 1029)
+++ trunk/grassaddons/v.generalize/smoothing.c 2007-08-16 22:01:10 UTC (rev 1030)
@@ -134,7 +134,7 @@
int with_z)
{
POINT p, c, s, tmp;
- int n, i, next, half, j;
+ int n, i, half, j;
double dists, d;
POINT *res;
@@ -153,7 +153,6 @@
point_assign(Points, 0, with_z, &res[0]);
- next = 1;
half = look_ahead / 2;
for (i = half; i + half < n; i++) {
@@ -178,14 +177,13 @@
};
point_scalar(s, slide / dists, &tmp);
point_scalar(c, (double)1.0 - slide, &s);
- point_add(s, tmp, &res[next]);
- next++;
+ point_add(s, tmp, &res[i]);
};
for (i = half; i + half < n; i++) {
- Points->x[i] = res[i - half].x;
- Points->y[i] = res[i - half].y;
- Points->z[i] = res[i - half].z;
+ Points->x[i] = res[i].x;
+ Points->y[i] = res[i].y;
+ Points->z[i] = res[i].z;
};
G_free(res);
From landa at grass.itc.it Fri Aug 17 10:44:57 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Fri Aug 17 10:44:59 2007
Subject: [grass-addons] r1031 - in trunk/grassaddons/gui: . display_driver
Message-ID: <200708170844.l7H8ivBB002882@grass.itc.it>
Author: landa
Date: 2007-08-17 10:43:28 +0200 (Fri, 17 Aug 2007)
New Revision: 1031
Added:
trunk/grassaddons/gui/display_driver/
trunk/grassaddons/gui/display_driver/Makefile
trunk/grassaddons/gui/display_driver/Makefile.in
trunk/grassaddons/gui/display_driver/driver.cc
trunk/grassaddons/gui/display_driver/driver.h
trunk/grassaddons/gui/display_driver/driver.i
Log:
Experimental C++ wxWidgets display driver for digitization tool.
The beta version of digitization tool is still unfinished, now disabled for user.
Added: trunk/grassaddons/gui/display_driver/Makefile
===================================================================
--- trunk/grassaddons/gui/display_driver/Makefile (rev 0)
+++ trunk/grassaddons/gui/display_driver/Makefile 2007-08-17 08:43:28 UTC (rev 1031)
@@ -0,0 +1,34 @@
+PYTHONVERSION=2.4
+
+MODULE_TOPDIR = ../../..
+
+include $(MODULE_TOPDIR)/include/Make/Lib.make
+include $(MODULE_TOPDIR)/include/Make/Doxygen.make
+
+SWIG=swig
+
+CFLAGS=-c -fpic -I/usr/include/python$(PYTHONVERSION) -I./ -I$(ARCH_DISTDIR)/include `wx-config --cxxflags`
+
+LDFLAGS=-shared -L$(ARCH_LIBDIR) -lgrass_vect -lgrass_gis `wx-config --libs`
+
+default: grass6_wxdriver.so
+
+clean:
+ -rm -f *.o *.so grass6_wxdriver_wrap.cxx grass6_wxdriver.py grass6_wxdriver.i grass6_wxdriver.pyc
+
+grass6_wxdriver.i:
+ cat ./driver.i > grass6_wxdriver.i
+ echo "/* auto-generate swig typedef file (with some GRASS functions removed) */" >> grass6_wxdriver.i
+ cat ./driver.h >> grass6_wxdriver.i
+
+grass6_wxdriver_wrap.cxx: grass6_wxdriver.i
+ $(SWIG) -c++ -python -shadow $<
+
+grass6_wxdriver_wrap.o: grass6_wxdriver_wrap.cxx
+ $(CXX) $(CFLAGS) $(INCLUDE_DIRS) $<
+
+driver.o: driver.cc
+ $(CXX) $(CFLAGS) $(INCLUDE_DIRS) $<
+
+grass6_wxdriver.so: grass6_wxdriver_wrap.o driver.o
+ $(CXX) $(LDFLAGS) grass6_wxdriver_wrap.o driver.o -o _grass6_wxdriver.so
Added: trunk/grassaddons/gui/display_driver/Makefile.in
===================================================================
--- trunk/grassaddons/gui/display_driver/Makefile.in (rev 0)
+++ trunk/grassaddons/gui/display_driver/Makefile.in 2007-08-17 08:43:28 UTC (rev 1031)
@@ -0,0 +1,38 @@
+### DEFINITIONS
+
+PYTHONVERSION=@PYVERSION@
+
+### END DEFINITIONS
+
+MODULE_TOPDIR = ../../..
+
+include $(MODULE_TOPDIR)/include/Make/Lib.make
+include $(MODULE_TOPDIR)/include/Make/Doxygen.make
+
+SWIG=swig
+
+CFLAGS=-c -fpic -I/usr/include/python$(PYTHONVERSION) -I./ -I$(ARCH_DISTDIR)/include `wx-config --cxxflags`
+
+LDFLAGS=-shared -L$(ARCH_LIBDIR) -lgrass_vect -lgrass_gis `wx-config --libs`
+
+default: grass6_wxdriver.so
+
+clean:
+ -rm -f *.o *.so grass6_wxdriver_wrap.cxx grass6_wxdriver.py grass6_wxdriver.i grass6_wxdriver.pyc
+
+grass6_wxdriver.i:
+ cat ./driver.i > grass6_wxdriver.i
+ echo "/* auto-generate swig typedef file (with some GRASS functions removed) */" >> grass6_wxdriver.i
+ cat ./driver.h >> grass6_wxdriver.i
+
+grass6_wxdriver_wrap.cxx: grass6_wxdriver.i
+ $(SWIG) -c++ -python -shadow $<
+
+grass6_wxdriver_wrap.o: grass6_wxdriver_wrap.cxx
+ $(CXX) $(CFLAGS) $(INCLUDE_DIRS) $<
+
+driver.o: driver.cc
+ $(CXX) $(CFLAGS) $(INCLUDE_DIRS) $<
+
+grass6_wxdriver.so: grass6_wxdriver_wrap.o driver.o
+ $(CXX) $(LDFLAGS) grass6_wxdriver_wrap.o driver.o -o _grass6_wxdriver.so
Added: trunk/grassaddons/gui/display_driver/driver.cc
===================================================================
--- trunk/grassaddons/gui/display_driver/driver.cc (rev 0)
+++ trunk/grassaddons/gui/display_driver/driver.cc 2007-08-17 08:43:28 UTC (rev 1031)
@@ -0,0 +1,400 @@
+/**
+ \file driver.cc
+
+ \brief Experimental C++ wxWidgets display driver
+
+ This driver is designed for wxPython GRASS GUI.
+ Displays vector map layers when Digitization tool is
+ activated.
+
+ \author Martin Landa
@@ -200,20 +203,20 @@
-Also, the outputed network may not be connected if the value of betweeness_thresh +Also, the outputed network may not be connected if the value of betweeness_thresh is too large.

This tutorial presents and explains the functionality of GRASS vector module v.generalize. +This module implements generalization operators for GRASS vector maps. The topics +covered in this tutorial are: simplification, smoothing, network generalization and +displacement. For the basic introduction to these operators chech the module's man pages +or for the exhausting introduction check McMaster and Shea (TODO: add reference). +
++It is recommended to read the official man page before reading this document, or read +these two documents at the same time since this tutorial does not contain the +(detail) descriptions of input parameters whereas the man page has very few examples +and no pictures at all. (Even the author of module and both of the documents must have consult the man page several times....) +This document is also meant to be a "report" showing the work done during the Google Summer of Code 2007. +
++Most of the examples in this text work with Spearfish dataset, which can +be downloaded here. Also, this +tutorial assumes that the user is already running GRASS session with the Spearfish +location and a monitor loaded. Also, if you click on any picture, it is shown in the full size. +
++All the algorithms presented in this document (try to) preserve the topology +of the input maps. This means, for example, that the smoothing and simplification methods +never remove the first and last points of lines and that displacement preserves the junctions. +
+ ++v.generalize implements many simplification algorithms. The most widely used +is Douglas-Peucker algorithm (TODO: reference). We can apply this algorithm to +any vector map in the following way: + +
+v.generalize input=roads output=roads_douglas method=douglas threshold=50 +
+Number of vertices was reduced from 5468 to 2107[38%] +
+d.vect roads +d.vect roads_douglas col=blue +

+The amount of the details removed can be specified by parameter: threshold. It is the +case that the output map has fewer vertices and details for greater values of threshold. +For example, if we run +
+v.generalize input=roads output=roads_douglas method=douglas threshold=200 --overwrite +
+v.generalize -r input=roads output=roads_douglas method=douglas threshold=200 --overwrite +

+It is also possible remove small lines/areas only (without any simplification). This is achieved +by method=remove_small: +
+v.generalize input=roads output=roads_remove_small method=remove_small threshold=200 +

+Douglas-Peucker Algorithm has very reasonable results, but it is very hard to find(guess) the +right value of threshold. Moreover, it is also impossible to simplify each line to (for example) 40%. +Exactly for such cases, v.generalize provides method=douglas_reduction. This algorithm +is a modification of Douglas-Peucker Algorithm which takes another paratemer reduction +which denotes (approximate) simplification of lines. For example, +
+v.generalize input=roads output=roads_douglas_reduction method=douglas_reduction threshold=0 reduction=50 --overwrite +d.erase +d.vect roads_douglas_reduction +

+v.generalize input=in output=out method=douglas threshold=eps +v.generalize input=in output=out method=douglas_reduction threshold=eps reduction=100 +
+Another algorithm implemented in this modules is "Vertex Reduction". This algorithm removes +the consecutive poins (on the same line) which are closer to each other than threshold. For example, +
+v.generalize input=in output=out method=reduction threshold=0 +
+The following four pictures show the results obtained by Reumann, Douglas, Lang
+and Vertex Reduction algorithm resp. The algorithms were run with threshold set to 50
+and Lang algorithm with look_ahead=7. The map produced by Reumann-Witkam algorithm contains 2522[46%] points,
+Douglas: 2107[38%] points, Lang: 2160[39%] and Vertex Reduction: 4296[78%].
+




+v.generalize also supports many smoothing algorithm. For basic descriptions, please +consult the man page. +
++Probably, the best results are produced by "Chaiken", "Hermite" and "Snakes" algorithms/methods. +However, the remaining algorithms may also produce very reasonable results. Although +the Chaiken and Hermite methods may produce the maps with a lot of new points, the methods +presented above (simplification) provide a good tool for tackling this problem. +
++If we run the following command +
+v.generalize input=roads output=roads_chaiken method=chaiken threshold=1 +

+d.erase +d.vect roads +d.vect roads_chaiken col=blue +


+v.generalize input=roads output=roads_hermite method=hermite threshold=1 +


+The algorithms mentioned above are suitable for smooth approximation of given lines. +On the other hand, if the aim of smoothing is to "straighten" the lines then the better +results are achieved by the other methods. For example, +
+v.generalize input=roads output=roads_sa method=sliding_averaging look_ahead=7 slide=1 +


+Very similar results can be obtained by Distance Weighting Algorithm (method=distance_weighting). +This is not very surprising since these algorithms are almost the same. For example, +the image below shows the outputs of "Distance Weighting Algorithm". The image was generated +by the following sequence of commands +
+v.generalize input=roads output=roads_dw1 method=distance_weighting look_ahead=7 slide=1 +v.generalize input=roads output=roads_dw2 method=distance_weighting look_ahead=7 slide=0.3 +d.erase +d.vect roads +d.vect roads_dw1 col=red +d.vect roads_dw2 col=blue +

+v.generalize input=roads output=roads_snakes method=snakes alpha=1 beta=1 +

+Last smoothing algorithm implemented in this module is "Boyle's Forward-Looking Algorithm" which +is another "straightening" algorithm. +
+v.generalize input=roads output=roads_boyle method=boyle look_ahead=5 +

+If we render entire Spearfish location, we can see in the upper half of the map two interstates which +overlap. This is not logically correct (I hope, they do not evarlap in real) and it is also +considered as an (presentation) error. For solving such problems, v.generalize provides +"dislplacement" method. As the name suggests, this method displaces linear features which are +close to each other so that they do not overlap/collide. Method implemented in this modules (based on Snakes) +has very good results but not very good perfomance. Therefore the calculations may take few(several) minutes. +For this reason, displacement is applied to the simplified lines in this document. +
+v.generalize input=roads output=roads_dr method=douglas_reduction threshold=0 reduction=50 +v.generalize input=roads_dr output=roads_dr_disp method=displacement alpha=0.01 beta=0.01 threshold=100 iterations=35 +

+Network generalization is suitable for selecting "the most important" subnetwork +of a network. For example, to select highways, interstates from a road network. Examples +in this section work with new GRASS default dataset, which can be downloaded +here. +
++If we render map "streets_wake" we really cannot see the streets, but the only +thing we can see is a big black rhombus. We will try to improve this. Firstly, network +generalization requites quite a lot of time and memory. Therefore, we begin with +simplification of "streets_wake": +
+v.generalize input=streets_wake output=streets_rs method=remove_small threshold=50 +
+v.generalize input=streets_rs output=streets_rs_network method=network betweeness_thresh=50 +


+v.generalize has some parameters and flags which affect the general behaviour +of module. +
++The simplest one is -c flag. "C" stands for copy and if this flag is on then the attributes +are copied from the old map to the new map. Note that the attributes of removed features are +dropped. +
++Default behaviour of this module is that the selected algorithm/method is applied to the all +lines/areas. It is possible to apply the most of the algorithms only to the selected features. +This is achieved by "type", "layer", "cats" and "where" parameters. This works for all algorithms +except "Network Generalization" which is always applied to the all features. +For example, the following command applies "Douglas Reduction" algorithm to interstates and highways (cat<3) +and leaves the other lines unaltered. It also copies the attributes +
+v.generalize -c input=roads output=roads_douglas_reduction2 method=douglas_reduction threshold=0 reduction=50 type=line where="cat<3" +
+v.generalize input=soils output=soils_remove_small method=remove_small threshold=200 type=area +
+v.generalize input=roads output=roads_displacement2 method=displacement threshold=75 alpha=0.01 beta=0.01 iterations=20 cats=1 +

+We end up with a complex example of a generalization of "roads" in Spearfish location. +
+#straighten the lines +v.generalize input=roads output=step1 method=snakes alpha=1 beta=1 +#simplification +v.generalize input=step1 output=step2 method=douglas_reduction threshold=0 reduction=55 +#displacement +v.generalize input=step2 output=step3 method=displacement alpha=0.01 beta=0.01 threshold=100 iterations=50 +#remove small areas +v.generalize input=step3 output=step4 method=remove_small threshold=75 +#network generalization +v.generalize input=step4 output=step5 method=network betweeness_thresh=5 closeness_thresh=0.0425 +#smoothing +v.generalize input=step5 output=step6 method=chaiken threshold=1 +#simplification +v.generalize input=step6 output=step7 method=douglas threshold=1 +#remove temporary maps +g.remove vect=step1,step2,step3,step4,step5,step6 +

+TODO +
+ + +Last changed: $Date: 2007/08/20 18:21:12 $
+
+
+
Property changes on: trunk/grassaddons/v.generalize/tutorial/tutorial.html
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.anim.gif
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.anim.gif
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.douglas.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.douglas.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.lang.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.lang.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.net200.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.net200.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.net50.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.net50.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic1.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic1.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic10.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic10.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic11.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic11.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic12.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic12.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic13.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic13.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic14.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic14.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic15.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic15.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic16.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic16.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic2.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic2.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic3.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic3.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic4.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic4.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic5.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic5.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic6.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic6.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic7.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic7.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic8.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic8.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic9.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.pic9.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.douglas.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.douglas.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.lang.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.lang.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.net200.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.net200.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.net50.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.net50.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic1.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic1.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic10.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic10.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic11.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic11.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic12.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic12.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic13.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic13.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic14.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic14.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic15.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic15.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic16.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic16.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic2.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic2.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic3.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic3.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic4.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic4.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic5.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic5.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic6.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic6.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic7.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic7.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic8.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic8.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic9.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.pic9.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.reduction.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.reduction.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.reumann.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.prev.reumann.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.reduction.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.reduction.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/v.generalize/tutorial/v.generalize.reumann.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/v.generalize/tutorial/v.generalize.reumann.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
From neteler at grass.itc.it Mon Aug 20 21:46:18 2007
From: neteler at grass.itc.it (neteler@grass.itc.it)
Date: Mon Aug 20 21:46:20 2007
Subject: [grass-addons] r1043 - trunk/grassaddons/i.pr/PRLIB
Message-ID: <200708201946.l7KJkIIL023361@grass.itc.it>
Author: neteler
Date: 2007-08-20 21:46:17 +0200 (Mon, 20 Aug 2007)
New Revision: 1043
Modified:
trunk/grassaddons/i.pr/PRLIB/training.c
Log:
don't crash on empty file
Modified: trunk/grassaddons/i.pr/PRLIB/training.c
===================================================================
--- trunk/grassaddons/i.pr/PRLIB/training.c 2007-08-20 16:36:06 UTC (rev 1042)
+++ trunk/grassaddons/i.pr/PRLIB/training.c 2007-08-20 19:46:17 UTC (rev 1043)
@@ -6,11 +6,11 @@
structure Training management
*/
-#include
+ v.path.obstacles Computes the visibility graph of a vector map containing lines, areas ( boundaries ) and points. The visibility graph is the graph where the nodes are the end point of the lines, boundaries or simply the points. There is an edge between two nodes if they are 'visible'. Two nodes are visibible if there is no segments in between them, i.e. the edge doesn't intersect any line or boundary in the vector map. This is useful to compute the sortest path in a vector map from any two points. To do this, first you need to compute the visibility graph and from it compute the shortest path using v.net.path or d.path.
+
+If you compute a shortest path after computing the visibility graph you will notice that this path might go through a vertix of a line. If this is not wanted you might to run the map through v.buffer first whith a small value. Example:
+The first argument is the input map. It supports lines, boudaries ( so areas ) and points. For the algorithm to work lines and boundaries must not be intersecting ( that includes overlapping ).
+ Last changed: Date: 03/07/2007
+ Last changed: Date: 23/08/2007
From neteler at grass.itc.it Thu Aug 23 23:10:34 2007
From: neteler at grass.itc.it (neteler@grass.itc.it)
Date: Thu Aug 23 23:10:35 2007
Subject: [grass-addons] r1053 - trunk/grassaddons/v.path.obstacles
Message-ID: <200708232110.l7NLAYtr014275@grass.itc.it>
Author: neteler
Date: 2007-08-23 23:10:32 +0200 (Thu, 23 Aug 2007)
New Revision: 1053
Modified:
trunk/grassaddons/v.path.obstacles/description.html
Log:
close dif tag
Modified: trunk/grassaddons/v.path.obstacles/description.html
===================================================================
--- trunk/grassaddons/v.path.obstacles/description.html 2007-08-23 18:03:48 UTC (rev 1052)
+++ trunk/grassaddons/v.path.obstacles/description.html 2007-08-23 21:10:32 UTC (rev 1053)
@@ -9,7 +9,7 @@
If you compute a shortest path after computing the visibility graph you will notice that this path might go through a vertix of a line. If this is not wanted you might to run the map through v.buffer first whith a small value. Example:
Last changed: Date: 23/08/2007
From barton at grass.itc.it Wed Aug 29 05:26:26 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Wed Aug 29 05:26:28 2007
Subject: [grass-addons] r1056 - trunk/grassaddons/gui
Message-ID: <200708290326.l7T3QQAm006741@grass.itc.it>
Author: barton
Date: 2007-08-29 05:26:06 +0200 (Wed, 29 Aug 2007)
New Revision: 1056
Modified:
trunk/grassaddons/gui/wxgui.py
Log:
Code for georectifier (not yet functional)
Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py 2007-08-24 19:17:29 UTC (rev 1055)
+++ trunk/grassaddons/gui/wxgui.py 2007-08-29 03:26:06 UTC (rev 1056)
@@ -56,7 +56,6 @@
import gui_modules.wxgui_utils as wxgui_utils
import gui_modules.mapdisp as mapdisp
-import gui_modules.render as render
import gui_modules.menudata as menudata
import gui_modules.menuform as menuform
import gui_modules.grassenv as grassenv
@@ -66,6 +65,8 @@
import gui_modules.rules as rules
import gui_modules.utils as utils
import gui_modules.cmd as cmd
+import gui_modules.georect as georect
+
from icons.icon import Icons as Icons
from gui_modules.debug import Debug as Debug
@@ -291,7 +292,8 @@
"""
Launch georectifier module
"""
- pass
+ print 'launch georect'
+ georect.GeorectWizard(self)
def OnMapsets(self, event):
"""
From barton at grass.itc.it Wed Aug 29 05:27:40 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Wed Aug 29 05:27:46 2007
Subject: [grass-addons] r1057 - trunk/grassaddons/gui/gui_modules
Message-ID: <200708290327.l7T3RedQ006761@grass.itc.it>
Author: barton
Date: 2007-08-29 05:27:05 +0200 (Wed, 29 Aug 2007)
New Revision: 1057
Modified:
trunk/grassaddons/gui/gui_modules/georect.py
Log:
Working on georectifier code. Set up is now a wizard.
Modified: trunk/grassaddons/gui/gui_modules/georect.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/georect.py 2007-08-29 03:26:06 UTC (rev 1056)
+++ trunk/grassaddons/gui/gui_modules/georect.py 2007-08-29 03:27:05 UTC (rev 1057)
@@ -30,6 +30,8 @@
import wx
import wx.aui
import wx.lib.filebrowsebutton as filebrowse
+import wx.wizard as wiz
+import wx.lib.rcsizer as rcs
from threading import Thread
try:
@@ -88,6 +90,246 @@
def StartUp(self):
pass
+class TitledPage(wiz.WizardPageSimple):
+ """
+ Class to make wizard pages. Generic methods to make
+ labels, text entries, and buttons.
+ """
+ def __init__(self, parent, title):
+ wiz.WizardPageSimple.__init__(self, parent)
+
+ self.title = wx.StaticText(self,-1,title)
+ self.title.SetFont(wx.Font(13, wx.SWISS, wx.NORMAL, wx.BOLD))
+ self.sizer = wx.BoxSizer(wx.VERTICAL)
+
+# self.sizer = rcs.RowColSizer()
+ tmpsizer = wx.BoxSizer(wx.VERTICAL)
+
+ tmpsizer.Add(self.title, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
+ tmpsizer.AddSpacer(10)
+ tmpsizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 0)
+ tmpsizer.Add(self.sizer, wx.EXPAND)
+
+ self.SetSizer(tmpsizer)
+ self.SetAutoLayout(True)
+ tmpsizer.Fit(self)
+# self.SetSizer(self.sizer)
+# self.sizer.Fit(tmpsizer)
+
+
+ def SwitchLocMapset(self, location, mapset):
+ cmdlst = ['g.mapset','mapset=%s' % mapset,'location=%s' % location,'--q']
+ cmd.Command(cmdlist)
+
+
+class GeorectWizard(object):
+ """
+ Start wizard here and finish wizard here
+ """
+
+ def __init__(self, parent):
+ wizbmp = wx.Image(os.path.join(os.getenv("GISBASE"),"etc","wx","images","wizard.png"), wx.BITMAP_TYPE_PNG)
+ wizbmp.Rescale(250,600)
+ wizbmp = wizbmp.ConvertToBitmap()
+
+ self.parent = parent
+
+ #set environmental variables
+ cmdlist = ['g.gisenv', 'get=GISDBASE']
+ self.grassdatabase = cmd.Command(cmdlist).module_stdout.read().strip()
+
+ cmdlist = ['g.gisenv', 'get=LOCATION_NAME']
+ self.curr_location = cmd.Command(cmdlist).module_stdout.read().strip()
+
+ cmdlist = ['g.gisenv', 'get=MAPSET']
+ self.curr_mapset = cmd.Command(cmdlist).module_stdout.read().strip()
+
+ self.StartDir = os.path.join(self.grassdatabase,self.curr_location)
+ self.maptype = ''
+ self.xy_grassdatabase = ''
+ self.xy_locationPath = ''
+ self.xy_location = ''
+ self.xy_mapset = ''
+ self.xy_mapsetPath = ''
+ self.xy_groupPath = ''
+ self.xy_group = ''
+ self.xy_dispmap = ''
+
+ # define wizard pages
+ self.wizard = wiz.Wizard(parent, -1, "Setup for georectification")
+ self.startpage = LocationPage(self.wizard, self, self.StartDir)
+ self.grouppage = GroupPage(self.wizard, self, self.xy_groupPath)
+ self.mappage = DispMapPage(self.wizard, self, self.curr_location, \
+ self.curr_mapset, self.xy_location, \
+ self.xy_mapset)
+
+ # Set the initial order of the pages
+ self.startpage.SetNext(self.grouppage)
+
+ self.grouppage.SetPrev(self.startpage)
+ self.grouppage.SetNext(self.mappage)
+
+ self.mappage.SetPrev(self.grouppage)
+
+ self.wizard.FitToPage(self.startpage)
+
+ success = False
+
+ if self.wizard.RunWizard(self.startpage):
+ success = self.onWizFinished()
+ if success == True:
+ pass
+ else:
+ wx.MessageBox("Georectifying setup canceled.")
+ else:
+ wx.MessageBox("Georectifying setup canceled.")
+
+# self.wizard.Destroy()
+
+ def onWizFinished(self):
+ return success
+
+class LocationPage(TitledPage):
+ """
+ Set map type (raster or vector) to georectify and
+ select location/mapset of map(s) to georectify.
+ """
+ def __init__(self, wizard, parent, startDir):
+ TitledPage.__init__(self, wizard, "Select map type and location/mapset")
+
+ self.parent = parent
+ self.StartDir = startDir
+
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ self.rb_maptype = wx.RadioBox(self, -1, "Map type to georectify",
+ wx.DefaultPosition, wx.DefaultSize,
+ ['raster','vector'], 2, wx.RA_SPECIFY_COLS)
+ box.Add(self.rb_maptype, 0, wx.ALIGN_CENTER|wx.ALL, 5)
+ self.sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ self.dbb_mapset = filebrowse.DirBrowseButton(
+ self, wx.ID_ANY, size=(450, -1),
+ labelText='Select mapset: ',
+ buttonText='Browse ...',
+ toolTip='Select mapset of maps to georeference',
+ dialogTitle='Mapsets',
+ startDirectory=self.StartDir,
+ changeCallback = self.On_dbb_mapset)
+ box.Add(self.dbb_mapset, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ self.sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+
+ self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.onPageChanging)
+ self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnPageChanged)
+
+ def On_dbb_mapset(self,event):
+ self.parent.xy_mapsetPath = event.GetString()
+ self.StartDir = self.parent.xy_mapsetPath
+ print 'general start =',self.StartDir
+
+ def onPageChanging(self,event=None):
+ if event.GetDirection() and self.parent.xy_mapsetPath == '':
+ wx.MessageBox('You must select a valid location and mapset in order to continue')
+ event.Veto()
+ return
+
+ def OnPageChanged(self,event=None):
+ self.parent.xy_locationPath,self.parent.xy_mapset = os.path.split(self.parent.xy_mapsetPath)
+ self.parent.xy_grassdatabase, self.parent.xy_location = os.path.split(self.parent.xy_locationPath)
+ self.parent.xy_groupPath = os.path.join(self.parent.xy_mapsetPath,'group')
+
+class GroupPage(TitledPage):
+ """
+ Set group to georectify. Create group if desired.
+ """
+ def __init__(self, wizard, parent, startDir):
+ TitledPage.__init__(self, wizard, "Select image/map group to georectify")
+
+ self.parent = parent
+ self.path = ''
+ self.StartDir = startDir
+
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ self.dbb_group = filebrowse.DirBrowseButton(
+ self, wx.ID_ANY, size=(450, -1),
+ labelText='Select group: ',
+ buttonText='Browse ...',
+ toolTip='Select group of images or maps to georeference',
+ dialogTitle='Groups',
+ startDirectory=self.StartDir,
+ changeCallback = self.On_dbb_group)
+ box.Add(self.dbb_group, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ self.sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ label = wx.StaticText(self, -1, 'Create group if none exists', style=wx.ALIGN_LEFT)
+ box.Add(label, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ self.btn_mkgroup = wx.Button(self, wx.ID_ANY, "Make group ...")
+ box.Add(self.btn_mkgroup, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ self.sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+
+ self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.onPageChanging)
+ self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnPageChanged)
+
+ def On_dbb_group(self,event):
+ self.path = event.GetString()
+ print 'group path =',self.path
+
+ def onPageChanging(self,event=None):
+ if event.GetDirection() and self.path == '':
+ wx.MessageBox('You must select a valid image/map group in order to continue')
+ event.Veto()
+ return
+
+ def OnPageChanged(self,event=None):
+ self.parent.xy_groupPath,self.parent.xy_group = os.path.split(self.path)
+
+class DispMapPage(TitledPage):
+ """
+ Select ungeoreferenced map to display for interactively
+ setting ground control points (GCPs).
+ """
+ def __init__(self, wizard, parent, curr_location, curr_mapset, xy_location, xy_mapset):
+ TitledPage.__init__(self, wizard, "Select image/map to display for ground control point (GCP) creation")
+
+ self.parent = parent
+ self.curr_location = curr_location
+ self.curr_mapset = curr_mapset
+ self.xy_location = xy_location
+ self.xy_mapset = xy_mapset
+ self.path = ''
+
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ label = wx.StaticText(self, -1, 'Select display image/map:', style=wx.ALIGN_LEFT)
+ box.Add(label, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ self.selection = select.Select(self, id=wx.ID_ANY, size=(300,-1),
+ type=self.parent.maptype )
+ box.Add(self.selection, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ self.sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+
+ self.Bind(wx.EVT_TEXT, self.OnSelection, self.selection)
+ self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.onPageChanging)
+ self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnPageChanged)
+
+ def OnSelection(self,event):
+ self.parent.xy_dispmap = event.GetString()
+ print 'map =',self.parent.xy_dispmap
+
+ def onPageChanging(self,event=None):
+ if event.GetDirection() and self.parent.xy_dispmap == '':
+ wx.MessageBox('You must select a valid image/map in order to continue')
+ event.Veto()
+ return
+ else:
+ pass
+ # return to current location/mapset
+
+ def OnPageChanged(self,event=None):
+ if event.GetDirection():
+ # switch to xy location
+ pass
+
+
class GeorectStart(wx.Dialog):
def __init__(self, parent, id=wx.ID_ANY, title=_('Set georectification parameters'),
pos=wx.DefaultPosition, size=(-1,-1),
@@ -105,8 +347,12 @@
self.curr_mapset = cmd.Command(cmdlist).module_stdout.read().strip()
self.StartDir = os.path.join(self.grassdatabase,self.curr_location)
+ self.xy_grassdatabase = ''
+ self.xy_locationPath = ''
+ self.xy_location = ''
self.xy_mapset = ''
- self.xy_mapsetDir = ''
+ self.xy_mapsetPath = ''
+ self.xy_groupPath = ''
self.xy_group = ''
#select display map (entry)
@@ -119,7 +365,7 @@
wx.DefaultPosition, wx.DefaultSize,
['raster','vector'], 2, wx.RA_SPECIFY_COLS)
box.Add(self.rb_maptype, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
- sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ self.sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
box = wx.BoxSizer(wx.HORIZONTAL)
self.dbb_mapset = filebrowse.DirBrowseButton(
@@ -131,12 +377,12 @@
startDirectory=self.StartDir,
changeCallback = self.On_dbb_mapset)
box.Add(self.dbb_mapset, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
- sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ self.sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
box = wx.BoxSizer(wx.HORIZONTAL)
self.btn_mkgroup = wx.Button(self, wx.ID_ANY, "Make group ...")
box.Add(self.btn_mkgroup, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
- sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ self.sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
box = wx.BoxSizer(wx.HORIZONTAL)
self.dbb_group = filebrowse.DirBrowseButton(
@@ -145,11 +391,11 @@
buttonText='Browse ...',
toolTip='Select group of maps to georeference',
dialogTitle='Groups',
- startDirectory=os.path.join(self.xy_mapset,"group"),
+ startDirectory=self.xy_groupPath,
changeCallback = self.On_dbb_group)
- # Need to deactivate until xy_mapsetDir is set
+ # Need to deactivate until xy_mapsetPath is set
box.Add(self.dbb_group, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
- sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ self.sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
#Select the display map here...????
#In TclTk, first switch to xy mapset; then select map
@@ -157,10 +403,10 @@
self.btn_selmap = wx.Button(self, wx.ID_ANY, "Select map ...")
box.Add(self.btn_selmap, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
- sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ self.sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
- sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)
+ self.sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)
btnsizer = wx.StdDialogButtonSizer()
@@ -172,7 +418,7 @@
btnsizer.AddButton(btn)
btnsizer.Realize()
- sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ self.sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
self.SetSizer(sizer)
sizer.Fit(self)
@@ -181,21 +427,25 @@
self.Bind(wx.EVT_BUTTON, self.OnSelectMap, self.btn_selmap)
def On_dbb_mapset(self,event):
- self.xy_mapsetDir = event.GetString()
- # Disable group select if no mapset selected?
- # need to split mapsetDir into xy_location and xy_mapset
-# self.xy_mapsetDir = os.path.join(self.grassdatabase,self.location,self.mapset)
+ self.xy_mapsetPath = event.GetString()
+ self.xy_locationPath,self.xy_mapset = os.path.split(self.xy_mapsetPath)
+ self.xy_grassdatabase, self.xy_location = os.path.split(self.xy_locationPath)
+ self.StartDir = self.xy_mapsetPath
+ self.xy_groupPath = os.path.join(self.xy_mapsetPath,'group')
+ self.Refresh()
+ print 'group start =',self.xy_groupPath
+ print 'general start =',self.StartDir
- print 'mapset =',self.mapset
-
def On_dbb_group(self,event):
- self.xy_group = event.GetString()
+ if self.xy_mapsetPath != '':
+ self.xy_groupPath,self.xy_group = os.path.split(event.GetString())
+ print 'group =',self.xy_group
+ else:
+ wx.MessageBox('You must select a valid mapset')
- print 'group =',self.xy_group
-
def OnSelectMap(self,event):
dlg = select.SelectDialog(self,title="Select map",type='cell')
-
+ dlg.CenterOnScreen()
if dlg.ShowModal() == wx.ID_OK:
self.xy_map = dlg.selection.GetValue()
@@ -204,6 +454,7 @@
def OnMkgroup(self,event):
+ menuform.GUI().ParseCommand('i.group', parentframe=self)
pass
def SwitchToXY(self):
From barton at grass.itc.it Wed Aug 29 09:16:34 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Wed Aug 29 09:16:57 2007
Subject: [grass-addons] r1058 - trunk/grassaddons/gui/gui_modules
Message-ID: <200708290716.l7T7GYFW010006@grass.itc.it>
Author: barton
Date: 2007-08-29 09:15:56 +0200 (Wed, 29 Aug 2007)
New Revision: 1058
Modified:
trunk/grassaddons/gui/gui_modules/georect.py
Log:
Updates to georectifier set up wizard. Now uses comboboxes to select
location, mapset, and group.
Modified: trunk/grassaddons/gui/gui_modules/georect.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/georect.py 2007-08-29 03:27:05 UTC (rev 1057)
+++ trunk/grassaddons/gui/gui_modules/georect.py 2007-08-29 07:15:56 UTC (rev 1058)
@@ -61,13 +61,30 @@
imagepath = images.__path__[0]
sys.path.append(imagepath)
+# global variables
+global grassdatabase
+global curr_location
+global curr_mapset
+
+global xy_location
+global xy_mapset
+global xy_group
+global xy_dispmap
+
+global maptype
+
+xy_location = ''
+xy_mapset = ''
+xy_group = ''
+xy_dispmap = ''
+maptype = 'raster'
+
class Georectify(object):
"""
Init class for georectifying. Launches startup dialog
for setting georectifying parameters.
"""
def __init__(self,parent):
- print 'in georectify start'
self.parent = parent
@@ -136,32 +153,24 @@
#set environmental variables
cmdlist = ['g.gisenv', 'get=GISDBASE']
- self.grassdatabase = cmd.Command(cmdlist).module_stdout.read().strip()
+ global grassdatabase
+ grassdatabase = cmd.Command(cmdlist).module_stdout.read().strip()
cmdlist = ['g.gisenv', 'get=LOCATION_NAME']
- self.curr_location = cmd.Command(cmdlist).module_stdout.read().strip()
+ global curr_location
+ curr_location = cmd.Command(cmdlist).module_stdout.read().strip()
cmdlist = ['g.gisenv', 'get=MAPSET']
- self.curr_mapset = cmd.Command(cmdlist).module_stdout.read().strip()
+ global curr_mapset
+ curr_mapset = cmd.Command(cmdlist).module_stdout.read().strip()
- self.StartDir = os.path.join(self.grassdatabase,self.curr_location)
self.maptype = ''
- self.xy_grassdatabase = ''
- self.xy_locationPath = ''
- self.xy_location = ''
- self.xy_mapset = ''
- self.xy_mapsetPath = ''
- self.xy_groupPath = ''
- self.xy_group = ''
- self.xy_dispmap = ''
# define wizard pages
self.wizard = wiz.Wizard(parent, -1, "Setup for georectification")
- self.startpage = LocationPage(self.wizard, self, self.StartDir)
- self.grouppage = GroupPage(self.wizard, self, self.xy_groupPath)
- self.mappage = DispMapPage(self.wizard, self, self.curr_location, \
- self.curr_mapset, self.xy_location, \
- self.xy_mapset)
+ self.startpage = LocationPage(self.wizard, self)
+ self.grouppage = GroupPage(self.wizard, self)
+ self.mappage = DispMapPage(self.wizard, self)
# Set the initial order of the pages
self.startpage.SetNext(self.grouppage)
@@ -194,12 +203,26 @@
Set map type (raster or vector) to georectify and
select location/mapset of map(s) to georectify.
"""
- def __init__(self, wizard, parent, startDir):
+ def __init__(self, wizard, parent):
TitledPage.__init__(self, wizard, "Select map type and location/mapset")
self.parent = parent
- self.StartDir = startDir
+ global grassdatabase
+ global xy_location
+ global xy_mapset
+ tmplist = os.listdir(grassdatabase)
+
+ self.locList = []
+
+ # Create a list of valid locations
+ for item in tmplist:
+ if os.path.isdir(os.path.join(grassdatabase,item)) and \
+ os.path.exists(os.path.join(grassdatabase,item,'PERMANENT')):
+ self.locList.append(item)
+
+ self.mapsetList = []
+
box = wx.BoxSizer(wx.HORIZONTAL)
self.rb_maptype = wx.RadioBox(self, -1, "Map type to georectify",
wx.DefaultPosition, wx.DefaultSize,
@@ -208,57 +231,89 @@
self.sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
box = wx.BoxSizer(wx.HORIZONTAL)
- self.dbb_mapset = filebrowse.DirBrowseButton(
- self, wx.ID_ANY, size=(450, -1),
- labelText='Select mapset: ',
- buttonText='Browse ...',
- toolTip='Select mapset of maps to georeference',
- dialogTitle='Mapsets',
- startDirectory=self.StartDir,
- changeCallback = self.On_dbb_mapset)
- box.Add(self.dbb_mapset, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ label = wx.StaticText(self, -1, 'select location:',
+ style=wx.ALIGN_RIGHT)
+ box.Add(label, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ self.cb_location = wx.ComboBox(self, wx.ID_ANY, "",
+ wx.DefaultPosition,
+ wx.DefaultSize,
+ choices = self.locList,
+ style=wx.CB_DROPDOWN|wx.CB_READONLY)
+ box.Add(self.cb_location, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
self.sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ label = wx.StaticText(self, -1, 'select mapset:',
+ style=wx.ALIGN_RIGHT)
+ box.Add(label, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ self.cb_mapset = wx.ComboBox(self, wx.ID_ANY, "",
+ wx.DefaultPosition,
+ wx.DefaultSize,
+ choices = self.mapsetList,
+ style=wx.CB_DROPDOWN|wx.CB_READONLY)
+ box.Add(self.cb_mapset, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ self.sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+
+ self.Bind(wx.EVT_COMBOBOX, self.OnLocation, self.cb_location)
+ self.Bind(wx.EVT_COMBOBOX, self.OnMapset, self.cb_mapset)
self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.onPageChanging)
self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnPageChanged)
- def On_dbb_mapset(self,event):
- self.parent.xy_mapsetPath = event.GetString()
- self.StartDir = self.parent.xy_mapsetPath
- print 'general start =',self.StartDir
+ def OnLocation(self, event):
+ global grassdatabase
+ global xy_location
+ xy_location = event.GetString()
+ tmplist = os.listdir(os.path.join(grassdatabase,xy_location))
+ self.mapsetList = []
+ for item in tmplist:
+ if os.path.isdir(os.path.join(grassdatabase,xy_location,item)):
+ self.mapsetList.append(item)
+
+ self.cb_mapset.SetItems(self.mapsetList)
+
+ def OnMapset(self, event):
+ global xy_mapset
+ global xy_location
+
+ if xy_location == '':
+ wx.MessageBox('You must select a valid location before selecting a mapset')
+ return
+
+ xy_mapset = event.GetString()
+
def onPageChanging(self,event=None):
- if event.GetDirection() and self.parent.xy_mapsetPath == '':
+ global xy_location
+ global xy_mapset
+
+ if event.GetDirection() and (xy_location == '' or xy_mapset == ''):
wx.MessageBox('You must select a valid location and mapset in order to continue')
event.Veto()
return
def OnPageChanged(self,event=None):
- self.parent.xy_locationPath,self.parent.xy_mapset = os.path.split(self.parent.xy_mapsetPath)
- self.parent.xy_grassdatabase, self.parent.xy_location = os.path.split(self.parent.xy_locationPath)
- self.parent.xy_groupPath = os.path.join(self.parent.xy_mapsetPath,'group')
+ pass
class GroupPage(TitledPage):
"""
Set group to georectify. Create group if desired.
"""
- def __init__(self, wizard, parent, startDir):
+ def __init__(self, wizard, parent):
TitledPage.__init__(self, wizard, "Select image/map group to georectify")
self.parent = parent
- self.path = ''
- self.StartDir = startDir
+ self.groupList = []
box = wx.BoxSizer(wx.HORIZONTAL)
- self.dbb_group = filebrowse.DirBrowseButton(
- self, wx.ID_ANY, size=(450, -1),
- labelText='Select group: ',
- buttonText='Browse ...',
- toolTip='Select group of images or maps to georeference',
- dialogTitle='Groups',
- startDirectory=self.StartDir,
- changeCallback = self.On_dbb_group)
- box.Add(self.dbb_group, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ label = wx.StaticText(self, -1, 'select group:',
+ style=wx.ALIGN_RIGHT)
+ box.Add(label, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ self.cb_group = wx.ComboBox(self, wx.ID_ANY, "",
+ wx.DefaultPosition,
+ wx.DefaultSize,
+ choices = self.groupList,
+ style=wx.CB_DROPDOWN|wx.CB_READONLY)
+ box.Add(self.cb_group, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
self.sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
box = wx.BoxSizer(wx.HORIZONTAL)
@@ -268,35 +323,63 @@
box.Add(self.btn_mkgroup, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
self.sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+ self.Bind(wx.EVT_COMBOBOX, self.OnGroup, self.cb_group)
self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.onPageChanging)
self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnPageChanged)
- def On_dbb_group(self,event):
- self.path = event.GetString()
- print 'group path =',self.path
+ def OnGroup(self, event):
+ global xy_location
+ global xy_mapset
+ global xy_group
+ if xy_location == '' or xy_mapset == '':
+ wx.MessageBox('You must select a valid location and mapset before selecting a group')
+ return
+
+ xy_group = event.GetString()
+
def onPageChanging(self,event=None):
- if event.GetDirection() and self.path == '':
+ global xy_group
+
+ if event.GetDirection() and xy_group == '':
wx.MessageBox('You must select a valid image/map group in order to continue')
event.Veto()
return
def OnPageChanged(self,event=None):
- self.parent.xy_groupPath,self.parent.xy_group = os.path.split(self.path)
+ global grassdatabase
+ global xy_location
+ global xy_mapset
+ self.groupList = []
+ tmplist = []
+ tmplist = os.listdir(os.path.join(grassdatabase,xy_location,xy_mapset,'group'))\
+
+ if tmplist == []:
+ wx.MessageBox('No map/imagery groups exist to georectify. You will need to create one')
+ else:
+ for item in tmplist:
+ if os.path.isdir(os.path.join(grassdatabase,xy_location,xy_mapset,'group',item)):
+ self.groupList.append(item)
+
+ self.cb_group.SetItems(self.groupList)
+
class DispMapPage(TitledPage):
"""
Select ungeoreferenced map to display for interactively
setting ground control points (GCPs).
"""
- def __init__(self, wizard, parent, curr_location, curr_mapset, xy_location, xy_mapset):
+ def __init__(self, wizard, parent):
TitledPage.__init__(self, wizard, "Select image/map to display for ground control point (GCP) creation")
self.parent = parent
- self.curr_location = curr_location
- self.curr_mapset = curr_mapset
- self.xy_location = xy_location
- self.xy_mapset = xy_mapset
+
+ global curr_location
+ global curr_mapset
+ global xy_location
+ global xy_mapset
+ global xy_group
+
self.path = ''
box = wx.BoxSizer(wx.HORIZONTAL)
@@ -312,11 +395,13 @@
self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnPageChanged)
def OnSelection(self,event):
- self.parent.xy_dispmap = event.GetString()
- print 'map =',self.parent.xy_dispmap
+ global xy_dispmap
+ xy_dispmap = event.GetString()
+ print 'map =',xy_dispmap
def onPageChanging(self,event=None):
- if event.GetDirection() and self.parent.xy_dispmap == '':
+ global xy_dispmap
+ if event.GetDirection() and xy_dispmap == '':
wx.MessageBox('You must select a valid image/map in order to continue')
event.Veto()
return
@@ -347,7 +432,7 @@
self.curr_mapset = cmd.Command(cmdlist).module_stdout.read().strip()
self.StartDir = os.path.join(self.grassdatabase,self.curr_location)
- self.xy_grassdatabase = ''
+ self.grassdatabase = ''
self.xy_locationPath = ''
self.xy_location = ''
self.xy_mapset = ''
@@ -429,12 +514,12 @@
def On_dbb_mapset(self,event):
self.xy_mapsetPath = event.GetString()
self.xy_locationPath,self.xy_mapset = os.path.split(self.xy_mapsetPath)
- self.xy_grassdatabase, self.xy_location = os.path.split(self.xy_locationPath)
+ self.grassdatabase, self.xy_location = os.path.split(self.xy_locationPath)
self.StartDir = self.xy_mapsetPath
self.xy_groupPath = os.path.join(self.xy_mapsetPath,'group')
self.Refresh()
print 'group start =',self.xy_groupPath
- print 'general start =',self.StartDir
+ print 'new start dir =',self.StartDir
def On_dbb_group(self,event):
if self.xy_mapsetPath != '':
From landa at grass.itc.it Fri Aug 31 19:00:47 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Fri Aug 31 19:00:50 2007
Subject: [grass-addons] r1059 - in trunk/grassaddons/gui: display_driver
gui_modules
Message-ID: <200708311700.l7VH0lQH018910@grass.itc.it>
Author: landa
Date: 2007-08-31 19:00:46 +0200 (Fri, 31 Aug 2007)
New Revision: 1059
Modified:
trunk/grassaddons/gui/display_driver/driver.cc
trunk/grassaddons/gui/display_driver/driver.h
trunk/grassaddons/gui/gui_modules/digit.py
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
Minor updates for digitization tool (still disabled).
Modified: trunk/grassaddons/gui/display_driver/driver.cc
===================================================================
--- trunk/grassaddons/gui/display_driver/driver.cc 2007-08-29 07:15:56 UTC (rev 1058)
+++ trunk/grassaddons/gui/display_driver/driver.cc 2007-08-31 17:00:46 UTC (rev 1059)
@@ -63,7 +63,7 @@
\brief Display content of the map in device
\param[in,out] device wxDC object where to draw vector features
-
+\
\return number of displayed features
\return -1 on error
*/
@@ -113,13 +113,19 @@
type = Vect_read_line (mapInfo, points, cats, line);
pointsScreen->Clear();
- //self.ids[line] = []
+
for (int i = 0; i < points->n_points; i++) {
Cell2Pixel(points->x[i], points->y[i], points->z[i],
&x, &y, &z);
pointsScreen->Append((wxObject*) new wxPoint(x, y)); /* TODO: 3D */
}
+ // add ids
+ // -> node1, line1, vertex1, line2, ..., node2
+ struct lineDesc desc = {points->n_points, dcId};
+ dcId += points->n_points * 2 - 1;
+ ids[line] = desc;
+
// draw vector feature
if (type & GV_LINES) {
switch (type) {
@@ -149,31 +155,30 @@
break;
}
- if (draw) {
- // highlight feature?
- if (IsSelected(line)) {
- dc->SetPen(wxPen(settings.highlight, settings.lineWidth, wxSOLID));
- }
+ // highlight feature?
+ if (draw && IsSelected(line)) {
+ dc->SetPen(wxPen(settings.highlight, settings.lineWidth, wxSOLID));
+ }
- //dc->DrawLines(pointsScreen);
- for (int i = 0; i < pointsScreen->GetCount() - 1;) {
- wxPoint *point_beg = (wxPoint *) pointsScreen->Item(i)->GetData();
- wxPoint *point_end = (wxPoint *) pointsScreen->Item(++i)->GetData();
+ long int startId = ids[line].startId + 1;
- ids[line].push_back(dcId);
- dc->SetId(dcId++);
+ for (int i = 0; i < pointsScreen->GetCount() - 1; startId += 2) {
+ wxPoint *point_beg = (wxPoint *) pointsScreen->Item(i)->GetData();
+ wxPoint *point_end = (wxPoint *) pointsScreen->Item(++i)->GetData();
+
+ wxRect rect (*point_beg, *point_end);
+ dc->SetIdBounds(startId, rect);
+ // draw line if needed
+ if (draw) {
+ dc->SetId(startId);
dc->DrawLine(point_beg->x, point_beg->y,
point_end->x, point_end->y);
}
+ }
- if (settings.vertex.enabled) {
- if (!IsSelected(line))
- dc->SetPen(wxPen(settings.vertex.color, settings.lineWidth, wxSOLID));
- DrawLineVerteces(line);
- }
- DrawLineNodes(line);
- }
+ DrawLineVerteces(line); // draw vertices
+ DrawLineNodes(line); // draw nodes
}
else if (type & GV_POINTS) {
if (type == GV_POINT && settings.point.enabled) {
@@ -220,10 +225,29 @@
*/
int DisplayDriver::DrawLineVerteces(int line)
{
- for (int i = 1; i < pointsScreen->GetCount() - 1; i++) {
- DrawCross(line, (const wxPoint*) pointsScreen->Item(i)->GetData());
+ long int id;
+ wxPoint *point;
+
+ // set id
+ id = ids[line].startId + 2;
+ for (int i = 1; i < pointsScreen->GetCount() - 1; i++, id += 2) {
+ point = (wxPoint*) pointsScreen->Item(i)->GetData();
+ wxRect rect (*point, *point);
+ dc->SetIdBounds(id, rect);
}
+ // draw vertices if needed
+ if (settings.vertex.enabled) {
+ if (!IsSelected(line))
+ dc->SetPen(wxPen(settings.vertex.color, settings.lineWidth, wxSOLID));
+
+ id = ids[line].startId + 2;
+ for (int i = 1; i < pointsScreen->GetCount() - 1; i++, id += 2) {
+ dc->SetId(id);
+ DrawCross(line, (const wxPoint*) pointsScreen->Item(i)->GetData());
+ }
+ }
+
return pointsScreen->GetCount() - 2;
}
@@ -237,9 +261,11 @@
int DisplayDriver::DrawLineNodes(int line)
{
int node;
+ long int id;
double east, north, depth;
int x, y, z;
int nodes [2];
+ bool draw;
Vect_get_line_nodes(mapInfo, line, &(nodes[0]), &(nodes[1]));
@@ -252,21 +278,35 @@
&x, &y, &z);
- // highlight feature?
- if (IsSelected(line)) {
- dc->SetPen(wxPen(settings.highlight, settings.lineWidth, wxSOLID));
+ if (Vect_get_node_n_lines(mapInfo, node) == 1) {
+ dc->SetPen(wxPen(settings.nodeOne.color, settings.lineWidth, wxSOLID));
+ draw = settings.nodeOne.enabled;
}
else {
- if (Vect_get_node_n_lines(mapInfo, node) == 1)
- dc->SetPen(wxPen(settings.nodeOne.color, settings.lineWidth, wxSOLID));
- else
- dc->SetPen(wxPen(settings.nodeTwo.color, settings.lineWidth, wxSOLID));
+ dc->SetPen(wxPen(settings.nodeTwo.color, settings.lineWidth, wxSOLID));
+ draw = settings.nodeTwo.enabled;
}
+
+ // highlight feature?
+ if (draw && IsSelected(line)) {
+ dc->SetPen(wxPen(settings.highlight, settings.lineWidth, wxSOLID));
+ }
+ // node1, line1, vertex1, line2, vertex2, ..., node2
+ if (i == 0) // first node
+ id = dcId - points->n_points * 2 + 1;
+ else // last node
+ id = dcId - 1;
+
wxPoint point(x, y);
- DrawCross(line, &point);
+ wxRect rect (point, point);
+ dc->SetIdBounds(id, rect);
- //elf.ids[line].append(self.mapwindow.DrawCross(coords, size=5))
+ // draw node if needed
+ if (draw) {
+ dc->SetId(id);
+ DrawCross(line, &point);
+ }
}
return 1;
@@ -391,9 +431,6 @@
if (!dc || !point)
return -1;
- ids[line].push_back(dcId);
- dc->SetId(dcId++);
-
dc->DrawLine(point->x - size, point->y, point->x + size, point->y);
dc->DrawLine(point->x, point->y - size, point->x, point->y + size);
@@ -472,12 +509,10 @@
{
for (ids_map::const_iterator i = ids.begin(), e = ids.end();
i != e; ++i) {
- std::cout << i->first << ":";
- for(std::vectorDESCRIPTION
-v.path.obstacles Computes the visibility graph of a map containing lines. This is the graph with vertices the end point of the lines and the edges are between two visibiles vertices. Two points are visibible if there no segments in between them, i.e. there are no lines e where the segment pq intersects it.
-
+v.buffer input=map output=bufferedmap buffer=1 type=point,line,area,boundary
+
+
+
+
+
input=map
output=map2
+coordinate=25556200,6686400,25556400,6686600
+
+v.net.visibility input=map vis=vis_map output=new_vis_map coordinate=25556200,6686400,25556400,6686600
+
EXAMPLE
Modified: trunk/grassaddons/v.path.obstacles/geometry.c
===================================================================
--- trunk/grassaddons/v.path.obstacles/geometry.c 2007-08-22 22:33:56 UTC (rev 1047)
+++ trunk/grassaddons/v.path.obstacles/geometry.c 2007-08-23 14:35:13 UTC (rev 1048)
@@ -88,7 +88,7 @@
/** returns 1 if the segment intersect with the half line starting from p pointing downards
x and y are the intersection point
*/
-int segment_intersect( struct Line * line, struct Point * p, double * x, double * y )
+int segment_intersect( struct Line * line, struct Point * p, double * y )
{
struct Point * p1 = line->p1;
struct Point * p2 = line->p2;
@@ -98,7 +98,6 @@
{
t = ( p->x - p1->x ) / ( p2->x - p1->x );
- *x = p->x;
*y = p1->y + t * ( p2->y - p1->y );
return 1;
Modified: trunk/grassaddons/v.path.obstacles/geometry.h
===================================================================
--- trunk/grassaddons/v.path.obstacles/geometry.h 2007-08-22 22:33:56 UTC (rev 1047)
+++ trunk/grassaddons/v.path.obstacles/geometry.h 2007-08-23 14:35:13 UTC (rev 1048)
@@ -28,7 +28,7 @@
int left_turn( struct Point * p1, struct Point * p2, struct Point * p3 );
int before( struct Point * p, struct Point * q, struct Line * e );
-int segment_intersect( struct Line * line, struct Point * p, double * x, double * y );
+int segment_intersect( struct Line * line, struct Point * p, double * y );
#endif
Modified: trunk/grassaddons/v.path.obstacles/main.c
===================================================================
--- trunk/grassaddons/v.path.obstacles/main.c 2007-08-22 22:33:56 UTC (rev 1047)
+++ trunk/grassaddons/v.path.obstacles/main.c 2007-08-23 14:35:13 UTC (rev 1048)
@@ -79,6 +79,12 @@
if(Vect_open_old(&in, input->answer, mapset) < 1) /* opens the map */
G_fatal_error(_("Could not open input"));
+ if (Vect_open_new(&out, output->answer, WITHOUT_Z) < 0)
+ {
+ Vect_close(&in);
+ G_fatal_error(_("Could not open output"));
+ }
+
if ( ovis->answer != NULL )
{
mapset = G_find_vector2( ovis->answer, NULL );
@@ -86,38 +92,23 @@
if( Vect_open_old(&vis, ovis->answer, mapset) < 1 )
G_fatal_error("Could not open vis");
- if(Vect_copy( ovis->answer, mapset, output->answer, NULL) < 0 )
- G_fatal_error("Could not copy map");
-
- mapset = G_find_vector2( output->answer, NULL );
-
- if( Vect_open_old(&out, output->answer, mapset) < 1 )
- G_fatal_error("Could not open vis");
+ if ( Vect_copy_map_lines (&vis, &out) > 0 )
+ G_fatal_error("Could not copy elements");
}
- else
- {
- if (Vect_open_new(&out, output->answer, WITHOUT_Z) < 0)
- {
- Vect_close(&in);
- G_fatal_error(_("Could not open output"));
- }
- }
if (G_projection () == PROJECTION_LL)
G_warning("We are in LL projection");
load_lines( &in, &points, &num_points, &lines, &num_lines);
-
if ( coor->answers != NULL )
n = add_points( coor->answers, &points, &num_points);
-
- G_message("We have %d new points", n );
if ( ovis->answer == NULL )
construct_visibility( points, num_points, lines, num_lines, &out );
else
+
visibility_points( points, num_points, lines, num_lines, &out, n );
G_free(points);
@@ -238,8 +229,6 @@
*points = G_malloc( *num_points * sizeof( struct Point ));
*lines = G_malloc( *num_lines * sizeof( struct Line ));
-
-
while( ( type = Vect_read_next_line( map, sites, cats) ) > -1 )
{
@@ -253,8 +242,8 @@
else if ( type == GV_POINT )
process_point( sites, points, &index_point, -1);
-
}
+
}
void process_point( struct line_pnts * sites, struct Point ** points, int * index_point, int cat)
From maldacker at grass.itc.it Thu Aug 23 16:41:47 2007
From: maldacker at grass.itc.it (maldacker@grass.itc.it)
Date: Thu Aug 23 16:41:48 2007
Subject: [grass-addons] r1049 - trunk/grassaddons/v.path.obstacles
Message-ID: <200708231441.l7NEfluE008568@grass.itc.it>
Author: maldacker
Date: 2007-08-23 16:41:44 +0200 (Thu, 23 Aug 2007)
New Revision: 1049
Modified:
trunk/grassaddons/v.path.obstacles/data_structures.h
trunk/grassaddons/v.path.obstacles/geometry.c
trunk/grassaddons/v.path.obstacles/main.c
Log:
removed warnings
Modified: trunk/grassaddons/v.path.obstacles/data_structures.h
===================================================================
--- trunk/grassaddons/v.path.obstacles/data_structures.h 2007-08-23 14:35:13 UTC (rev 1048)
+++ trunk/grassaddons/v.path.obstacles/data_structures.h 2007-08-23 14:41:44 UTC (rev 1049)
@@ -34,4 +34,4 @@
int partition( struct Point a[], int l, int r);
-#endif
\ No newline at end of file
+#endif
Modified: trunk/grassaddons/v.path.obstacles/geometry.c
===================================================================
--- trunk/grassaddons/v.path.obstacles/geometry.c 2007-08-23 14:35:13 UTC (rev 1048)
+++ trunk/grassaddons/v.path.obstacles/geometry.c 2007-08-23 14:41:44 UTC (rev 1049)
@@ -105,4 +105,4 @@
else
return -1;
-}
\ No newline at end of file
+}
Modified: trunk/grassaddons/v.path.obstacles/main.c
===================================================================
--- trunk/grassaddons/v.path.obstacles/main.c 2007-08-23 14:35:13 UTC (rev 1048)
+++ trunk/grassaddons/v.path.obstacles/main.c 2007-08-23 14:41:44 UTC (rev 1049)
@@ -33,7 +33,7 @@
struct Point * points;
struct Line * lines;
int num_points, num_lines;
- int n;
+ int n = 0;
From maldacker at grass.itc.it Thu Aug 23 16:51:29 2007
From: maldacker at grass.itc.it (maldacker@grass.itc.it)
Date: Thu Aug 23 16:51:30 2007
Subject: [grass-addons] r1050 - trunk/grassaddons/v.path.obstacles
Message-ID: <200708231451.l7NEpTsq009495@grass.itc.it>
Author: maldacker
Date: 2007-08-23 16:51:26 +0200 (Thu, 23 Aug 2007)
New Revision: 1050
Modified:
trunk/grassaddons/v.path.obstacles/data_structures.c
trunk/grassaddons/v.path.obstacles/data_structures.h
trunk/grassaddons/v.path.obstacles/geometry.c
Log:
bug correction
Modified: trunk/grassaddons/v.path.obstacles/data_structures.c
===================================================================
--- trunk/grassaddons/v.path.obstacles/data_structures.c 2007-08-23 14:41:44 UTC (rev 1049)
+++ trunk/grassaddons/v.path.obstacles/data_structures.c 2007-08-23 14:51:26 UTC (rev 1050)
@@ -15,6 +15,10 @@
#include "data_structures.h"
+/* stack variables */
+static int stack_index = 0;
+static struct Point ** stack = NULL;
+
struct Point * pop()
{
stack_index--;
@@ -156,3 +160,5 @@
}
+
+
Modified: trunk/grassaddons/v.path.obstacles/data_structures.h
===================================================================
--- trunk/grassaddons/v.path.obstacles/data_structures.h 2007-08-23 14:41:44 UTC (rev 1049)
+++ trunk/grassaddons/v.path.obstacles/data_structures.h 2007-08-23 14:51:26 UTC (rev 1050)
@@ -25,9 +25,6 @@
int empty_stack();
void init_stack();
-static int stack_index = 0;
-static struct Point ** stack = NULL;
-
int cmp_points(const void* v1, const void* v2, void * param);
void quickSort( struct Point a[], int l, int r);
Modified: trunk/grassaddons/v.path.obstacles/geometry.c
===================================================================
--- trunk/grassaddons/v.path.obstacles/geometry.c 2007-08-23 14:41:44 UTC (rev 1049)
+++ trunk/grassaddons/v.path.obstacles/geometry.c 2007-08-23 14:51:26 UTC (rev 1050)
@@ -96,9 +96,19 @@
if ( in_between(p, line ) )
{
- t = ( p->x - p1->x ) / ( p2->x - p1->x );
+ if ( p2->x != p1->x )
+ {
+ t = ( p->x - p1->x ) / ( p2->x - p1->x );
- *y = p1->y + t * ( p2->y - p1->y );
+ *y = p1->y + t * ( p2->y - p1->y );
+ }
+ else
+ {
+ if ( p1->y > p->y || p2->y > p->y )
+ return -1;
+
+ *y = p1->y > p2->y ? p1->y : p2->y;
+ }
return 1;
}
From maldacker at grass.itc.it Thu Aug 23 19:41:47 2007
From: maldacker at grass.itc.it (maldacker@grass.itc.it)
Date: Thu Aug 23 19:41:59 2007
Subject: [grass-addons] r1051 - trunk/grassaddons/v.path.obstacles
Message-ID: <200708231741.l7NHfl22011170@grass.itc.it>
Author: maldacker
Date: 2007-08-23 19:41:40 +0200 (Thu, 23 Aug 2007)
New Revision: 1051
Modified:
trunk/grassaddons/v.path.obstacles/main.c
trunk/grassaddons/v.path.obstacles/proto.h
trunk/grassaddons/v.path.obstacles/rotation_tree.c
trunk/grassaddons/v.path.obstacles/visibility.c
Log:
memory allocation bug fix
Modified: trunk/grassaddons/v.path.obstacles/main.c
===================================================================
--- trunk/grassaddons/v.path.obstacles/main.c 2007-08-23 14:51:26 UTC (rev 1050)
+++ trunk/grassaddons/v.path.obstacles/main.c 2007-08-23 17:41:40 UTC (rev 1051)
@@ -100,15 +100,34 @@
if (G_projection () == PROJECTION_LL)
G_warning("We are in LL projection");
+
+ /* counting how many points and lines we have to allocate */
+ count( &in, &num_points, &num_lines);
+
+ G_message("We have %d poitns", num_points);
+
+ /* modify the number if we have new points to add */
+ if ( coor->answers != NULL )
+ num_points+= count_new( coor->answers );
+
+ G_message("Now we have %d points", num_points);
+
+ /* and allocate */
+ points = G_malloc( num_points * sizeof( struct Point ));
+ lines = G_malloc( num_lines * sizeof( struct Line ));
+
+ /* and finally set the lines */
load_lines( &in, &points, &num_points, &lines, &num_lines);
-
+ G_message("And now we have %d points", num_points);
+
if ( coor->answers != NULL )
- n = add_points( coor->answers, &points, &num_points);
+ add_points( coor->answers, &points, &num_points);
+
+ G_message("And finally we have %d points", num_points);
if ( ovis->answer == NULL )
construct_visibility( points, num_points, lines, num_lines, &out );
else
-
visibility_points( points, num_points, lines, num_lines, &out, n );
G_free(points);
@@ -121,13 +140,10 @@
}
-/** add points to the visibility graph
-*/
-int add_points( char ** coor, struct Point ** points, int * index_point )
+/* count how many new points we have to add */
+int count_new( char ** coor )
{
- int i, n;
- double x, y;
-
+ int n, i;
/* first count how many points we are going to add */
n = 0; i = 0;
while ( coor[i] != NULL )
@@ -136,8 +152,15 @@
i+=2;
}
- /* resizing points acordingly */
- *points = G_realloc( *points, (*index_point+n)*sizeof( struct Point ) );
+ return n;
+}
+
+/** add points to the visibility graph
+*/
+void add_points( char ** coor, struct Point ** points, int * index_point )
+{
+ int i;
+ double x, y;
/* and defining the points */
@@ -161,8 +184,6 @@
(*index_point)++;
}
-
- return n;
}
/** counts the number of individual segments ( boundaries and lines ) and vertices
@@ -224,11 +245,6 @@
sites = Vect_new_line_struct();
cats = Vect_new_cats_struct();
- count( map, num_points, num_lines);
-
- *points = G_malloc( *num_points * sizeof( struct Point ));
- *lines = G_malloc( *num_lines * sizeof( struct Line ));
-
while( ( type = Vect_read_next_line( map, sites, cats) ) > -1 )
{
@@ -243,6 +259,9 @@
process_point( sites, points, &index_point, -1);
}
+
+ *num_points = index_point;
+ *num_lines = index_line;
}
Modified: trunk/grassaddons/v.path.obstacles/proto.h
===================================================================
--- trunk/grassaddons/v.path.obstacles/proto.h 2007-08-23 14:51:26 UTC (rev 1050)
+++ trunk/grassaddons/v.path.obstacles/proto.h 2007-08-23 17:41:40 UTC (rev 1051)
@@ -21,6 +21,8 @@
void process_point( struct line_pnts * sites, struct Point ** points, int * index_point, int cat);
void process_line( struct line_pnts * sites, struct Point ** points, int * index_point, struct Line ** lines, int * index_line, int cat);
void process_boundary( struct line_pnts * sites, struct Point ** points, int * index_point, struct Line ** lines, int * index_line, int cat);
-int add_points( char ** coor, struct Point ** points, int * num_points );
+void add_points( char ** coor, struct Point ** points, int * num_points );
+int count_new( char ** coor);
+
#endif
Modified: trunk/grassaddons/v.path.obstacles/rotation_tree.c
===================================================================
--- trunk/grassaddons/v.path.obstacles/rotation_tree.c 2007-08-23 14:51:26 UTC (rev 1050)
+++ trunk/grassaddons/v.path.obstacles/rotation_tree.c 2007-08-23 17:41:40 UTC (rev 1051)
@@ -79,8 +79,7 @@
r->left_brother = l;
if ( f->rightmost_son == p )
- //f->rightmost_son = NULL;
- f->rightmost_son = l;
+ f->rightmost_son = NULL;
p->father = NULL;
p->left_brother = NULL;
Modified: trunk/grassaddons/v.path.obstacles/visibility.c
===================================================================
--- trunk/grassaddons/v.path.obstacles/visibility.c 2007-08-23 14:51:26 UTC (rev 1050)
+++ trunk/grassaddons/v.path.obstacles/visibility.c 2007-08-23 17:41:40 UTC (rev 1051)
@@ -43,6 +43,8 @@
/* loop through the tree */
while( ( p = avl_t_next( &it ) ) != NULL )
{
+ if ( segment1(p) == NULL && segment2(p) == NULL)
+ continue;
/* test for intersection and get the intersecting point */
if ( segment1(p) != NULL && segment_intersect( segment1(p), &points[i], &y1 ) > -1 )
@@ -96,7 +98,7 @@
/* if both weren't deleted, it means there is at least one other point on the left, so add the current */
/* also there is no point adding the point if there is no segment attached to it */
- if ( (s1 == NULL || s2 == NULL ) && ( segment1(&points[i]) != NULL || segment2(&points[i]) != NULL ))
+ if ( (s1 == NULL || s2 == NULL ) )
{
avl_insert( tree, &points[i] );
}
From maldacker at grass.itc.it Thu Aug 23 20:03:51 2007
From: maldacker at grass.itc.it (maldacker@grass.itc.it)
Date: Thu Aug 23 20:03:54 2007
Subject: [grass-addons] r1052 - trunk/grassaddons/v.path.obstacles
Message-ID: <200708231803.l7NI3p4e012512@grass.itc.it>
Author: maldacker
Date: 2007-08-23 20:03:48 +0200 (Thu, 23 Aug 2007)
New Revision: 1052
Modified:
trunk/grassaddons/v.path.obstacles/description.html
Log:
update of the documentation
Modified: trunk/grassaddons/v.path.obstacles/description.html
===================================================================
--- trunk/grassaddons/v.path.obstacles/description.html 2007-08-23 17:41:40 UTC (rev 1051)
+++ trunk/grassaddons/v.path.obstacles/description.html 2007-08-23 18:03:48 UTC (rev 1052)
@@ -36,14 +36,48 @@
EXAMPLE
+EXAMPLE 1
+A simple example showing how to use the module
+
+v.path.obstacles input=lines output=graph
+d.vect graph
+d.vect lines col=red
+EXAMPLE 2
+An example on how to use v.buffer with the module
+v.buffer input=lines output=buffered_lines buffer=1
+v.path.obstacles input=buffered_lines output=graph
+d.vect graph
+d.vect lines col=red
+EXAMPLE 3
+An example on how to use the coordinate parameter. This will compute the visibility graph of the vector map lines with the point 2555678,6686343
+
+v.path.obstacles input=lines output=graph coordinate=2555678,6686343
+d.vect graph
+d.vect lines col=red
+EXAMPLE 4
+An example on how to use the coordinate parameter with the vis parameter. Here the vector map graph is computed then a new visibility graph is computed from it with the point 2555678,6686343 extra
+
v.path.obstacles input=lines output=graph
d.vect graph
d.vect lines col=red
+v.path.obstacles input=lines vis=graph output=new_graph coordinate=2555678,6686343
+d.erase
+d.vect new_graph
+d.vect lines col=red
KNOWN BUGS
+In some cases when 3 points or nodes are collinear, some wrong edges are added. This happens only really rarly and shouldn't be a big problem.
+When two points have the exact same x coordinate and are visible, some wrong edges are added.
+
SEE ALSO
d.path,
@@ -58,4 +92,4 @@
Maximilian Maldacker
-
v.buffer input=map output=bufferedmap buffer=1 type=point,line,area,boundary
-
+
v.buffer input=map output=bufferedmap buffer=1 type=point,line,area,boundary
-
AUTHOR
-
Maximilian Maldacker
+Mentor : Wolf Bergenheim
v.buffer input=map output=bufferedmap buffer=1 type=point,line,area,boundary
-
+
Last changed: Date: 23/08/2007 +
Last changed: Date: 31/08/2007