[Users] internet explorer extremely slow with spatial filter

Simone Dalmasso simone.dalmasso at gmail.com
Wed Nov 24 15:51:40 CET 2010


Thanks Matt for your help, it has been really helpful:
I post my solution:

*var sites = new OpenLayers.Layer.Vector('Sites',{*
* **styleMap: styleMap,*
* **strategies: [*
* **new OpenLayers.Strategy.Filter({*
* **filter: new OpenLayers.Filter.Comparison({type:
OpenLayers.Filter.Comparison.EQUAL_TO,property: 'approved',value: "true"})*
* **}),*
* **new OpenLayers.Strategy.BBOX({ratio: 1, resFactor: 1})*
* **], *
* **projection: new OpenLayers.Projection("EPSG:4326"), *
* **protocol: new OpenLayers.Protocol.WFS({ *
* **version: "1.1.0", *
* **        srsName: "EPSG:4326",*
* **url: '/geoserver/wfs/',*
* **featureType: 'fs',*
* **        featurePrefix: "prefix",*
* **geometryName: 'point',*
* **maxFeatures: "100"*
* **})*
* **});*

the category filter is set dynamically when the user chooses one:

*
new Ext.form.ComboBox({
id: 'category',
store: new Ext.data.ArrayStore({
 fields: ['id','category'],
data: sitesCategories
 }),
valueField: 'id',
displayField: 'category',
 mode: 'local',
typeAhead: true,
forceSelection: true,
 emptyText: 'Select a Category...',
triggerAction: 'all',
 editable: false,
width: 200,
listeners: {
 select: function(){
 if(this.value !== 'ALL'){
 sites.filter = new OpenLayers.Filter.Comparison({type:
OpenLayers.Filter.Comparison.EQUAL_TO,property: 'category',value:
this.value});
 }else{sites.filter = null;}
sites.redraw();
}
 }//end listeners
})// end combo box
*

in that way each time the user pans, zooms or selects a category the layer
is redrawed and are always keps at most 100 features.

Thanks a lot.

2010/11/23 Matt Priour <mpriour at kestrelcomputer.com>

> In memory spatial filtering is a computationally expensive process. IE (<9)
> has a significantly!!! slower js engine than other browsers, so doing the
> filtering in this way is very slow on IE.
> The better way to accomplish what you are trying to do is to use a WFS or
> other "feature server" and do the filtering on the server side.
> To use a WFS you would do something like this:
>
> var catFilter = new OpenLayers.Filter({...});
>
> var wfsVector = new OpenLayers.Layer.Vector('my wfs layer',{
>  protocol:new OpenLayers.Protocol.WFS({ ... }),
>  strategies:[new OpenLayers.Strategy.BBOX()],
>  style:new OpenLayers.Style({rules:[catFilter]})
> });
>
> When the user zooms or pans, the WFS will be called and you will get the
> features in the view extent.
> When the user chooses a category to filter the features by, you write the
> correct value to the catFilter and then call wfsVector.redraw()
>
> OpenLayers.Vector.redraw() - will just redraw the existing features and
> re-evaluate the styles & filters. It will not request features from the WFS.
>
> Matt Priour
> Kestrel Computer Consutling
>
>
>
> From: Simone Dalmasso
> Sent: Tuesday, November 23, 2010 4:21 AM
> To: users at geoext.org
> Subject: [Users] internet explorer extremely slow with spatial filter
>
>
>
> Hi, I need to have my map to show features if they are in the current
> extent and if they match a selected category.
> So I've written a filter function that uses the filterBy of the
> FeatureStore:
>
>
> function sitesFilter(){
> var extent = map.getExtent();
> featureStore.filterBy(function(record){
> var currentCategory = Ext.getCmp('category').value;
> var feature = record.data.feature;
> if(feature.data.category == currentCategory){
> return extent.containsLonLat(new
> OpenLayers.LonLat(feature.geometry.x,feature.geometry.y));
> }else if(!currentCategory || currentCategory == 'ALL'){
> return extent.containsLonLat(new
> OpenLayers.LonLat(feature.geometry.x,feature.geometry.y));
> }
> });
>
>
> this is called on zoomend, moveend or when a category is chosen.
> All works pretty well and quick with each browser except for ie which is
> extremely slow and unusable.
>
>
> Is there something I can do to speed it up?
>
>
> Thanks in advance
> --
> Simone
>
>
>
>
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>



-- 
Simone Dalmasso, Ing.
ITHACA
Information Technology for Humanitarian Assistance, Cooperation and Action
www.ithacaweb.org
Via Pier Carlo Boggio 61 - 10138 Torino
Tel: +39.011.1975.1854
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20101124/e28cfebc/attachment.htm 


More information about the Users mailing list