htmldriver.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. g.region vector=zipcodes_wake
  89. d.mon start=html
  90. </pre></div>
  91. Display text strings (HREF's) and polygons
  92. <div class="code"><pre>
  93. echo "https://en.wikipedia.org/wiki/Raleigh,_North_Carolina" | d.text
  94. d.vect map=zipcodes_wake where="ZIPNAME = 'RALEIGH'"
  95. echo "https://en.wikipedia.org/wiki/Cary,_North_Carolina" | d.text
  96. d.vect map=zipcodes_wake where="ZIPNAME = 'CARY'" fill_color=180:200:210
  97. </pre></div>
  98. Stop the driver once all polygon have been displayed. This will create
  99. a file named 'htmlmap' in your current directory:
  100. <div class="code"><pre>
  101. d.mon stop=html
  102. </pre></div>
  103. You will also want to create an image for your image map. Use the PNG
  104. driver and other utilities to create .gif or .jpg files.
  105. <i>The following example is somewhat out of date and refers to options
  106. available in GRASS 5.</i>
  107. <div class="code"><pre>
  108. # using previous GRASS_RENDER_WIDTH &amp; GRASS_RENDER_HEIGHT
  109. d.mon start=png
  110. d.rast map=terrain
  111. d.vect map=area51 fillcolor=white linecolor=blue
  112. d.vect map=roswell fillcolor=yellow linecolor=blue
  113. d.vect map=states color=green
  114. d.vect map=roads color=black
  115. d.mon stop=png
  116. <!-- ???? FIXME and the ppm stuff looks overly complicated -->
  117. # make the region the same as the newly created cell for ppm export
  118. g.region save=saved.reg
  119. g.region raster=D_cell
  120. r.out.ppm -q input=D_cell output=alien.ppm
  121. # use the netpbm utilities to create a gif (quantize if needed)
  122. ppmquant 128 &lt;alien.ppm | ppmtogif &gt;alien.gif
  123. # assemble some html with the image and the image map
  124. echo '&lt;html&gt;&lt;body&gt;&lt;img src="alien.gif" usemap="#map"&gt;' &gt;alien.html
  125. cat htmlmap &gt;&gt;alien.html
  126. echo '&lt;/body&gt;&lt;/html&gt;' &gt;&gt;alien.html
  127. # don't forget to reset your region
  128. g.region region=saved.reg
  129. # take a look and test it out
  130. netscape file:`pwd`/alien.html &amp;
  131. </pre></div>
  132. <h2>NOTES</h2>
  133. HTML was adapted from the CELL driver in GRASS 4.3.
  134. Point-in-polygon test code was lifted from Randolph Franklin's web
  135. page, see
  136. <ul>
  137. <li><a href="http://www.ecse.rpi.edu/Homepages/wrf/">http://www.ecse.rpi.edu/Homepages/wrf/</a>
  138. </li>
  139. <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>
  140. </li>
  141. </ul>
  142. <p>If you create an HTML file with two or more images and image maps, you
  143. will need to edit the map names. The HTML driver creates its map
  144. with the name
  145. <tt>map</tt>. A small sed script can easily change the map name:
  146. <div class="code"><pre>
  147. sed -e 's/NAME="map"/NAME="foomap"/' &lt; htmlmap &gt; foomap.html
  148. </pre></div>
  149. <h2>SEE ALSO</h2>
  150. <em>
  151. <a href="cairodriver.html">Cairo driver</a>,
  152. <a href="pngdriver.html">PNG driver</a>,
  153. <a href="htmldriver.html">HTML driver</a>,
  154. <a href="variables.html">variables</a>
  155. <br><br>
  156. <a href="d.rast.html">d.rast</a>,
  157. <a href="d.vect.html">d.vect</a>,
  158. <a href="d.mon.html">d.mon</a>,
  159. <a href="d.erase.html">d.erase</a>,
  160. <a href="d.redraw.html">d.redraw</a>
  161. </em>
  162. <!--
  163. <p>
  164. <i>Last changed: $Date$</i>
  165. -->