How to use the tilecloud.layout.template.TemplateTileLayout function in tilecloud

To help you get started, we’ve selected a few tilecloud examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github camptocamp / tilecloud / tilecloud / __init__.py View on Github external
return NullTileStore()
        if name.startswith("bounds://"):
            from tilecloud.store.boundingpyramid import BoundingPyramidTileStore

            return BoundingPyramidTileStore(BoundingPyramid.from_string(name[9:]))
        if name.startswith("file://"):
            from tilecloud.layout.template import TemplateTileLayout
            from tilecloud.store.filesystem import FilesystemTileStore

            return FilesystemTileStore(TemplateTileLayout(name[7:]),)
        if name.startswith("http://") or name.startswith("https://"):
            from tilecloud.layout.template import TemplateTileLayout
            from tilecloud.store.url import URLTileStore

            return URLTileStore((TemplateTileLayout(name),))
        if name.startswith("memcached://"):
            from tilecloud.layout.template import TemplateTileLayout
            from tilecloud.store.memcached import MemcachedTileStore
            from tilecloud.lib.memcached import MemcachedClient

            server, template = name[12:].split("/", 1)
            host, port = server.split(":", 1)
            client = MemcachedClient(host, int(port))
            return MemcachedTileStore(client, TemplateTileLayout(template))
        if name.startswith("s3://"):
            from tilecloud.layout.template import TemplateTileLayout
            from tilecloud.store.s3 import S3TileStore

            bucket, template = name[5:].split("/", 1)
            return S3TileStore(bucket, TemplateTileLayout(template))
        if name.startswith("sqs://"):
github camptocamp / tilecloud / tilecloud / __init__.py View on Github external
"""
        if name == "null://":
            from tilecloud.store.null import NullTileStore

            return NullTileStore()
        if name.startswith("bounds://"):
            from tilecloud.store.boundingpyramid import BoundingPyramidTileStore

            return BoundingPyramidTileStore(BoundingPyramid.from_string(name[9:]))
        if name.startswith("file://"):
            from tilecloud.layout.template import TemplateTileLayout
            from tilecloud.store.filesystem import FilesystemTileStore

            return FilesystemTileStore(TemplateTileLayout(name[7:]),)
        if name.startswith("http://") or name.startswith("https://"):
            from tilecloud.layout.template import TemplateTileLayout
            from tilecloud.store.url import URLTileStore

            return URLTileStore((TemplateTileLayout(name),))
        if name.startswith("memcached://"):
            from tilecloud.layout.template import TemplateTileLayout
            from tilecloud.store.memcached import MemcachedTileStore
            from tilecloud.lib.memcached import MemcachedClient

            server, template = name[12:].split("/", 1)
            host, port = server.split(":", 1)
            client = MemcachedClient(host, int(port))
            return MemcachedTileStore(client, TemplateTileLayout(template))
        if name.startswith("s3://"):
            from tilecloud.layout.template import TemplateTileLayout
github camptocamp / tilecloud / tilecloud / __init__.py View on Github external
return URLTileStore((TemplateTileLayout(name),))
        if name.startswith("memcached://"):
            from tilecloud.layout.template import TemplateTileLayout
            from tilecloud.store.memcached import MemcachedTileStore
            from tilecloud.lib.memcached import MemcachedClient

            server, template = name[12:].split("/", 1)
            host, port = server.split(":", 1)
            client = MemcachedClient(host, int(port))
            return MemcachedTileStore(client, TemplateTileLayout(template))
        if name.startswith("s3://"):
            from tilecloud.layout.template import TemplateTileLayout
            from tilecloud.store.s3 import S3TileStore

            bucket, template = name[5:].split("/", 1)
            return S3TileStore(bucket, TemplateTileLayout(template))
        if name.startswith("sqs://"):
            from tilecloud.store.sqs import SQSTileStore
            import boto.sqs  # pylint: disable=import-error
            from boto.sqs.jsonmessage import JSONMessage  # pylint: disable=import-error

            region_name, queue_name = name[6:].split("/", 1)
            connection = boto.sqs.connect_to_region(region_name)
            queue = connection.create_queue(queue_name)
            queue.set_message_class(JSONMessage)
            return SQSTileStore(queue)
        if name.startswith("redis://"):
            from tilecloud.store.redis import RedisTileStore

            return RedisTileStore(name)
        _, ext = os.path.splitext(name)
        if ext == ".bsddb":
github camptocamp / tilecloud / tilecloud / __init__.py View on Github external
return FilesystemTileStore(TemplateTileLayout(name[7:]),)
        if name.startswith("http://") or name.startswith("https://"):
            from tilecloud.layout.template import TemplateTileLayout
            from tilecloud.store.url import URLTileStore

            return URLTileStore((TemplateTileLayout(name),))
        if name.startswith("memcached://"):
            from tilecloud.layout.template import TemplateTileLayout
            from tilecloud.store.memcached import MemcachedTileStore
            from tilecloud.lib.memcached import MemcachedClient

            server, template = name[12:].split("/", 1)
            host, port = server.split(":", 1)
            client = MemcachedClient(host, int(port))
            return MemcachedTileStore(client, TemplateTileLayout(template))
        if name.startswith("s3://"):
            from tilecloud.layout.template import TemplateTileLayout
            from tilecloud.store.s3 import S3TileStore

            bucket, template = name[5:].split("/", 1)
            return S3TileStore(bucket, TemplateTileLayout(template))
        if name.startswith("sqs://"):
            from tilecloud.store.sqs import SQSTileStore
            import boto.sqs  # pylint: disable=import-error
            from boto.sqs.jsonmessage import JSONMessage  # pylint: disable=import-error

            region_name, queue_name = name[6:].split("/", 1)
            connection = boto.sqs.connect_to_region(region_name)
            queue = connection.create_queue(queue_name)
            queue.set_message_class(JSONMessage)
            return SQSTileStore(queue)
github camptocamp / tilecloud / tiles / stamen_com / watercolor.py View on Github external
from tilecloud.layout.template import TemplateTileLayout
from tilecloud.store.url import URLTileStore


tilestore = URLTileStore(
    (
        TemplateTileLayout("http://{0!s}.tile.stamen.com/watercolor/%(z)d/%(x)d/%(y)d.jpg".format(server))
        for server in "abcd"
    ),
    attribution='Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>.',
    content_type="image/jpg",
)
github camptocamp / tilecloud / tiles / stamen_com / toner.py View on Github external
from tilecloud.layout.template import TemplateTileLayout
from tilecloud.store.url import URLTileStore


tilestore = URLTileStore(
    (
        TemplateTileLayout("http://{0!s}.tile.stamen.com/toner/%(z)d/%(x)d/%(y)d.png".format(server))
        for server in "abcd"
    ),
    attribution='Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>.',
    content_type="image/png",
)
github camptocamp / tilecloud / tilecloud / store / tilejson.py View on Github external
if "bounding_pyramid" not in kwargs:
            zmin, zmax = d.get("minzoom", 0), d.get("maxzoom", 22)
            if "bounds" in d:
                lonmin, latmin, lonmax, latmax = d["bounds"]
                bounding_pyramid = BoundingPyramid.from_wgs84(zmin, zmax, lonmin, lonmax, latmin, latmax)
            else:
                bounding_pyramid = BoundingPyramid.full(zmin, zmax)
            kwargs["bounding_pyramid"] = bounding_pyramid
        urls = d[urls_key]
        if "content_type" not in kwargs:
            exts = set(os.path.splitext(urlparse(url1).path)[1] for url1 in urls)
            content_types = set(mimetypes.types_map.get(ext) for ext in exts)
            assert len(content_types) == 1
            kwargs["content_type"] = content_types.pop()
        templates = [re.sub(r"\{([xyz])\}", lambda m: "%({0!s})d".format(m.group(1)), url2) for url2 in urls]
        tilelayouts = map(TemplateTileLayout, templates)
        URLTileStore.__init__(self, tilelayouts, **kwargs)
github camptocamp / tilecloud / tiles / openstreetmap_org.py View on Github external
from tilecloud.layout.template import TemplateTileLayout
from tilecloud.store.url import URLTileStore


tilestore = URLTileStore(
    (
        TemplateTileLayout("http://{0!s}.tile.openstreetmap.org/%(z)d/%(x)d/%(y)d.png".format(server))
        for server in "abc"
    ),
    attribution="&copy; OpenStreetMap contributors, CC-BY-SA",
    content_type="image/png",
)
github camptocamp / tilecloud / tiles / mapquest_com.py View on Github external
from tilecloud.layout.template import TemplateTileLayout
from tilecloud.store.url import URLTileStore


tilestore = URLTileStore(
    (
        TemplateTileLayout("http://otile{0:d}.mqcdn.com/tiles/1.0.0/osm/%(z)d/%(x)d/%(y)d.png".format(i))
        for i in range(1, 5)
    ),
    attribution='Data, imagery and map information provided by MapQuest, <a href="http://www.openstreetmap.org/">Open Street Map</a> and contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>.',
    content_type="image/png",
)
github camptocamp / tilecloud / tiles / stamen_com / terrain.py View on Github external
from tilecloud.layout.template import TemplateTileLayout
from tilecloud.store.url import URLTileStore


tilestore = URLTileStore(
    (
        TemplateTileLayout("http://{0!s}.tile.stamen.com/terrain/%(z)d/%(x)d/%(y)d.jpg".format(server))
        for server in "abcd"
    ),
    attribution='Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>.',
    content_type="image/jpg",
)