Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strict option for cogeo validation #109

Merged
merged 3 commits into from Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion rio_cogeo/cogeo.py
Expand Up @@ -280,14 +280,16 @@ def cog_translate(
copy(tmp_dst, dst_path, copy_src_overviews=True, **dst_kwargs)


def cog_validate(src_path):
def cog_validate(src_path, strict=False):
"""
Validate Cloud Optimized Geotiff.

Parameters
----------
src_path : str or PathLike object
A dataset path or URL. Will be opened in "r" mode.
strict: bool
Treat warnings as errors

This script is the rasterio equivalent of
https://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/validate_cloud_optimized_geotiff.py
Expand Down Expand Up @@ -436,4 +438,7 @@ def cog_validate(src_path):

return False

if warnings and strict:
return False

return True
7 changes: 5 additions & 2 deletions rio_cogeo/scripts/cli.py
Expand Up @@ -231,9 +231,12 @@ def create(

@cogeo.command(short_help="Validate COGEO")
@options.file_in_arg
def validate(input):
@click.option(
"--strict", default=False, is_flag=True, help="Treat warnings as errors.",
)
def validate(input, strict):
"""Validate Cloud Optimized Geotiff."""
if cog_validate(input):
if cog_validate(input, strict=strict):
click.echo("{} is a valid cloud optimized GeoTIFF".format(input))
else:
click.echo("{} is NOT a valid cloud optimized GeoTIFF".format(input))