| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

TileCache

Page history last edited by Corey Alix 11 years, 9 months ago

TileCache is one of several open source GIS tile server solutions.  Others include MapProxy and GeoWebCache.

 

TileCache is a python based solution and obtains imagery from a WMS service and persists that imagery to the file system via DiskCache.

 

Installing TileCache on Windows/IIS

 

  1. Download TileCache from one of the links on TileCache.org.
  2. Launch IIS Manager and create a site, application or virtual directory pointing to the "tilecache" folder.
  3. Open the newly created endpoint (e.g. http://localhost:83/TileCache/) in a browser and notice that you have a map with broken tiles.
  4. Change the extension of tilecache.cgi to tilecache.py
  5. Edit tilecache.py by removing the first line and accessing the config file directly (see http://viswaug.files.wordpress.com/2008/02/croppercapture19.png)

from TileCache import Service, cgiHandler, cfgfiles

if __name__ == '__main__':

    svc = Service.load("D:\\code\\tilecache\\tilecache.cfg")

    cgiHandler(svc)

  • Modify index.html to reference tilecache.py (instead of tilecache.cgi). 
  • Launch Turn Windows features on or off and check "Internet Information Services/World Wide Web Services/Application Development Features/CGI"
  • Back in IIS Manager  register *.py (Add Script Mapping with Request path=*.py, Executable="c:\python27\python.exe" %s %s, Name=Python27)
  • Attempt to access a tile (e.g. http://localhost:83/TileCache/tilecache.py?LAYERS=basic&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=-180,-90,-90,0&WIDTH=256&HEIGHT=256
  • If it worked you're done!  Otherwise read on.  (I received An error occurred: No section: 'cache' because I used the SVN trunk). 
  • Return to tilecache.py and add brackets around the path  Service.load(["D:\\code\\tilecache\\tilecache.cfg"]).
  • And now my map works...my tiles are being saved to \tmp\tilecache (e.g. D:\tmp\tilecache\basic\01\000\000\003\000\000\001.png)

 

Configuration TileCache

Open tilecache.cfg  and search for the [cache] section.  Modify the base value as necessary:

[cache]

type=Disk

base=g:\tilecache\Cache

 

Create your services simply by introducing a new section:

[Assets]

type=WMS

layers=2,3,4,5,6,7,8,9,10,11,12,13,14,15

url=http://usgvwhansendev1:5000/arcgis/services/DevVegasN/MapServer/WMSServer?TRANSPARENT=TRUE

extension=png

extent_type=loose

srs=EPSG:4326

spherical_mercator=true

levels=22

 

These tiles are accessible using a WMS query string (e.g. http://localhost:83/TileCache/tilecache.py?LAYERS=basic&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=-180,-90,-90,0&WIDTH=256&HEIGHT=256) and assume 4326 projection.  

The metacarta sample test service is accessible in other projection as discovered by http://vmap0.tiles.osgeo.org/wms/vmap0?REQUEST=GetCapabilities&SERVICE=WMS.  They include 4269 and 900913.

 

Generating tile using a the 3857 projection requires modifying index.html and the tilecache.cfg.

[Test3857]

type=WMS

layers=river

url=http://labs.metacarta.com/wms/vmap0

extension=png

extent_type=loose

spherical_mercator=true

bbox=-20037508.34,-20037508.34,20037508.34,20037508.34

srs=EPSG:900913

levels=20

 

And the change to the open layers code in index.html to overlay the OpenStreetMap with the river layer:

 

function init(){

    var map, layer, options;

    options = {

      projection: new OpenLayers.Projection("EPSG:900913"),

      displayProjection: new OpenLayers.Projection("EPSG:4326")

    };

    map = new OpenLayers.Map('map', options);

    var mapnik = new OpenLayers.Layer.OSM("OpenStreetMap (Mapnik)");

    map.addLayers([mapnik]);

    var layer = new OpenLayers.Layer.WMS( "Rivers", "http://localhost:83/tilecache/tilecache.py?", {layers: 'Test3857', format: 'image/png', TRANSPARENT: true } );

    map.addLayers([layer]);

}

 

External Links

http://tilecache.org/docs/README.html

http://viswaug.wordpress.com/2008/02/03/setting-up-tilecache-on-iis/

http://www.esdmdata.co.uk/tilecache-on-iis7-how-to

 

Comments (0)

You don't have permission to comment on this page.