htmldriver.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>HTML driver</title>
  5. <meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
  6. <link rel="stylesheet" href="grassdocs.css" type="text/css">
  7. </head>
  8. <body bgColor=white>
  9. <img src="grass_logo.png" alt="GRASS logo"><hr align=center size=6 noshade>
  10. <h2>NAME</h2>
  11. <em><b>HTML driver</b></em> - display driver to create HTML image maps.
  12. <h2>DESCRIPTION</h2>
  13. The HTML driver allows the generation of HTML image maps for area
  14. vector data. HTML image maps are used in conjunction with images to
  15. provide unique URL targets for different portions of an image. The
  16. HTML driver can create both client-side image maps embedded into HTML
  17. files, or server-side image maps used by web server software.
  18. <p>Polygons can at most have 100 vertices (this limit imposed by HTML
  19. image map formats, see <b>GRASS_HTMLMAXPOINTS</b> below.) The driver
  20. will attempt to trim polygons that have more that 100 vertices by
  21. removing vertices with the least amount of angle to the next
  22. vertice. Also, any polygon that is entirely bounded by another polygon
  23. will be discarded.
  24. <p>Text written to the driver before polygons are used as the HREF tag
  25. for all subsequent polygons written. All polygons that exist in a
  26. vector map will have the same HREF tag.
  27. <p>The only GRASS display commands that should be used with this driver
  28. are:
  29. <ul>
  30. <li><em><a href="d.text.html">d.text</a></em> - pass href
  31. information for resulting image maps.</li>
  32. <li><em><a href="d.vect.html">d.vect</a></em> - draw polygons from a
  33. vector map.</li>
  34. </ul>
  35. <h2>USAGE</h2>
  36. <h3>Environment variables</h3>
  37. The HTML driver can be enabled by
  38. setting <b>GRASS_RENDER_IMMEDIATE</b> variable, eg.
  39. <div class="code"><pre>
  40. export GRASS_RENDER_IMMEDIATE=html
  41. </pre></div>
  42. Several environment variables effect the operation of the HTML driver:
  43. <ul>
  44. <li><b>GRASS_WIDTH=xxx</b><br>
  45. the width of the image map (default is 640).
  46. </li>
  47. <li><b>GRASS_HEIGHT=yyy</b><br>
  48. the height of the image map (default is 480).
  49. </li>
  50. <li><b>GRASS_HTMLTYPE=type</b><br> type of image mape to create
  51. (default is CLIENT):
  52. <dl>
  53. <dd><tt><b>CLIENT</b></tt> &nbsp;&nbsp; Netscape/IE client-side
  54. image map (NAME="map").</dd>
  55. <dd><tt><b>APACHE</b></tt> &nbsp;&nbsp; Apache/NCSA server-side image
  56. map.</dd>
  57. <dd><tt><b>RAW</b></tt>
  58. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Raw url and polygon
  59. vertices (<i>url&nbsp; x1&nbsp; y1&nbsp; x2&nbsp; y2&nbsp;
  60. .....</i>), suitable for conversion to CERN server format, or
  61. any other format with user supplied conversion program.</dd>
  62. </dl>
  63. </li>
  64. <li><b>GRASS_HTMLFILE=filename</b><br>
  65. specifies the resulting file to store the html image map, default
  66. is <tt>htmlmap</tt>. Files without absolute path names are written
  67. in the current directory where the driver was started.
  68. <br>
  69. <em>Any existing file of the same name is overwritten without
  70. warning.</em>
  71. </li>
  72. <li><b>GRASS_HTMLMINDIST=n</b><br>
  73. specifies the minimum distance in pixels that a point must change
  74. from the previous point to keep in the list of vertices for a
  75. polygon. The default is <tt>2</tt>, which means that a point's x
  76. and y difference from the previous point must change by a number
  77. of pixels greater than this value. This parameter helps to
  78. eliminate closely spaced points.
  79. </li>
  80. <li><b>GRASS_HTMLMINBBOX=n</b><br>
  81. specifies the minimum bounding box dimensions to record a polygon
  82. as a clickable area. The default is <tt>2</tt>, which means that a
  83. polygon with a bounding box of less than this value is not
  84. included. This parameter helps to eliminate polygons than are a
  85. point or line.
  86. </li>
  87. <li><b>GRASS_HTMLMAXPOINTS=n</b><br>
  88. specifies the maximum number of vertices included in a polygon's
  89. clickable area. The default is <tt>99</tt>. Some browsers can only
  90. accommodate polygons of 100 vertices or less. The HTMLMAP driver
  91. automatically ensures that a polygon is closed by making the last
  92. point the same as the first point.</li>
  93. </ul>
  94. <h3>Example</h3>
  95. Start up the driver
  96. <div class="code"><pre>
  97. d.mon start=html
  98. </pre></div>
  99. Display text strings (HREF's) and polygons
  100. <div class="code"><pre>
  101. echo "http://www.no-such-place.net/area51/" | d.text
  102. d.vect map=area51
  103. echo "http://www.roswell-nm.net/little/green/men.html" | d.text
  104. d.vect map=roswell
  105. </pre></div>
  106. Stop the driver when all polygon have been displayed. This will cause
  107. a file named 'htmlmap' to be created in your current directory.
  108. <div class="code"><pre>
  109. d.mon stop=html
  110. </pre></div>
  111. You will also want to create an image for your image map. Use the PNG
  112. driver and other utilities to create .gif or .jpg files.
  113. <i>The following example is somewhat out of date and refers to options
  114. available in GRASS 5.</i>
  115. <div class="code"><pre>
  116. # using previous GRASS_WIDTH &amp; GRASS_HEIGHT
  117. d.mon start=png
  118. d.rast map=terrain
  119. d.vect map=area51 fillcolor=white linecolor=blue
  120. d.vect map=roswell fillcolor=yellow linecolor=blue
  121. d.vect map=states color=green
  122. d.vect map=roads color=black
  123. d.mon stop=png
  124. <!-- ???? FIXME -->
  125. # make the region the same as the newly created cell for ppm export
  126. g.region save=saved.reg
  127. g.region raster=D_cell
  128. r.out.ppm -q input=D_cell output=alien.ppm
  129. # use the netpbm utilities to create a gif (quantize if needed)
  130. ppmquant 128 &lt;alien.ppm | ppmtogif &gt;alien.gif
  131. # assemble some html with the image and the image map
  132. echo '&lt;html&gt;&lt;body&gt;&lt;img src="alien.gif" usemap="#map"&gt;' &gt;alien.html
  133. cat htmlmap &gt;&gt;alien.html
  134. echo '&lt;/body&gt;&lt;/html&gt;' &gt;&gt;alien.html
  135. # don't forget to reset your region
  136. g.region region=saved.reg
  137. # take a look and test it out
  138. netscape file:`pwd`/alien.html &amp;
  139. </pre></div>
  140. <h2>NOTES</h2>
  141. HTML was adapted from the CELL driver in GRASS 4.3.
  142. Point-in-polygon test code was lifted from Randolph Franklin's web
  143. page, see
  144. <ul>
  145. <li><a href="http://www.ecse.rpi.edu/Homepages/wrf/">http://www.ecse.rpi.edu/Homepages/wrf/</a>
  146. </li>
  147. <li><a href="http://www.ecse.rpi.edu/Homepages/wrf/research/geom/pnpoly.html">http://www.ecse.rpi.edu/Homepages/wrf/research/geom/pnpoly.html</a>
  148. </li>
  149. </ul>
  150. <p>If you create an HTML file with two or more images and image maps, you
  151. will need to edit the map names. The HTML driver creates its map
  152. with the name
  153. <tt>map</tt>. A small sed script can easily change the map name:
  154. <pre>
  155. sed -e 's/NAME="map"/NAME="foomap"/' &lt; htmlmap &gt; foomap.html
  156. </pre>
  157. <h2>SEE ALSO</h2>
  158. <em>
  159. <a href="cairodriver.html">Cairo driver</a>,
  160. <a href="pngdriver.html">PNG driver</a>,
  161. <a href="htmldriver.html">HTML driver</a>,
  162. <a href="variables.html">variables</a>
  163. <br><br>
  164. <a href="d.rast.html">d.rast</a>,
  165. <a href="d.vect.html">d.vect</a>,
  166. <a href="d.mon.html">d.mon</a>,
  167. <a href="d.erase.html">d.erase</a>,
  168. <a href="d.redraw.html">d.redraw</a>
  169. </em>
  170. <p><i>Last changed: $Date$</i>