htmldriver.html 6.7 KB

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