/usr/share/pyshared/ModestMaps/Providers.py is in python-modestmaps 1.3.1-1.
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 62 63 64 65 66 67 68 69 70 71 72 73 74 | import re
from math import pi, pow
from Core import Coordinate
from Geo import LinearProjection, MercatorProjection, deriveTransformation
ids = ('MICROSOFT_ROAD', 'MICROSOFT_AERIAL', 'MICROSOFT_HYBRID',
'YAHOO_ROAD', 'YAHOO_AERIAL', 'YAHOO_HYBRID',
'BLUE_MARBLE',
'OPEN_STREET_MAP')
class IMapProvider:
def __init__(self):
raise NotImplementedError("Abstract method not implemented by subclass.")
def getTileUrls(self, coordinate):
raise NotImplementedError("Abstract method not implemented by subclass.")
def getTileUrls(self, coordinate):
raise NotImplementedError("Abstract method not implemented by subclass.")
def tileWidth(self):
raise NotImplementedError("Abstract method not implemented by subclass.")
def tileHeight(self):
raise NotImplementedError("Abstract method not implemented by subclass.")
def locationCoordinate(self, location):
return self.projection.locationCoordinate(location)
def coordinateLocation(self, location):
return self.projection.coordinateLocation(location)
def sourceCoordinate(self, coordinate):
raise NotImplementedError("Abstract method not implemented by subclass.")
def sourceCoordinate(self, coordinate):
wrappedColumn = coordinate.column % pow(2, coordinate.zoom)
while wrappedColumn < 0:
wrappedColumn += pow(2, coordinate.zoom)
return Coordinate(coordinate.row, wrappedColumn, coordinate.zoom)
class TemplatedMercatorProvider(IMapProvider):
""" Convert URI templates into tile URLs, using a tileUrlTemplate identical to:
http://code.google.com/apis/maps/documentation/overlays.html#Custom_Map_Types
"""
def __init__(self, template):
# the spherical mercator world tile covers (-π, -π) to (π, π)
t = deriveTransformation(-pi, pi, 0, 0, pi, pi, 1, 0, -pi, -pi, 0, 1)
self.projection = MercatorProjection(0, t)
self.templates = []
while template:
match = re.match(r'^(http://\S+?)(,http://\S+)?$', template)
first = match.group(1)
if match:
self.templates.append(first)
template = template[len(first):].lstrip(',')
else:
break
def tileWidth(self):
return 256
def tileHeight(self):
return 256
def getTileUrls(self, coordinate):
x, y, z = str(int(coordinate.column)), str(int(coordinate.row)), str(int(coordinate.zoom))
return [t.replace('{X}', x).replace('{Y}', y).replace('{Z}', z) for t in self.templates]
|