GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-bea8435a9e
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
24
struct
html_state
html
;
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) {
40
html
.
BBOX_MINIMUM
=
DEF_MINBBOX
;
41
}
42
}
43
else
{
44
html
.
BBOX_MINIMUM
=
DEF_MINBBOX
;
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) {
54
html
.
MAX_POINTS
=
DEF_MAXPTS
;
55
}
56
}
57
else
{
58
html
.
MAX_POINTS
=
DEF_MAXPTS
;
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) {
68
html
.
MINIMUM_DIST
=
DEF_MINDIST
;
69
}
70
}
71
else
{
72
html
.
MINIMUM_DIST
=
DEF_MINDIST
;
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'
;
125
html
.
last_text_len
=
INITIAL_TEXT
;
126
127
html
.
head
=
NULL
;
128
html
.
tail
= &
html
.
head
;
129
130
return
0;
131
}
NULL
#define NULL
Definition:
ccmath.h:32
G_fatal_error
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
G_malloc
#define G_malloc(n)
Definition:
defs/gis.h:94
G_verbose_message
void void G_verbose_message(const char *,...) __attribute__((format(printf
driver.h
screen_height
int screen_height
Definition:
driver/init.c:30
screen_width
int screen_width
Definition:
driver/init.c:29
driverlib.h
gis.h
G_gisinit
#define G_gisinit(pgm)
Definition:
gis.h:72
glocale.h
_
#define _(str)
Definition:
glocale.h:10
HTML_Graph_set
int HTML_Graph_set(void)
Definition:
htmldriver/graph_set.c:26
html
struct html_state html
Definition:
htmldriver/graph_set.c:24
htmlmap.h
DEF_MAXPTS
#define DEF_MAXPTS
Definition:
htmlmap.h:6
DEF_MINDIST
#define DEF_MINDIST
Definition:
htmlmap.h:5
INITIAL_TEXT
#define INITIAL_TEXT
Definition:
htmlmap.h:10
RAW
#define RAW
Definition:
htmlmap.h:15
FILE_NAME
#define FILE_NAME
Definition:
htmlmap.h:8
APACHE
#define APACHE
Definition:
htmlmap.h:12
DEF_MINBBOX
#define DEF_MINBBOX
Definition:
htmlmap.h:4
CLIENT
#define CLIENT
Definition:
htmlmap.h:14
html_state
Definition:
htmlmap.h:25
html_state::MAX_POINTS
int MAX_POINTS
Definition:
htmlmap.h:32
html_state::type
int type
Definition:
htmlmap.h:28
html_state::head
struct MapPoly * head
Definition:
htmlmap.h:30
html_state::last_text
char * last_text
Definition:
htmlmap.h:26
html_state::last_text_len
int last_text_len
Definition:
htmlmap.h:27
html_state::tail
struct MapPoly ** tail
Definition:
htmlmap.h:31
html_state::output
FILE * output
Definition:
htmlmap.h:29
html_state::MINIMUM_DIST
int MINIMUM_DIST
Definition:
htmlmap.h:34
html_state::BBOX_MINIMUM
int BBOX_MINIMUM
Definition:
htmlmap.h:33
lib
htmldriver
graph_set.c
Generated on Sun Nov 24 2024 07:03:38 for GRASS GIS 8 Programmer's Manual by
1.9.1