File: Example.py.txt

package info (click to toggle)
tilecache 2.11%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 536 kB
  • sloc: python: 3,086; makefile: 92
file content (32 lines) | stat: -rwxr-xr-x 1,524 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python

# This example code demonstrates how you can construct
# a custom service as an alternative to the config file.
# This allows you to, for example, determine what layers to
# load based on request parameters or something similar --
# the config file based loading technique is handy, but 
# probably doesn't solve all problems.

from TileCache.Service import Service, modPythonHandler, cgiHandler
from TileCache.Caches.Disk import Disk
import TileCache.Layers.WMS as WMS
import TileCache.Layers.MapServer as MS

myService = Service (
  Disk("/www/wms-c/cache"), 
  { 
    "basic"     : MS.MapServer( "basic", "/www/wms-c/basic.map" ),
    "satellite" : MS.MapServer( "satellite", "/www/wms-c/basic.map", extension = "jpeg" ),
    "cascade"   : WMS.WMS( "basic", "http://labs.metacarta.com/wms/vmap0?", extension = "jpeg" ),
    "DRG"       : WMS.WMS( "DRG", "http://terraservice.net/ogcmap.ashx?", extension = "jpeg" ),
    "OSM"       : WMS.WMS( "roads", "http://aesis.metacarta.com/cgi-bin/mapserv?FORMAT=png8&map=/home/crschmidt/osm.map&TRANSPARENT=TRUE&", extension = "png" ),
    "Boston"    : WMS.WMS( "border,water,openspace,roads,buildings,rapid_transit", "http://nyc.freemap.in/cgi-bin/mapserv?map=/www/freemap.in/boston/map/gmaps.map&" ),
    "hfoot"     : WMS.WMS( "hfoot", "http://beta.sedac.ciesin.columbia.edu/mapserver/wms/hfoot?", levels = 20, extension = "jpeg" )
  }
) 

def handler (req):
    return modPythonHandler(req, myService)

if __name__ == '__main__':
    cgiHandler(myService)