def __init__(self, xyz, srs):
        self.xyz = xyz
        self.srs = self.normalizeSrs(srs)
        self.tilesize = 256
        self.resolutions = [2**(x + 1) for x in list(reversed(range(15)))
                            ] + [1.0 / 2**x for x in range(10)]

        self.standardProjections = {
            'EPSG:3857': SphericalMercator(),
            'EPSG:900913': SphericalMercator(),
            'EPSG:4326': WGS84()
        }

        standardProjection = self.standardProjections.get(self.srs, None)
        self.coordinateProj = standardProjection.coordinateProj if standardProjection else self._coordinateProj
Exemple #2
0
 def renderTile(self, width, height, srs, coord):
     """
     """
     if srs != SphericalMercator().srs:
         raise Exception('Tile projection must be spherical mercator, not "%(srs)s"' % locals())
     
     return render_tile(self.source_dir, coord, 0)
Exemple #3
0
    def __init__(self, demdir, tiledir, tmpdir, source):
        """
        """
        cache = Disk(tiledir, dirs='safe')
        config = Configuration(cache, '.')
        Layer.__init__(self, config, SphericalMercator(), Metatile())

        self.provider = Provider(self, demdir, tmpdir, source)
Exemple #4
0
                offset += 1

if __name__ == '__main__':

    path.insert(0, '.')

    options, zooms = parser.parse_args()

    lat1, lon1, lat2, lon2 = options.bbox
    south, west = min(lat1, lat2), min(lon1, lon2)
    north, east = max(lat1, lat2), max(lon1, lon2)

    northwest = Location(north, west)
    southeast = Location(south, east)

    webmerc = SphericalMercator()

    ul = webmerc.locationCoordinate(northwest)
    lr = webmerc.locationCoordinate(southeast)

    for (i, zoom) in enumerate(zooms):
        if not zoom.isdigit():
            raise KnownUnknown('"%s" is not a valid numeric zoom level.' % zoom)

        zooms[i] = int(zoom)

    layer = SeedingLayer(options.demdir, options.tiledir, options.tmpdir, options.source)

    for (offset, count, coord) in generateCoordinates(ul, lr, zooms, 0):

        mimetype, content = getTile(layer, coord, 'TIFF', True)
Exemple #5
0
from PIL import Image
import numpy

from .. import save_slope_aspect

# used to prevent clobbering in /vsimem/, see:
# http://osgeo-org.1803224.n2.nabble.com/gdal-dev-Outputting-to-vsimem-td6221295.html
vsimem_counter = 1

#
# Set up some useful projections.
#

osr.UseExceptions()  # <-- otherwise errors will be silent and useless.

webmerc_proj = SphericalMercator()
webmerc_sref = osr.SpatialReference()
webmerc_sref.ImportFromProj4(webmerc_proj.srs)


class SeedingLayer(Layer):
    """ Tilestache-compatible seeding layer for preparing tiled data.
    
        Intended for use in hillup-seed.py script for preparing a tile directory.
    """
    def __init__(self, demdir, tiledir, tmpdir, source, size):
        """
        """
        cache = Disk(tiledir, dirs='safe')
        config = Configuration(cache, '.')
        Layer.__init__(self,
Exemple #6
0
from sys import argv
from urlparse import urlparse
from os.path import splitext

from ModestMaps.Core import Coordinate, Point
from ModestMaps.OpenStreetMap import Provider
from TileStache.Geography import SphericalMercator

mercator = SphericalMercator()
zoom, scale = 6, 611.496226
output_dir = argv[1]

hrefs = ['http://b.tile.openstreetmap.org/6/0/20.png',
         'http://a.tile.openstreetmap.org/6/4/13.png',
         'http://a.tile.openstreetmap.org/6/20/28.png',
         'http://b.tile.openstreetmap.org/6/22/22.png',
         'http://c.tile.openstreetmap.org/6/15/28.png']

paths = [urlparse(href).path for href in hrefs]
tiles = [splitext(path)[0].lstrip('/') for path in paths]
values = [map(int, tile.split('/', 2)) for tile in tiles]
rows, cols = zip(*[(y, x) for (z, x, y) in values])

rows_cols = []

for row in range(min(rows), max(rows) + 1):
    for col in range(min(cols), max(cols) + 1):
        rows_cols.append((row, col))

for (index, (row, col)) in enumerate(rows_cols):
    coord = Coordinate(row, col, zoom)
Exemple #7
0
__FILENAME__ = tile - out
from sys import argv
from urlparse import urlparse
from os.path import splitext

from ModestMaps.Core import Coordinate, Point
from ModestMaps.OpenStreetMap import Provider
from TileStache.Geography import SphericalMercator

mercator = SphericalMercator()
zoom, scale = 6, 611.496226
output_dir = argv[1]

hrefs = [
    'http://b.tile.openstreetmap.org/6/0/20.png',
    'http://a.tile.openstreetmap.org/6/4/13.png',
    'http://a.tile.openstreetmap.org/6/20/28.png',
    'http://b.tile.openstreetmap.org/6/22/22.png',
    'http://c.tile.openstreetmap.org/6/15/28.png'
]

paths = [urlparse(href).path for href in hrefs]
tiles = [splitext(path)[0].lstrip('/') for path in paths]
values = [map(int, tile.split('/', 2)) for tile in tiles]
rows, cols = zip(*[(y, x) for (z, x, y) in values])

rows_cols = []

for row in range(min(rows), max(rows) + 1):
    for col in range(min(cols), max(cols) + 1):
        rows_cols.append((row, col))