/usr/share/pyshared/TileCache/Services/WMTS.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 | # BSD Licensed, Copyright (c) 2006-2010 TileCache Contributors
from TileCache.Service import Request, Capabilities, TileCacheException
import TileCache.Layer as Layer
class WMTS (Request):
meters_per_unit = { 'degrees': 111118.752,
'meters': 1,
'feet': 0.3048
}
def parse (self, fields, path, host):
for key in ['scale','layer','tilerow','tilecol']:
if fields.has_key(key.upper()):
fields[key] = fields[key.upper()]
elif not fields.has_key(key):
fields[key] = ""
layer = self.getLayer(fields['layer'])
if not layer.units:
raise TileCacheException("No units were specified on the layer. WMTS support requires units to be defined for the layer.")
res = .00028 * float(fields['scale']) / self.meters_per_unit[layer.units]
z = layer.getLevel(res, layer.size)
tile = None
maxY = int(
round(
(layer.bbox[3] - layer.bbox[1]) /
(res * layer.size[1])
)
) - 1
tile = Layer.Tile(layer, int(fields['tilecol']), maxY - int(fields['tilerow']), z)
return tile
|