htmldriver.html 6.9 KB

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