[OpenLayers-Dev] Performance question

Antonio volpicelli at oato.inaf.it
Sat Jul 28 05:56:35 EDT 2007


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.
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.
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?
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) .
 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
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?

Thanks a lot

Antonio

Diez, Matthew wrote:
>  
> I've been developing an application to do animation of Untiled layers,
> but I'm running across a bit of a design issue.
>
> Snippet #1 - The blinking animation 
> ===================================
>
> // on timestamp change event
>
> var curLayer = objRef.oLlayers[layerName]				
> curLayer.mergeNewParams({"TIME":timestamp.firstChild.nodeValue});
>
> The above calls mergeNewParams, which of course, destroys/erases the
> image div, and then draws the new image with the new timestamp.
> The problem is, when trying to animate, you get a pattern of:
> Draw Frame 1 -> Erase Frame 1 -> Draw Frame 2.
>
> The 'erase' step in between causes for some pretty awful flicker. So I
> tried Snippet #2.
>
> Snippet #2 - The memory leak
> ============================
>
> var curLayer = objRef.oLlayers[layerName]				
> curLayer.tile = null;
> curLayer.mergeNewParams({"TIME":timestamp.firstChild.nodeValue});
>
> By setting the tile to null, it actually doesn't do destroy the image
> div, it merely replaces the contents. 
> This yields:
> Draw Frame 1 -> Draw Frame 2 -> Draw Frame X
>
> This is, of course, the desired behavior, but it causes two problems:
> A) Frame 1's DIV never gets destroyed/erased, causing a memory leak
> B) When using transparent images, all are drawn on top of one another.
>
> So, on to Snippet #3 
> ==============================
>
> /* This is Draw 1, Draw 2, Remove 1 
> curLayer.tile = null;
> curLayer.mergeNewParams({"TIME":timestamp.firstChild.nodeValue});
> var oldImageId = curLayer.tile.imgDiv.id;
> 				
> var commandString = 'removeNode(\"' + oldImageId + '\")';
>
> setTimeout(commandString, 1000);
>
> function removeNode(oldImageId) {
> 	var olddiv = document.getElementById(oldImageId);
> 		
> 	var d = olddiv.parentNode;
> 	var e = d.parentNode;
> 	d.removeChild(olddiv);
> 	e.removeChild(d);			
> }
>
>
> So, here, 
> Draws Frame 1, Draws Frame 2, and then removeNode waits a second and
> destroys Frame 1. 
>
> This solves Snippet 2, Issue A, but looks hideous for Issue B.
> Basically, you can actually see Frame 1 being drawn on top of, and then
> removed, which makes for an admittedly awful user experience, even with
> only 5 ms of time-delay.
>
> And, then, Snippet #4 - URL substitution
> =====================
>
> var oldImageUrl = curLayer.tile.imgDiv.src;
> var newImageUrl = oldImageUrl;		
> newImageUrl = newImageUrl.replace(/TIME\=.*?\&/,'TIME=' +
> timestamp.firstChild.nodeValue + '&');
> curLayer.tile.imgDiv.src = newImageUrl;
>
> Okay, so what we're doing here is direct regexp replacement of the URL.
> This works, but with some issues.
> A) It's somewhat slower than using mergeNewParams (cannot figure out
> why)
> B) I really don't like doing direct URL pattern substitution like this
> (it strikes me as error-prone)
> C) Is there a more 'OpenLayers-ish' way to do this?
>
> So, can anyone suggest something that might be better than Snippet #4?
>
> Thanks, 
> Matthew D. Diez
>
>
> IEM CONFIDENTIAL INFORMATION PLEASE READ OUR NOTICE:
> http://www.iem.com/e_mail_confidentiality_notice.html
>
> Effective July 15, 2007 IEM Headquarters will have a new physical and mailing address:
> 8550 United Plaza Blvd, Suite 501
> Baton Rouge, LA 70809
> If you should have any questions, please feel free to contact us at 225.952.8191
>
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>   

-- 
/-------------------------------------------------------\
       PLEASE WARNING: E-mail is CHANGED
             volpicelli at oato.inaf.it
/-------------------------------------------------------\




More information about the Dev mailing list