[Cartoweb-users] Creating a filter plugin

Oliver Christen oliver.christen at camptocamp.com
Mon Apr 23 02:06:20 EDT 2007

see comments below

> 1. How do I transfer an array of FilterRequest objects? Do I need a 
> separate class in the common part?

yes, you need to define a class whose structure correspond to your array of 
FilterRequest Object

have a look at existing "common" part of existing plugin for example 
(outline is a easy one)

> 2. How should the wsdl for the FilterRequest class look like? Probably
>      <complexType name="FilterRequest">
>        <all>
>          <element name="layerId" type="xsd:string"/>
>          <element name="filter" type="xsd:string"/>
>        </all>
>      </complexType>

you only need the wsdl part if you use cartoweb in Soap mode. If you use it 
in direct mode, you can ignore the wsdl.
again, for example, have a look at the outline plugin

> But how do I handle the array of requests?

the root element need to be an array, and its children will be of 
FilterRequest type

> 3. Which function on the server side should I use to handle the request 
> and set the filter strings?

Since you seem to want to set the data of layers on the fly, you must act 
before the handleDrawing function. I would do it in the handlePreDrawing 
(see http://www.cartoweb.org/doc/misc/plugins_diagram.pdf)

then it is just a matter of using mapOverlay to set the change you have 
passed in your FilterRequests.

> And finally a general question:
> I would like to prevent that Cartoweb fails and shows an error message if 
> the provided filter is wrong, e.g. syntax errors. Supposed a user provides 
> an incorrect filter string, can I somehow test the filter and ignore it?

a wrong provider will most certainly trigger a mapserver error.

maybe you can catch it in the handlePostDrawing, but im not sure, i never 
tried to handle mapserver errors.


More information about the Cartoweb-users mailing list