How to use the mercantile.bounding_tile function in mercantile

To help you get started, we’ve selected a few mercantile 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 mapbox / mercantile / tests / test_funcs.py View on Github external
def test_overflow_bounding_tile():
    assert mercantile.bounding_tile(
        -179.99999999999997, -90.00000000000003, 180.00000000000014, -63.27066048950458
    ) == (0, 0, 0)
github mapbox / mercantile / tests / test_funcs.py View on Github external
def test_bounding_tile_pt():
    """A point is a valid input"""
    assert mercantile.bounding_tile(-91.5, 1.0).z == 28
github mapbox / mercantile / tests / test_funcs.py View on Github external
def test_bounding_tile(bounds, tile):
    assert mercantile.bounding_tile(*bounds) == mercantile.Tile(*tile)
github mapbox / mercantile / tests / test_funcs.py View on Github external
def test_bounding_tile_roundtrip(t):
    """bounding_tile(bounds(tile)) gives the tile"""
    val = mercantile.bounding_tile(*mercantile.bounds(t))
    assert val.x == t.x
    assert val.y == t.y
    assert val.z == t.z
github mapbox / mercantile / tests / test_funcs.py View on Github external
def test_bounding_tile_truncate():
    """Input is truncated"""
    assert mercantile.bounding_tile(
        -181.0, 1.0, truncate=True
    ) == mercantile.bounding_tile(-180.0, 1.0)
github mapbox / mercantile / tests / test_funcs.py View on Github external
def test_bounding_tile_truncate():
    """Input is truncated"""
    assert mercantile.bounding_tile(
        -181.0, 1.0, truncate=True
    ) == mercantile.bounding_tile(-180.0, 1.0)
github mojodna / marblecutter / marblecutter / catalogs / remote.py View on Github external
left, bottom, right, top = warp.transform_bounds(
            bounds_crs, WGS84_CRS, *bounds)

        # account for rounding errors when converting between tiles and coords
        left += 0.000001
        bottom += 0.000001
        right -= 0.000001
        top -= 0.000001

        if (self._bounds[0] <= left <= self._bounds[2]
                or self._bounds[0] <= right <= self._bounds[2]) and (
                    self._bounds[1] <= bottom <= self._bounds[3]
                    or self._bounds[1] <= top <= self._bounds[3]) and (
                        self._minzoom <= zoom <= self._maxzoom):
            tile = mercantile.bounding_tile(left, bottom, right, top)

            with requests.get(
                    self.endpoint.format(x=tile.x, y=tile.y, z=tile.z)) as rsp:
                if not rsp:
                    self._log.warn("%s failed: %s", rsp.url, rsp.text)
                    return

                for source in rsp.json():
                    yield Source(**source)
github mapbox / mercantile / mercantile / scripts / __init__.py View on Github external
raise click.BadParameter(
                    "{0}".format(bbox), param=input, param_hint="input"
                )
        elif isinstance(obj, dict):
            if "bbox" in obj:
                bbox = obj["bbox"]
            else:
                box_xs = []
                box_ys = []
                for feat in obj.get("features", [obj]):
                    lngs, lats = zip(*list(coords(feat)))
                    box_xs.extend([min(lngs), max(lngs)])
                    box_ys.extend([min(lats), max(lats)])
                bbox = min(box_xs), min(box_ys), max(box_xs), max(box_ys)
        west, south, east, north = bbox
        vals = mercantile.bounding_tile(west, south, east, north, truncate=False)
        output = json.dumps(vals)
        if seq:
            click.echo(u"\x1e")
        click.echo(output)
github radiantearth / community-sprints / 10252017-boulder-co / extensions / dg_converter.py View on Github external
def thumbnail_url(rec):
    bounds = shape(rec['geometry']).bounds
    tile = mercantile.bounding_tile(*bounds)
    return tms_template_url(rec).format(z=tile.z, x=tile.x, y=tile.y)