- Illinois State Museum - - ISM Programs -

How do you go from an HTML form to an Arc/Info Map?

Updated Tue Jun 20 13:23:45 CDT 1995
Well, it takes many steps. This document is primarily for Arc/Info programers who are working with the workstation version of Arc. We are presently running Rev 6.1.1, on an IBM RS6000, AIX 3.2.4 (more or less) that is also our web server. The examples are for the Faunmap queries that you can run at https://www.museum.state.il.us/research/faunmap/query/index.html. You can let me know if you have any further questions or comments (erich@museum.state.il.us).

Sorry, but I now find that the two links in the following paragraph are broken, Nov 9, 1998.

I got my information from several places, but the basic method is a combination of examples given by Barry Rowlingson at his Lancaster Street Map, in which a query form returns a postscript file, the impressive efforts of Phil Massam and his Atlas, and some discussions on the GeoWeb mailing list during Septemember of 1994. You should probably look at Barry's description before you try it yourself.

This explaination is in three documents: how.html, wwwquery.html, and ps2gif.html. I couldn't keep them very linear because there is alot of jumping from the AML to shell scripts. But, here it goes...

The basic series of steps is:

  1. Create the form
  2. Pass the results to a script (CGI)

    Learn how to do the first steps first! If you're already an AML programer, that second step is a BIG one.

  3. Start up Arc/Info while passing the arguments to an AML (Arc Macro Language) script

    This AML will then:

    1. Make the necessary map and translate it to postscript
    2. Translate the postscript file 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.

Create the form

HTML forms are pretty easy. You should read about them on the net, for exampe the Fill-out Forms Overview at NCSA, among other places.

Here is an example of the source for my simple input form (the forms with scrolling scientific or common names are very large):



<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN//2.0">
<html>
<HEAD>
<title>Faunmap Query Form for Lynx</title>
</HEAD>
<BODY>
<h2>Faunmap Query Form</h2>
<hr>
This form should produce an on-the-fly map based on the Faunmap database. 
Depending on the question and traffic on our server, it may take 2-3 minutes
of processing time before the result is sent back to you.  
<b>PLEASE</b> do not stop the process after you submit it--this leaves the
Arc/Info process running on our server.
<p>

<FORM METHOD="POST" ACTION="/CGI/research/faunmap/query/mapform.cgi">

Age: <input name="age" size=5>
Here is a copy of the 
<a href="/research/faunmap/query/agecodes.html">age codes</a>.
<p>
Taxon: <input name="taxon" size=5> (Note: these are case-sensitive)
You will <i>need</i> to have a copy of the list of
<a href="/research/faunmap/query/taxalist.html">taxon codes</a>.<p>

If we have it for this taxon, do you want the modern distribution?<br>

<input type="radio" name=dist value="y" checked>Yes 
<input type="radio" name=dist value="n" >No<p>
<INPUT TYPE="submit" VALUE="Submit">
<INPUT TYPE="reset" VALUE="Erase">

</FORM>

<HR>
eks Fri May 30 13:50:14 CDT 1995
</body>
</html>



Pass the form results to a script (CGI)

This is the part that I don't really understand as I don't know that much about shell scripts. I used the routine "cgi-postin.c" developed by Chip Rosenthal as part of his tools for gn administration, "gn" being the server software we are using here. The scripts used here also include Chip's "mkmenus" script, something that is necessary to allow our server to send out the new images. If you are not using gn, don't worry about it.

Here is the script that is called by the form (called mapform.cgi):


#!/bin/sh
# First, run cgi-postin as explained by Chip Rosenthal in his example.
# cgi-postin parses the output into shell variables (like $age, or $taxon)

exec 2>&1
eval "`/u/WWW/cgi/cgi-postin`" || exit 1

#
# gn requires that the CGI processor emit a "Content-type" header.
# and after that we set up the top portion of the html document to
# be returned.
cat << 'EOM'
Content-type: text/html

<HTML>

<HEAD>
<TITLE>Faunmap Query form</TITLE>
<LINK REV="MADE" HREF="mailto:erich@museum.state.il.us">
</HEAD>

<BODY>

<H2><img src="http:/images/fmaptrans.gif">Faunmap</H2>
EOM

# now check to see if the form was filled out

if test "X$age$taxon" = "X" ; then
        echo "Hey!  You didn't fill out the form."
        echo "Please try again. <P>"
        exit 0
fi

#continue with the output document a little bit

cat << EOM

<hr>
Here are the Faunmap localities for: Age=${age}, and Taxon=${taxon}<br>

EOM

# Pass things on to the script that runs arcinfo
# this is where most of the work is really done

/u/WWW/research/faunmap/query/faunmap-map.csh $age $taxon $dist

# close up the output document

cat << EOM
</pre>
<hr>
<TT>@(#) eks test arcinfo form</tt>
</body>
</html>

EOM

#
# Thats all folks.
#

exit 0


I created the above script and form by editing the examples provided by Chip. It took me many tries just to get to the point of being able to pass the infomation from the form to a script. Once I got a form-script pair that worked, I just copied them over and edited them for what ever I want.

Start up Arc/Info with an AML

I have a very short script that:
  1. Executes as a csh script (the default on the RS6000 is ksh)
  2. Sets up three environment variables for finding arc/info, the license, and the home for faunmap coverages and data files
  3. Sets up a variable with the process id (PID1) to be used to guard against duplicate file names in case of multiple sessions running Note: This is a recent addition and stems from my watching two people looking for Early Holocene beaver records at the same time
  4. Executes arc with a default aml, while passing on the variables to the &ARGS directive
Here is the script, called "faunmap-map.csh":
#! /bin/csh
setenv ARCHOME /usr/paleo/arcexe61
setenv FAUNMAPHOME /usr/faunmap 
setenv LM_LICENSE_FILE $ARCHOME/sysgen/license.dat
setenv PID1 `echo $$` 
$ARCHOME/programs/arc \&run $FAUNMAPHOME/wwwquery.aml $PID1 $1 $2

This, then, moves on to...

The wwwquery.aml AML program


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


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