[mapserver-users] How Filter items only if provided parameter

Smith, Michael ERDC-RDE-CRREL-NH Michael.Smith at erdc.dren.mil
Sat Feb 23 04:30:10 PST 2013


Andrea,

What I do is set the default_idvalue to "1=1" and change the filter to
FILTER "%idvalue%". Then the cgi value is something like &idvalue="id=1"

Your valididation regex becomes more complex though.

Mike

-- 
Michael Smith

US Army Corps
Remote Sensing GIS/Center



On 2/23/13 7:15 AM, "Andrea Peri" <aperi2007 at gmail.com> wrote:

>Hi,
>
>I need to set a layer to allow to retrieve in the response all the
>elements available in the layer, and when the request has a specific
>parameter it should apply a filter to limit the show to only the
>filtered geometries.
>
>To do this until now I have set this configuration:
>
>LAYER
>   ...
>    DATA "geometry from table using unique gid srid=25832"
>    FILTER "PK_FIELD like '%idvalue%' "
>    VALIDATION
>      'idvalue' '^[a-zA-Z0-9\-_]+$'
>    END
>   ...
>   METADATA
>      'default_idvalue' '%'
>
>This configuration work pretty well when the PK is a string field.
>Infact is the request has no the idvalue parameter it show all the
>records , thx to the "default_idvalue  %" definitioni,
>instead if the request has a parameter as example
>..&idvalue=xxx1
>
>It show only the specific item having PK_FIELD=xxx1
>
>Now I have the same need for a layer where the PK is numeric.
>
>With this layer the solution described seem don't work, infact the
>'default_idvalue' '%'
>
>is not working with a numeric field.
>
>There same other solution to have the same result?
>
>I need to show all the records and apply the filter only when there is
>a specific parameter in the request.
>
>Thx,
>
>-- 
>-----------------
>Andrea Peri
>. . . . . . . . .
>qwerty àèìòù
>-----------------
>_______________________________________________
>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