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

grass.temporal: Do not fail when registering maps with missing range file #2382

Merged
merged 2 commits into from
Sep 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions python/grass/temporal/c_libraries_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,9 +744,11 @@ def _read_raster_info(name, mapset):
libraster.Rast_init_fp_range(byref(range))
ret = libraster.Rast_read_fp_range(name, mapset, byref(range))
if ret < 0:
logging.error(_("Unable to read range file"))
return None
if ret == 2:
logging.warning(_("Unable to read range file"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the values seems fine, but the warning text is technically not correct for ret == 2:
https://grass.osgeo.org/programming7/defs_2raster_8h.html#a9efe2d261c71822b99f546c6d740395c
I know this is fairly minor, but still...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Addressed in faab6c1. Could probably be solved with less code duplication, but I am not sure it is worth doing bigger changes here...

kvp["min"] = None
kvp["max"] = None
elif ret == 2:
logging.warning(_("Raster range file is empty"))
kvp["min"] = None
kvp["max"] = None
else:
Expand All @@ -760,9 +762,11 @@ def _read_raster_info(name, mapset):
libraster.Rast_init_range(byref(range))
ret = libraster.Rast_read_range(name, mapset, byref(range))
if ret < 0:
logging.error(_("Unable to read range file"))
return None
if ret == 2:
logging.warning(_("Unable to read range file"))
kvp["min"] = None
kvp["max"] = None
elif ret == 2:
logging.warning(_("Raster range file is empty"))
kvp["min"] = None
kvp["max"] = None
else:
Expand Down