GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
htmldriver/graph_set.c
Go to the documentation of this file.
1 /*
2  * Start up graphics processing. Anything that needs to be assigned, set up,
3  * started-up, or otherwise initialized happens here. This is called only at
4  * the startup of the graphics driver.
5  *
6  * The external variables define the pixle limits of the graphics surface. The
7  * coordinate system used by the applications programs has the (0,0) origin
8  * in the upper left-hand corner. Hence,
9  * screen_left < screen_right
10  * screen_top < screen_bottom
11  *
12  */
13 
14 #include <string.h>
15 #include <stdlib.h>
16 
17 #include <grass/gis.h>
18 #include <grass/glocale.h>
19 
20 #include "driverlib.h"
21 #include "driver.h"
22 #include "htmlmap.h"
23 
25 
26 int HTML_Graph_set(void)
27 {
28  char *file_name;
29  char *p;
30 
31  G_gisinit("HTMLMAP driver");
32 
33  /*
34  * set the minimum bounding box dimensions
35  */
36 
37  if (NULL != (p = getenv("GRASS_RENDER_HTMLMINBBOX"))) {
38  html.BBOX_MINIMUM = atoi(p);
39  if (html.BBOX_MINIMUM <= 0) {
41  }
42  }
43  else {
45  }
46 
47  /*
48  * set the maximum number of points
49  */
50 
51  if (NULL != (p = getenv("GRASS_RENDER_HTMLMAXPOINTS"))) {
52  html.MAX_POINTS = atoi(p);
53  if (html.MAX_POINTS <= 0) {
55  }
56  }
57  else {
59  }
60 
61  /*
62  * set the minimum difference to keep a point
63  */
64 
65  if (NULL != (p = getenv("GRASS_RENDER_HTMLMINDIST"))) {
66  html.MINIMUM_DIST = atoi(p);
67  if (html.MINIMUM_DIST <= 0) {
69  }
70  }
71  else {
73  }
74 
75 
76  /*
77  * open the output file
78  */
79 
80  if (NULL != (p = getenv("GRASS_RENDER_FILE"))) {
81  if (strlen(p) == 0) {
82  p = FILE_NAME;
83  }
84  }
85  else {
86  p = FILE_NAME;
87  }
88  file_name = p;
89 
90  html.output = fopen(file_name, "w");
91  if (html.output == NULL) {
92  G_fatal_error("HTMLMAP: couldn't open output file %s", file_name);
93  exit(EXIT_FAILURE);
94  }
95 
96 
97  G_verbose_message(_("html: collecting to file '%s'"), file_name);
98  G_verbose_message(_("html: image size %dx%d"),
100 
101  /*
102  * check type of map wanted
103  */
104 
105  if (NULL == (p = getenv("GRASS_RENDER_HTMLTYPE"))) {
106  p = "CLIENT";
107  }
108 
109  if (strcmp(p, "APACHE") == 0) {
110  html.type = APACHE;
111  G_verbose_message(_("html: type '%s'"), "apache");
112  }
113  else if (strcmp(p, "RAW") == 0) {
114  html.type = RAW;
115  G_verbose_message(_("html: type '%s'"), "raw");
116  }
117  else {
118  html.type = CLIENT;
119  G_verbose_message(_("html: type '%s'"), "client");
120  }
121 
122  /*
123  * initialize text memory and list pointers
124  */
125 
126  html.last_text = (char *)G_malloc(INITIAL_TEXT + 1);
127  html.last_text[0] = '\0';
129 
130  html.head = NULL;
131  html.tail = &html.head;
132 
133  return 0;
134 }
#define G_malloc(n)
Definition: defs/gis.h:112
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
FILE * output
Definition: htmlmap.h:32
int last_text_len
Definition: htmlmap.h:30
#define DEF_MINDIST
Definition: htmlmap.h:6
int HTML_Graph_set(void)
char * last_text
Definition: htmlmap.h:29
int type
Definition: htmlmap.h:31
int screen_width
Definition: driver/init.c:29
int screen_height
Definition: driver/init.c:30
#define NULL
Definition: ccmath.h:32
struct MapPoly * head
Definition: htmlmap.h:33
#define RAW
Definition: htmlmap.h:16
int MAX_POINTS
Definition: htmlmap.h:35
struct html_state html
struct MapPoly ** tail
Definition: htmlmap.h:34
#define G_gisinit(pgm)
Definition: gis.h:53
int MINIMUM_DIST
Definition: htmlmap.h:37
int BBOX_MINIMUM
Definition: htmlmap.h:36
#define DEF_MAXPTS
Definition: htmlmap.h:7
#define FILE_NAME
Definition: htmlmap.h:9
#define CLIENT
Definition: htmlmap.h:15
#define _(str)
Definition: glocale.h:10
#define DEF_MINBBOX
Definition: htmlmap.h:5
#define APACHE
Definition: htmlmap.h:13
#define INITIAL_TEXT
Definition: htmlmap.h:11
char * getenv()
void void G_verbose_message(const char *,...) __attribute__((format(printf