Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have been trying to figure out how to send a filter to geoserver using wfs.

The filter that I want to send is:

                filterXML = '<Filter>'+
                            '<Crosses>'+
                                '<PropertyName>the_geom</PropertyName>'+
                                '<Function name="collectGeometries">'+
                                    '<Function name="queryCollection">'+
                                        '<Literal>tasmania_water_bodies</Literal>'+
                                        '<Literal>the_geom</Literal>'+
                                        '<Literal>AREA = 1064866676</Literal>'+
                                    '</Function>'+
                                '</Function>'+
                            '</Crosses>'+
                        '</Filter>';

I have a WFS protocol and i would like to attach that filter with this request:

            wfsProtocol = new OpenLayers.Protocol.WFS({
                        url: "http://localhost:8080/geoserver/wfs",
                        featureType: ["tasmania_water_bodies"],
                        featureNS: "http://www.openplans.org/topp"
                    });

        wfsLayer = new OpenLayers.Layer.Vector("LinesWFS", {
                    strategies: [new OpenLayers.Strategy.Fixed()],
                    protocol: wfsProtocol
                });

I have tried converting it to a filter using this:

        parser = new OpenLayers.Format.Filter.v1_1_0 ();
        xml = new OpenLayers.Format.XML();
        my_filter_xml = fil; //your filter string

        var x = xml.read(my_filter_xml).documentElement
        var filter1 = parser.read(x);
        console.log(filter1)

That works for very basic xml filters, but not the one that I want to convert.

Am I doing it the wrong way?

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.