Recursion

My brain hurts! I've gotten so mentally flabby on doing this type of thinking… My internet connection's been down for a lot of the day because of snowfall, so I've been tinkering with the dynamic mapping system. The problem is the size of the dataset. My tests that you've seen here have been rendered using the giant map — 21,600 pixels across. That's something like 200 meg of image to crop and rescale, so it chews through at least a second of CPU time. No big deal for my testing here, but unacceptable once it's on the server.

So how to render fast? My first experiment involves subdividing the map into 16 sections — four vertical divisions and four horizontal ones. From this 4×4 grid I create nine 2×2 submaps. Each one of those submaps is broken down again, and then their submaps are also broken down, resulting in about a thousand 2700 pixel wide images, with a final resolution of about 1km per pixel at full zoom, although it will do an infinite amount of digital zoom past that (not that it's meaningful past 200%).

Anyway, below shows a quick drawing of what I'm talking about:

Then, on the rendering level, once I have the edge points of the desired map (in radians), I calculate the area of the desired map. Then I seed the process using the world map's data. I then check to see if the desired map fits inside any of the nine submaps. Any that do are recursed again down to the maximum depth. At the end of it all, the software uses the map with the least differential between actual area and desired area. In the case of ties, it picks the most centred version.

2700 pixels across is still a fairly large map size, but I think, given the power of this server, that it should strike a happy medium. After all, if I instead went with 1350 pixels in width (my original plan), it would result in almost ten thousand images… And with every iteration the level of redundancy increases (and from a quality point of view, nothing much is saved).

In any case, if my thinking is straight on the matter, it means that a 50% resolution map of 2km per pixel (worst case scenario; most maps will render at 100% resolution) can be rendered for any rectangle on the globe). If I get ambitious I'll make the map loop (so for example, Ankorage AK and Tokyo Japan would be rendered as a tight crop, not as a world map), but that's most definitely a project for another day.

Anyway, hope that wasn't toooooo boring.

Wow Shannon, that's really annoying! What is it, 1997 on Geocities? Retroweb is NOT cool!

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*