[GRASS-SVN] r65136 - grass-addons/grass7/gui/wxpython/wx.mwprecip

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Apr 25 11:13:56 PDT 2015


Author: krejcmat
Date: 2015-04-25 11:13:56 -0700 (Sat, 25 Apr 2015)
New Revision: 65136

Modified:
   grass-addons/grass7/gui/wxpython/wx.mwprecip/g.gui.mwprecip.py
   grass-addons/grass7/gui/wxpython/wx.mwprecip/mw3.py
Log:
fix data export

Modified: grass-addons/grass7/gui/wxpython/wx.mwprecip/g.gui.mwprecip.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.mwprecip/g.gui.mwprecip.py	2015-04-25 10:33:55 UTC (rev 65135)
+++ grass-addons/grass7/gui/wxpython/wx.mwprecip/g.gui.mwprecip.py	2015-04-25 18:13:56 UTC (rev 65136)
@@ -387,7 +387,7 @@
         if 'colorRules' in self.settings:
             self.colorRules.SetValue(self.settings['colorRules'])
         if 'colorName' in self.settings:
-            self.colorsName.SetValue(self.settings['colorsName'])
+            self.colorsName.SetValue(self.settings['colorName'])
 
     def saveSettings(self, evt=None, sett=None):
         if sett:
@@ -451,8 +451,26 @@
         self.chkpol = wx.CheckBox(self, label='polarization')
         self.okBtt = wx.Button(self, label='export')
         self.layout()
-        # self.chkprecip.Bind(wx.EVT_CHECKBOX,self.onChckPrec)
+        self.chkprecip.Bind(wx.EVT_CHECKBOX, self.onChckPrec)
 
+    def onChckPrec(self,evt):
+        if self.chkprecip.GetValue():
+            self.chkrx.Disable()
+            self.chktx.Disable()
+            self.chkfreq.Disable()
+            self.chkpol.Disable()
+
+            self.chkrx.SetValue(False)
+            self.chktx.SetValue(False)
+            self.chkfreq.SetValue(False)
+            self.chkpol.SetValue(False)
+        else:
+            self.chkrx.Enable()
+            self.chktx.Enable()
+            self.chkfreq.Enable()
+            self.chkpol.Enable()
+
+
     def layout(self):
         mainSizer = wx.BoxSizer(wx.VERTICAL)
 
@@ -508,7 +526,7 @@
         self.ntb.AddPage(page=self.pointInter, text='Points Interpolation')
 
         self.grassLayers = GrassLayers(self.ntb, self.settings)
-        self.ntb.AddPage(page=self.grassLayers, text='Layers')
+        self.ntb.AddPage(page=self.grassLayers, text='Colors')
 
         #def initProfileSett(self):
         self.loadScheme = wx.StaticText(self.mainPanel, label='Load settings', id=wx.ID_ANY)
@@ -825,17 +843,21 @@
             interface.initTimeWinMW()
             interface.initBaseline()
             interface.doCompute()
-            conn = self.GetConnection()
+            if interface.connStatus:
+                conn= interface.dbConn
+
             sql = 'SELECT * FROM %s.%s' % (interface.dbConn.schema, interface.dbConn.computedPrecip)
             res = conn.connection.executeSql(sql, True, True)
             lines = ''
             for r in res:
                 lines += str(r)[1:][:-1] + '\n'
+
             print conn.pathworkSchemaDir
             #path=os.path.join(conn.pathworkSchemaDir, "export")
             io0 = open(path, "w+")
             io0.writelines(lines)
             io0.close()
+            os.remove(os.path.join(interface.dbConn.pathworkSchemaDir, "precip"))
             GMessage('Data exported<%s>' % path)
 
         self.exportDialog.Destroy()

Modified: grass-addons/grass7/gui/wxpython/wx.mwprecip/mw3.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.mwprecip/mw3.py	2015-04-25 10:33:55 UTC (rev 65135)
+++ grass-addons/grass7/gui/wxpython/wx.mwprecip/mw3.py	2015-04-25 18:13:56 UTC (rev 65136)
@@ -392,6 +392,10 @@
                                  self.sumStep)
         self.database.connection.executeSql(sql, False, True)
 
+        sql ='ALTER %s %s.%s\
+                ADD %s VARCHAR(11) '% (self.viewStatement, self.schema, self.viewDB,self.database.colorCol)
+        self.database.connection.executeSql(sql, False, True)
+
     def setTimestamp(self):
         self.timestamp_min = self.database.minTimestamp()
         self.timestamp_max = self.database.maxTimestamp()
@@ -550,6 +554,7 @@
             self.timeWin.createWin()
             self.status['bool'] = True
 
+
     def GetStatus(self):
         return self.status.get('bool'), self.status.get('msg')
 
@@ -1004,8 +1009,6 @@
                 temp.append(out)
 
         grass.message("Computing precipitation-done")
-        # write values to flat file
-        # print temp
         pathExp = os.path.join(self.database.pathworkSchemaDir, "precip")
         io = open(pathExp, 'w+')
         io.writelines(temp)
@@ -1013,14 +1016,16 @@
         #if getData:
         grass.message("Computed data has been saved to <%s>" % pathExp)
         grass.message("File structure is <linkid> <time> <precipitation>")
-        if dataOnly:
-            return False
 
+
+
         grass.message("Writing computed precipitation to database...")
         io1 = open(os.path.join(self.database.pathworkSchemaDir, "precip"), "r")
         self.database.connection.copyfrom(io1, compPrecTab)
-        #grass.message("Done")
-        #
+
+        if dataOnly:
+            return False
+
         return True
 
     def computeAlphaK(self, freq, polarization):
@@ -1121,8 +1126,9 @@
                        use='attr',
                        column=self.database.precipColName,
                        color=self.color,
-                       rgb_column='GRASSRGB',
+                       rgb_column=self.database.colorCol,
                        layer=lay)
+
         if self.rules is not None:
             for lay in range(1, self.getNumLayer(self.database.linkVecMapName), 1):
                 Module('v.colors',
@@ -1130,8 +1136,9 @@
                        use='attr',
                        column=self.database.precipColName,
                        rules=self.rules,
-                       rgb_column='GRASSRGB',
+                       rgb_column=self.database.colorCol,
                        layer=lay)
+
         grass.message('Creating RGB column in database-done')
 
     def getNumLayer(self, map):
@@ -1317,6 +1324,7 @@
         self.rgaugRecord = 'rgauge_record'
         self.rgaugeTableName = 'rgauge'
         self.precipColName = 'precip_mm_h'
+        self.colorCol= 'rgb'
 
         self.nodeVecMapName = nodeVecMapName
         self.linkVecMapName = linkVecMapName



More information about the grass-commit mailing list