Skip to content

Commit

Permalink
remove rasterio
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed Aug 19, 2021
1 parent 9e63a22 commit eaa0e13
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions morecantile/scripts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import sys

import click
from rasterio.crs import CRS
from rasterio.rio.helpers import coords
from pyproj import CRS

import morecantile

Expand Down Expand Up @@ -78,6 +77,28 @@ def feature_gen():
return feature_gen()


def coords(obj):
"""Yield all coordinate coordinate tuples from a geometry or feature.
From python-geojson package.
Original code from https://github.com/mapbox/rasterio/blob/3910956d6cfadd55ea085dd60790246c167967cd/rasterio/rio/helpers.py
License: Copyright (c) 2013, MapBox
"""
if isinstance(obj, (tuple, list)):
coordinates = obj
elif "geometry" in obj:
coordinates = obj["geometry"]["coordinates"]
else:
coordinates = obj.get("coordinates", obj)
for e in coordinates:
if isinstance(e, (float, int)):
yield tuple(coordinates)
break
else:
for f in coords(e):
yield f


# The CLI command group.
@click.group(help="Command line interface for the Morecantile Python package.")
@click.option("--verbose", "-v", count=True, help="Increase verbosity.")
Expand Down

0 comments on commit eaa0e13

Please sign in to comment.