GRASS GIS 8 Programmer's Manual 8.3.2(2024)-exported
Loading...
Searching...
No Matches
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 * open the output file
77 */
78
79 if (NULL != (p = getenv("GRASS_RENDER_FILE"))) {
80 if (strlen(p) == 0) {
81 p = FILE_NAME;
82 }
83 }
84 else {
85 p = FILE_NAME;
86 }
87 file_name = p;
88
89 html.output = fopen(file_name, "w");
90 if (html.output == NULL) {
91 G_fatal_error("HTMLMAP: couldn't open output file %s", file_name);
92 exit(EXIT_FAILURE);
93 }
94
95 G_verbose_message(_("html: collecting to file '%s'"), file_name);
96 G_verbose_message(_("html: image size %dx%d"), screen_width, screen_height);
97
98 /*
99 * check type of map wanted
100 */
101
102 if (NULL == (p = getenv("GRASS_RENDER_HTMLTYPE"))) {
103 p = "CLIENT";
104 }
105
106 if (strcmp(p, "APACHE") == 0) {
107 html.type = APACHE;
108 G_verbose_message(_("html: type '%s'"), "apache");
109 }
110 else if (strcmp(p, "RAW") == 0) {
111 html.type = RAW;
112 G_verbose_message(_("html: type '%s'"), "raw");
113 }
114 else {
115 html.type = CLIENT;
116 G_verbose_message(_("html: type '%s'"), "client");
117 }
118
119 /*
120 * initialize text memory and list pointers
121 */
122
123 html.last_text = (char *)G_malloc(INITIAL_TEXT + 1);
124 html.last_text[0] = '\0';
126
127 html.head = NULL;
128 html.tail = &html.head;
129
130 return 0;
131}
#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:108
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
Definition gis/error.c:159
int HTML_Graph_set(void)
struct html_state html
#define DEF_MAXPTS
Definition htmlmap.h:6
#define DEF_MINDIST
Definition htmlmap.h:5
#define INITIAL_TEXT
Definition htmlmap.h:10
#define RAW
Definition htmlmap.h:15
#define FILE_NAME
Definition htmlmap.h:8
#define APACHE
Definition htmlmap.h:12
#define DEF_MINBBOX
Definition htmlmap.h:4
#define CLIENT
Definition htmlmap.h:14
int MAX_POINTS
Definition htmlmap.h:32
int type
Definition htmlmap.h:28
struct MapPoly * head
Definition htmlmap.h:30
char * last_text
Definition htmlmap.h:26
int last_text_len
Definition htmlmap.h:27
struct MapPoly ** tail
Definition htmlmap.h:31
FILE * output
Definition htmlmap.h:29
int MINIMUM_DIST
Definition htmlmap.h:34
int BBOX_MINIMUM
Definition htmlmap.h:33