Browse Source

v.colors: +flag to output color table type and value range (see https://trac.osgeo.org/grass/ticket/3077)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@73186 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 6 years ago
parent
commit
d0cae636a3
2 changed files with 16 additions and 1 deletions
  1. 14 1
      vector/v.colors/main.c
  2. 2 0
      vector/v.colors/scan_attr.c

+ 14 - 1
vector/v.colors/main.c

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

+ 2 - 0
vector/v.colors/scan_attr.c

@@ -107,6 +107,7 @@ void color_rules_to_cats(dbCatValArray *cvarr, int is_fp,
     /* 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 @@ void color_rules_to_cats(dbCatValArray *cvarr, int is_fp,
 	Rast_add_c_color_rule((const CELL*) &cat, red, grn, blu,
 			      (const CELL*) &cat, red, grn, blu, colors);
     }
+    G_percent(2, 2, 2);
 }