[mapserver-users] passing cgi query params to wms layers

Stephen Woodbridge woodbri at swoodbridge.com
Tue Sep 27 12:29:38 EDT 2011


On 9/27/2011 9:27 AM, Puneet Kishor wrote:
>
> On Sep 26, 2011, at 11:22 PM, Mr. Puneet Kishor wrote:
>
>> On Sep 26, 2011, at 11:04 PM, Stephen Woodbridge wrote:
>>
>>> On 9/26/2011 10:29 PM, Puneet Kishor wrote:
>>>> I am using OpenLayers as the front-end, requesting a WMS layer from MapServer that is getting data from Pg. My DATA statement is like so
>>>>
>>>> 	DATA "the_geom FROM (SELECT gid, pc, the_geom FROM table) t USING UNIQUE gid USING srid=4326"
>>>>         FILTER "pc = 'na'"
>>>>
>>>> The above works fine. However, I would like to send the value of "pc" from OpenLayers (that is another problem that I am experiencing; I have asked on OL list on how to send query params to WMS layers, but if any of you know the solution, I would welcome that). In any case, I thought (naively), that I could change my FILTER statement like so
>>>>
>>>> 	FILTER "pc = '[pc]'"
>>>>
>>>> I tried sending a WMS query directly to test the above like so [http://server/cgi-bin/app?.. blah ..&pc=na] but no joy. Forcing a query error showed me that MapServer was executing the following
>>>>
>>>> 	select .. from (..) t where the_geom&&   GeomFromText(..) and (pc = '[pc]')
>>>>
>>>> How can I dynamically supply MapServer a filter value?
>>>
>>> Does this doc answer your question?
>>> http://mapserver.org/cgi/runsub.html
>>>
>>
>>
>> Yes it does. I had not seen that doc (hence, I was naively trying [var] kinda sub)
>
>
> So, it seems I can't use Perl compatible regexps inside the map file for runtime substitution. For example, the following fails
>
> 	'pc_validation_pattern' '^\w\w$'
>
> with "msValidateParameter(): Regular expression error. Parameter pattern validation failed." But the following works
>
> 	'pc_validation_pattern' '^[a-zA-Z][a-zA-Z]$'
>
> Is there a compile time switch to make MapServer Perl-savvy?

No, that would be a nice option. I'm not sure if there is a ticket or 
not for adding pcre support. If not you might want to add one. I find 
Perl expressions much easier to work with.

-Steve W



More information about the mapserver-users mailing list