The basic principle of Web map tiling is each zoom level is made up of tiles one half the width and one half the height of the zoom level above. Or put another way, each tile is the parent of four child tiles. Together all four child tiles have the same bounding box as their parent. Every tile has the same number of pixels. Therefore, the great grand children of a parent tile, of which there are 64, represent a portion of the map one eight as wide and one eight as high. Taken together the original image is 8 times as dense.
Why are these details important? Introductions to web map tiling focus on projection details and hacks that make the numbers work out. Understanding the relationships between tiles unlocks a deeper understanding of how the algorithm works.
The index of a parent tile can be computed by subtracting one for the zoom level, and integer dividing X and Y by 2.
The pixel index of a parent tile can be found by using the remainder of division by 2. The associated quadrant depends on whether X and Y of the child tile are odd or even.
The recursive definition of tile indices generalises nicely. Integer division discards the remainder. The relative layer index can be calculated by dividing by powers of 2.
For example, if is 7 and then is 3 and then is 0.
Given a tile index, represented by three integers Z, X and Y, it is also possible to find the indices of all descendents.
Physical images are used to represent the first N layers. As mentioned previously, each layer contains 4 times as many tiles as the previous layer.
For pragmatic reasons, it is desirable to only generate the images needed to represent the data at the correct resolution
A virtual tile is a tile generated from a physical tile by cropping the physical tile and resizing the cropped image to the tile size.
The first step to generating a virtual tile is to identify it's physical ancestor tile. This can be done by iteratively searching parent tiles, i.e. subtract one for the level index and integer dividing by 2 to find the X/Y indices.
Below a certain number of layers, the whole tile is generated by a single pixel.
Virtual web maps offer an efficient alternative to pre-rendered maps.