- Illinois State Museum - - ISM Programs -

The wwwquery.aml AML program

Updated Tue Jun 20 13:45:05 CDT 1995
This AML will:
  1. Make the necessary map and translate it to postscript
  2. Translate the map to an image (Ghostscript ==> netpbm utilities)
  3. Unload a listing of the sites to a temporary file
  4. Serve the image and listing
  5. Clean up the scratch files
  6. End the html document and serve it.
And, finally, as the aml exits (&return) the two scripts (faunmap.csh and mapform.cgi) also exit and the html document is served.

I'm sorry, but although the AML is one document I'm going to have to chop it up for discussion here. I think that this is ok because there is no reason that you would want to use it intact as so much is dependent on the pathnames on this system.

Anyway, here goes:

&args pid age taxon dist
&messages &off
&workspace /usr/faunmap/www
&if %dist% cn 'y' &then
&if [exists $FAUNMAPHOME/mammal/[locase %taxon%] -cover] &then
&s dist = y
&s dist = n

The four &ARGS are: pid, the PID of faunmap-map.csh (used to maintain unique filenames); age, the 4-character age category code; taxon, the taxon code (for example ODva for Odocoileus virginianus or White-tailed deer), and; dist, a 1-character code "y" or "n" determining whether a modern distribution is requested. Arc info messages are turned off, and if we do not have the modern distribution digitized, the value of dist is set to "n".
&if [exists /usr/faunmap/www/images/[locase %age%%taxon%%dist%].gif -file] &then 
&goto nomap

Check to see if this combination of age, taxon, and distribution has already been been produced by previous queries. If so, don't bother remaking the map. This saves lots of time and the GIF's are small so it doesn't take up much disk space. If the map does not exist, then run arcplot.

The arcplot stuff is all standard, so I won't bother to discuss it.

display 1040

pagesize 5 5
mape $FAUNMAPHOME/base/usabase
mapposition cen cen
maplimits [show mapextent page]
&if %age% ne 'ALL' &then res alltaxa.dat info age cn [quote %age%]
res alltaxa.dat info taxon cn [quote %taxon%]
res $FAUNMAPHOME/data/sites point keyfile alltaxa.dat sites-id
&s count [extract 1 [show select $FAUNMAPHOME/data/sites point]]
&if %count% eq 0 &then
  &type Sorry, there are no localities that match Age= %age%, and Taxon = %taxon%
  &goto nothing
&if %dist% cn 'y' &then
  reselect $FAUNMAPHOME/mammal/[locase %taxon%] poly [locase %taxon%]-id gt 0
  shadeset colornames
  polygonshades $FAUNMAPHOME/mammal/[locase %taxon%] 25
arcs $FAUNMAPHOME/base/base 
arcs $FAUNMAPHOME/base/country 
arcs $FAUNMAPHOME/base/states
markercolor 2
points $FAUNMAPHOME/data/sites
&s count [extract 1 [show select $FAUNMAPHOME/data/sites point]]
&s ybase = [extract 2 [show maplimits]]
&s xbase = [extract 1 [show maplimits]]
move %xbase% [calc %ybase% - 0.5]
textset font.txt
textsymbol 1
textsize .2
text [quote N= %count%]
move %xbase% [calc %ybase% - 0.25]
text [quote Age= %age%   Taxon= %taxon%]

Ok, now we are out of arcplot. Unfortunately the eps files created by the display 1040 2 command in Rev 6 doesn't seem to work with ghostscript, so I have to make a normal display 1040 ".gra" file and use the arc postscript command. The "&label nothing" is for cases where the query came up blank and in those cases the AML drops out of arc.

What is more important here is the

&sys /u/WWW/research/faunmap/query/ps2gif.cgi...
directive as that is where the postscript file is translated to a GIF.
postscript /tmp/[locase %age%%taxon%%dist%%pid%.gra] /tmp/%age%%taxon%%dist%%pid%.ps 
&label nothing
&sys rm /tmp/[locase %age%%taxon%%dist%%pid%].gra
&if %count% lt 1 &then &return 
&sys /u/WWW/research/faunmap/query/ps2gif.cgi [locase %age%%taxon%%dist%] %pid%

&label nomap

Now we echo the necessary anchor and image tags to imbed the GIF as an inline image that can be downloaded. Also the necessary text to act as a legend is added below the image.
&type <a href="/research/faunmap/query/images/[locase %age%%taxon%%dist%].gif">
&type <img src="/research/faunmap/query/images/[locase %age%%taxon%%dist%].gif"
&type alt=[quote %age%%taxon%%dist%.gif]></a><br>
&if %dist% eq 'y' &then &type Shaded area is the modern distribution. <br>

Now we make the listing. My very strong advice is to do this portion first, before you try the inline map mess. I say this because it is a faster and clearer way to test to see if you arguments are being passed correctly.

This section works by starting up tables, doing the necessary reselects, unloading to results to a temporary file, then using "&sys cat" to stick it into the html document. It also works just to set "&messages &on" and do a "list" command.

The relate is set up to serve as a lookup table so I can save a little space.

sel alltaxa.dat
&if %age% ne 'ALL' &then reselect age cn [quote %age% ]
reselect taxon cn [quote %taxon% ]
&fullscreen &nopaging
relate add

&type <hr>The following localities have records for:
&if %age% eq 'ALL' &then 
  &type Taxon = <b>%taxon%</b> for all ages
  &type <pre>
  &type Mach# Age  Taxon       Site Name                     State/County
  &type age= <b>%age%</b> and taxon = <b> %taxon%</b>
  &type <pre>
  &type Mach# Taxon       Site Name                        State/County
&type ============================================================

&if %age% eq 'ALL' &then unload /tmp/[locase %age%%taxon%%pid%].txt num,ag,tx,site//name,site//st,site//county COLUMNAR /tmp/temp.fmt init
&else unload /tmp/[locase %age%%taxon%%pid%].txt num,tx,site//name,site//st,site//county COLUMNAR /tmp/temp.fmt init
q stop
&system cat /tmp/[locase %age%%taxon%%pid%].txt
&system rm /tmp/[locase %age%%taxon%%pid%].txt


Everything now returns to the way it was, except there is now a new GIF image sitting on our server.

| ISM Home | | General Information | | Programs | | Events | | Exhibits | | Collections | | Sites | | Membership |

© Illinois State Museum Society-- Last updated 21-Mar-96 by Erich Schroeder