htmldriver.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <HTML>
  3. <HEAD>
  4. <TITLE>HTMLMAP 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>HTMLMAP driver</B></EM> - driver to create HTML image maps.
  12. <BR><EM>(drivers)</EM>
  13. <H2>DESCRIPTION</H2>
  14. The HTMLMAP driver allows the generation of HTML image maps
  15. for area vector data. HTML image maps are used in conjunction with images to
  16. provide unique URL targets for different portions of an image. The HTMLMAP
  17. driver can create both client-side image maps embedded into HTML files, or
  18. server-side image maps used by web server software.
  19. <P>
  20. Note that GRASS display commands that require the MOUSE will not work
  21. correctly (or at all!)
  22. <P>
  23. Polygons can at most have 100 vertices (this limit imposed by HTML image map
  24. formats, see <B>GRASS_HTMLMAXPOINTS</B> below.) The driver will attempt to
  25. trim polygons that have more that 100
  26. vertices by removing vertices with the least amount of angle to the next
  27. vertice. Also, any polygon that is entirely bounded by another polygon will be
  28. discarded.
  29. <P>
  30. Text written to the driver before polygons are used as the HREF tag for all
  31. subsequent polygons written. All polygons that exist in a vector map will have
  32. the same HREF tag.
  33. <P>
  34. The only GRASS display commands that should be used with this driver are:
  35. <UL>
  36. <LI><a href="d.text.html">d.text</A>
  37. - pass href information for resulting image maps.</LI>
  38. <LI><a href="d.vect.html">d.vect</A>
  39. - draw polygons from a vector map.</LI>
  40. </UL>
  41. <H2>USAGE</H2>
  42. <H3>Environment variables</H3>Several environment variables effect the operation
  43. of HTMLMAP.
  44. <UL>
  45. <LI><B>GRASS_WIDTH=xxx</B><BR>the width of the image map (default is
  46. 640).
  47. </LI>
  48. <LI><B>GRASS_HEIGHT=yyy</B><BR>the height of the image map (default is
  49. 480).
  50. </LI>
  51. <LI><B>GRASS_HTMLTYPE=type</B><BR>the type of image mape to create (default is
  52. CLIENT):
  53. <DL>
  54. <DD><TT><B>CLIENT</B></TT> &nbsp;&nbsp; Netscape/IE client-side image map.
  55. (NAME="map")<BR>
  56. <DD><TT><B>APACHE</B></TT> &nbsp;&nbsp; Apache/NCSA server-side image
  57. map.<BR>
  58. <DD><TT><B>RAW</B></TT> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Raw url
  59. and polygon vertices ( <I>url&nbsp; x1&nbsp; y1&nbsp; x2&nbsp; y2&nbsp;
  60. ..... </I>), suitable for conversion to CERN server format, or any other
  61. 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
  66. the html image map, default is <tt>htmlmap</tt>. Files without absolute path
  67. names are written 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>specifies the minimum distance in pixels
  73. that a point must change from the previous point to keep in the list of
  74. vertices for a polygon. The default is <tt>2</tt>, which means that a
  75. point's x and y difference from the previous point must change by a number
  76. of pixels greater than this value. This parameter helps to eliminate
  77. closely spaced points.
  78. </LI>
  79. <LI><B>GRASS_HTMLMINBBOX=n</B><BR>specifies the minimum bounding box
  80. dimensions to record a polygon as a clickable area.
  81. The default is <tt>2</tt>, which means that a polygon with a bounding box
  82. of less than this value is not included. This parameter helps to eliminate
  83. polygons than are a point or line.
  84. </LI>
  85. <LI><B>GRASS_HTMLMAXPOINTS=n</B><BR>specifies the maximum number of
  86. vertices included in a polygon's clickable area.
  87. The default is <tt>99</tt>. Some browsers can only accommodate polygons of
  88. 100 vertices or less. The HTMLMAP driver automatically ensures that a
  89. polygon is closed by making the last point the same as the first
  90. point.</LI>
  91. </UL>
  92. <H3>Typical usage</H3>
  93. <UL>
  94. <LI>Start up the driver
  95. <DIV class="code"><PRE>
  96. d.mon start=HTMLMAP
  97. </PRE></DIV>
  98. </LI>
  99. <LI>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. <LI>Stop the driver when all polygon have been displayed. This will cause a file
  107. named 'htmlmap' to be created in your current directory.
  108. <DIV class="code"><PRE>
  109. d.mon stop=HTMLMAP
  110. </PRE></DIV>
  111. <LI>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.mon select=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. </LI>
  142. </UL>
  143. <H2>NOTES</H2>
  144. HTMLMAP was adapted from the CELL driver in GRASS 4.3.
  145. Point-in-polygon test code was lifted from Randolph Franklin's web page, see
  146. <UL>
  147. <LI><a href="http://www.ecse.rpi.edu/Homepages/wrf/">http://www.ecse.rpi.edu/Homepages/wrf/</A></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></LI>
  149. </UL>
  150. <P>
  151. If you create an HTML file with two or more images and image maps, you will
  152. need to edit the map names. The HTMLMAP driver creates its map 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="displaydrivers.html">Display drivers</a>
  160. <br>
  161. <a href="pngdriver.html">PNG driver</A>,
  162. <a href="psdriver.html">PostScript driver</A>,
  163. <a href="xdriver.html">XDRIVER</A>
  164. <BR>
  165. <A href="d.mon.html">d.mon</A>,
  166. <a href="d.text.html">d.text</A>,
  167. <a href="d.vect.html">d.vect</A>
  168. </EM>
  169. <p>
  170. <i>Last changed: $Date: 2008-03-23 14:34:53 +0000 (Sun, 23 Mar 2008) $</i>