|
@@ -35,12 +35,13 @@ int main(int argc, char *argv[])
|
|
} flag;
|
|
} flag;
|
|
|
|
|
|
struct {
|
|
struct {
|
|
- struct Option *map, *field, *colr, *rast, *volume, *rules,
|
|
|
|
- *attrcol, *rgbcol, *range, *use;
|
|
|
|
|
|
+ struct Option *map, *field, *colr, *rast, *volume, *rules, *attrcol,
|
|
|
|
+ *rgbcol, *range, *use;
|
|
} opt;
|
|
} opt;
|
|
|
|
|
|
int layer;
|
|
int layer;
|
|
- int overwrite, remove, is_from_stdin, stat, have_colors, convert, use;
|
|
|
|
|
|
+ int overwrite, remove, is_from_stdin, stat, have_colors, convert, invert,
|
|
|
|
+ use;
|
|
const char *mapset, *cmapset;
|
|
const char *mapset, *cmapset;
|
|
const char *style, *rules, *cmap, *attrcolumn, *rgbcolumn;
|
|
const char *style, *rules, *cmap, *attrcolumn, *rgbcolumn;
|
|
char *name;
|
|
char *name;
|
|
@@ -188,6 +189,7 @@ int main(int argc, char *argv[])
|
|
attrcolumn = opt.attrcol->answer;
|
|
attrcolumn = opt.attrcol->answer;
|
|
rgbcolumn = opt.rgbcol->answer;
|
|
rgbcolumn = opt.rgbcol->answer;
|
|
convert = flag.c->answer;
|
|
convert = flag.c->answer;
|
|
|
|
+ invert = flag.n->answer;
|
|
use = USE_CAT;
|
|
use = USE_CAT;
|
|
if (opt.use->answer) {
|
|
if (opt.use->answer) {
|
|
switch (opt.use->answer[0]) {
|
|
switch (opt.use->answer[0]) {
|
|
@@ -212,7 +214,8 @@ int main(int argc, char *argv[])
|
|
if (use == USE_ATTR && !attrcolumn)
|
|
if (use == USE_ATTR && !attrcolumn)
|
|
G_fatal_error(_("Option <%s> required"), opt.attrcol->key);
|
|
G_fatal_error(_("Option <%s> required"), opt.attrcol->key);
|
|
if (use != USE_ATTR && attrcolumn) {
|
|
if (use != USE_ATTR && attrcolumn) {
|
|
- G_important_message(_("Option <%s> given, assuming <use=attr>..."), opt.attrcol->key);
|
|
|
|
|
|
+ G_important_message(_("Option <%s> given, assuming <use=attr>..."),
|
|
|
|
+ opt.attrcol->key);
|
|
use = USE_ATTR;
|
|
use = USE_ATTR;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -253,7 +256,8 @@ int main(int argc, char *argv[])
|
|
if (remove) {
|
|
if (remove) {
|
|
stat = Vect_remove_colors(name, mapset);
|
|
stat = Vect_remove_colors(name, mapset);
|
|
if (stat < 0)
|
|
if (stat < 0)
|
|
- G_fatal_error(_("Unable to remove color table of vector map <%s>"), name);
|
|
|
|
|
|
+ G_fatal_error(_("Unable to remove color table of vector map <%s>"),
|
|
|
|
+ name);
|
|
if (stat == 0)
|
|
if (stat == 0)
|
|
G_warning(_("Color table of vector map <%s> not found"), name);
|
|
G_warning(_("Color table of vector map <%s> not found"), name);
|
|
return EXIT_SUCCESS;
|
|
return EXIT_SUCCESS;
|
|
@@ -262,9 +266,8 @@ int main(int argc, char *argv[])
|
|
G_suppress_warnings(TRUE);
|
|
G_suppress_warnings(TRUE);
|
|
have_colors = Vect_read_colors(name, mapset, NULL);
|
|
have_colors = Vect_read_colors(name, mapset, NULL);
|
|
|
|
|
|
- if (have_colors > 0 && !overwrite) {
|
|
|
|
|
|
+ if (have_colors > 0 && !overwrite)
|
|
G_fatal_error(_("Color table exists. Exiting."));
|
|
G_fatal_error(_("Color table exists. Exiting."));
|
|
- }
|
|
|
|
|
|
|
|
G_suppress_warnings(FALSE);
|
|
G_suppress_warnings(FALSE);
|
|
|
|
|
|
@@ -302,12 +305,12 @@ int main(int argc, char *argv[])
|
|
else if (use == USE_Z) {
|
|
else if (use == USE_Z) {
|
|
scan_z(&Map, layer, style, rules,
|
|
scan_z(&Map, layer, style, rules,
|
|
opt.range->answer ? &range : NULL,
|
|
opt.range->answer ? &range : NULL,
|
|
- &colors);
|
|
|
|
|
|
+ &colors, invert);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
scan_attr(&Map, layer, attrcolumn, style, rules,
|
|
scan_attr(&Map, layer, attrcolumn, style, rules,
|
|
opt.range->answer ? &range : NULL,
|
|
opt.range->answer ? &range : NULL,
|
|
- &colors, NULL);
|
|
|
|
|
|
+ &colors, NULL, invert);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
@@ -332,13 +335,10 @@ int main(int argc, char *argv[])
|
|
colors_tmp = colors;
|
|
colors_tmp = colors;
|
|
scan_attr(&Map, layer, attrcolumn, style, rules,
|
|
scan_attr(&Map, layer, attrcolumn, style, rules,
|
|
opt.range->answer ? &range : NULL,
|
|
opt.range->answer ? &range : NULL,
|
|
- &colors, &colors_tmp);
|
|
|
|
|
|
+ &colors, &colors_tmp, invert);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (flag.n->answer)
|
|
|
|
- Rast_invert_colors(&colors);
|
|
|
|
-
|
|
|
|
/* TODO ?
|
|
/* TODO ?
|
|
if (flag.e->answer) {
|
|
if (flag.e->answer) {
|
|
if (!have_stats)
|
|
if (!have_stats)
|
|
@@ -357,6 +357,9 @@ int main(int argc, char *argv[])
|
|
colors = colors_tmp;
|
|
colors = colors_tmp;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (use == USE_CAT && invert)
|
|
|
|
+ Rast_invert_colors(&colors);
|
|
|
|
+
|
|
G_important_message(_("Writing color rules..."));
|
|
G_important_message(_("Writing color rules..."));
|
|
|
|
|
|
if (style || rules || opt.rast->answer || opt.volume->answer) {
|
|
if (style || rules || opt.rast->answer || opt.volume->answer) {
|
|
@@ -375,8 +378,8 @@ int main(int argc, char *argv[])
|
|
|
|
|
|
G_message(_("Color table for vector map <%s> set to '%s'"),
|
|
G_message(_("Color table for vector map <%s> set to '%s'"),
|
|
G_fully_qualified_name(name, mapset),
|
|
G_fully_qualified_name(name, mapset),
|
|
- is_from_stdin || convert ? "rules" : style ? style : rules ? rules :
|
|
|
|
- cmap);
|
|
|
|
|
|
+ is_from_stdin || convert ? "rules" :
|
|
|
|
+ (style ? style : (rules ? rules : cmap)));
|
|
|
|
|
|
exit(EXIT_SUCCESS);
|
|
exit(EXIT_SUCCESS);
|
|
}
|
|
}
|