Tuesday, March 3, 2009

Asynchronous downloads

One of the things I've learned about the download code is that it uses Asynchronous calls to handle the downloading of the image files from the server in the background.

I found a good article on doing these calls in .NET which explains a lot of the World Wind .NET download code and what it is doing.

http://www.codeproject.com/KB/dotnet/async_pattern.aspx

I need to understand this in order to really implement the more robust queuing method.

Sunday, March 1, 2009

Download code

So I have struggled with the infamous "download code" for the past week or more. It was really difficult to untangle what connects to what and where. I found myself resorting to drawing my own class diagrams to keep the pieces straight from what I could tell.

What was interesting is that there looks like two separate and independent "download code" implementations that do almost the same thing for different areas of the application.

The first component, if you will, was in the project called WebDownload, this was the first one I was able to step my way through. Unfortunately, it was not the component that could solve the problem I was tasked with fixing.


The next set of classes was in another project, PluginSDK. Here was where I eventually made some quick changes to actually stop the repeating downloads from happening.



The QuadTileSet is the center of action here, it has the queue of download requests that it services. I changed this class to have a Hashtable where it would store the download requests for tiles where the server responded with a 404 response. Then it wouldn't re-add these items to the download queue if they were in this Hashtable already.

All in all I had to make some slight changes to three classes here:

  • QuadTileSet

  • GeoSpatialDownloadRequest

  • WebDownload




You may notice the snazzy UML class diagrams I used above. I am not really big on UML, though I used to do class diagrams a lot for a previous company. I went looking for some free, preferably Open Source UML Editors, just to let me crank out the class diagrams above (which I had already hand-drawn on paper).

I tried out two, both were basically Eclipse plugins. One did not work and the other I felt was too complex and buggy for the simple diagrams I want to do.
Papyrus UML - this actually worked but was difficult to use

acceleo - I installed this in my Eclipse environment as a plugin as per directions. I didn't allow me to create any diagrams after about 10 minutes of trying so I uninstalled it.