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
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
/*
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"
),
99
screen_width
,
screen_height
);
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'
;
128
html
.
last_text_len
=
INITIAL_TEXT
;
129
130
html
.
head
=
NULL
;
131
html
.
tail
= &
html
.
head
;
132
133
return
0;
134
}
glocale.h
G_malloc
#define G_malloc(n)
Definition:
defs/gis.h:112
htmlmap.h
html_state
Definition:
htmlmap.h:27
G_fatal_error
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
html_state::output
FILE * output
Definition:
htmlmap.h:32
html_state::last_text_len
int last_text_len
Definition:
htmlmap.h:30
DEF_MINDIST
#define DEF_MINDIST
Definition:
htmlmap.h:6
HTML_Graph_set
int HTML_Graph_set(void)
Definition:
htmldriver/graph_set.c:26
html_state::last_text
char * last_text
Definition:
htmlmap.h:29
html_state::type
int type
Definition:
htmlmap.h:31
screen_width
int screen_width
Definition:
driver/init.c:29
driver.h
screen_height
int screen_height
Definition:
driver/init.c:30
NULL
#define NULL
Definition:
ccmath.h:32
gis.h
html_state::head
struct MapPoly * head
Definition:
htmlmap.h:33
RAW
#define RAW
Definition:
htmlmap.h:16
html_state::MAX_POINTS
int MAX_POINTS
Definition:
htmlmap.h:35
html
struct html_state html
Definition:
htmldriver/graph_set.c:24
html_state::tail
struct MapPoly ** tail
Definition:
htmlmap.h:34
G_gisinit
#define G_gisinit(pgm)
Definition:
gis.h:53
html_state::MINIMUM_DIST
int MINIMUM_DIST
Definition:
htmlmap.h:37
html_state::BBOX_MINIMUM
int BBOX_MINIMUM
Definition:
htmlmap.h:36
DEF_MAXPTS
#define DEF_MAXPTS
Definition:
htmlmap.h:7
FILE_NAME
#define FILE_NAME
Definition:
htmlmap.h:9
CLIENT
#define CLIENT
Definition:
htmlmap.h:15
_
#define _(str)
Definition:
glocale.h:10
DEF_MINBBOX
#define DEF_MINBBOX
Definition:
htmlmap.h:5
APACHE
#define APACHE
Definition:
htmlmap.h:13
driverlib.h
INITIAL_TEXT
#define INITIAL_TEXT
Definition:
htmlmap.h:11
getenv
char * getenv()
G_verbose_message
void void G_verbose_message(const char *,...) __attribute__((format(printf
lib
htmldriver
graph_set.c
Generated on Mon May 31 2021 05:21:29 for GRASS GIS 7 Programmer's Manual by
1.8.13