[GRASS-SVN] r41958 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Apr 21 17:05:30 EDT 2010


Author: martinl
Date: 2010-04-21 17:05:30 -0400 (Wed, 21 Apr 2010)
New Revision: 41958

Modified:
   grass/trunk/gui/wxpython/gui_modules/dbm.py
   grass/trunk/gui/wxpython/gui_modules/gdialogs.py
Log:
wxGUI/dbm: fix for linked ogr vectors


Modified: grass/trunk/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/dbm.py	2010-04-21 19:23:14 UTC (rev 41957)
+++ grass/trunk/gui/wxpython/gui_modules/dbm.py	2010-04-21 21:05:30 UTC (rev 41958)
@@ -273,8 +273,15 @@
     def AddDataRow(self, i, record, columns, keyId):
         """!Add row to the data list"""
         self.itemDataMap[i] = []
+        keyColumn = self.mapDBInfo.layers[self.layer]['key']
         j = 0
+        cat = None
         
+        if keyColumn == 'OGC_FID':
+            self.itemDataMap[i].append(i+1)
+            j += 1
+            cat = i + 1
+        
         for value in record.split('|'):
             if self.columns[columns[j]]['ctype'] != types.StringType:
                 try:
@@ -291,29 +298,20 @@
                     self.itemDataMap[i].append(_("Unable to decode value. "
                                                  "Set encoding in GUI preferences ('Attributes')."))
                 
-            if keyId > -1 and keyId == j:
+            if not cat and keyId > -1 and keyId == j:
                 try:
                     cat = self.columns[columns[j]]['ctype'] (value)
                 except ValueError, e:
                     cat = -1
-                    wx.MessageBox(parent=self,
+                    gcmd.GMessage(parent = self,
                                   message=_("Error loading attribute data. "
                                             "Record number: %(rec)d. Unable to convert value '%(val)s' in "
                                             "key column (%(key)s) to integer.\n\n"
                                             "Details: %(detail)s") % \
                                       { 'rec' : i + 1, 'val' : value,
-                                        'key' : keyColumn, 'detail' : e},
-                                  caption=_("Error"),
-                                  style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+                                        'key' : keyColumn, 'detail' : e})
             j += 1
-
-        # insert to table
-        # index = self.InsertStringItem(index=sys.maxint, label=str(self.itemDataMap[i][0]))
-        # for j in range(len(self.itemDataMap[i][1:])):
-        # self.SetStringItem(index=index, col=j+1, label=str(self.itemDataMap[i][j+1]))
-            
-        # self.SetItemData(item=index, data=i)
-            
+        
         self.itemIndexMap.append(i)
         if keyId > -1: # load cats only when LoadData() is called first time
             self.itemCatsMap[i] = cat

Modified: grass/trunk/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gdialogs.py	2010-04-21 19:23:14 UTC (rev 41957)
+++ grass/trunk/gui/wxpython/gui_modules/gdialogs.py	2010-04-21 21:05:30 UTC (rev 41958)
@@ -1347,15 +1347,17 @@
                        'layers=%s' % layer,
                        'output=%s' % output]
             elif self.importType == 'ogr':
+                if layer.rfind(ext) > -1:
+                    layer = layer.replace(ext, '')
                 if self.link:
                     cmd = ['v.external',
                            'dsn=%s' % dsn,
                            'output=%s' % output,
-                           'layer=%s' % layer.rstrip(ext)]
+                           'layer=%s' % layer]
                 else:
                     cmd = ['v.in.ogr',
                            'dsn=%s' % dsn,
-                           'layer=%s' % layer.rstrip(ext),
+                           'layer=%s' % layer,
                            'output=%s' % output]
             else: # gdal
                 if self.link:



More information about the grass-commit mailing list