How to use the tilecloud.layout.re_.RETileLayout 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 / layout / tilecache.py View on Github external
import re

from tilecloud import TileCoord
from tilecloud.layout.re_ import RETileLayout


class TileCacheDiskLayout(RETileLayout):
    """TileCache disk layout"""

    PATTERN = r"[0-9]{2}(?:/[0-9]{3}){6}"
    RE = re.compile(r"([0-9]{2})/([0-9]{3})/([0-9]{3})/([0-9]{3})/([0-9]{3})/([0-9]{3})/([0-9]{3})")

    def __init__(self):
        RETileLayout.__init__(self, self.PATTERN, self.RE)

    @staticmethod
    def filename(tilecoord, metadata=None):
        zs = "{0:02d}".format(tilecoord.z)
        xs = "{0:09d}".format(tilecoord.x)
        ys = "{0:09d}".format(tilecoord.y)
        return "/".join((zs, xs[0:3], xs[3:6], xs[6:9], ys[0:3], ys[3:6], ys[6:9]))

    @staticmethod
github camptocamp / tilecloud / tilecloud / layout / template.py View on Github external
import re

from tilecloud import TileCoord
from tilecloud.layout.re_ import RETileLayout


class TemplateTileLayout(RETileLayout):
    def __init__(self, template):
        self.template = template
        self.prefix = None
        index, patterns, filename_patterns = 0, [], []
        for match in re.finditer(r"%\(([xyz])\)d", self.template):
            prematch_pattern = re.escape(self.template[index : match.start()])
            if self.prefix is None:
                self.prefix = self.template[index : match.start()]
            patterns.append(prematch_pattern)
            patterns.append(r"\d+")
            filename_patterns.append(prematch_pattern)
            filename_patterns.append(r"(?P<{0!s}>\d+)".format(match.group(1)))
            index = match.end()
        postmatch_pattern = re.escape(self.template[index:])
        patterns.append(postmatch_pattern)
        filename_patterns.append(postmatch_pattern)
github camptocamp / tilecloud / tilecloud / layout / osm.py View on Github external
import re

from tilecloud import TileCoord
from tilecloud.layout.re_ import RETileLayout


class OSMTileLayout(RETileLayout):
    """OpenStreetMap tile layout"""

    PATTERN = r"[0-9]+/[0-9]+/[0-9]+"
    RE = re.compile(r"([0-9]+)/([0-9]+)/([0-9]+)\Z")

    def __init__(self):
        RETileLayout.__init__(self, self.PATTERN, self.RE)

    @staticmethod
    def filename(tilecoord, metadata=None):
        return "{0:d}/{1:d}/{2:d}".format(tilecoord.z, tilecoord.x, tilecoord.y)

    @staticmethod
    def _tilecoord(match):
        return TileCoord(*map(int, match.groups()))
github camptocamp / tilecloud / tilecloud / layout / i3d.py View on Github external
import re

from tilecloud import TileCoord
from tilecloud.layout.re_ import RETileLayout


class I3DTileLayout(RETileLayout):
    """I3D (FHNW/OpenWebGlobe) tile layout"""

    PATTERN = r"(?:[0-3]{2}/)*[0-3]{1,2}"
    RE = re.compile(PATTERN + r"\Z")

    def __init__(self):
        RETileLayout.__init__(self, self.PATTERN, self.RE)

    @staticmethod
    def filename(tilecoord, metadata=None):
        return "/".join(re.findall(r"[0-3]{1,2}", I3DTileLayout.quadcode_from_tilecoord(tilecoord)))

    @staticmethod
    def _tilecoord(match):
        return I3DTileLayout.tilecoord_from_quadcode(re.sub(r"/", "", match.group()))