[mapserver-users] Change CLASS Expression using MapScript
Steve Lime
Steve.Lime at dnr.state.mn.us
Mon Oct 12 16:56:52 PDT 2009
It makes sense but the class change needs to happen:
1) by passing the change to the WMS server somehow (SLD?)
2) by writing a custom mapfile that reflects the change
3) by writing a custom WMS service that makes the change and then behaves as WMS
Others might have other/better ideas. I don't know enough about SLD to know if option 1 is
possible but that's the easiest. Basically you're configuring the WMS server on-the-fly
by passing SLD via OpenLayers. I know you can do that with straight MapServer CGI.
Steve
>>> On 10/12/2009 at 6:47 PM, in message
<1255391265612-3811491.post at n2.nabble.com>, Dash <jimlug at co.clackamas.or.us>
wrote:
> Thanks for the quick response.
>
> I'll go ahead and make the appropriate change for the layerObj. As for the
> change of expression with the mapfile, I did not know you had to save the
> changes. I just wanted the expression to be changed based on what a user
> selects from a form.
>
> The page that leads up to the map page allows a user to select either
> elementary, middle or high schools to display. Since our GIS layer has
> these as attributes I wanted to refrain from specifying these layers
> multiple times in the mapfile. I would rather pass an expression into the
> mapfile and display the appropriate level. I hope this makes sense?
>
> I had this procedure working before, however, I was never specifiying WMS as
> a layer.
>
> Thanks...
>
>
> Steve Lime wrote:
>>
>> Couple of things:
>>
>> 1) you don't need to open/close a layerObj to change it
>>
>> 2) something doesn't make sense in your approach. Are you saving the
>> mapfile somehow with the
>> changes so that the subsequent WMS call can make use of it? I don't know
>> how the WMS call would
>> know you mucked with the class otherwise.
>>
>> Steve
>>
>>>>> On 10/12/2009 at 6:29 PM, in message
>> <1255390195922-3811433.post at n2.nabble.com>, Dash
>> <jimlug at co.clackamas.or.us>
>> wrote:
>>
>>> Hey there folks,
>>>
>>> I am banging my head against this problem for sometime now. I have a
>>> MapFile that is set up to deliver WMS layers when requested through
>>> OpenLayers. Within my web page I am trying to change the Class
>>> Expression
>>> (MapScript/PHP). Below is the method I am using to gain access to the
>>> Class
>>> and change the expression. I am performing this before I enter a body
>>> tag.
>>> The body tag has a onload event that fires off the parameters/layers I am
>>> using within OpenLayers and makes the call to the WMS layers within my
>>> MapFile. Am I missing something here? I thought since I am declaring
>>> the
>>> expression before I'm displaying the map everything would be ok. I've
>>> even
>>> retrieved the edited expression and it should work. The only thing I can
>>> imagine is that it has something to do with a WMS setting. Any help
>>> would
>>> be greatly appreciated. Thanks.
>>>
>>> <head>
>>> .
>>> .
>>> .
>>> </head>
>>>
>>> <?php
>>> $situsEnc = $_POST['home'];
>>> $situs = urldecode($situsEnc);
>>>
>>> $map_path="/something/other/than/dirty/socks/wms/";
>>> $map = ms_newMapObj($map_path."schools.map");
>>>
>>> $mafLyr = $map->getLayerByName('maf');
>>> $mafLyr->open();
>>> $mafClass = $mafLyr->getClass(0);
>>> $mafClass->setExpression("('[situs]' = '" . $situs . "')");
>>> $mafLyr->close();
>>>
>>> <body onload=i"nit()">
>>> <div id="map"></div>
>>> </body>
>>
>> _______________________________________________
>> mapserver-users mailing list
>> mapserver-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
>>
More information about the MapServer-users
mailing list