[mapserver-users] Tips on generating tiles from mapserver

Lars Lingner ml at lingner.eu
Tue Oct 6 03:54:49 PDT 2009


Adrian Popa schrieb:
> Hello everyone,
> 
> I have some mapserver layers that I would like to generate into tiles
> (because the content doesn't change much). I would like to find out the
> following:
> 1) a link to a tutorial or help on how to do this (which tools to use)

You could use TileCache. It comes with an tilecache_seed.py script which
generates the tiles queering MapServer.

A sample config can look like:

- MapServer layer

LAYER
    TYPE POLYGON
    STATUS ON
    NAME "landuse"
    CONNECTIONTYPE POSTGIS
    CONNECTION "host=<host> port=<port> dbname=<dbname> user=<dbuser>
password=<dbpasswd>"
    DATA "way from (select way,id ,landuse from otg_polygon where
landuse is not null ) as foo using unique id using srid=900913"
    PROCESSING "LABEL_NO_CLIP=ON"
    PROCESSING "CLOSE_CONNECTION=DEFER"
    CLASSITEM "landuse"
    METADATA
      WMS_TITLE "landuse"
      WMS_GROUP_TITLE "landuse"
      WMS_EXTENT "-3654301.4476046 3830412.5307382 6971056.978358
9730128.1208444"
      WMS_ABSTRACT "layer landuse"
    END #metadata
    CLASS
        STYLE
            COLOR "#E3E2DF"
        END
    END
END

- corresponding TileCache config

[landuse]
type=WMS
url=http://example.org/cgi-bin/mapserv?map=/path/to/mapfile.map
layers=landuse
extension=png
bbox=-3654301.4476046,3830412.5307382,6971056.978358,9730128.1208444
maxResolution=9783.93961875
srs=EPSG:900913
metaTile=true
metaSize=8,8

You have to adjust the extents, resolutions, srs, url to your needs
Have a look at TileCache docs for further explanation. (www.tilecache.org)

> 2) how can I calculate an estimate of the size those tiles would occupy

I have no formula at hand.

> 3) what naming convention (or extra details) are needed to make the
> tiles viewable in OpenLayers.
> 

Either you are using TileCache or you can direct access the cache
directory via an OpenLayers.Layer.TileCache so you don't have to bother
with naming.


Lars



More information about the MapServer-users mailing list