[OpenLayers-Dev] Performance question

Christopher Schmidt crschmidt at metacarta.com
Sat Jul 28 08:35:34 EDT 2007


On Sat, Jul 28, 2007 at 11:56:35AM +0200, Antonio wrote:
> Hi dev,
> In my application I need to overlay 11 layers.
> One of these has about 15000 entries in its shapefile. Each entry is a 
> polygon ( a rectangle ) and the vertices are in meters because I use a 
> Mollweide(54004) projection.
> So I add these 11 layers in the my map object  and the first time at the 
> max extent bounds it is fast.

In general, I would advise against having 11 seperate layers on a map.
It's possible that this really is neccesary, but in general, 11 layers
is more likely to confuse the user: You're the map maker, make some
decisions about how the map should look, and combine some of the layers.

I could be wrong, especially in the case of analysis, but in general,
I've found that as you add more layers, users feel less comfortable,
rather than more, despite the addtional level of control it offers. 

> When I zoom in the performances are very very poor and when I go to the 
> max zoom level I can see that the requests send to the web server are 
> about 1000.

You must have a pretty big map in your web page: 90 tiles per layer
sounds pretty excessive. If you really are getting that many, you might
want to drop the 'buffer' setting on the layer down by one, though that
will not affect things *that* much with that many tiles in the window...
you also might want to think about a larger tile size.

> I suppose too that for each of these 1000 requests to MapServer  has it  
> to scan 15000 entries to get just only the polygons that are inside the 
> requested tile? Is it right?

You should index your shapefiles. If you index your shapefiles, then
bounding box queries are faster. Look into 'shptree':  
http://mapserver.gis.umn.edu/docs/reference/utilityreference/referencemanual-all-pages

> So I tried to add just one layer , clearly the performance is better but 
> at max zoom level the requests to the web server are about 50.
> My question is:
> 1) Is it possible to change the area , and then the number of tiles , 
> and I suppose the number of requests ,  that OL ask to cover around the 
> visible area ( what my visible extent is on the browser) .

Options:
  * 'buffer': 0 or 'buffer': 1 on your WMS layer will decrease the number of
    tiles drawn outside your map.
    http://dev.openlayers.org/docs/files/OpenLayers/Layer/Grid-js.html#OpenLayers.Layer.Grid.buffer
    
  * 'singleTile': true (trunk) or WMS.Untiled will cause your map to
    only  request one tile at a time, rather than using a tiled view.
    

>  2) When I add the layers to the map object and then add the 
> LayerSwitcher control , all the overlay layers are checked. It is 
> possible to set some layers at unchecked status
 
setVisibility(false) on the layer before you add it. 
 
> 3) I have seen that is easy to add layers to the map dynamically  , but 
> is not so easy to remove they. There are some one that has the code to 
> do that?

Eric already hit on this one.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Dev mailing list