[OpenLayers-Users] Speed up my filtering

Paul Meems bontepaarden at gmail.com
Mon May 7 07:00:24 EDT 2012


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"  })});

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.

What else can I do to speed up this filter?

Thanks,

Paul

--
Organizing the International Open Source GIS conference 2012 in The
Netherlands:
http://www.mapwindow.org/conference/2012/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120507/e5732a14/attachment.html


More information about the Users mailing list