[OpenLayers-Users] Problems with Openlayers.Filter.Function in WFS

Bart van den Eijnden bartvde at opengeo.org
Sat Jul 13 23:26:16 PDT 2013


Thanks for your work (and perseverance) on this, any chance you can open up a github pull request for this? TIA.

Best regards,
Bart

-- 
Bart van den Eijnden
OpenGeo - http://opengeo.org
Expert service straight from the developers.



On Jul 14, 2013, at 12:38 AM, brking <brking at gmail.com> wrote:

> If anyone is interested in how to make this work.
> 
> Format/Filter/v1.js:
> 
> add "FUNCTION" to the filter map
> 
>    filterMap: {
>        "&&": "And",
> ...
>        "FID": "_featureIds",
>        "FUNCTION": "Function"
>    },
> 
> I also wanted to support PropertyName as an argument to a function, so
> change the writer to add a "properties" collection:
> 
>            "Function": function(filter) {
>                var node = this.createElementNSPlus("ogc:Function", {
>                    attributes: {
>                        name: filter.name
>                    }
>                });
>                var params = filter.params;
>                for(var i=0, len=params.length; i<len; i++){
>                    this.writeOgcExpression(params[i], node);
>                }
>                var properties = filter.properties;
>                for(var i=0, len=properties.length; i<len; i++){
>                    var propNode =
> this.createElementNSPlus("ogc:PropertyName", { value:
> properties[i] });
>                    node.appendChild(propNode);
>                }
>                return node;
>            },
> 
> Now I can use it like this:
> 
>                var subFilter = new OpenLayers.Filter.Function({
>                    type: 'FUNCTION',
>                    name: 'MyFunction',
>                    params: [1.23, 4.56, 'param3'],
>                    properties: ['Altitude', 'Heading']
>                });
> 
>                var timeFilter = new OpenLayers.Filter.Logical( {
>                        type: OpenLayers.Filter.Logical.AND,
>                        filters: [
>                            new OpenLayers.Filter.Comparison({
>                                type:
> OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO,
>                                property: 'startdate',
>                                value: startDate
>                            }),
>                            subFilter
>                        ]
>                    }
>                );
> 
> and get OGC encoded like this:
> 
> <wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs"
> service="WFS" version="1.0.0"
> xsi:schemaLocation="http://www.opengis.net/wfs
> http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> 	<wfs:Query typeName="feature:nyc_buildings" xmlns:feature="ncr">
> 		<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
> 			<ogc:And>
> 				<ogc:And>
> 					<ogc:PropertyIsGreaterThanOrEqualTo>
> 						<ogc:PropertyName>startdate</ogc:PropertyName>
> 						<ogc:Literal>"2003-04-12 04:00:00 z"</ogc:Literal>
> 					</ogc:PropertyIsGreaterThanOrEqualTo>
> 					<ogc:Function name="MyFunction">
> 						<ogc:Literal>1.23</ogc:Literal>
> 						<ogc:Literal>4.56</ogc:Literal>
> 						<ogc:Literal>param3</ogc:Literal>
> 						<ogc:PropertyName>Altitude</ogc:PropertyName>
> 						<ogc:PropertyName>Heading</ogc:PropertyName>
> 					</ogc:Function>
> 				</ogc:And>
> 				<ogc:BBOX>
> 					<ogc:PropertyName>the_geom</ogc:PropertyName>
> 					<gml:Box xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
> 						<gml:coordinates decimal="." cs="," ts=" ">-188.17578125,-2.275390625
> -7.82421875,82.275390625</gml:coordinates>
> 					</gml:Box>
> 				</ogc:BBOX>
> 			</ogc:And>
> 		</ogc:Filter>
> 	</wfs:Query>
> </wfs:GetFeature>
> 
> 
> 
> 
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/Problems-with-Openlayers-Filter-Function-in-WFS-tp5066248p5066253.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130714/334e3dba/attachment-0001.html>


More information about the Users mailing list