Requires:
ModestMaps-py
from ModestMaps.Geo import MercatorProjection, Location, Coordinate | |
m = MercatorProjection(0) | |
points = [[38.0, -79.0], [37.0, -79.0]] | |
i = float('inf') | |
w = 800 | |
h = 600 | |
tl = [min(map(lambda x: x[0], points)), min(map(lambda x: x[1], points))] | |
br = [max(map(lambda x: x[0], points)), max(map(lambda x: x[1], points))] | |
c1 = m.locationCoordinate(Location(tl[0], tl[1])) | |
c2 = m.locationCoordinate(Location(br[0], br[1])) | |
while (abs(c1.column - c2.column) * 256.0) < w and (abs(c1.row - c2.row) * 256.0) < h: | |
c1 = c1.zoomBy(1) | |
c2 = c2.zoomBy(1) | |
center = m.coordinateLocation(Coordinate( | |
(c1.row + c2.row) / 2, | |
(c1.column + c2.column) / 2, | |
c1.zoom)) | |
print center, c1.zoom |