How to use the svgis.utils.modfloor function in svgis

To help you get started, we’ve selected a few svgis 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 fitnr / svgis / tests / test_utils.py View on Github external
def test_modfloor(self):
        assert utils.modfloor(10, 3) == 9
        assert utils.modfloor(17, 4) == 16
github fitnr / svgis / tests / test_utils.py View on Github external
def test_modfloor(self):
        assert utils.modfloor(10, 3) == 9
        assert utils.modfloor(17, 4) == 16
github fitnr / svgis / svgis / graticule.py View on Github external
if crs_or_method == 'file':
        raise ValueError("'file' is not a valid option for projecting graticules.")

    if crs_or_method:
        out_crs = projection.pick(crs_or_method, bounds=bounds, file_crs=utils.DEFAULT_GEOID)

        bounds = bounding.transform(utils.DEFAULT_GEOID, out_crs, bounds)
        unproject = partial(fiona.transform.transform, out_crs, utils.DEFAULT_GEOID)

    else:
        def unproject(x, y):
            return x, y

    minx, miny, maxx, maxy = bounds

    minx, miny = utils.modfloor(minx, step), utils.modfloor(miny, step)
    maxx, maxy = utils.modceil(maxx, step), utils.modceil(maxy, step)

    frange = partial(utils.frange, cover=True)

    for i, X in enumerate(frange(minx, maxx + step, step), 1):
        coords = unproject(*list(zip(*[(X, y) for y in frange(miny, maxy + step, step / 2.)])))
        yield _feature(i, tuple(zip(*coords)), axis='x', coord=X)

    for i, Y in enumerate(frange(miny, maxy + step, step), i + 1):
        coords = unproject(*list(zip(*[(x, Y) for x in frange(minx, maxx + step, step / 2.)])))
        yield _feature(i, tuple(zip(*coords)), axis='y', coord=Y)