Преглед изворни кода

Support user defined column names.

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@48379 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert пре 13 година
родитељ
комит
9aa1da0dc5
1 измењених фајлова са 18 додато и 5 уклоњено
  1. 18 5
      raster/r.to.vect/main.c

+ 18 - 5
raster/r.to.vect/main.c

@@ -59,7 +59,7 @@ dbString sql, label;
 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 @@ int main(int argc, char *argv[])
     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 @@ int main(int argc, char *argv[])
 	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) {