[GRASS-SVN] r48379 - grass/trunk/raster/r.to.vect

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Sep 20 08:03:28 EDT 2011


Author: huhabla
Date: 2011-09-20 05:03:28 -0700 (Tue, 20 Sep 2011)
New Revision: 48379

Modified:
   grass/trunk/raster/r.to.vect/main.c
Log:
Support user defined column names.


Modified: grass/trunk/raster/r.to.vect/main.c
===================================================================
--- grass/trunk/raster/r.to.vect/main.c	2011-09-20 07:06:44 UTC (rev 48378)
+++ grass/trunk/raster/r.to.vect/main.c	2011-09-20 12:03:28 UTC (rev 48379)
@@ -59,7 +59,7 @@
 int main(int argc, char *argv[])
 {
     struct GModule *module;
-    struct Option *in_opt, *out_opt, *feature_opt;
+    struct Option *in_opt, *out_opt, *feature_opt, *column_name;
     struct Flag *smooth_flg, *value_flg, *z_flg, *no_topol;
     int feature;
 
@@ -86,6 +86,14 @@
     feature_opt->answer = "line";
     feature_opt->description = _("Feature type");
 
+    column_name = G_define_option();
+    column_name->key = "column";
+    column_name->type = TYPE_STRING;
+    column_name->required = NO;
+    column_name->multiple = NO;
+    column_name->answer = "value";
+    column_name->description = _("The name of the column in the vector table. The name must be SQL compliant.");
+
     smooth_flg = G_define_flag();
     smooth_flg->key = 's';
     smooth_flg->description = _("Smooth corners of area features");
@@ -172,10 +180,15 @@
 	db_append_string(&sql, buf);
 
 	if (!value_flag) {	/* add value to the table */
-	    if (data_type == CELL_TYPE)
-		db_append_string(&sql, ", value integer");
-	    else
-		db_append_string(&sql, ", value double precision");
+	    if (data_type == CELL_TYPE) {
+		db_append_string(&sql, ", ");
+		db_append_string(&sql, column_name->answer);
+		db_append_string(&sql, " integer");
+	    } else {
+		db_append_string(&sql, ",");
+		db_append_string(&sql, column_name->answer);
+		db_append_string(&sql, " double precision");
+	    }
 	}
 
 	if (has_cats) {



More information about the grass-commit mailing list