Generating Google Tiles With mapserver

Stephen Woodbridge woodbri at SWOODBRIDGE.COM
Sat May 7 07:53:31 PDT 2005


Hi all,

I posted about generating google-like tiles using mapserver earlier. I
took it to the next step of writing a perl/mapscript script to compute
the cellsize for each zoom scale and used that to compute the number of
tiles I would need to generate to cover my map extents. I thought I
would share the results with you. You can probably save maybe 20-30% on
the number of tiles if you can recognize all water only tiles and
eliminate them, but this leaves you with 70-80% of what looks like
infinity for most of us.

        Scale   Num Tiles
   ---------- -----------
     50000000         256
      4000000        3072
      1000000       40960
       500000      150784
       150000     1634816
        50000    14586880
        15000   161796096
        10000   363410944
         5000  1453643776
         2700  4984920576
   ---------- -----------
  Total Tiles  6980188160
  Approx. Disk Space (assume 3K per tile) = 21,443,138,027,520

SOoooo, it requires about 7 Billion 128x128 tiles and assuming that the
average tile size is about 3K (the smallest tile that I have seen google
return) it requires 21 Tera bytes of disk space. It gets worse!

If you assume you can generate 1000 tiles minute (16+/sec) then:

6,980,188,160 / 1000 tiles/min / 60 min/hr / 24 hr/day / 365 day/yr =
13.3 yrs

   1,000 tiles/min = 13.3 yr =  4847 days
  10,000 tiles/min = 1.33 yr =   485 days
100,000 tiles/min = 0.13 yr =    49 days

The only way to do the higher generation rates is in a highly
distributed environment or you run into I/O bottle necks both reading
and writing data.

Oh yeah, I only used 10 zoom scales above, Google has 15, so you do the
math :)

An alternative to pre generating the tiles, is generating them on the
fly as they are need and caching them, then removing the least used ones
over time. This is a much more complicated scenario and requires a lot
of additional code to manage them. Also you can not just generate a
single tile as needed because of the way mapserver handles dynamic
placement of labels. You would need to generate a "super" tile of say
8x8 or 16x16 tiles and chop it into the standard tiles. I looked at
generating a 16x16 super tile at 2048x2048 pixels that would get chopped
into 256 tiles for pre-generation, but 6x6 tiles (768x768 pixels) might
be better for dynamic generation. You would have to find the sweet spot
where the super tile is large enough to minimize labeling issues and
small enough the it generates and chops quickly.

-Steve W.



More information about the MapServer-users mailing list