&args mapname
&if [null %mapname%] &then &return Usage: mkmapserver
&if [exists %mapname% -cover] &then
&return %mapname%? Oops! You do not want to overwrite a coverage!
/******************************
/* mkmakserver.aml Version 0.1
/*
/* An AML routine to help in the initial production of
/* mapserver 3.3 files.
/* This routine creates a directory below your current
/* location with the name that you provide on the command
/* line, and then creates a mapfile called .map in that
/* directory. The values in the mapfile are based on the layers that
/* you chooose, with the first (base) layer providing the initial
/* extent value.
/*
/* The routine also runs the arcshape command and places the resulting
/* shape files in the directory with the mapfile, and also makes very
/* rough initialization and template html files.
/*
/* There is some rudimentary checking of the coverages to set the
/* poly/line/point type of the layers and shapefiles.
/*
/* As of v0.1 you will need to edit the imagepath and imageurl values
/* in the mapfile, and set the map path correctly in the
/* _init.html file.
/*
/* Erich Schroeder (erich@museum.state.il.us)
/* Illinois State Museum
/*
/* v 0.1 Initial release Feb 17, 2000
/* v 0.1a Added code to test for accidental coverage overwrite 02/18/2000
/* Also fixed bad code which gave the same name to each layer (doh!)
/*
/*****************************
&type Starting creation of template map file
&if [exists %mapname% -directory] &then
&do
&type The mapserver project %mapname% exists
&select [getchar 'Do you want to rewrite it? (y/n)' y]
&when y
&s deval [delete [locase %mapname%] -directory]
&when n
&stop
&otherwise
&stop
&end
&end
&sys mkdir [locase %mapname%]
&type -------
&watch %mapname%/%mapname%.map
&type #
&type # Start of mapfile
&type #
&type NAME %mapname%
&type STATUS ON
&type SIZE 600 600
&type SHADESET symbols/shade.sym
&type MARKERSET symbols/marker.sym
&type LINESET symbols/line.sym
&watch &off
&type ----------
&type Ok, Lets choose a base layer...
&do tmpnum = 1 &repeat tmpnum +1 &until %ok%
&s cover [response 'Enter full path to coverage']
&s ok [exists %cover% -cover]
&end
&describe %cover%
&type xmin = %dsc$xmin%, ymin = %dsc$ymin%, xmax = %dsc$xmax%, ymax = %dsc$ymax%
&type -------
&watch %mapname%/%mapname%.map &append
&type EXTENT %dsc$xmin% %dsc$ymin% %dsc$xmax% %dsc$ymax%
&type UNITS feet
&type IMAGECOLOR 255 255 255
&type #
&type # Start of web interface definition
&type #
&type WEB
&type HEADER %mapname%_header.html
&type TEMPLATE %mapname%.html
&type MINSCALE 1000
&type MAXSCALE 1550000
&type IMAGEPATH /edit_me/
&type IMAGEURL /edit_me/
&type END
&type #
&type # Start of legend
&type #
&type LEGEND
&type KEYSIZE 18 12
&type LABEL
&type TYPE BITMAP
&type SIZE MEDIUM
&type COLOR 0 0 89
&type END
&type STATUS ON
&type END
&type #
&type # Start of scalebar
&type #
&type SCALEBAR
&type IMAGECOLOR 255 255 255
&type LABEL
&type COLOR 0 0 0
&type SIZE SMALL
&type END
&type SIZE 350 5
&type COLOR 255 255 255
&type BACKGROUNDCOLOR 0 0 0
&type OUTLINECOLOR 0 0 0
&type UNITS kilometers
&type INTERVALS 5
&type STATUS ON
&type END
&type #
&type # Start of layer definitions
&type #
&watch &off
&type ------
&type Now we are starting with layers, beginning with
&type the first base coverage you entered before
&s layernum = 0
&do &until %done%
&s layernum = %layernum% + 1
&call getlayer
&s done = [query 'Are you done with layers?']
&end
&watch %mapname%/%mapname%.map &append
&type END
&type # end of map file
&watch &off
/* make the default initialization file
&call writehtmlinit
/* make the default template file
&call writehtml
&return Done with %mapname%
/* end of mkmapserver.aml
/*****************************************************
&routine getlayer
&if %layernum% gt 1 &then
&do &until %ok%
&s cover [response 'Enter full path to coverage']
&s ok [exists %cover% -cover]
&end
&s tmplayername [entryname %cover%]
&type tmplayername = %tmplayername%
&s layername [response [quote What do you want to call this layer/shapefile? (%tmplayername%)] %tmplayername%]
&describe %cover%
&if %DSC$POINTS% gt 0 &then &s type = POINT'
&if %DSC$QTOPOLOGY% &then &s type = POLYGON
&else &s type = LINE
arcshape %cover% %type% %mapname%/%layername%
&s color [response 'Enter color as R G B' '20 20 20']
&if %DSC$QTOPOLOGY% &then
&s outlinecolor [response 'Enter outline color as R G B' '0 0 0']
&watch %mapname%/%mapname%.map &append
&type # Layer %layernum%
&type LAYER
&type NAME %layername%
&type TYPE %type%
&type STATUS DEFAULT
&type DATA %layername%
&type CLASS
&type SYMBOL 0
&if %DSC$QTOPOLOGY% &then
&type OUTLINECOLOR %outlinecolor%
&type COLOR %color%
&type END
&type END
&type #
&watch &off
&return
/* end of subroutine getlayer
&routine writehtmlinit
&watch %mapname%/%mapname%_init.html
&type
&type MapServer %mapname% initialization
&type
&type MapServer %mapname% initialization
&type
&type Click on the initialize button to fire up the %mapname% map with a %layernum% layers.
&type
&type
&type
&watch &off
&return
/* end of subroutine writehtmlinit
&routine writehtml
&watch %mapname%/%mapname%.html
&type
&type %mapname%
&type
&type %mapname%
&type
&type
&type
&type
&watch &off
&return
/* end of subroutine writehtml