1htmldriver(1) GRASS GIS User's Manual htmldriver(1)
2
3
4
6 HTML display driver to create HTML image maps.
7
9 The HTML driver allows the generation of HTML image maps for area vec‐
10 tor data. HTML image maps are used in conjunction with images to pro‐
11 vide unique URL targets for different portions of an image. The HTML
12 driver can create both client-side image maps embedded into HTML files,
13 or server-side image maps used by web server software.
14
15 Polygons can at most have 100 vertices (this limit imposed by HTML im‐
16 age map formats, see GRASS_RENDER_HTMLMAXPOINTS below.) The driver will
17 attempt to trim polygons that have more that 100 vertices by removing
18 vertices with the least amount of angle to the next vertice. Also, any
19 polygon that is entirely bounded by another polygon will be discarded.
20
21 Text written to the driver before polygons are used as the HREF tag for
22 all subsequent polygons written. All polygons that exist in a vector
23 map will have the same HREF tag.
24
25 The only GRASS display commands that should be used with this driver
26 are:
27
28 • d.text - pass href information for resulting image maps.
29
30 • d.vect - draw polygons from a vector map.
31
33 Environment variables
34 The HTML driver can be enabled by setting GRASS_RENDER_IMMEDIATE vari‐
35 able, eg.
36 export GRASS_RENDER_IMMEDIATE=html
37 Several environment variables affect the operation of the HTML driver:
38
39 • GRASS_RENDER_WIDTH=xxx
40 the width of the image map (default is 640).
41
42 • GRASS_RENDER_HEIGHT=yyy
43 the height of the image map (default is 480).
44
45 • GRASS_RENDER_HTMLTYPE=type
46 type of image mape to create (default is CLIENT):
47 CLIENT Â Â Netscape/IE client-side image map (NAME="map").
48 APACHE Â Â Apache/NCSA server-side image map.
49 RAW        Raw url and polygon vertices (url x1Â
50 y1Â x2Â y2Â .....), suitable for conversion to CERN server
51 format, or any other format with user supplied conversion pro‐
52 gram.
53
54 • GRASS_RENDER_FILE=filename
55 specifies the resulting file to store the html image map, de‐
56 fault is htmlmap. Files without absolute path names are written
57 in the current directory where the driver was started.
58 Any existing file of the same name is overwritten without warn‐
59 ing.
60
61 • GRASS_RENDER_HTMLMINDIST=n
62 specifies the minimum distance in pixels that a point must
63 change from the previous point to keep in the list of vertices
64 for a polygon. The default is 2, which means that a point’s x
65 and y difference from the previous point must change by a num‐
66 ber of pixels greater than this value. This parameter helps to
67 eliminate closely spaced points.
68
69 • GRASS_RENDER_HTMLMINBBOX=n
70 specifies the minimum bounding box dimensions to record a poly‐
71 gon as a clickable area. The default is 2, which means that a
72 polygon with a bounding box of less than this value is not in‐
73 cluded. This parameter helps to eliminate polygons than are a
74 point or line.
75
76 • GRASS_RENDER_HTMLMAXPOINTS=n
77 specifies the maximum number of vertices included in a poly‐
78 gon’s clickable area. The default is 99. Some browsers can
79 only accommodate polygons of 100 vertices or less. The HTMLMAP
80 driver automatically ensures that a polygon is closed by making
81 the last point the same as the first point.
82
83 Example
84 Start up the driver
85 g.region vector=zipcodes_wake
86 d.mon start=html
87 Display text strings (HREF’s) and polygons
88 echo "https://en.wikipedia.org/wiki/Raleigh,_North_Carolina" | d.text
89 d.vect map=zipcodes_wake where="ZIPNAME = ’RALEIGH’"
90 echo "https://en.wikipedia.org/wiki/Cary,_North_Carolina" | d.text
91 d.vect map=zipcodes_wake where="ZIPNAME = ’CARY’" fill_color=180:200:210
92 Stop the driver once all polygon have been displayed. This will create
93 a file named ’htmlmap’ in your current directory:
94 d.mon stop=html
95 You will also want to create an image for your image map. Use the PNG
96 driver and other utilities to create .gif or .jpg files. The following
97 example is somewhat out of date and refers to options available in
98 GRASS 5.
99 # using previous GRASS_RENDER_WIDTH & GRASS_RENDER_HEIGHT
100 d.mon start=png
101 d.rast map=terrain
102 d.vect map=area51 fillcolor=white linecolor=blue
103 d.vect map=roswell fillcolor=yellow linecolor=blue
104 d.vect map=states color=green
105 d.vect map=roads color=black
106 d.mon stop=png
107 # make the region the same as the newly created cell for ppm export
108 g.region save=saved.reg
109 g.region raster=D_cell
110 r.out.ppm -q input=D_cell output=alien.ppm
111 # use the netpbm utilities to create a gif (quantize if needed)
112 ppmquant 128 <alien.ppm | ppmtogif >alien.gif
113 # assemble some html with the image and the image map
114 echo ’<html><body><img src="alien.gif" usemap="#map">’ >alien.html
115 cat htmlmap >>alien.html
116 echo ’</body></html>’ >>alien.html
117 # don’t forget to reset your region
118 g.region region=saved.reg
119 # take a look and test it out
120 netscape file:`pwd`/alien.html &
121
123 HTML was adapted from the CELL driver in GRASS 4.3. Point-in-polygon
124 test code was lifted from Randolph Franklin’s web page, see
125
126 • http://www.ecse.rpi.edu/Homepages/wrf/
127
128 • http://www.ecse.rpi.edu/Homepages/wrf/research/geom/pnpoly.html
129
130 If you create an HTML file with two or more images and image maps, you
131 will need to edit the map names. The HTML driver creates its map with
132 the name map. A small sed script can easily change the map name:
133 sed -e ’s/NAME="map"/NAME="foomap"/’ < htmlmap > foomap.html
134
136 Cairo driver, PNG driver, HTML driver, variables
137 d.rast, d.vect, d.mon, d.erase, d.redraw
138
140 Glynn Clements
141
142 Main index | Topics index | Keywords index | Graphical index | Full in‐
143 dex
144
145 © 2003-2023 GRASS Development Team, GRASS GIS 8.2.1 Reference Manual
146
147
148
149GRASS 8.2.1 htmldriver(1)