Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a project using OpenLayers which displays radar data on a map. The radar data itself is just a bunch of polygons each of which is filled with one of 6 possible colors. The goal is to animate the radar on the map. Each file contains radar data for a given time and the files are separated by about 5 minutes so my current approach is to loop through all the files and load them one by one into new separate layers. Once each layer is created it has its visibility set to false and it's added to the map. I then animate the layers using a timer which turns on the visibility of one layer and turns off the visibility of the preceding layer. Currently the layers are all vector layers and the data is loaded from KML files although the data files can be pretty much any format that will work best for this project.

The problem with this approach is that once I hit a fairly large time span (around 3 hours or so) of data (equating to approximately 36 layers) the memory consumption gets pretty high (around 250mb). The final product is supposed to be able to handle up to 18 hours of data in one loop which based on the above number would require over 1GB of memory just for the animation and would likely crash the browser or at least make it very sluggish.

I attempted the same thing using WMS layers for each layer but the redrawing was too slow (the animation changes layers every 100ms) and the memory consumption wasn't much better than the vector version.

I have scoured the net trying to find some example of how to do this but so far am coming up empty handed. Does anyone out there have any suggestions on how to do this? I'll take any ideas you have at this point as I've been stuck on this for weeks now with no answer in sight.

share|improve this question
add comment

3 Answers

up vote 9 down vote accepted

Try a sliding window of sorts. You can buffer 10 layers at a time. Start destroying layers and removing them from the DOM and memory once you reach 10 layers. So once you hit layer 10, layer 0-9 are destroyed and layers 20-30 are loaded with visibility to false. This will give you a buffer of about 10 layers but you can modify your tolerance as you see fit for performance. If you feel 20 layers works better, go with 20.

          {Destroy Layers} |10|11...19|20| {Start Loading Layers}
|---------------------------------------------------------------------------|
                           ↑
        Timespan           Current Possition
share|improve this answer
    
You sir are a genius! I haven't actually put this into practice yet but I don't see any reason for it to not work, and the adjustable buffer means we can further customize this for varying environments. I cannot thank you enough for this suggestion! –  TheOx Feb 25 '12 at 0:18
    
Thanks, I hope it works in practice. Let us know how it works out. –  CaptDragon Feb 27 '12 at 13:38
    
Just completed initial testing and it is working well! There's still some room for optimization in the code but this method keeps the memory footprint way down and is configurable based on the client machine's memory and bandwidth. Thanks again for the excellent suggestion! –  TheOx Mar 1 '12 at 20:27
    
Awesome, good to hear that. –  CaptDragon Mar 1 '12 at 20:47
    
@CaptDragon: (or TheOx) Would it be possible to post to a working example? I understand the solution to a point but seeing a simple example and the code would greatly help as I have pretty much the same issue. Thanks! –  teknocreator Jan 6 at 21:44
add comment

Have you considered simplifying the vector layers to reduce their file size. If the polygons contain more vertices than are needed for the purposes of your display then simplifying (smoothing) them will reduce the file size with the cost of reduced detail. I'm not sure what software you have at your disposal but several GIS desktop applications contain a geoprocessing function to simplify features.

share|improve this answer
    
It's a good idea but unfortunately the project requires displaying the data in its full resolution. However I will keep that in mind for some other data layers down the road where we might be able to use that trick. –  TheOx Feb 25 '12 at 0:15
add comment

Other than simplifying the data (even a little may save a lot of space) have you tried MapServer or some other way of turning your data into tiles with transparency and creating a map layer to lay on top of the background layer. I've seen this approach with cloropleth maps that have hundreds to hundreds of thousands of polygons (or markers), but haven't been able to try it myself yet (due to the server side requirement).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.