[GRASS-SVN] r69698 - in grass/branches/releasebranch_7_2/display: d.legend.vect d.vect d.vect.thematic
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Oct 15 20:22:49 PDT 2016
Author: annakrat
Date: 2016-10-15 20:22:49 -0700 (Sat, 15 Oct 2016)
New Revision: 69698
Modified:
grass/branches/releasebranch_7_2/display/d.legend.vect/d.legend.vect.html
grass/branches/releasebranch_7_2/display/d.legend.vect/draw.c
grass/branches/releasebranch_7_2/display/d.vect.thematic/legend.c
grass/branches/releasebranch_7_2/display/d.vect/legend.c
Log:
d.legend.vect: add new column to legend file to be able to distinguish line/fill color by d.vect and primary/secondary color by d.vect.thematic (merge from trunk, r69697)
Modified: grass/branches/releasebranch_7_2/display/d.legend.vect/d.legend.vect.html
===================================================================
--- grass/branches/releasebranch_7_2/display/d.legend.vect/d.legend.vect.html 2016-10-16 03:11:40 UTC (rev 69697)
+++ grass/branches/releasebranch_7_2/display/d.legend.vect/d.legend.vect.html 2016-10-16 03:22:49 UTC (rev 69698)
@@ -53,16 +53,19 @@
<p>
Legend file has this format:
<pre>
-label|symbol_name|feature_color|fill_color|size|line_width|geometry_type|feature_count
+label|symbol_name|size|color_type|feature_color|fill_color|line_width|geometry_type|feature_count
</pre>
+Color type can be 'lf' or 'ps'. Based on color type color columns are interpreted
+as line color and fill colors (lf), or primary and secondary colors (ps).
+Module d.vect always uses 'lf' and d.vect.thematic 'ps'.
Here is an example of legend file with subtitles:
<pre>
-Infrastructure|||||||
-major roads|legend/line|5|black|200:200:200|2|line|355
-bridges|extra/bridge|15|black|black|1|point|10938
-Hydrology|||||||
-streams|legend/line_crooked|5|30:144:255|200:200:200|3|line|8554
-water bodies|legend/area_curved|5|none|30:144:255|1|area|27764
+Infrastructure||||||||
+major roads|legend/line|5|lf|black|200:200:200|2|line|355
+bridges|extra/bridge|15|lf|black|black|1|point|10938
+Hydrology||||||||
+streams|legend/line_crooked|5|lf|30:144:255|200:200:200|3|line|8554
+water bodies|legend/area_curved|5|lf|none|30:144:255|1|area|27764
</pre>
<img alt="Example of subheadings used in vector legend"
src="d_legend_vect_subheadings.png">
Modified: grass/branches/releasebranch_7_2/display/d.legend.vect/draw.c
===================================================================
--- grass/branches/releasebranch_7_2/display/d.legend.vect/draw.c 2016-10-16 03:11:40 UTC (rev 69697)
+++ grass/branches/releasebranch_7_2/display/d.legend.vect/draw.c 2016-10-16 03:22:49 UTC (rev 69698)
@@ -29,7 +29,7 @@
char buf[BUFFSIZE];
int got_new;
SYMBOL *Symb;
- char *symb_name, *line_color_str, *fill_color_str, *label, *type_str;
+ char *symb_name, *line_color_str, *fill_color_str, *label, *type_str, *color_type;
double size, line_width;
double row_w, text_h, title_h, title_w;
RGBA_Color *line_color, *fill_color;
@@ -67,7 +67,7 @@
file_in = fopen(file_name, "r");
sub_delim = G_malloc(GNAME_MAX);
- snprintf(sub_delim, sizeof(GNAME_MAX), "%s%s%s%s%s", sep, sep, sep, sep, sep);
+ snprintf(sub_delim, sizeof(GNAME_MAX), "%s%s%s%s%s%s", sep, sep, sep, sep, sep, sep);
if (!file_in)
G_fatal_error(_("Unable to open input file <%s>"), file_name);
@@ -83,7 +83,7 @@
tokens = G_tokenize(buf, sep);
symb_name = G_store(tokens[1]);
size = atof(tokens[2]);
- type_str = G_store(tokens[6]);
+ type_str = G_store(tokens[7]);
G_free_tokens(tokens);
/* Symbol */
@@ -167,10 +167,11 @@
label = G_store(tokens[0]);
symb_name = G_store(tokens[1]);
size = atof(tokens[2]);
- line_color_str = G_store(tokens[3]);
- fill_color_str = G_store(tokens[4]);
- line_width = atof(tokens[5]);
- type_str = G_store(tokens[6]);
+ color_type = G_store(tokens[3]);
+ line_color_str = G_store(tokens[4]);
+ fill_color_str = G_store(tokens[5]);
+ line_width = atof(tokens[6]);
+ type_str = G_store(tokens[7]);
G_free_tokens(tokens);
/* Symbol */
@@ -233,8 +234,17 @@
x = x0 + offs_x + def_symb_w/2.;
y = y0 + offs_y - symb_h/2;
D_line_width(line_width);
- D_symbol(Symb, x, y, line_color, fill_color);
-
+ /* lf - line, fill (as in d.vect)*/
+ if (strcmp(color_type, "lf") == 0)
+ D_symbol(Symb, x, y, line_color, fill_color);
+ /* ps - primary, secondary (as in d.vect.thematic) */
+ else if (strcmp(color_type, "ps") == 0)
+ D_symbol2(Symb, x, y, line_color, fill_color);
+ else {
+ G_warning(_("Invalid value for color type in legend file. "
+ "Use one of 'lf' or 'ps'."));
+ D_symbol(Symb, x, y, line_color, fill_color);
+ }
x = x0 + offs_x + def_symb_w + sym_lbl_space;
y = y0 + offs_y - symb_h/2. + text_h/2.;
D_pos_abs(x, y);
Modified: grass/branches/releasebranch_7_2/display/d.vect/legend.c
===================================================================
--- grass/branches/releasebranch_7_2/display/d.vect/legend.c 2016-10-16 03:11:40 UTC (rev 69697)
+++ grass/branches/releasebranch_7_2/display/d.vect/legend.c 2016-10-16 03:22:49 UTC (rev 69698)
@@ -30,7 +30,7 @@
fprintf(fd, "%s|", leglab);
else
fprintf(fd, "%s|", map);
- fprintf(fd, "%s|%s|%s|%s|%s", icon, size, color, fcolor, width);
+ fprintf(fd, "%s|%s|lf|%s|%s|%s", icon, size, color, fcolor, width);
fprintf(fd, "|%s|%d\n", "point", nfeatures);
}
}
@@ -43,7 +43,7 @@
fprintf(fd, "%s|", leglab);
else
fprintf(fd, "%s|", map);
- fprintf(fd, "%s|%s|%s|%s|%s", icon_line, size, color, fcolor, width);
+ fprintf(fd, "%s|%s|lf|%s|%s|%s", icon_line, size, color, fcolor, width);
fprintf(fd, "|%s|%d\n", "line", nfeatures);
}
}
@@ -56,7 +56,7 @@
fprintf(fd, "%s|", leglab);
else
fprintf(fd, "%s|", map);
- fprintf(fd, "%s|%s|%s|%s|%s", icon_area, size, color, fcolor, width);
+ fprintf(fd, "%s|%s|lf|%s|%s|%s", icon_area, size, color, fcolor, width);
fprintf(fd, "|%s|%d\n", "area", nfeatures);
}
}
@@ -68,7 +68,7 @@
fprintf(fd, "%s|", leglab);
else
fprintf(fd, "%s|", map);
- fprintf(fd, "%s|%s|%s|%s|%s", icon, size, color, fcolor, width);
+ fprintf(fd, "%s|%s|lf|%s|%s|%s", icon, size, color, fcolor, width);
fprintf(fd, "|%s|%d\n", "centroid", nfeatures);
}
}
Modified: grass/branches/releasebranch_7_2/display/d.vect.thematic/legend.c
===================================================================
--- grass/branches/releasebranch_7_2/display/d.vect.thematic/legend.c 2016-10-16 03:11:40 UTC (rev 69697)
+++ grass/branches/releasebranch_7_2/display/d.vect.thematic/legend.c 2016-10-16 03:22:49 UTC (rev 69698)
@@ -28,7 +28,7 @@
fd = fopen(legfile, "a");
/* Title */
- fprintf(fd, "|||||%s\n", title);
+ fprintf(fd, "||||||%s\n", title);
/* First line */
if (stats_min > breakpoints[0]){
@@ -37,16 +37,16 @@
else{
fprintf(fd, "%.2f - %.2f|",stats_min, breakpoints[0]);
}
- 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,
+ fprintf(fd, "%s|%d|ps|%d:%d:%d|%d:%d:%d|%d|%s|%d\n",
+ icon, size, colors[0].r, colors[0].g, colors[0].b,
+ bcolor.r, bcolor.g, bcolor.b, default_width,
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",
+ fprintf(fd, "%.2f - %.2f|%s|%d|ps|%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,
+ icon, size, colors[i].r, colors[i].g, colors[i].b,
+ bcolor.r, bcolor.g, bcolor.b, default_width,
topo, frequencies[i]);
}
/* Last one */
@@ -56,9 +56,9 @@
else {
fprintf(fd, "%.2f - %.2f|", breakpoints[nbreaks - 1], stats_max);
}
- 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,
+ fprintf(fd, "%s|%d|ps|%d:%d:%d|%d:%d:%d|%d|%s|%d\n",
+ icon, size, colors[nbreaks].r, colors[nbreaks].g, colors[nbreaks].b,
+ bcolor.r, bcolor.g, bcolor.b, default_width,
topo, frequencies[nbreaks]);
fclose(fd);
More information about the grass-commit
mailing list