def _check_cog(filename): import validate_cloud_optimized_geotiff try: _, errors, _ = validate_cloud_optimized_geotiff.validate(filename, full_check=True) assert not errors, 'validate_cloud_optimized_geotiff failed' except OSError: pytest.fail('validate_cloud_optimized_geotiff failed')
def _check_cog(filename): path = '../../gdal/swig/python/samples' if path not in sys.path: sys.path.append(path) import validate_cloud_optimized_geotiff try: _, errors, _ = validate_cloud_optimized_geotiff.validate(filename, full_check=True) assert not errors, 'validate_cloud_optimized_geotiff failed' except OSError: pytest.fail('validate_cloud_optimized_geotiff failed')
} remove_tmpfile = True f = open(tmpfilename, 'wb') f.write(r.content) f.close() ds = gdal.OpenEx(tmpfilename, allowed_drivers=['GTiff']) if ds is None: return json.dumps({ 'status': 'failure', 'error': '%s is not a GTiff file' % url }), 400, { "Content-Type": "application/json" } errors, details = validate_cloud_optimized_geotiff.validate(ds) info = gdal.Info(ds, format='json') if 'local_filename' in args or remove_tmpfile: del info['files'] info['description'] = url ds = None if remove_tmpfile: os.unlink(tmpfilename) if len(errors) == 0: return json.dumps({ 'status': 'success', 'gdal_info': info, 'details': details }), 200, { "Content-Type": "application/json"