[GRASS-SVN] r42719 - in grass/trunk: gui/wxpython/scripts imagery/i.atcorr

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jul 8 08:08:41 EDT 2010


Author: aghisla
Date: 2010-07-08 12:08:41 +0000 (Thu, 08 Jul 2010)
New Revision: 42719

Modified:
   grass/trunk/gui/wxpython/scripts/r.li.setup.py
   grass/trunk/imagery/i.atcorr/GeomCond.cpp
   grass/trunk/imagery/i.atcorr/GeomCond.h
   grass/trunk/imagery/i.atcorr/Iwave.cpp
   grass/trunk/imagery/i.atcorr/Iwave.h
Log:
Added AVNIR atmospherical correction - thanks Daniel Victoria for Python conversion script. Check welcome before backport.

Modified: grass/trunk/gui/wxpython/scripts/r.li.setup.py
===================================================================
--- grass/trunk/gui/wxpython/scripts/r.li.setup.py	2010-07-08 10:35:07 UTC (rev 42718)
+++ grass/trunk/gui/wxpython/scripts/r.li.setup.py	2010-07-08 12:08:41 UTC (rev 42719)
@@ -21,6 +21,10 @@
 import sys
 import locale
 import platform
+
+GUIModulesPath = os.path.join(os.getenv("GISBASE"), "etc", "gui", "wxpython", "gui_modules")
+sys.path.append(GUIModulesPath)
+
 import globalvar
 
 import wx
@@ -37,3 +41,687 @@
 
 print >> sys.stderr, "TODO: implement r.li.setup wizard..."
 
+class BaseClass(wx.Object):
+    """!Base class providing basic methods"""
+    def __init__(self):
+        pass
+
+    def MakeLabel(self, text="", style=wx.ALIGN_LEFT, parent=None):
+        """!Make aligned label"""
+        if not parent:
+            parent = self
+        return wx.StaticText(parent=parent, id=wx.ID_ANY, label=text,
+                             style=style)
+
+    def MakeTextCtrl(self, text='', size=(100,-1), style=0, parent=None):
+        """!Generic text control"""
+        if not parent:
+            parent = self
+        return wx.TextCtrl(parent=parent, id=wx.ID_ANY, value=text,
+                           size=size, style=style)
+
+    def MakeButton(self, text, id=wx.ID_ANY, size=(-1,-1), parent=None):
+        """!Generic button"""
+        if not parent:
+            parent = self
+        return wx.Button(parent=parent, id=id, label=text,
+                         size=size)
+
+class TitledPage(BaseClass, wiz.WizardPageSimple):
+    """
+    Class to make wizard pages. Generic methods to make
+    labels, text entries, and buttons.
+    """
+    def __init__(self, parent, title):
+
+        self.page = wiz.WizardPageSimple.__init__(self, parent)
+
+        # page title
+        self.title = wx.StaticText(parent=self, id=wx.ID_ANY, label=title)
+        self.title.SetFont(wx.Font(13, wx.SWISS, wx.NORMAL, wx.BOLD))
+
+        # main sizers
+        self.pagesizer = wx.BoxSizer(wx.VERTICAL)
+        self.sizer = wx.GridBagSizer(vgap=0, hgap=0)
+        
+    def DoLayout(self):
+        """!Do page layout"""
+      
+
+        self.pagesizer.Add(item=self.title, proportion=0,
+                     flag=wx.ALIGN_CENTRE | wx.ALL,
+                     border=5)
+        self.pagesizer.Add(item=wx.StaticLine(self, -1), proportion=0,
+                     flag=wx.EXPAND | wx.ALL,
+                     border=0)
+        self.pagesizer.Add(item=self.sizer)
+
+        self.SetAutoLayout(True)
+        self.SetSizer(self.pagesizer)
+        # tmpsizer.Fit(self)
+        self.Layout()
+        
+        
+class LocationWizard(wx.Object):
+    """
+    Start wizard here and finish wizard here
+    """
+    def __init__(self, parent): 
+#        global coordsys
+        self.parent = parent
+
+        #
+        # define wizard image
+        #
+        # file = "loc_wizard.png"
+        file = "loc_wizard_qgis.png"
+        imagePath = os.path.join(globalvar.ETCWXDIR, "images", file)
+        wizbmp = wx.Image(imagePath, wx.BITMAP_TYPE_PNG)
+        # wizbmp.Rescale(250,600)
+        wizbmp = wizbmp.ConvertToBitmap()
+
+        #
+        # get georeferencing information from tables in $GISBASE/etc
+        #
+#        self.__readData()
+#        
+#        #
+#        # datum transform number and list of datum transforms
+#        #
+#        self.datumtrans = 0
+#        self.proj4string = ''
+#
+#        #
+#        # define wizard pages
+#        #
+        self.wizard = wiz.Wizard(parent, id=wx.ID_ANY, title=_("I m!"),
+                                 bitmap=wizbmp)
+        self.startpage = SummaryPage(self.wizard, self)
+#        self.csystemspage = CoordinateSystemPage(self.wizard, self)
+#        self.projpage = ProjectionsPage(self.wizard, self)
+#        self.datumpage = DatumPage(self.wizard, self)
+#        self.paramspage = ProjParamsPage(self.wizard,self)
+#        self.epsgpage = EPSGPage(self.wizard, self)
+#        self.filepage = GeoreferencedFilePage(self.wizard, self)
+#        self.wktpage = WKTPage(self.wizard, self)
+#        self.ellipsepage = EllipsePage(self.wizard, self)
+#        self.custompage = CustomPage(self.wizard, self)
+#        self.sumpage = SummaryPage(self.wizard, self)
+#
+#        #
+#        # set the initial order of the pages
+#        # (should follow the epsg line)
+#        #
+#        self.startpage.SetNext(self.csystemspage)
+#
+#        self.csystemspage.SetPrev(self.startpage)
+#        self.csystemspage.SetNext(self.sumpage)
+#
+#        self.projpage.SetPrev(self.csystemspage)
+#        self.projpage.SetNext(self.paramspage)
+#
+#        self.paramspage.SetPrev(self.projpage)
+#        self.paramspage.SetNext(self.datumpage)
+#
+#        self.datumpage.SetPrev(self.paramspage)
+#        self.datumpage.SetNext(self.sumpage)
+#
+#        self.ellipsepage.SetPrev(self.paramspage)
+#        self.ellipsepage.SetNext(self.sumpage)
+#
+#        self.epsgpage.SetPrev(self.csystemspage)
+#        self.epsgpage.SetNext(self.sumpage)
+#
+#        self.filepage.SetPrev(self.csystemspage)
+#        self.filepage.SetNext(self.sumpage)
+#
+#        self.wktpage.SetPrev(self.csystemspage)
+#        self.wktpage.SetNext(self.sumpage)
+#
+#        self.custompage.SetPrev(self.csystemspage)
+#        self.custompage.SetNext(self.sumpage)
+#
+#        self.sumpage.SetPrev(self.csystemspage)
+#
+#        #
+#        # do pages layout
+#        #
+#        self.startpage.DoLayout()
+#        self.csystemspage.DoLayout()
+#        self.projpage.DoLayout()
+#        self.datumpage.DoLayout()
+#        self.paramspage.DoLayout()
+#        self.epsgpage.DoLayout()
+#        self.filepage.DoLayout()
+#        self.wktpage.DoLayout()
+#        self.ellipsepage.DoLayout()
+#        self.custompage.DoLayout()
+#        self.sumpage.DoLayout()
+#        self.wizard.FitToPage(self.datumpage)
+#
+#        # new location created?
+#        self.location = None 
+#        success = False
+#        
+#        # location created in different GIS database?
+#        self.altdb = False
+
+        #
+        # run wizard...
+        #
+        if self.wizard.RunWizard(self.startpage):
+            pass
+#            msg = self.OnWizFinished()
+#            if len(msg) < 1:
+#                self.wizard.Destroy()
+#                self.location = self.startpage.location
+#                
+#                if self.altdb == False: 
+#                    dlg = wx.MessageDialog(parent=self.parent,
+#                                           message=_("Do you want to set the default "
+#                                                     "region extents and resolution now?"),
+#                                           caption=_("Location <%s> created") % self.location,
+#                                           style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
+#                    dlg.CenterOnScreen()
+#                    if dlg.ShowModal() == wx.ID_YES:
+#                        dlg.Destroy()
+#                        defineRegion = RegionDef(self.parent, location=self.location)
+#                        defineRegion.CenterOnScreen()
+#                        defineRegion.Show()
+#                    else:
+#                        dlg.Destroy()
+#            else: # -> error
+#                self.wizard.Destroy()
+#                wx.MessageBox(parent=self.parent,
+#                              message="%s" % _("Unable to create new location. "
+#                                               "Location <%(loc)s> not created.\n\n"
+#                                               "Details: %(err)s") % \
+#                                  { 'loc' : self.startpage.location,
+#                                    'err' : msg },
+#                              caption=_("Location wizard"),
+#                              style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+#        else:
+#            win = wx.MessageBox(parent=self.parent,
+#                                message=_("Location wizard canceled. "
+#                                          "Location not created."),
+#                                caption=_("Location wizard"))
+    
+    def __readData(self):
+        """!Get georeferencing information from tables in $GISBASE/etc"""
+
+        # read projection and parameters
+        f = open(os.path.join(globalvar.ETCDIR, "proj-parms.table"), "r")
+        self.projections = {}
+        self.projdesc = {}
+        for line in f.readlines():
+            line = line.strip()
+            try:
+                proj, projdesc, params = line.split(':')
+                paramslist = params.split(';')
+                plist = []
+                for p in paramslist:
+                    if p == '': continue
+                    p1, pdefault = p.split(',')
+                    pterm, pask = p1.split('=')
+                    p = [pterm.strip(), pask.strip(), pdefault.strip()]
+                    plist.append(p)
+                self.projections[proj.lower().strip()] = (projdesc.strip(), plist)
+                self.projdesc[proj.lower().strip()] = projdesc.strip()
+            except:
+                continue
+        f.close()
+
+        # read datum definitions
+        f = open(os.path.join(globalvar.ETCDIR, "datum.table"), "r")
+        self.datums = {}
+        paramslist = []
+        for line in f.readlines():
+            line = line.expandtabs(1)
+            line = line.strip()
+            if line == '' or line[0] == "#":
+                continue
+            datum, info = line.split(" ", 1)
+            info = info.strip()
+            datumdesc, params = info.split(" ", 1)
+            datumdesc = datumdesc.strip('"')
+            paramlist = params.split()
+            ellipsoid = paramlist.pop(0)
+            self.datums[datum] = (ellipsoid, datumdesc.replace('_', ' '), paramlist)
+        f.close()
+
+        # read ellipsiod definitions
+        f = open(os.path.join(globalvar.ETCDIR, "ellipse.table"), "r")
+        self.ellipsoids = {}
+        for line in f.readlines():
+            line = line.expandtabs(1)
+            line = line.strip()
+            if line == '' or line[0] == "#":
+                continue
+            ellipse, rest = line.split(" ", 1)
+            rest = rest.strip('" ')
+            desc, params = rest.split('"', 1)
+            desc = desc.strip('" ')
+            paramslist = params.split()
+            self.ellipsoids[ellipse] = (desc, paramslist)
+        f.close()
+        
+        # read projection parameter description and parsing table
+        f = open(os.path.join(globalvar.ETCDIR, "proj-desc.table"), "r")
+        self.paramdesc = {}
+        for line in f.readlines():
+            line = line.strip()
+            try:
+                pparam, datatype, proj4term, desc = line.split(':')
+                self.paramdesc[pparam] = (datatype, proj4term, desc)
+            except:
+                continue
+        f.close()
+
+    def OnWizFinished(self):
+        database = self.startpage.grassdatabase
+        location = self.startpage.location
+        global coordsys
+        msg = '' # error message (empty on success)
+        
+        # location already exists?
+        if os.path.isdir(os.path.join(database,location)):
+            dlg = wx.MessageDialog(parent=self.wizard,
+                                   message="%s <%s>: %s" % \
+                                       (_("Unable to create new location"),
+                                        os.path.join(database, location),
+                                        _("Location already exists in GRASS Database.")),
+                                   caption=_("Error"),
+                                   style=wx.OK | wx.ICON_ERROR)
+            dlg.ShowModal()
+            dlg.Destroy()
+            return False
+        
+        # current GISDbase or a new one?
+        current_gdb = grass.gisenv()['GISDBASE']
+        if current_gdb != database:
+            # change to new GISDbase or create new one
+            if os.path.isdir(database) != True:
+                # create new directory
+                os.mkdir(database)
+                
+            # change to new GISDbase directory
+            gcmd.RunCommand('g.gisenv',
+                            parent = self.wizard,
+                            set='GISDBASE=%s' % database)
+            
+            wx.MessageBox(parent=self.wizard,
+                          message=_("Location <%(loc)s> will be created "
+                                    "in GIS data directory <%(dir)s>."
+                                    "You will need to change the default GIS "
+                                    "data directory in the GRASS startup screen.") % \
+                              { 'loc' : location, 'dir' : database},
+                          caption=_("New GIS data directory"), 
+                          style=wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
+            # location created in alternate GISDbase
+            self.altdb = True
+            
+        if coordsys == "xy":
+            msg = self.XYCreate()
+        elif coordsys == "proj":
+            proj4string = self.CreateProj4String()
+            msg = self.Proj4Create(proj4string)
+        elif coordsys == 'custom':
+            msg = self.CustomCreate()
+        elif coordsys == "epsg":
+            msg = self.EPSGCreate()
+        elif coordsys == "file":
+            msg = self.FileCreate()
+        elif coordsys == "wkt":
+            msg = self.WKTCreate()
+
+        return msg
+
+    def XYCreate(self):
+        """!Create an XY location
+
+        @return error message (empty string on success)
+        """        
+        database = self.startpage.grassdatabase
+        location = self.startpage.location
+        
+        # create location directory and PERMANENT mapset
+        try:
+            os.mkdir(os.path.join(database, location))
+            os.mkdir(os.path.join(database, location, 'PERMANENT'))
+            # create 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 + '%s' % os.linesep)
+            defwind.close()
+            
+            shutil.copy(os.path.join(database, location, "PERMANENT", "DEFAULT_WIND"),
+                        os.path.join(database, location, "PERMANENT", "WIND"))
+            
+            # create MYNAME file
+            myname = open(os.path.join(database, location, "PERMANENT",
+                                       "MYNAME"), 'w')
+            myname.write('%s' % os.linesep)
+            myname.close()
+        except OSError, e:
+            return e
+        
+        return ''
+
+    def CreateProj4String(self):
+        """!Constract PROJ.4 string"""
+        location = self.startpage.location
+        proj = self.projpage.p4proj
+        projdesc = self.projpage.projdesc
+        proj4params = self.paramspage.p4projparams
+                
+        datum = self.datumpage.datum
+        if self.datumpage.datumdesc:
+            datumdesc = self.datumpage.datumdesc +' - ' + self.datumpage.ellipse
+        else:
+            datumdesc = ''
+        datumparams = self.datumpage.datumparams        
+        ellipse = self.ellipsepage.ellipse
+        ellipsedesc = self.ellipsepage.ellipsedesc
+        ellipseparams = self.ellipsepage.ellipseparams
+                
+        #
+        # creating PROJ.4 string
+        #
+        proj4string = '%s %s' % (proj, proj4params)
+                            
+        # set ellipsoid parameters
+        if ellipse != '': proj4string = '%s +ellps=%s' % (proj4string, ellipse)
+        for item in ellipseparams:
+            if item[:4] == 'f=1/':
+                item = ' +rf='+item[4:]
+            else:
+                item = ' +'+item
+            proj4string = '%s %s' % (proj4string, item)
+            
+        # set datum and transform parameters if relevant
+        if datum != '': proj4string = '%s +datum=%s' % (proj4string, datum)
+        if datumparams:
+            for item in datumparams:
+                proj4string = '%s +%s' % (proj4string,item)
+
+        proj4string = '%s +no_defs' % proj4string
+        
+        return proj4string
+        
+    def Proj4Create(self, proj4string):
+        """!Create a new location for selected projection
+        
+        @return error message (empty string on success)
+        """
+        ret, msg = gcmd.RunCommand('g.proj',
+                                   flags = 'c',
+                                   proj4 = proj4string,
+                                   location = self.startpage.location,
+                                   datumtrans = self.datumtrans,
+                                   getErrorMsg = True)
+        
+        if ret == 0:
+            return ''
+
+        return msg
+        
+
+    def CustomCreate(self):
+        """!Create a new location based on given proj4 string
+
+        @return error message (empty string on success)
+        """
+        proj4string = self.custompage.customstring
+        location = self.startpage.location
+        
+        ret, msg = gcmd.RunCommand('g.proj',
+                                   flags = 'c',
+                                   proj4 = proj4string,
+                                   location = location,
+                                   getErrorMsg = True)
+        
+        if ret == 0:
+            return ''
+        
+        return msg
+
+    def EPSGCreate(self):
+        """!Create a new location from an EPSG code.
+
+        @return error message (empty string on success)
+        """
+        epsgcode = self.epsgpage.epsgcode
+        epsgdesc = self.epsgpage.epsgdesc
+        location = self.startpage.location
+        
+        # should not happend
+        if epsgcode == '':
+            return _('EPSG code missing.')
+        
+        ret, msg = gcmd.RunCommand('g.proj',
+                                   flags = 'c',
+                                   epsg = epsgcode,
+                                   location = location,
+                                   datumtrans = self.datumtrans,
+                                   getErrorMsg = True)
+        
+        if ret == 0:
+            return ''
+
+        return msg
+
+    def FileCreate(self):
+        """!Create a new location from a georeferenced file
+
+        @return error message (empty string on success)
+        """
+        georeffile = self.filepage.georeffile
+        location = self.startpage.location
+        
+        # this should not happen
+        if not georeffile or not os.path.isfile(georeffile):
+            return _("File not found.")
+        
+        # creating location
+        ret, msg = gcmd.RunCommand('g.proj',
+                                   flags = 'c',
+                                   georef = georeffile,
+                                   location = location,
+                                   getErrorMsg = True)
+        
+        if ret == 0:
+            return ''
+        
+        return msg
+
+    def WKTCreate(self):
+        """!Create a new location from a WKT file
+        
+        @return error message (empty string on success)
+        """
+        wktfile = self.wktpage.wktfile
+        location = self.startpage.location
+        
+        # this should not happen
+        if not wktfile or not os.path.isfile(wktfile):
+            return _("File not found.")
+        
+        # creating location
+        ret, msg = gcmd.RunCommand('g.proj',
+                                   flags = 'c',
+                                   wkt = wktfile,
+                                   location = location,
+                                   getErrorMsg = True)
+        
+        if ret == 0:
+            return ''
+        
+        return msg
+    
+class SummaryPage(TitledPage):
+    """
+    Shows summary result of choosing coordinate system parameters
+    prior to creating location
+    """
+    def __init__(self, wizard, parent):
+        TitledPage.__init__(self, wizard, _("Summary"))
+
+        self.parent = parent
+
+        # labels
+        self.ldatabase  = self.MakeLabel("")
+        self.llocation  = self.MakeLabel("")
+        self.lprojection = self.MakeLabel("")
+        self.lproj4string = self.MakeLabel("")
+        self.lproj4stringLabel = self.MakeLabel("")
+        
+        self.lprojection.Wrap(400)
+        
+        self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)
+        # self.Bind(wx.EVT_BUTTON, self.OnFinish, wx.ID_FINISH)
+
+        # do sub-page layout
+        self.__DoLayout()
+        
+    def __DoLayout(self):
+        """!Do page layout"""
+        self.sizer.AddGrowableCol(1)
+        self.sizer.Add(item=self.MakeLabel(_("GRASS Database:")),
+                       flag=wx.ALIGN_LEFT | wx.ALL,
+                       border=5, pos=(1, 0))
+        self.sizer.Add(item=self.ldatabase, 
+                       flag=wx.ALIGN_LEFT | wx.ALL,
+                       border=5, pos=(1, 1))
+        self.sizer.Add(item=self.MakeLabel(_("Location Name:")),
+                       flag=wx.ALIGN_LEFT | wx.ALL,
+                       border=5, pos=(2, 0))
+        self.sizer.Add(item=self.llocation,
+                       flag=wx.ALIGN_LEFT | wx.ALL,
+                       border=5, pos=(2, 1))
+        self.sizer.Add(item=self.MakeLabel(_("Projection:")),
+                       flag=wx.ALIGN_LEFT | wx.ALL,
+                       border=5, pos=(3, 0))
+        self.sizer.Add(item=self.lprojection,
+                       flag=wx.ALIGN_LEFT | wx.ALL,
+                       border=5, pos=(3, 1))
+        self.sizer.Add(item=self.lproj4stringLabel,
+                       flag=wx.ALIGN_LEFT | wx.ALL,
+                       border=5, pos=(4, 0))
+        self.sizer.Add(item=self.lproj4string,
+                       flag=wx.ALIGN_LEFT | wx.ALL,
+                       border=5, pos=(4, 1))
+        self.sizer.Add(item=(10,20),
+                       flag=wx.ALIGN_CENTER_HORIZONTAL | wx.ALL,
+                       border=5, pos=(5, 0), span=(1, 2))
+
+    def OnEnterPage(self,event):
+        """
+        Insert values into text controls for summary of location creation options
+        """
+
+#        database = self.parent.startpage.grassdatabase
+#        location = self.parent.startpage.location
+        proj4string = self.parent.CreateProj4String()
+        epsgcode = self.parent.epsgpage.epsgcode
+        dtrans = self.parent.datumtrans
+        
+        global coordsys
+        if coordsys not in ['proj', 'epsg']:
+            self.lproj4stringLabel.Hide()
+            self.lproj4string.Hide()
+            self.lproj4stringLabel.SetLabel('')
+            self.lproj4string.SetLabel('')
+        else:
+            self.lproj4string.Show()
+            self.lproj4stringLabel.SetLabel(_("PROJ.4 definition:"))
+            if coordsys == 'proj':
+                ret, msg, err = gcmd.RunCommand('g.proj',
+                                       flags = 'j',
+                                       proj4 = proj4string,
+                                       datumtrans = dtrans,
+                                       location = location,
+                                       getErrorMsg = True,
+                                       read = True)
+            elif coordsys == 'epsg':
+                ret, msg, err = gcmd.RunCommand('g.proj',
+                                       flags = 'j',
+                                       epsg = epsgcode,
+                                       datumtrans = dtrans,
+                                       location = location,
+                                       getErrorMsg = True,
+                                       read = True)
+            
+            if ret == 0:
+                projlabel = ''
+                for line in msg.splitlines():
+                    projlabel = projlabel + '%s ' % line
+                self.lproj4string.SetLabel(projlabel)
+            else:
+                wx.MessageBox(err, 'Error', wx.ICON_ERROR)
+
+            self.lproj4string.Wrap(400)
+            
+        projdesc = self.parent.projpage.projdesc
+        ellipsedesc = self.parent.ellipsepage.ellipsedesc
+        datumdesc = self.parent.datumpage.datumdesc
+#        self.ldatabase.SetLabel(database)
+#        self.llocation.SetLabel(location)
+        label = ''
+        
+        if coordsys == 'epsg':
+            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
+            self.lprojection.SetLabel(label)
+        elif coordsys == 'wkt':
+            label = 'matches file %s' % self.parent.wktpage.wktfile
+            self.lprojection.SetLabel(label)
+        elif coordsys == 'proj':
+            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 = ('%s' % self.parent.custompage.customstring)
+            self.lprojection.SetLabel(label)
+
+    def OnFinish(self, event):
+        dlg = wx.MessageDialog(parent=self.wizard,
+                               message=_("Do you want to create GRASS location <%s>?") % location,
+                               caption=_("Create new location?"),
+                               style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
+
+        if dlg.ShowModal() == wx.ID_NO:
+            dlg.Destroy()
+            event.Veto()
+        else:
+            dlg.Destroy()
+            event.Skip()
+      
+if __name__ == "__main__":
+    app = wx.App()
+    gWizard = LocationWizard(None)
+#    gWizard.Show()
+    app.MainLoop()
\ No newline at end of file

Modified: grass/trunk/imagery/i.atcorr/GeomCond.cpp
===================================================================
--- grass/trunk/imagery/i.atcorr/GeomCond.cpp	2010-07-08 10:35:07 UTC (rev 42718)
+++ grass/trunk/imagery/i.atcorr/GeomCond.cpp	2010-07-08 12:08:41 UTC (rev 42719)
@@ -363,7 +363,8 @@
     case 7: /* tm    ( landsat ) * enter month,day,hh.ddd,long.,lat. */
     case 8: /* etm+  ( landsat7) * enter month,day,hh.ddd,long.,lat. */
     case 9: /* liss  ( IRS 1C)   * enter month,day,hh.ddd,long.,lat. */
-     case 10: /* aster            * enter month,day,hh.ddd,long.,lat. */
+    case 10: /* aster            * enter month,day,hh.ddd,long.,lat. */
+    case 11: /* avnir            * enter month,day,hh.ddd,long.,lat. */
     {
 	cin >> month;
 	cin >> jday;
@@ -409,7 +410,7 @@
 /* ---- print geometrical conditions ---- */
 void GeomCond::print()
 {
-    static const string etiq1[11] = {
+    static const string etiq1[12] = {
 	string(" user defined conditions     "),
 	string(" meteosat observation        "),
 	string(" goes east observation       "),
@@ -420,7 +421,8 @@
 	string(" t.m.     observation        "),
 	string(" etm+     observation        "),
 	string(" liss     observation        "),
-	string(" aster    observation        ")
+	string(" aster    observation        "),
+	string(" avnir    observation        ")
     };
 
     static const string head(" geometrical conditions identity  ");

Modified: grass/trunk/imagery/i.atcorr/GeomCond.h
===================================================================
--- grass/trunk/imagery/i.atcorr/GeomCond.h	2010-07-08 10:35:07 UTC (rev 42718)
+++ grass/trunk/imagery/i.atcorr/GeomCond.h	2010-07-08 12:08:41 UTC (rev 42719)
@@ -49,7 +49,9 @@
 /*                                                                      c */
 /*         10      aster             * enter month,day,hh.ddd,long.,lat.c */
 /*                                                                      c */
+/*         11      avnir             * enter month,day,hh.ddd,long.,lat.c */
 /*                                                                      c */
+/*                                                                      c */
 /*     note:       for hrv and tm experiments long. and lat. are the    c */
 /*                 coordinates of the scene center.                     c */
 /*                 lat. must be > 0 for north lat., < 0 for south lat.  c */

Modified: grass/trunk/imagery/i.atcorr/Iwave.cpp
===================================================================
--- grass/trunk/imagery/i.atcorr/Iwave.cpp	2010-07-08 10:35:07 UTC (rev 42718)
+++ grass/trunk/imagery/i.atcorr/Iwave.cpp	2010-07-08 12:08:41 UTC (rev 42719)
@@ -1958,6 +1958,90 @@
     }
 }
 
+void IWave::avnir(int iwa)
+{
+    /* band 1 of avnir */
+    static const float sr1[64] = {
+        0.00,    0.00,    0.00,    0.00,    0.00,    0.01,    0.01,
+        0.02,    0.03,    0.08,    0.13,    0.27,    0.40,    0.54,
+        0.67,    0.70,    0.72,    0.72,    0.73,    0.72,    0.72,
+        0.77,    0.82,    0.85,    0.88,    0.91,    0.93,    0.93,
+        0.93,    0.93,    0.93,    0.93,    0.94,    0.94,    0.94,
+        0.94,    0.94,    0.94,    0.94,    0.96,    0.98,    0.96,
+        0.94,    0.89,    0.85,    0.80,    0.75,    0.70,    0.66,
+        0.61,    0.56,    0.52,    0.47,    0.42,    0.38,    0.33,
+        0.28,    0.24,    0.19,    0.14,    0.09,    0.05,    0.00,
+        0.00 };
+
+    /* band 2 of avnir */
+    static const float sr2[84] = {
+        0.00,    0.00,    0.00,    0.00,    0.00,    0.04,    0.09,
+        0.13,    0.17,    0.22,    0.26,    0.30,    0.35,    0.39,
+        0.43,    0.48,    0.52,    0.57,    0.61,    0.65,    0.70,
+        0.74,    0.78,    0.83,    0.87,    0.87,    0.87,    0.89,
+        0.90,    0.93,    0.95,    0.96,    0.98,    0.99,    1.00,
+        0.99,    0.98,    0.94,    0.89,    0.83,    0.78,    0.77,
+        0.75,    0.72,    0.69,    0.56,    0.44,    0.30,    0.16,
+        0.10,    0.04,    0.03,    0.01,    0.01,    0.00,    0.00,
+        0.00,    0.01,    0.03,    0.04,    0.06,    0.07,    0.09,
+        0.11,    0.12,    0.14,    0.15,    0.17,    0.18,    0.20,
+        0.21,    0.23,    0.24,    0.26,    0.27,    0.29,    0.30,
+        0.32,    0.33,    0.35,    0.36,    0.38,    0.39,    0.41 };
+
+
+    /* band 3 of avnir */
+    static const float sr3[80] = {
+        0.00,    0.00,    0.00,    0.00,    0.00,    0.00,    0.00,
+        0.00,    0.00,    0.00,    0.00,    0.01,    0.01,    0.01,
+        0.01,    0.01,    0.02,    0.03,    0.03,    0.04,    0.06,
+        0.10,    0.14,    0.21,    0.28,    0.39,    0.49,    0.57,
+        0.66,    0.72,    0.78,    0.79,    0.80,    0.78,    0.76,
+        0.74,    0.72,    0.70,    0.68,    0.66,    0.64,    0.62,
+        0.60,    0.58,    0.56,    0.54,    0.52,    0.50,    0.48,
+        0.46,    0.44,    0.42,    0.40,    0.38,    0.36,    0.34,
+        0.32,    0.30,    0.28,    0.26,    0.24,    0.22,    0.20,
+        0.15,    0.09,    0.07,    0.04,    0.03,    0.02,    0.01,
+        0.01,    0.01,    0.01,    0.01,    0.00,    0.00,    0.00,
+        0.00,    0.00,    0.00 };
+
+    /* band 4 of avnir */
+    static const float sr4[90] = {
+        0.00,    0.00,    0.00,    0.00,    0.00,    0.00,    0.00,
+        0.00,    0.00,    0.00,    0.00,    0.00,    0.00,    0.01,
+        0.01,    0.02,    0.03,    0.05,    0.07,    0.12,    0.16,
+        0.23,    0.31,    0.44,    0.57,    0.72,    0.88,    0.94,
+        1.00,    0.99,    0.98,    0.96,    0.93,    0.91,    0.89,
+        0.88,    0.86,    0.86,    0.86,    0.88,    0.89,    0.92,
+        0.94,    0.94,    0.95,    0.95,    0.96,    0.94,    0.92,
+        0.90,    0.87,    0.84,    0.82,    0.78,    0.75,    0.73,
+        0.71,    0.69,    0.67,    0.66,    0.64,    0.64,    0.63,
+        0.63,    0.62,    0.62,    0.62,    0.60,    0.58,    0.58,
+        0.59,    0.59,    0.59,    0.57,    0.55,    0.53,    0.50,
+        0.45,    0.39,    0.32,    0.25,    0.19,    0.13,    0.10,
+        0.07,    0.06,    0.04,    0.03,    0.02,    0.01 };
+
+    static const float wli[4] = {0.390, 0.485, 0.545, 0.700};
+    static const float wls[4] = {0.550, 0.695, 0.745, 0.925};
+
+    ffu.wlinf = (float)wli[iwa-1];
+    ffu.wlsup = (float)wls[iwa-1];
+
+    int i;
+    for(i = 0; i < 1501; i++) ffu.s[i] = 0;
+
+    switch(iwa)
+    {
+    case 1: for(i = 0; i < 64; i++)  ffu.s[56+i] = sr1[i];
+        break;
+    case 2: for(i = 0; i < 84; i++)  ffu.s[94+i] = sr1[i];
+        break;
+    case 3: for(i = 0; i < 80; i++)  ffu.s[118+i] = sr1[i];
+        break;
+    case 4: for(i = 0; i < 90; i++)  ffu.s[180+i] = sr1[i];
+        break;
+    }
+}
+
 float IWave::equivwl() const
 {
     float seb = 0;
@@ -2025,6 +2109,7 @@
 	else if(iwave <= 67)	etmplus(iwave - 60);
 	else if(iwave <= 71)	irs_1c_liss(iwave - 67);
 	else if(iwave <= 80)	aster(iwave - 71);
+	else if(iwave <= 84)    avnir(iwave - 80);
 	else G_warning(_("Unsupported iwave value: %d"), iwave);
     }
 
@@ -2041,7 +2126,7 @@
 /* --- spectral condition ---- */
 void IWave::print()
 {
-    static const string nsat[82] = {
+    static const string nsat[86] = {
 	string(" constant        "), string(" user s          "),
 	string(" meteosat        "), string(" goes east       "), string(" goes west       "),
 	string(" avhrr 1 (noaa6) "), string(" avhrr 2 (noaa6) "),
@@ -2075,7 +2160,9 @@
 	string(" liss 5          "),
 	string(" aster 1         "), string(" aster 2         "), string(" aster 3N        "),
 	string(" aster 4         "), string(" aster 5         "), string(" aster 6         "),
-	string(" aster 7         "), string(" aster 8         "), string(" aster 9         ")
+	string(" aster 7         "), string(" aster 8         "), string(" aster 9         "),
+	string(" avnir 1         "), string(" avnir 2         "), string(" avnir 3         "),
+	string(" avnir 4         ")
     };
 
 

Modified: grass/trunk/imagery/i.atcorr/Iwave.h
===================================================================
--- grass/trunk/imagery/i.atcorr/Iwave.h	2010-07-08 10:35:07 UTC (rev 42718)
+++ grass/trunk/imagery/i.atcorr/Iwave.h	2010-07-08 12:08:41 UTC (rev 42719)
@@ -102,6 +102,10 @@
 c        78  7th      "               ( 2.200-2.393 )                  c
 c        79  8th      "               ( 2.248-2.475 )                  c
 c        80  9th      "               ( 2.295-2.538 )                  c
+c        81  1st band of avnir        ( 0.390-0.550 )                  c
+c        82  2nd      "               ( 0.485-0.695 )                  c
+c        83  3rd      "               ( 0.545-0.745 )                  c
+c        84  4th      "               ( 0.700-0.925 )                  c
 c  note: wl has to be in micrometer                                    c
 c**********************************************************************/
 
@@ -138,6 +142,7 @@
 	void etmplus(int iwa);
 	void irs_1c_liss(int iwa);
 	void aster(int iwa);
+	void avnir(int iwa);
 
 
 public:



More information about the grass-commit mailing list