README 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. HTMLMAP driver
  2. Tom Poindexter
  3. tpoindex@nyx.net
  4. This display driver is to allow the generation of HTML image maps for
  5. area vector data. HTML image maps are used in conjunction with images
  6. to provide unique URL targets for different portions of an image. The HTMLMAP
  7. driver can create both client-side image maps embedded into HTML files, or
  8. server-side image maps used by web server software.
  9. Note that commands that require the MOUSE will NOT work correctly (or
  10. at all!)
  11. Polygons can at most have 100 vertices (this limit imposed by HTML image map
  12. formats.) The driver will attempt to trim polygons that have more that 100
  13. vertices (also see GRASS_RENDER_HTMLMAXPOINTS, below.) Also, any polygon that is
  14. entirely bounded by another polygon will be discarded.
  15. Text written to the driver before polygons are used as the HREF tag for
  16. all subsequent polygons written. It is intended that all polygons
  17. that exists in a vector file will have the same HREF tag.
  18. The only GRASS display commands that should be used with this driver are:
  19. d.text - pass href information for resulting image maps.
  20. d.vect.area - draw polygons from a vector file.
  21. 0. Set environment variables:
  22. GRASS_RENDER_WIDTH=xxx #if you want another size than the default 640
  23. export GRASS_RENDER_WIDTH
  24. GRASS_RENDER_HEIGHT=xxx #if you want another size than the default 480
  25. export GRASS_RENDER_WIDTH
  26. Additionally, HTMLMAP driver recognizes:
  27. export GRASS_RENDER_HTMLTYPE
  28. GRASS_RENDER_HTMLTYPE=xxx
  29. specifies the type of Html map to create:
  30. CLIENT - Netscape client-side image map (default). (NAME="map")
  31. APACHE - Apache/NCSA server-side image map
  32. RAW - Raw url and polygon vertices ("url x1 y1 x2 y2 .....")
  33. suitable for conversion to CERN server format, or
  34. any other format with user supplied conversion program.
  35. export GRASS_RENDER_FILE
  36. GRASS_RENDER_FILE=xxxxxx
  37. specifies the resulting file to store the html image map,
  38. default is 'htmlmap'. Files without absolute path names are
  39. written in the current directory where the driver was started.
  40. Any existing file is overwritten without warning.
  41. export GRASS_RENDER_HTMLMINDIST
  42. GRASS_RENDER_HTMLMINDIST=xx
  43. specifies the minimum distance (in pixels) that a point must
  44. change from the previous one to keep in the list of vertices
  45. for a polygon. The default is '2', which means that a point's
  46. x or y difference from the previous point must change by a number
  47. of pixels greate than this value. This parameters helps
  48. to eliminate points closely spaced points.
  49. export GRASS_RENDER_HTMLMINBBOX
  50. GRASS_RENDER_HTMLMINBBOX=xx
  51. specifies the minimum bounding box dimensions (both width and
  52. height) in order to store a polygon. The default is '2', which
  53. means any polygon having bounding box width or height extent
  54. of less than 2 pixels will not be output as a clickable area.
  55. This parameter helps to eliminate clickable areas that are one
  56. pixel in height or width, typically a single point or line.
  57. export GRASS_RENDER_HTMLMAXPOINTS
  58. GRASS_RENDER_HTMLMAXPOINTS=xx
  59. specifies the maxiumum number of vertices that a polygon can
  60. have. The default is 99. Some browser can only handle
  61. image map polygons of less that 100 vertices.
  62. 1. Start it up.
  63. # set the environment variables (above) if desired, or use defaults
  64. d.mon start=HTMLMAP
  65. d.mon select=HTMLMAP
  66. 2. Display text strings (href's) and area polygons:
  67. echo "http://www.no-such-place.net/area51/" | d.text
  68. d.vect.area map=area51
  69. echo "http://www.roswell-nm.net/little/green/men.html" | d.text
  70. d.vect.area map=roswell
  71. 3. When done displaying stuff to HTMLMAP driver, use
  72. d.mon stop=HTMLMAP
  73. This will write the image map file file. A new file called 'htmlmap'
  74. (or whatever you specified with GRASS_RENDER_FILE) will be created
  75. in your current directory.
  76. 4. In practice, you'll want to create gif/jpg/png images that correspond
  77. with your newly created image map:
  78. # using previous GRASS_RENDER_WIDTH & GRASS_RENDER_HEIGHT
  79. d.mon start=CELL
  80. d.mon select=CELL
  81. d.rast map=terrain
  82. d.vect.area map=area51 fillcolor=white linecolor=blue
  83. d.vect.area map=roswell fillcolor=yellow linecolor=blue
  84. d.vect map=states color=green
  85. d.vect map=roads color=blue
  86. d.mon stop=CELL
  87. # make the region the same as the newly created cell for ppm export
  88. g.pushregion.sh # or g.region save=saved.reg
  89. g.region raster=D_cell
  90. r.out.ppm -q input=D_cell output=alien.ppm
  91. # use the netpbm utilities to create a gif (quantize if needed)
  92. ppmquant 128 <alien.ppm | ppmtogif >alien.gif
  93. # assemble some html with the image and the image map
  94. echo '<html><body><img src="alien.gif" usemap="#map">' >alien.html
  95. cat htmlmap >>alien.html
  96. echo '</body></html>' >>alien.html
  97. # don't forget to reset your region
  98. g.popregion.sh # or g.region region=saved.reg
  99. # take a look and test it out
  100. netscape file:`pwd`/alien.html &
  101. Building the HTMLMAP driver:
  102. Change to the HTMLMAP directory, and make it:
  103. cd src/display/devices/HTMLMAP
  104. gmake5
  105. If all goes well, the HTMLMAP driver will be compiled and moved into
  106. your device driver directory ($GISBASE/driver) and "etc/monitorcap"
  107. will be modified.
  108. Other:
  109. Don't forget to add the HTMLMAP driver in your monitorcap file!
  110. Your monitorcap file exists as $GISBASE/etc/monitorcap.
  111. HTMLMAP:driver/HTMLMAP:Create HTML Image Map: \
  112. /usr/local/grass43/dev/fifo.9a /usr/local/grass43/dev/fifo.9b \
  113. ::any terminal
  114. Note: This job will be done by the Gmakefile.
  115. HTMLMAP was adapted from the CELL driver in GRASS 4.3. Point-in-
  116. polygon-test code was lifted from Randolph Franklin's web page, see
  117. http://www.ecse.rpi.edu/Homepages/wrf/
  118. http://www.ecse.rpi.edu/Homepages/wrf/research/geom/pnpoly.html
  119. If you create an HTML file with two or more images & image maps, you
  120. will need to edit the map names. The HTMLMAP driver creates its map
  121. with the name 'map'. A small sed script can easily change the map name:
  122. sed -e 's/NAME="map"/NAME="foomap"/' <htmlmap >foomap.html
  123. -----------------------------
  124. http://www.nyx.net/~tpoindex/grass-stuff/