GRASS GIS 8 Programmer's Manual 8.2.1(2023)-exported
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
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 NULL
Definition: ccmath.h:32
int screen_height
Definition: driver/init.c:30
int screen_width
Definition: driver/init.c:29
void G_verbose_message(const char *msg,...)
Print a message to stderr but only if module is in verbose mode.
Definition: gis/error.c:109
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
Definition: gis/error.c:160
int HTML_Graph_set(void)
struct html_state html
#define DEF_MAXPTS
Definition: htmlmap.h:7
#define DEF_MINDIST
Definition: htmlmap.h:6
#define INITIAL_TEXT
Definition: htmlmap.h:11
#define RAW
Definition: htmlmap.h:16
#define FILE_NAME
Definition: htmlmap.h:9
#define APACHE
Definition: htmlmap.h:13
#define DEF_MINBBOX
Definition: htmlmap.h:5
#define CLIENT
Definition: htmlmap.h:15
int MAX_POINTS
Definition: htmlmap.h:35
int type
Definition: htmlmap.h:31
struct MapPoly * head
Definition: htmlmap.h:33
char * last_text
Definition: htmlmap.h:29
int last_text_len
Definition: htmlmap.h:30
struct MapPoly ** tail
Definition: htmlmap.h:34
FILE * output
Definition: htmlmap.h:32
int MINIMUM_DIST
Definition: htmlmap.h:37
int BBOX_MINIMUM
Definition: htmlmap.h:36