[OpenLayers-Users] Filtering a WFS Layer

Ivan Grcic igrcic at gmail.com
Fri Mar 12 18:26:46 EST 2010


Hi,

OpenLayers.Filter.FeatureId should recieve object with fids property, like this:

  new OpenLayers.Filter.FeatureId({
                                fids: [feature.fid]
 })

On Fri, Mar 12, 2010 at 11:23 AM, Andrew Haigh
<haighaj+ollist at googlemail.com> wrote:
> I'm attempting to work out how to apply a filter to a WFS layer (from
> GeoServer 2.0.1), I've looked at the examples / documentation / forums and
> there seems to be a lot of discussion about doing this but I can't seem to
> find a definative solution.
>
> I've seen this thread
> http://n2.nabble.com/WFS-GetFeature-Filter-td4026139.html which seems to
> indicate I need to download the latest build, so I'm using the nightly build
> from the OpenLayers site which reports a version number of 'Revision 10086'.
>
> This is my code:
>
> wfsLayer = new OpenLayers.Layer.Vector( "WFS", {
>    strategies: [new OpenLayers.Strategy.BBOX()],
>    projection: new OpenLayers.Projection("EPSG:27700"),
>    maxExtent: new OpenLayers.Bounds(0, 0, 13000000, 13000000),
>    styleMap: mstylemap,
>    protocol: new OpenLayers.Protocol.WFS({
>        url: "/MyApp/Proxy.ashx",
>        version: "1.1.0",
>        srsName: "EPSG:27700",
>        featurePrefix: "ora_store",
>        featureType: "BOUNDARY",
>        geometryName: "GEOM",
>        featureID: "OBJECTID",
>        defaultFilter: new
> OpenLayers.Filter.FeatureId(["BOUNDARY.1102283472"]) // should this be
> 1102283472 ?
>    })
> });
>
> The FireFox error console reports: Error: uncaught exception: Filter writing
> not supported for rule type: undefined
>
> If I comment out the filter then the WFS layer works fine.
>
> So it appears that I've done something wrong in configuring my filter but I
> can't seem to work out what.
>
> Do I need to set the filter elsewhere?
>
You can aslo apply filter to filter property on layer, you dont have
to do it on defaultFilter on protocol. If both filters are supplied
they get combined  I think...

> Also when using the FeatureId filter I assume I should use the ID as
> returned in GML (BOUNDARY.1102283472) and not as stored in the database
> (1102283472) - is that correct? I've tested both ways and get the same
> error.
>
Yesm ID is same as Geoserver supplies it

> Thanks in advance
>
> Andrew

Cheers,
>

-- 
Ivan



More information about the Users mailing list