[OpenLayers-Users] WFS with script protocol and filters

Phil Scadden p.scadden at gns.cri.nz
Thu May 3 17:17:32 EDT 2012


The filterToparams is rather crude and doesnt support all filters. I had 
to write my own for filtering I wanted done. You might get some 
enlightenment by searching the archive for this list for HOWTO and 
Script protocol as I wrote up some of my efforts.

I would pursue this by using firebug to see what GET was being generated 
by the protocol and look closely at the parameters. If you take the URL 
(remove the callback) and hack it till the server delivers, then you can 
work back to get the generation that you need.

cql_filter DOES work. I used script protocol to convert an ordinary 
filter into a cql_filter.

My code would look something like:

new OpenLayers.Protocol.Script({
                         url: mylayerurl,
                         callbackKey: "format_options",
                         callbackPrefix: "callback:",
                         params: {
                             service: "WFS",
                             version: "1.1.0",
                             srsName: projstr,
                             request: "GetFeature",
                             featurePrefix: myfeaturePrefix,
                             typeName: myfeatureType,
                             outputFormat: "json"
                         },
                         filterToParams: function (filter, params) {
                              params.cql_filter = '';
                             params.cql_filter = 
cvtFilter(filter,params.cql_filter);
                             return params;
                         }

you could simply set params.cql_filter to your desired cql expression.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.



More information about the Users mailing list