[OpenLayers-Users] geojson - Performance issue

Andreas Hocevar ahocevar at opengeo.org
Wed Jan 6 10:35:15 EST 2010


Hi,

2000+ features is way too much for rendering in the browser.

if you use mapserver already, then you can also query the layer as WMS
layer, using sld_body with a filter. If your query is complex, use
Layer.WMS.Post instead of Layer.WMS to avoid urls that are too long for IE.

Regards,
Andreas.

On 2010-01-06 16:29, Steve.Toutant at inspq.qc.ca wrote:
>
> Hi,
> I created a WMS (mapserver) layer containing 13400 polygons. It loads
> in less then 3 seconds. Good.
>
> I need to develop a tool for the user so he can create a custom query
> on this layer to retreive specific polygons. In a form, the user
> select the parameters and launch the request. Here is the code below.
> That works, but it takes minutes to render. Per example, a query that
> returns 2482 polygons, In firebug I see that the query runs in less
> then 2 seconds.
> But, It seems that the creation of the geometries is an heavy task. I
> get this warning in FF
>
>
> I click on Continue several times and then I get geometries in the map.
>
> I guess 2482 polygons is simply too much for a vector layer. If that
> is the case, is there another format then GeoJson I could use? Maybe
> my approach is totally wrong...
>
> Any comments would be appreciated.
> Thanks for your help,
> Steve
>
> The code used:
>
> Ext.Ajax.request({
> url: 'requeteVulnerabilite.php',
> method:'POST',
> params: { inddef: cb_inddefValue},
> failure: function(){alert("Ca pas marché");},
> success: function(result, request )
>         {
>                 //alert(result.responseText);
>                 vulnerabiliteLayer.destroyFeatures();
>                 var features = new
> OpenLayers.Format.GeoJSON({'internalProjection':map.baseLayer.projection,'externalProjection':map.baseLayer.projection
>
>                                                                      
>                                    }).read(result.responseText);
>                 var bounds;
>                 if(features)
>                 {
>                         if(features.constructor != Array) {
>                                 features = [features];
>                         }
>                         for(var i=0; i<features.length; ++i) {
>                                 if (!bounds) {
>                                         bounds =
> features[i].geometry.getBounds();
>                                 } else {
>                                        
> bounds.extend(features[i].geometry.getBounds());
>                                 }
>                         }
>                         vulnerabiliteLayer.addFeatures(features);
>                         map.zoomToExtent(bounds);
>                 }
>        
>         }
> });
>
>
>
>
> /Steve Toutant, M. Sc./
> Analyste en géomatique
> Secteur environnement
> Direction de la santé environnementale et de la toxicologie
> Institut national de santé publique du Québec
> 945, avenue Wolfe
> Québec, Qc G1V 5B3
>
> Tél.: (418) 650-5115 #5281
> Fax.: (418) 654-3144_
> __steve.toutant at inspq.qc.ca_ <mailto:steve.toutant at inspq.qc.ca>_
> __http://www.inspq.qc.ca_ <http://www.inspq.qc.ca/>
>
>  
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>   


-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.




More information about the Users mailing list