<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
Hi Stefanie,<br>
<br>
I recently finished something similar to your problem, that may or may
not be helpful.&nbsp; In our situation, we needed to accept a normal
incoming WMS request, and within that request, provide application
specific variables (similar to what you need to provide) which are then
substituted by mapserver to pull out the data dynamically.<br>
<br>
Mapserver can accept parameters following the standard WMS
specifications, as well as providing extra functionality via the
mapscript cgi interface.&nbsp; Our end result used a backend mapserver
(which published a layer of data drawn out of a postgis database), and
a front end pseudoWMS server.&nbsp; I wrote the pseudo WMS server as a
simple java servlet.&nbsp; The PseudoWMSServer acts as the WMS compliant
entry point to the mapserver, and as such *should* accept incoming
GetMap, and GetCapabilities requests.&nbsp; Clients make a request to this
WMS
server in a format something like this:<br>
<br>
request:
<a class="moz-txt-link-freetext"
 href="http://www.refractions.net/PseudoWMSServer/PseudoWMSServer?request=GetMap&amp;layers=layerName,variable1,variable2&amp;etc">http://www.refractions.net/PseudoWMSServer/PseudoWMSServer?request=GetMap&amp;layers=layerName,variable1,variable2&amp;etc</a>.<br>
<br>
The PseudoWMSServer accepts this incoming request, parses it, and
creates a new request to the mapserver instance.&nbsp; This new request uses
the mapscript CGI interface to pass in the same request, along with the
variables.&nbsp; In our case, the new request made to the mapserver instance
looked like:<br>
<br>
mapserverURLStr =
<a class="moz-txt-link-freetext"
 href="http://www.refractions.net/cgi-bin/mapserv&amp;map=/pathToMapFile&amp;MODE=MAP&amp;MINX=1&amp;MINY=1&amp;MAXX=2&amp;MAXY=2&amp;MAPSIZE=640+480&amp;LAYERS=layerName&amp;variable1=variable1Value">http://www.refractions.net/cgi-bin/mapserv&amp;map=/pathToMapFile&amp;MODE=MAP&amp;MINX=1&amp;MINY=1&amp;MAXX=2&amp;MAXY=2&amp;MAPSIZE=640+480&amp;LAYERS=layerName&amp;variable1=variable1Value</a><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
In the mapserver instance's mapfile, we have a layer defined this way:<br>
<br>
&nbsp;LAYER<br>
&nbsp;&nbsp;&nbsp; NAME "layerName"<br>
&nbsp;&nbsp;&nbsp; TYPE LINE<br>
&nbsp;&nbsp;&nbsp; STATUS ON<br>
&nbsp;&nbsp;&nbsp; CONNECTIONTYPE postgis<br>
&nbsp;&nbsp;&nbsp; CONNECTION "host=hostname dbname=dbname user=username"<br>
&nbsp;&nbsp;&nbsp; DATA "the_geom from (SELECT * FROM tablename WHERE
blah=%variable1%)"<br>
&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; etc..<br>
<br>
The PseudoWMSServer then opens up a stream to the mapserver, reads in
the bytes, and spits them back out through the waiting http
connection.&nbsp; Using this technique, you can maintain the use of WMS
specifications, as well as making use of mapserver's extra
functionality.<br>
<br>
Hopefully that helps.&nbsp; I have some kind lying around here, let me know
if you need any of it.<br>
<br>
--Adam<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
<br>
Stefanie Weykam wrote:<br>
<blockquote cite="midLBEBIABPHLLJINHFPKLHIEPMCAAA.sweykam@teleline.es"
 type="cite">
  <pre wrap="">Hi list members,

A while ago I developed a very simple mapserver application which I would
now like to make available as WMS. I wonder if it is possible to modify the
class expressions via the WMS GetMap-request ?? Or can this only be done by
WFS?

You can see the application here at: <a
 class="moz-txt-link-freetext" href="http://161.111.161.171/Atlas/">http://161.111.161.171/Atlas/</a> 
It contains maps of 3 thematic groups (species distribution maps, maps on
biodiversity indices and environmental factors) and a query that allows to
generate a list of species, biodiversity indices and environmental factors
for each graticule.

The species distribution maps are what I would like to make available as web
map service but I can't figure out how to pass the parameter on that
indicates the species code. 

The problem is the layer 'Dlyr', my species distribution layer. 
As for the application, the user selects a species name from a list and this
variable is then used to render the map by modifying the predefined classes
in the map file.
  $clObj0=$Dlyr-&gt;getClass(0);
  $clObj0-&gt;setExpression('(['.$sp.']=0)'); 
  $clObj1=$Dlyr-&gt;getClass(1);
  $clObj1-&gt;setExpression('(['.$sp.']&gt;0 AND ['.$sp.']&lt;=20)'); 
  $clObj2=$Dlyr-&gt;getClass(2);
  $clObj2-&gt;setExpression('(['.$sp.']&gt;20 AND ['.$sp.']&lt;=40)'); 
  $clObj3=$Dlyr-&gt;getClass(3);
  $clObj3-&gt;setExpression('(['.$sp.']&gt;40 AND ['.$sp.']&lt;=60)');  
  $clObj4=$Dlyr-&gt;getClass(4);
  $clObj4-&gt;setExpression('(['.$sp.']&gt;60 AND ['.$sp.']&lt;=80)');  
  $clObj5=$Dlyr-&gt;getClass(5);
  $clObj5-&gt;setExpression('(['.$sp.']&gt;80)');

The class ranges never change, no matter what species is selected.
The species code $sp identifies a column in a PostgreSQL table, i.e. [DEMI].
Each species has its table column.

I have already prepared a first version that you may try typing this in your
browser: 
<a class="moz-txt-link-freetext"
 href="http://161.111.161.171/cgi-bin/AtlasAves.exe?service=WMS&amp;request=GetCapabili">http://161.111.161.171/cgi-bin/AtlasAves.exe?service=WMS&amp;request=GetCapabili</a>
ties

You may retrieve a map composition, for example...
<a class="moz-txt-link-freetext"
 href="http://161.111.161.171/cgi-bin/AtlasAves.exe?service=WMS&amp;version=1.1.1&amp;reque">http://161.111.161.171/cgi-bin/AtlasAves.exe?service=WMS&amp;version=1.1.1&amp;reque</a>
st=GetMap&amp;layers=fondo,Dlyr,cuad50,cuad_anno&amp;format=png&amp;transparent

First, the client has to have as well a species list that allows to select
and pass on the species code (I will later make this list available). How is
the species identifier added to the request string ?

I guess, this calls for providing the layer as WFS instead (?). The client
then creates his own classes and I don't have to modify my code at all?

Is it possible to avoid that the whole data set is retrieved by a
GetFeature-request? I tried by specifying 'wfs_maxfeatures', but it had no
effect on the GetFeature response.

I am using MapServer 4.4 and this layer is a PostGIS table.

Thanks for your comments,
Stefanie Weykam

  </pre>
</blockquote>
</body>
</html>