File: Graph_Set.c

package info (click to toggle)
grass 6.0.2-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 40,044 kB
  • ctags: 31,303
  • sloc: ansic: 321,125; tcl: 25,676; sh: 11,176; cpp: 10,098; makefile: 5,025; fortran: 1,846; yacc: 493; lex: 462; perl: 133; sed: 1
file content (140 lines) | stat: -rw-r--r-- 2,852 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
 * Start up graphics processing.  Anything that needs to be assigned, set up,
 * started-up, or otherwise initialized happens here.  This is called only at
 * the startup of the graphics driver.
 *
 * The external variables define the pixle limits of the graphics surface.  The
 * coordinate system used by the applications programs has the (0,0) origin
 * in the upper left-hand corner.  Hence,
 *    screen_left < screen_right
 *    screen_top  < screen_bottom 
 *
 */

#include <string.h>
#include <stdlib.h>

#include "gis.h"
#include "driverlib.h"
#include "driver.h"
#include "htmlmap.h"

char *last_text;
int   last_text_len;
char *file_name;
int   html_type;
FILE *output;

struct MapPoly *head;
struct MapPoly **tail;

int BBOX_MINIMUM;
int MAX_POINTS;
int MINIMUM_DIST;

int Graph_Set (int argc, char **argv) 
{
    char *p;

    G_gisinit("HTMLMAP driver") ;

    NCOLORS = 256;

    /*
     * set the minimum bounding box dimensions 
     */

    if (NULL != (p = getenv ("GRASS_HTMLMINBBOX"))) {
	BBOX_MINIMUM = atoi (p);
        if (BBOX_MINIMUM <= 0) {
            BBOX_MINIMUM = DEF_MINBBOX;
        }
    } else {
	BBOX_MINIMUM = DEF_MINBBOX;
    }

    /*
     * set the maximum number of points
     */

    if (NULL != (p = getenv ("GRASS_HTMLMAXPOINTS"))) {
	MAX_POINTS = atoi (p);
        if (MAX_POINTS <= 0) {
            MAX_POINTS = DEF_MAXPTS;
        }
    } else {
	MAX_POINTS = DEF_MAXPTS;
    }

    /*
     * set the minimum difference to keep a point
     */

    if (NULL != (p = getenv ("GRASS_HTMLMINDIST"))) {
	MINIMUM_DIST = atoi (p);
        if (MINIMUM_DIST <= 0) {
            MINIMUM_DIST = DEF_MINDIST;
        }
    } else {
	MINIMUM_DIST = DEF_MINDIST;
    }


    /*
     * open the output file
     */

    if (NULL != (p = getenv ("GRASS_HTMLFILE"))) {
        if (strlen(p) == 0) {
            p = FILE_NAME;
        }
    } else {
        p = FILE_NAME;
    }
    file_name = p;

    output = fopen(file_name, "w");
    if (output == NULL) {
        fprintf(stderr,"HTMLMAP: couldn't open output file %s\n",file_name);
        exit(1);
    }


    printf("HTMLMAP: collecting to file: %s\n width = %d, height = %d, ",
		file_name, screen_right, screen_bottom);

    /*
     * check type of map wanted
     */

    if (NULL == (p = getenv ("GRASS_HTMLTYPE"))) {
        p = "CLIENT";
    }

    if (strcmp(p,"APACHE") == 0) {
        html_type = APACHE;
        printf("type = APACHE\n");

    } else if (strcmp(p,"RAW") == 0) {
        html_type = RAW;
        printf("type = RAW\n");

    } else {
        html_type = CLIENT;
        printf("type = CLIENT\n");
    }


    /*
     * initialize text memory and list pointers
     */
    
    last_text = (char *) malloc(INITIAL_TEXT+1);
    last_text[0] = '\0';
    last_text_len = INITIAL_TEXT;

    head = NULL;
    tail = &head;

    return 0;
}