/usr/share/pyshared/TileCache/Services/VETMS.py is in tilecache 2.11-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # BSD Licensed, Copyright (c) 2006-2010 TileCache Contributors
from TileCache.Service import Request, Capabilities
import TileCache.Layer as Layer
class VETMS (Request):
"""
Support for Virtual Earth quadkey-based URLs.
<host>?ve=true&layer=global_mosaic&tile=000.jpg
"""
def parse (self, fields, path, host):
"""Take in VETMS params and return a tile."""
for key in ['layer', 'tile']:
if fields.has_key(key.upper()):
fields[key] = fields[key.upper()]
elif not fields.has_key(key):
fields[key] = ""
layer = self.getLayer(fields['layer'])
tilenumber = str(fields['tile'])
quadkey = tilenumber.split(".")[0]
tile = None
cell = self.unquad(quadkey)
tile = Layer.Tile(layer, cell[0], cell[1], cell[2])
return tile
def unquad (self, quad):
"""
Returns x/y/z ints based on a quadkey.
>>> ve = VETMS({})
>>> ve.unquad("1")
[1, 1, 1]
>>> ve.unquad("")
[0, 0, 0]
>>> ve.unquad("02")
[0, 2, 2]
"""
z = len(quad)
col = int(0)
row = int(pow(2, z)-1)
quadint = int(0)
for i in range (0, z):
quadint = int(quad[i])
tmp = int(pow(2, z-(i+1)))
if (quadint == 1):
col += tmp
elif (quadint == 2):
row -= tmp
elif (quadint == 3):
col += tmp
row -= tmp
cell = [int(col), int(row), int(z)]
return cell
def serverCapabilities (self, host):
"""Report capabilities for VETMS."""
return Capabilities("text/xml", """<?xml version="1.0" encoding="UTF-8" ?>
<Services>
<VETileMapService version="1.0.0" href="%s?ve=true/" />
</Services>""" % host)
|