[GRASS-SVN] r71147 - grass-addons/grass7/vector/v.sort.points

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 27 08:57:59 PDT 2017


Author: mlennert
Date: 2017-05-27 08:57:58 -0700 (Sat, 27 May 2017)
New Revision: 71147

Modified:
   grass-addons/grass7/vector/v.sort.points/v.sort.points.py
Log:
v.sort.points: handle non-first key column (fix #3352: Behavior of v.sort.points)

Modified: grass-addons/grass7/vector/v.sort.points/v.sort.points.py
===================================================================
--- grass-addons/grass7/vector/v.sort.points/v.sort.points.py	2017-05-26 13:21:30 UTC (rev 71146)
+++ grass-addons/grass7/vector/v.sort.points/v.sort.points.py	2017-05-27 15:57:58 UTC (rev 71147)
@@ -20,6 +20,10 @@
 #%option G_OPT_V_INPUT
 #% required: yes
 #%end
+#%option G_OPT_V_FIELD
+#% required: yes
+#% answer: 1
+#%end
 #%option G_OPT_V_OUTPUT
 #% required: yes
 #%end
@@ -49,6 +53,7 @@
 def main():
     options, flags = gscript.parser()
     inputmap = options['input']
+    layer = options['layer']
     outputmap = options['output']
     sort_column = options['column']
     reverse = True
@@ -56,6 +61,7 @@
         reverse = False
 
     columns = gscript.vector_columns(inputmap)
+    key_column = gscript.vector_layer_db(inputmap, layer)['key']
     sort_index = columns[sort_column]['index']+2
     sorted_cols = sorted(columns.iteritems(), key=lambda (x, y): y['index'])
     column_def="x DOUBLE PRECISION, y DOUBLE PRECISION, cat INTEGER"
@@ -65,6 +71,8 @@
         type = sorted_cols[colcount][1]['type']
 	if name == sort_column and (type != 'INTEGER' and type != 'DOUBLE PRECISION'):
 	    gscript.fatal('Sort column must be numeric')
+        if name == key_column:
+            continue
         colnames.append(name)
         column_def += ", %s %s" % (name, type)
 



More information about the grass-commit mailing list