[GRASS-SVN] r54501 - grass/trunk/gui/wxpython/iclass
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jan 2 08:54:45 PST 2013
Author: martinl
Date: 2013-01-02 08:54:45 -0800 (Wed, 02 Jan 2013)
New Revision: 54501
Modified:
grass/trunk/gui/wxpython/iclass/frame.py
Log:
wxGUI/iclass: fix broken connections when importing vector training areas map
Modified: grass/trunk/gui/wxpython/iclass/frame.py
===================================================================
--- grass/trunk/gui/wxpython/iclass/frame.py 2013-01-02 16:33:42 UTC (rev 54500)
+++ grass/trunk/gui/wxpython/iclass/frame.py 2013-01-02 16:54:45 UTC (rev 54501)
@@ -45,7 +45,7 @@
from vdigit.toolbars import VDigitToolbar
from gui_core.mapdisp import DoubleMapFrame
from core.render import Map, MapLayer
-from core.gcmd import RunCommand, GMessage, GError
+from core.gcmd import RunCommand, GMessage, GError, GWarning
from gui_core.dialogs import SetOpacityDialog
from dbmgr.vinfo import VectorDBInfo
import grass.script as grass
@@ -522,6 +522,14 @@
wx.EndBusyCursor()
return False
+ # check if attribute table really exists (fix broken connections)
+ for layer in grass.vector_db(vector):
+ if 0 != RunCommand('v.db.select', map = vector, where = "0 = 1"):
+ GWarning(_("Vector map <%s>: no attribute table found") % vector,
+ parent = self)
+ RunCommand('v.db.connect', flags = 'd', map = vector, layer = layer,
+ quiet = True)
+
if 0 != RunCommand('g.copy',
vect = [vector, self.trainingAreaVector],
overwrite = True, quiet = True,
@@ -633,11 +641,13 @@
vName = dlg.GetVectorName()
self.exportVector = vName
withTable = dlg.WithTable()
+ dlg.Destroy()
- self.ExportAreas(vectorName = vName, withTable = withTable)
-
- dlg.Destroy()
-
+ if self.ExportAreas(vectorName = vName, withTable = withTable):
+ GMessage(_("%d training areas (%d classes) exported to vector map <%s>.") % \
+ (self.GetAreasCount(), len(self.statisticsList),
+ self.exportVector), parent = self)
+
def ExportAreas(self, vectorName, withTable):
"""!Export training areas to new vector map (with attribute table).
@@ -657,7 +667,7 @@
vect = [self.trainingAreaVector, vectorName],
overwrite = True, quiet = True, parent = self):
wx.EndBusyCursor()
- return
+ return False
# remove connection if exists
dbinfo = grass.vector_db(vectorName)
@@ -670,7 +680,7 @@
if not withTable:
wx.EndBusyCursor()
- return
+ return False
# add new table
columns = ["class varchar(30)",
@@ -690,7 +700,7 @@
columns = columns,
parent = self):
wx.EndBusyCursor()
- return
+ return False
# populate table
for cat in self.statisticsList:
@@ -710,7 +720,8 @@
self._runDBUpdate(map = vectorName, column = "band%d_max" % (i + 1), value = stat.bands[i].max, cat = cat)
wx.EndBusyCursor()
-
+ return True
+
def _runDBUpdate(self, map, column, value, cat):
"""!Helper function for calling v.db.update.
More information about the grass-commit
mailing list