[OpenLayers-Users] Slow WFS filter layer
Milo van der Linden
milo at dogodigi.net
Mon Jul 2 12:33:18 PDT 2012
I am doing something similar, but my initial filter is an empty string ""
that gets set to a valid string later on. I do not use an id, but use the
filter to limit results to a viewers organizational unit. I have seen over
a hunderd features displayed in less then a second. The underlying table is
oracle spatial with less then 10k records.
To dig in deeper:
1. Are geoserver and your db on the same machine?
2. Do you have enough RAM?
3. Did you test smaller datasets which generate the same result and are
they faster?
4. What browser are you using?
On Jul 2, 2012 9:18 PM, "Paul Meems" <bontepaarden at gmail.com> wrote:
> I use GeoServer and PostGIS and OpenLayers to show the data.
> For one page I'm using a WFS layer and I filter on address.
>
> The user first need to select an address. This is done with an AJAX call
> and the adresID and the location (X, Y) are returned.
> I zoom to that location and change my filter.
> This is my initial set-up of my layer, an addressID of -1 doesn't exists
> so it starts with just the baselayer:
>
> var myLayer = new OpenLayers.Layer.Vector("tmp", { displayInLayerSwitcher: true, strategies: [new OpenLayers.Strategy.BBOX()], filter: new OpenLayers.Filter.Comparison({ type: OpenLayers.Filter.Comparison.EQUAL_TO, property: "_adresid", value: "-1"}), styleMap: new OpenLayers.StyleMap(), protocol: new OpenLayers.Protocol.WFS({ url: ".../wfs", featureType: "myName", srsName: "EPSG:3857", geometryName: "geomgoogle" })});
>
> But this call takes long because it tries to find the -1 value.
> *Q1*: How can I add a WFS layer without data?
>
> And this is the method I call after the user selects an address:
>
> function changeFilter(newValue, x, y){ myLayer.destroyFeatures(); filter = new OpenLayers.Filter.Logical({ type: OpenLayers.Filter.Logical.AND, filters: [ new OpenLayers.Filter.Comparison({ type: OpenLayers.Filter.Comparison.EQUAL_TO, property: "_adresid", value: newValue }), new OpenLayers.Filter.Spatial({ type: OpenLayers.Filter.Spatial.BBOX, value: new OpenLayers.Bounds(x-50, y-50, x+50, y+50), projection: "EPSG:3857" }) ] }); myLayer.filter = filter; myLayer.refresh({force: true});
> showAttributes();
> }
>
>
> This is working great, but is does take a very long time: about 7-10
> seconds.
> The result are just a few features: 3-10
>
> Of course I have an index in the database on _adresid and a spatial index.
>
> *Q2*: What else can I do to speed up this filter?
>
> Thanks,
>
> Paul
>
> _______________________________________________
> 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/20120702/70cfae81/attachment.html>
More information about the Users
mailing list