How to use the tilecloud.Bounds 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 / grid / quad.py View on Github external
def fill_up(z, bounds):
        assert z > 0
        xbounds, ybounds = bounds
        return (
            Bounds(xbounds.start // 2, max(xbounds.stop // 2, 1)),
            Bounds(ybounds.start // 2, max(ybounds.stop // 2, 1)),
        )
github camptocamp / tilecloud / tilecloud / store / geometry.py View on Github external
def list(self):
        bbox = self.geom.bounds
        bounds = {}
        for zoom in range(0, len(self.metatile_configuration.resolutions)):
            x_bounds = Bounds(self.unit_to_metatile(bbox[0], zoom, self.metatile_configuration.max_extent[0]),
                self.unit_to_metatile(bbox[2], zoom, self.metatile_configuration.max_extent[0]) + 1)
            y_bounds = Bounds(self.unit_to_metatile(bbox[1], zoom, self.metatile_configuration.max_extent[1]),
                self.unit_to_metatile(bbox[3], zoom, self.metatile_configuration.max_extent[1]) + 1)
            bounds[zoom] = (x_bounds, y_bounds)

        bounding_pyramid = BoundingPyramid(bounds)
        for tilecoord in bounding_pyramid:
            zoom, meta_x, meta_y = tilecoord.z, tilecoord.x, tilecoord.y
            for x in range(meta_x * self.metatile_configuration.size,
                    meta_x * self.metatile_configuration.size + self.metatile_configuration.size):
                for y in range(meta_y * self.metatile_configuration.size,
                        meta_y * self.metatile_configuration.size + self.metatile_configuration.size):
                    extent = loads_wkt(self.polygon((
                            self.tile_to_unit(x, zoom, self.metatile_configuration.max_extent[0]),
                            self.tile_to_unit(y, zoom, self.metatile_configuration.max_extent[1]),
                            self.tile_to_unit(x + 1, zoom, self.metatile_configuration.max_extent[0]),
                            self.tile_to_unit(y + 1, zoom, self.metatile_configuration.max_extent[1])
                    )))
github camptocamp / tilecloud / tilecloud.py View on Github external
def add(self, tilecoord):
        if tilecoord.z in self.bounds:
            xbounds, ybounds = self.bounds[tilecoord.z]
            xbounds.add(tilecoord.x)
            ybounds.add(tilecoord.y)
        else:
            self.bounds[tilecoord.z] = (Bounds(tilecoord.x), Bounds(tilecoord.y))
github camptocamp / tilecloud / tilecloud.py View on Github external
def union(self, other):
        if self and other:
            return Bounds(min(self.start, other.start), max(self.start, other.start))
        elif self:
            return Bounds(self.start, self.stop)
        elif other:
            return Bounds(other.start, other.stop)
        else:
            return Bounds()
github camptocamp / tilecloud / tilecloud.py View on Github external
def union(self, other):
        if self and other:
            return Bounds(min(self.start, other.start), max(self.start, other.start))
        elif self:
            return Bounds(self.start, self.stop)
        elif other:
            return Bounds(other.start, other.stop)
        else:
            return Bounds()
github camptocamp / tilecloud / tilecloud.py View on Github external
def from_string(cls, s):
        match = re.match(r'(?P\d+)/(?P\d+)/(?P\d+):(?:(?P\d+)/)?(?P\+)?(?P\d+)/(?P\+)?(?P\d+)\Z', s)
        if not match:
            raise RuntimeError # FIXME
        z1 = int(match.group('z1'))
        x1, x2 = int(match.group('x1')), int(match.group('x2'))
        xbounds = Bounds(x1, x1 + x2 if match.group('plusx') else x2)
        y1, y2 = int(match.group('y1')), int(match.group('y2'))
        ybounds = Bounds(y1, y1 + y2 if match.group('plusy') else y2)
        result = cls({z1: (xbounds, ybounds)})
        if match.group('z2'):
            z2 = int(match.group('z2'))
            if z1 < z2:
                result.filldown(z2)
            elif z1 > z2:
                result.fillup(z2)
        return result
github camptocamp / tilecloud / tilecloud / grid / quad.py View on Github external
def fill_down(z, bounds):
        xbounds, ybounds = bounds
        return (Bounds(2 * xbounds.start, 2 * xbounds.stop), Bounds(2 * ybounds.start, 2 * ybounds.stop))
github camptocamp / tilecloud / tilecloud.py View on Github external
def from_string(cls, s):
        match = re.match(r'(?P\d+)/(?P\d+)/(?P\d+):(?:(?P\d+)/)?(?P\+)?(?P\d+)/(?P\+)?(?P\d+)\Z', s)
        if not match:
            raise RuntimeError # FIXME
        z1 = int(match.group('z1'))
        x1, x2 = int(match.group('x1')), int(match.group('x2'))
        xbounds = Bounds(x1, x1 + x2 if match.group('plusx') else x2)
        y1, y2 = int(match.group('y1')), int(match.group('y2'))
        ybounds = Bounds(y1, y1 + y2 if match.group('plusy') else y2)
        result = cls({z1: (xbounds, ybounds)})
        if match.group('z2'):
            z2 = int(match.group('z2'))
            if z1 < z2:
                result.filldown(z2)
            elif z1 > z2:
                result.fillup(z2)
        return result