[GRASS-SVN] r68857 - grass-addons/grass7/vector/v.civil

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 4 06:48:40 PDT 2016


Author: jfc
Date: 2016-07-04 06:48:40 -0700 (Mon, 04 Jul 2016)
New Revision: 68857

Modified:
   grass-addons/grass7/vector/v.civil/road_tables.py
   grass-addons/grass7/vector/v.civil/v.road.py
Log:
v.road update rewrite_obj funtion

Modified: grass-addons/grass7/vector/v.civil/road_tables.py
===================================================================
--- grass-addons/grass7/vector/v.civil/road_tables.py	2016-07-04 12:53:22 UTC (rev 68856)
+++ grass-addons/grass7/vector/v.civil/road_tables.py	2016-07-04 13:48:40 UTC (rev 68857)
@@ -8,6 +8,8 @@
 # from grass.pygrass.vector.table import Link
 import time
 import grass.script as grass
+import grass.lib.vector as libvect
+from grass.pygrass.errors import GrassError
 from grass.pygrass.vector.geometry import Point
 from grass.pygrass.vector import sql
 from grass.pygrass.vector.table import Link
@@ -465,15 +467,36 @@
         """Return
         """
         self.polygon.open('rw', self.layer, with_z=True)
+        cat = attrs[0]
 
-        if isinstance(obj, Point):
-            type_obj = 'points'
-        else:
-            type_obj = 'lines'
+        if obj.gtype == 1:
+            vtype = 'points'
+        elif obj.gtype == 2:
+            vtype = 'lines'
+        elif obj.gtype == 3:
+            vtype = 'boundary'
+        elif obj.gtype == 4:
+            vtype = 'centroid'
 
-        obj_org = self.polygon.cat(attrs[0], type_obj, self.layer)[0]
-        obj_org.x, obj_org.y, obj_org.z = obj.x, obj.y, obj.z
-        self.polygon.rewrite(obj_org, attrs[0], attrs[1:])
+        line = self.polygon.cat(cat, vtype, self.layer)[0]
+
+        if self.polygon.table is not None and attrs:
+            self.polygon.table.update(key=line.cat, values=attrs[1:])
+        elif self.polygon.table is None and attrs:
+            print("Table for vector {name} does not exist, attributes not"
+                  " loaded".format(name=self.name))
+        # libvect.Vect_cat_set(obj.c_cats, self.layer, line.cat)
+
+        result = libvect.Vect_rewrite_line(self.polygon.c_mapinfo,
+                                           line.id, obj.gtype,
+                                           obj.c_points,
+                                           line.c_cats)
+        if result == -1:
+            raise GrassError("Not able to write the vector feature.")
+
+        # return offset into file where the feature starts
+        obj.offset = result
+
         self.polygon.table.conn.commit()
         self.polygon.close()
 

Modified: grass-addons/grass7/vector/v.civil/v.road.py
===================================================================
--- grass-addons/grass7/vector/v.civil/v.road.py	2016-07-04 12:53:22 UTC (rev 68856)
+++ grass-addons/grass7/vector/v.civil/v.road.py	2016-07-04 13:48:40 UTC (rev 68857)
@@ -680,8 +680,7 @@
             # if 'nnbathy' in tinraster:
                 # tin.nnbathy()
 
-        else:
-            sys.exit(0)
+        sys.exit(0)
 
 ################### Backup ##################
 



More information about the grass-commit mailing list