[Cartoweb-users] Creating a filter plugin

Dirk Jesko ml.dje at geocontent.de
Mon Apr 23 07:21:09 EDT 2007


Hello Oliver,

thanks. Everything is working now. After a few test, I found out that 
initializeRequest (not handlePreDrawing) needs to be used. Otherwise, 
the query plugin will not recognize the changed map object and return 
all results. Unfortunately, this causes another side effect: If a query 
result exists and the filter is changed, an error is triggered 
("Attribute query returned no results") if none of the existing query 
results fits the new filter. If at least one result fits the filter, all 
are kept.

Do you have any idea, how I could synchronize the query results if the 
filter changes?

Regards,
Dirk



Oliver Christen wrote:
> 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 stage.
> (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.
>
> regards
> Oliver
>
>


More information about the Cartoweb-users mailing list