Convert Quadtree to TMS or ZXY

I had a set of map tiles generated using Microsoft Research’s free and pretty useful MapCruncher tool. The problem is that it outputs the tiles in the “Quadtree” format used by Bing maps (fair enough) so that you can easily create a Bing maps mashup, whereas I wanted to use the resultant tiles with one of the many popular javascript mapping libraries out there, in this particular case Leaflet.js.

Most of these libraries come with plugins so that you can use different sources for the map tiles, but for Layer I couldn’t find one that would allow me to easily use the MapCruncher Quadtree tiles directly.

As fortune would have it, the actual files that quadtree uses are the same tiles that are used in the more widely-standardised ZXY format. The only difference is in the naming of the files and the way they are all stored in a single directory for Quadtree vs being in subfolders for ZXY (where the Z is the zoom level).

Therefore, using a known formula you can rename and move the quadtree files to get a set of files that can be used directly by most map-rendering javascripts using the default map provider.

The raw Java code I used for this is below. When I get time I’ll try and package this into a jar file or put a basic GUI on it for you, but in the meantime, you’ll have to compile and run it yourself, sorry.