How to use the tilecloud.TileCoord 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.py View on Github external
def fillup(self, top=0):
        for z in xrange(max(self.bounds), top, -1):
            xbounds, ybounds = self.bounds[z]
            self.add(TileCoord(z - 1, xbounds.start // 2, ybounds.start // 2))
            self.add(TileCoord(z - 1, xbounds.stop // 2, ybounds.stop // 2))
github camptocamp / tilecloud-chain / tilecloud_chain / generate.py View on Github external
if self._options.role in ('local', 'master') and 'logging' in self._gene.config:
            self._gene.imap(DatabaseLoggerInit(
                self._gene.config['logging'],
                self._options is not None and self._options.daemon,
            ))

        if self._options.local_process_number is not None:  # pragma: no cover
            self._gene.add_local_process_filter()

        elif self._options.role == 'hash':
            try:
                z, x, y = (int(v) for v in self._options.get_hash.split('/'))
                if layer.get('meta'):
                    self._gene.set_tilecoords([TileCoord(z, x, y, layer['meta_size'])], layer)
                else:
                    self._gene.set_tilecoords([TileCoord(z, x, y)], layer)
            except ValueError as e:  # pragma: no cover
                exit(
                    "Tile '{}' is not in the format 'z/x/y'\n{}".format(
                        self._options.get_hash, repr(e))
                )

        # At this stage, the tilestream contains metatiles that intersect geometry
        self._gene.add_logger()

        self._count_metatiles = self._gene.counter()

        if self._options.role == 'master':  # pragma: no cover
            # Put the metatiles into the SQS or Redis queue
            self._gene.put(self._queue_tilestore)
            self._count_tiles = self._gene.counter()
github camptocamp / tilecloud / tilecloud.py View on Github external
def ziter(self, z):
        if z in self.bounds:
            xbounds, ybounds = self.bounds[z]
            for x in xbounds:
                for y in ybounds:
                    yield TileCoord(z, x, y)
github camptocamp / tilecloud-chain / tilecloud_chain / server.py View on Github external
return self.error(400, "Wrong Layer '{}'".format(params['LAYER']), **kwargs)

            for dimension in layer['dimensions']:
                value = params[dimension['name'].upper()] \
                    if dimension['name'].upper() in params \
                    else dimension['default']
                dimensions.append(value)
                metadata["dimension_" + dimension['name']] = value

        if params['STYLE'] != layer['wmts_style']:
            return self.error(400, "Wrong Style '{}'".format(params['STYLE']), **kwargs)
        if params['TILEMATRIXSET'] != layer['grid']:
            return self.error(400, "Wrong TileMatrixSet '{}'".format(params['TILEMATRIXSET']), **kwargs)

        metadata['layer'] = layer['name']
        tile = Tile(TileCoord(
            # TODO fix for matrix_identifier = resolution
            int(params['TILEMATRIX']),
            int(params['TILECOL']),
            int(params['TILEROW']),
        ), metadata=metadata)

        if params['REQUEST'] == 'GetFeatureInfo':
            if \
                    'I' not in params or \
                    'J' not in params or \
                    'INFO_FORMAT' not in params:  # pragma: no cover
                return self.error(400, "Not all required parameters are present", **kwargs)
            if 'query_layers' in layer:
                return self.forward(
                    layer['url'] + '?' + urlencode({
                        'SERVICE': 'WMS',
github camptocamp / tilecloud / tilecloud / layout / i3d.py View on Github external
def tilecoord_from_quadcode(quadcode):
        z, x, y = len(quadcode), 0, 0
        for i, c in enumerate(quadcode):
            mask = 1 << (z - i - 1)
            if c in ["1", "3"]:
                x |= mask
            if c in ["2", "3"]:
                y |= mask
        return TileCoord(z, x, y)
github camptocamp / tilecloud / tilecloud / layout / template.py View on Github external
def _tilecoord(match):
        return TileCoord(*(int(match.group(s)) for s in "zxy"))
github camptocamp / tilecloud / tilecloud / store / mbtiles.py View on Github external
def _unpackitem(self, row):
        z, x, y, data = row
        y = y if self.tilecoord_in_topleft else (1 << z) - y - 1
        return (TileCoord(z, x, y), data)
github camptocamp / tilecloud / tilecloud / grid / quad.py View on Github external
def children(self, tilecoord):
        if self.max_zoom is None or tilecoord.z < self.max_zoom:
            yield TileCoord(tilecoord.z + 1, 2 * tilecoord.x, 2 * tilecoord.y)
            yield TileCoord(tilecoord.z + 1, 2 * tilecoord.x + 1, 2 * tilecoord.y)
            yield TileCoord(tilecoord.z + 1, 2 * tilecoord.x, 2 * tilecoord.y + 1)
            yield TileCoord(tilecoord.z + 1, 2 * tilecoord.x + 1, 2 * tilecoord.y + 1)