[GRASS-SVN] r69284 - grass/trunk/display/d.vect.thematic

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Aug 27 12:34:29 PDT 2016


Author: annakrat
Date: 2016-08-27 12:34:29 -0700 (Sat, 27 Aug 2016)
New Revision: 69284

Added:
   grass/trunk/display/d.vect.thematic/legend.c
Log:
d.vect.thematic: missing file added

Added: grass/trunk/display/d.vect.thematic/legend.c
===================================================================
--- grass/trunk/display/d.vect.thematic/legend.c	                        (rev 0)
+++ grass/trunk/display/d.vect.thematic/legend.c	2016-08-27 19:34:29 UTC (rev 69284)
@@ -0,0 +1,65 @@
+/* Author: Adam Laza, GSoC 2016
+ *
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <math.h>
+#include <grass/gis.h>
+#include <grass/symbol.h>
+#include <grass/vector.h>
+#include <grass/display.h>
+#include <grass/colors.h>
+#include <grass/dbmi.h>
+#include <grass/glocale.h>
+#include "plot.h"
+#include "local_proto.h"
+
+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)
+{
+    FILE *fd;
+    int i;
+
+    if (strcmp(legfile,"stdout") == 0)
+        fd = stdout;
+    else
+        fd = fopen(legfile, "a");
+
+    /* Title */
+    fprintf(fd, "|||||%s\n", title);
+
+    /* First line */
+    if (stats_min > breakpoints[0]){
+        fprintf(fd, "< %.2f|", breakpoints[0]);
+    }
+    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,
+            topo, nfeatures);
+    /* 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);
+    }
+    /* Last one */
+    if(stats_max < breakpoints[nbreaks-1]){
+        fprintf(fd, ">%.2f|", breakpoints[nbreaks - 1]);
+    }
+    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,
+            topo, nfeatures);
+
+    fclose(fd);
+}



More information about the grass-commit mailing list