Browse Source

v.report: cat mismatch bug fixed (merge from 60359)

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@60361 15284696-431f-4ddb-bdfa-cd5b030d7da7
Huidae Cho 11 years ago
parent
commit
a3f19a1521
1 changed files with 6 additions and 2 deletions
  1. 6 2
      scripts/v.report/v.report.py

+ 6 - 2
scripts/v.report/v.report.py

@@ -4,6 +4,7 @@
 #
 # MODULE:       v.report
 # AUTHOR(S):    Markus Neteler, converted to Python by Glynn Clements
+#               Bug fixed by Huidae Cho <grass4u gmail.com>
 # PURPOSE:      Reports geometry statistics for vector maps
 # COPYRIGHT:    (C) 2005, 2007-2009 by MN and the GRASS Development Team
 #
@@ -67,7 +68,6 @@ def main():
         grass.fatal(_("Vector map <%s> not found") % mapname)
 
     colnames = grass.vector_columns(mapname, layer, getDict = False, stderr = nuldev)
-    
     if not colnames:
         colnames = ['cat']
 
@@ -124,7 +124,11 @@ def main():
         records2.sort()
 
         #make pre-table
-        records3 = [r1 + r2[1:] for r1, r2 in zip(records1, records2)]
+	# len(records1) may not be the same as len(records2) because
+	# v.db.select can return attributes that are not linked to features.
+        records3 = []
+        for r2 in records2:
+            records3.append(filter(lambda r1: r1[0] == r2[0], records1)[0] + r2[1:])
     else:
         records1 = []
         p = grass.pipe_command('v.category', inp = mapname, layer = layer, option = 'print')