Thursday, March 29, 2012

MapBox Tiles - The paging version

MBTiles databases are deceptively simple.  They're just a database with a little metadata, right?

Yes, and that's what makes them tricky.  From an implementation perspective, here are some of the problems:

  • They can be sparse.  Just because there's a level 7 tile at (40,41) doesn't mean there's one at (20,18).
  • They can be empty up top.  A user might neglect to include levels 0-5 because they don't need them.
  • They don't cover the whole earth.  Usually.
There are good reasons for all of those, mostly having to do with 2D map display.  In 3D this gets interesting.  

To do this right I have to map a 2D quad tree onto a sphere for proper data paging.  You have to either hack it or work in screen space.  I'm doing the latter and it means projecting representative pixels to the screen and deciding how important their associated tiles are.  It's a nice general solution and should work well for other data types too.

The point to all of this is that MapBox Tile paging support is underway.  That will open up a host of other interesting areas too.