[GRASS-SVN] r69307 - grass/trunk/display/d.vect.thematic
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Aug 30 20:05:21 PDT 2016
Author: annakrat
Date: 2016-08-30 20:05:21 -0700 (Tue, 30 Aug 2016)
New Revision: 69307
Modified:
grass/trunk/display/d.vect.thematic/legend.c
grass/trunk/display/d.vect.thematic/local_proto.h
grass/trunk/display/d.vect.thematic/main.c
Log:
d.vect.thematic: show correct number of features for classes, make legendfile and -e flag deprecated
Modified: grass/trunk/display/d.vect.thematic/legend.c
===================================================================
--- grass/trunk/display/d.vect.thematic/legend.c 2016-08-30 22:48:04 UTC (rev 69306)
+++ grass/trunk/display/d.vect.thematic/legend.c 2016-08-31 03:05:21 UTC (rev 69307)
@@ -17,7 +17,7 @@
void write_into_legend_file(const char *legfile, const char *icon, const char *title, double stats_min, double stats_max,
double *breakpoints, int nbreaks, int size, struct color_rgb bcolor,
- struct color_rgb *colors, int default_width, int nfeatures, const char *topo)
+ struct color_rgb *colors, int default_width, int* frequencies, const char *topo)
{
FILE *fd;
int i;
@@ -40,14 +40,14 @@
fprintf(fd, "%s|%d|%d:%d:%d|%d:%d:%d|%d|%s|%d\n",
icon, size, bcolor.r, bcolor.g, bcolor.b,
colors[0].r, colors[0].g, colors[0].b, default_width,
- topo, nfeatures);
+ topo, frequencies[0]);
/* Middle lines */
for (i = 1; i < nbreaks; i++){
fprintf(fd, "%.2f - %.2f|%s|%d|%d:%d:%d|%d:%d:%d|%d|%s|%d\n",
breakpoints[i-1],breakpoints[i],
icon, size, bcolor.r, bcolor.g, bcolor.b,
colors[i].r, colors[i].g, colors[i].b, default_width,
- topo, nfeatures);
+ topo, frequencies[i]);
}
/* Last one */
if(stats_max < breakpoints[nbreaks-1]){
@@ -59,7 +59,7 @@
fprintf(fd, "%s|%d|%d:%d:%d|%d:%d:%d|%d|%s|%d\n",
icon, size, bcolor.r, bcolor.g, bcolor.b,
colors[nbreaks].r, colors[nbreaks].g, colors[nbreaks].b, default_width,
- topo, nfeatures);
+ topo, frequencies[nbreaks]);
fclose(fd);
}
Modified: grass/trunk/display/d.vect.thematic/local_proto.h
===================================================================
--- grass/trunk/display/d.vect.thematic/local_proto.h 2016-08-30 22:48:04 UTC (rev 69306)
+++ grass/trunk/display/d.vect.thematic/local_proto.h 2016-08-31 03:05:21 UTC (rev 69307)
@@ -31,4 +31,4 @@
/* legend.c */
void write_into_legend_file(const char *, const char *, const char *, double, double,
double *, int, int, struct color_rgb,
- struct color_rgb *, int, int, const char *);
+ struct color_rgb *, int, int*, const char *);
Modified: grass/trunk/display/d.vect.thematic/main.c
===================================================================
--- grass/trunk/display/d.vect.thematic/main.c 2016-08-30 22:48:04 UTC (rev 69306)
+++ grass/trunk/display/d.vect.thematic/main.c 2016-08-31 03:05:21 UTC (rev 69307)
@@ -60,7 +60,7 @@
struct Option *size_opt;
struct Option *title_opt;
struct Flag *legend_flag, *algoinfo_flag, *nodraw_flag;
- char *desc;
+ char *desc, *deprecated;
struct cat_list *Clist;
int *cats, ncat, nrec, ctype;
@@ -208,8 +208,12 @@
legend_file_opt = G_define_standard_option(G_OPT_F_OUTPUT);
legend_file_opt->key = "legendfile";
- legend_file_opt->description =
- _("Output legend file");
+ deprecated = NULL;
+ G_asprintf(&deprecated,
+ "[%s] %s",
+ _("DEPRECATED"),
+ _("Output legend file"));
+ legend_file_opt->description = deprecated;
legend_file_opt->required = NO;
legend_file_opt->guisection = _("Legend");
@@ -219,16 +223,20 @@
_("Create legend information and send to stdout");
legend_flag->guisection = _("Legend");
+ nodraw_flag = G_define_flag();
+ nodraw_flag->key = 'n';
+ nodraw_flag->description = _("Do not draw map, only output the legend information");
+ nodraw_flag->guisection = _("Legend");
+
algoinfo_flag = G_define_flag();
algoinfo_flag->key = 'e';
- algoinfo_flag->description =
- _("When printing legend info, include extended statistical info from classification algorithm");
+ deprecated = NULL;
+ G_asprintf(&deprecated,
+ "[%s] %s",
+ _("DEPRECATED"),
+ _("When printing legend info, include extended statistical info from classification algorithm"));
+ algoinfo_flag->description = deprecated;
algoinfo_flag->guisection = _("Legend");
-
- nodraw_flag = G_define_flag();
- nodraw_flag->key = 'n';
- nodraw_flag->description = _("Do not draw map, only output the legend");
- nodraw_flag->guisection = _("Legend");
G_option_required(algo_opt, breaks_opt, NULL);
G_option_exclusive(algo_opt, breaks_opt, NULL);
@@ -238,6 +246,15 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+ if (algoinfo_flag->answer)
+ G_warning(_("Flag -e is deprecated, set verbose mode with --v to get the extended statistical info."));
+
+ if (legend_file_opt->answer)
+ G_warning(_("Option legendfile is deprecated, either use flag -l "
+ "to print legend to standard output, "
+ "or set GRASS_LEGEND_FILE environment variable "
+ "(see d.legend.vect for details)."));
+
if (G_verbose() > G_verbose_std())
verbose = TRUE;
@@ -496,36 +513,33 @@
/*Get basic statistics about the data */
AS_basic_stats(data, nrec, &stats);
- /* Print legfile to stdout */
+ /* Print statistics */
+ G_verbose_message(_("\nTotal number of records: %.0f\n"),
+ stats.count);
+ G_verbose_message(_("Classification of %s into %i classes\n"),
+ column_opt->answer, nbreaks + 1);
+ G_verbose_message(_("Using algorithm: *** %s ***\n"),
+ algo_opt->answer);
+ G_verbose_message(_("Mean: %f\tStandard deviation = %f\n"),
+ stats.mean, stats.stdev);
+
+ if (G_strcasecmp(algo_opt->answer, "dis") == 0)
+ G_verbose_message(_("Last chi2 = %f\n"), class_info);
+ if (G_strcasecmp(algo_opt->answer, "std") == 0)
+ G_verbose_message(_("Stdev multiplied by %.4f to define step\n"),
+ class_info);
+ G_verbose_message("\n");
+
+ /* Print legfile to stdout */
if ((legend_flag->answer) ||
((legend_file_opt->answer) && (strcmp(legend_file_opt->answer,"-") == 0))) {
- /* Print statistics */
- if (algoinfo_flag->answer) {
- fprintf(stdout, _("\nTotal number of records: %.0f\n"),
- stats.count);
- fprintf(stdout, _("Classification of %s into %i classes\n"),
- column_opt->answer, nbreaks + 1);
- fprintf(stdout, _("Using algorithm: *** %s ***\n"),
- algo_opt->answer);
- fprintf(stdout, _("Mean: %f\tStandard deviation = %f\n"),
- stats.mean, stats.stdev);
-
- if (G_strcasecmp(algo_opt->answer, "dis") == 0)
- fprintf(stdout, _("Last chi2 = %f\n"), class_info);
- if (G_strcasecmp(algo_opt->answer, "std") == 0)
- fprintf(stdout,
- _("Stdev multiplied by %.4f to define step\n"),
- class_info);
- fprintf(stdout, "\n");
- }
-
while (TRUE) {
nfeatures = Vect_get_num_primitives(&Map, GV_POINT);
if (nfeatures > 0) {
write_into_legend_file("stdout", icon_opt->answer,
title, stats.min, stats.max, breakpoints,
nbreaks, size, bcolor, colors, default_width,
- nfeatures, "point");
+ frequencies, "point");
break;
}
nfeatures = Vect_get_num_primitives(&Map, GV_LINE);
@@ -533,7 +547,7 @@
write_into_legend_file("stdout", icon_line_opt->answer,
title, stats.min, stats.max, breakpoints,
nbreaks, size, bcolor, colors, default_width,
- nfeatures, "line");
+ frequencies, "line");
break;
}
nfeatures = Vect_get_num_primitives(&Map, GV_BOUNDARY);
@@ -541,7 +555,7 @@
write_into_legend_file("stdout", icon_area_opt->answer,
title, stats.min, stats.max, breakpoints,
nbreaks, size, bcolor, colors, default_width,
- nfeatures, "area");
+ frequencies, "area");
break;
}
}
@@ -556,7 +570,7 @@
write_into_legend_file(leg_file, icon_opt->answer,
title, stats.min, stats.max, breakpoints,
nbreaks, size, bcolor, colors, default_width,
- nfeatures, "point");
+ frequencies, "point");
break;
}
nfeatures = Vect_get_num_primitives(&Map, GV_LINE);
@@ -564,7 +578,7 @@
write_into_legend_file(leg_file, icon_line_opt->answer,
title, stats.min, stats.max, breakpoints,
nbreaks, size, bcolor, colors, default_width,
- nfeatures, "line");
+ frequencies, "line");
break;
}
nfeatures = Vect_get_num_primitives(&Map, GV_BOUNDARY);
@@ -572,13 +586,11 @@
write_into_legend_file(leg_file, icon_area_opt->answer,
title, stats.min, stats.max, breakpoints,
nbreaks, size, bcolor, colors, default_width,
- nfeatures, "area");
+ frequencies, "area");
break;
}
}
}
- else
- G_fatal_error(_("Unable to open legend file %s."), leg_file);
/* Write into user-specified output file */
@@ -589,7 +601,7 @@
write_into_legend_file(legend_file_opt->answer, icon_opt->answer,
title, stats.min, stats.max, breakpoints,
nbreaks, size, bcolor, colors, default_width,
- nfeatures, "point");
+ frequencies, "point");
break;
}
nfeatures = Vect_get_num_primitives(&Map, GV_LINE);
@@ -597,7 +609,7 @@
write_into_legend_file(legend_file_opt->answer, icon_line_opt->answer,
title, stats.min, stats.max, breakpoints,
nbreaks, size, bcolor, colors, default_width,
- nfeatures, "line");
+ frequencies, "line");
break;
}
nfeatures = Vect_get_num_primitives(&Map, GV_BOUNDARY);
@@ -605,7 +617,7 @@
write_into_legend_file(legend_file_opt->answer, icon_area_opt->answer,
title, stats.min, stats.max, breakpoints,
nbreaks, size, bcolor, colors, default_width,
- nfeatures, "area");
+ frequencies, "area");
break;
}
}
More information about the grass-commit
mailing list