[GRASS-SVN] r73186 - grass/trunk/vector/v.colors

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Aug 26 12:57:53 PDT 2018


Author: mmetz
Date: 2018-08-26 12:57:53 -0700 (Sun, 26 Aug 2018)
New Revision: 73186

Modified:
   grass/trunk/vector/v.colors/main.c
   grass/trunk/vector/v.colors/scan_attr.c
Log:
v.colors: +flag to output color table type and value range (see #3077)

Modified: grass/trunk/vector/v.colors/main.c
===================================================================
--- grass/trunk/vector/v.colors/main.c	2018-08-26 19:57:42 UTC (rev 73185)
+++ grass/trunk/vector/v.colors/main.c	2018-08-26 19:57:53 UTC (rev 73186)
@@ -30,7 +30,7 @@
 {
     struct GModule *module;
     struct {
-	struct Flag *r, *w, *l, *g, *a, *n, *c;
+	struct Flag *r, *w, *l, *d, *g, *a, *n, *c;
     } flag; 
 
     struct {
@@ -132,6 +132,13 @@
     flag.l->suppress_required = YES;
     flag.l->guisection = _("Print");
 
+    flag.d = G_define_flag();
+    flag.d->key = 'd';
+    flag.d->label = _("List available rules with description then exit");
+    flag.d->description = _("If a color rule is given, only this rule is listed");
+    flag.d->suppress_required = YES;
+    flag.d->guisection = _("Print");
+
     flag.n = G_define_flag();
     flag.n->key = 'n';
     flag.n->description = _("Invert colors");
@@ -166,6 +173,12 @@
 	return EXIT_SUCCESS;
     }
 
+    if (flag.d->answer) {
+	G_list_color_rules_description_type(stdout, opt.colr->answer);
+
+        return EXIT_SUCCESS;
+    }
+
     overwrite = !flag.w->answer;
     remove = flag.r->answer;
     name = opt.map->answer;

Modified: grass/trunk/vector/v.colors/scan_attr.c
===================================================================
--- grass/trunk/vector/v.colors/scan_attr.c	2018-08-26 19:57:42 UTC (rev 73185)
+++ grass/trunk/vector/v.colors/scan_attr.c	2018-08-26 19:57:53 UTC (rev 73186)
@@ -107,6 +107,7 @@
     /* color table for categories */
     G_message(_("Converting color rules into categories..."));
     for (i = 0; i < cvarr->n_values; i++) {
+	G_percent(i, cvarr->n_values, 2);
 	cv = &(cvarr->value[i]);
 	cat = cv->cat;
 	if (is_fp) {
@@ -130,4 +131,5 @@
 	Rast_add_c_color_rule((const CELL*) &cat, red, grn, blu,
 			      (const CELL*) &cat, red, grn, blu, colors);
     }
+    G_percent(2, 2, 2);
 }



More information about the grass-commit mailing list