[OpenLayers-Users] How to use geoserver filter function with openlayers?

Tim Schaub tschaub at opengeo.org
Wed Mar 24 17:52:24 EDT 2010


zoggo wrote:
> Hi there,
> 
> I'm using Geoserver 2.0 with Openlayers 2.8. My geoserver is supporting a
> lot filter functions 
> http://docs.geoserver.org/2.0.x/en/user/filter/function_reference.html
> http://docs.geoserver.org/2.0.x/en/user/filter/function_reference.html . How
> can I access a filter function like centroid.
> 

Our filter encoding format doesn't currently support more of 
ogc:expression than ogc:Literal, ogc:PropertyName, or simple expressions 
composed of those elements.  This means the parser is not currently set 
up to serialize (or deserialize) ogc:Function elements.

I think we could handle expressions in a fairly generic way - allowing 
their appearance in a symbolizer value or in filters.  The SLD and 
Filter formats could be made to support reading and writing of 
expressions in a way that would allow you to take advantage of custom 
filter functions in GeoServer or define functions to be evaluated on the 
client.

This type of enhancement is generally brought into the library when a 
developer is specifically funded to implement it.

Tim

> My WFS Layer looks like this:
> 
> var propertyFilter1 = new OpenLayers.Filter.Comparison({
> 	        type: OpenLayers.Filter.Comparison.LIKE,
> 	        property: 'GEMEINDENA',
> 	        value: '*m*'
> 	    });
> 		
> var propertyFilter2 = new OpenLayers.Filter.Comparison({
> 	        type: OpenLayers.Filter.Comparison.LIKE,
> 	        property: 'GEMEINDENA',
> 	        value: '*M*'
> 	    });
> 		
> var propertyFilter = new OpenLayers.Filter.Logical({
> 	        type: OpenLayers.Filter.Logical.OR,
> 	        filters: [propertyFilter1,propertyFilter2]
> 	    });
> 
> var layerGemeinden = new OpenLayers.Layer.Vector("Gemeindegrenzen ZH", {
> 		strategies: [new OpenLayers.Strategy.BBOX()],
> 		filter: propertyFilter,
> 		 protocol: new OpenLayers.Protocol.WFS({
> 				version: "1.1.0",
> 			        url: "http://www.stadtlandfluss-gmbh.ch:8080/geoserver/ows",
> 			        featureType: "GemeindenZH",
> 				feature: "gbis",
> 			        featureNS: "http://www.stadtlandfluss.ch/gbis",
> 			        srsName: "EPSG:900913"
> 			    }),
> 		srsName: "EPSG:21781"
> 		
> 		});
> 
> Maybe there's a way using ocg:filter??? It would be great to use this filter
> function with openlayers.


-- 
Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.



More information about the Users mailing list