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

r.geomorphon: separate input from output #1052

Merged
merged 3 commits into from
Nov 17, 2020
Merged

r.geomorphon: separate input from output #1052

merged 3 commits into from
Nov 17, 2020

Conversation

infrastation
Copy link
Contributor

These three commits remove some excess code in a way that should be easy to review. It would be fine to squash these changes together.

@infrastation
Copy link
Contributor Author

One of the checks had timed out after 6 hours.

for (i = 1; i < io_size; ++i) { /* WARNING: loop starts from one, zero is for input */
for (i = o_forms; i < io_size; ++i) { /* WARNING: loop starts from one, zero is for input */
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add a comment that opt_output[0] is unused? The current comment does not necessarily imply that. Perhaps to the definition of opt_output. If my understanding isn't correct, even more reasons comment on this more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comment at the first for loop says that, but not at the subsequent loops. opt_output[0] is accessed outside of the for loops, although to a questionable effect, so the next commit removes the element from the array. Let me push an updated version to see.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, I didn't mean to submit the review yet and meant to delete this comment. The subsequent commit resolved this. I don't know if you needed to update anything.

Comment on lines 114 to 117
opt_input = G_define_standard_option(G_OPT_R_ELEV);
opt_input->key = rasters[0].name;
opt_input->key = "elevation";
opt_input->required = YES;
opt_input->description = _(rasters[0].description);
opt_input->description = _("Name of input elevation raster map");
Copy link
Member

@wenzeslaus wenzeslaus Oct 30, 2020

Choose a reason for hiding this comment

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

You can actually drop key and description here. See https://grass.osgeo.org/grass78/manuals/parser_standard_options.html It is the same.

What you did is much better from GRASS GIS point of view than the previous implementation. (Standardization of interface between modules is more important than something (which looks) smart in one particular module, although that is not to say that the lib is perfect.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. And required is excess as well.

Copy link
Member

Choose a reason for hiding this comment

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

Right, esp. because elevation is the only input, so there is no need to be explicit about elevation being required.

The for loops that iterate over opt_output[] started from hard-coded 1
(o_forms), which is the first output, but not the first element in the
array. Use the enumeration constant to iterate properly regardless of
the amount of any preceding items in the array. Remove a comment that no
longer applies.
All the output rasters were hard-coded as not required regardless of
what was in the array, and the only input raster is a standard option
that is required by default, so just remove the field from the
structure.
The input raster element did not belong to the array because it used
only two structure fields to store string constants that were excess for
a standard option anyway; it also created a place for an off-by-one
error in every loop over the array. Remove the element from the array,
merge the single-use type into the only declaration that needs it and
constify some fields. Rename io_size to o_size, remove i_dem, UNKNOWN
and a stale comment.
@infrastation
Copy link
Contributor Author

Thank you for the review. Here is a new revision, which should address the points you have raised.

Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

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

Shorter and simpler code. What else to ask for?

I guess the removal of typedef for IO rasters is a matter of taste. It makes sense to me here. It might be less readable for people coming from Python, but that's hard to guess.

@infrastation
Copy link
Contributor Author

It would be great to have this merged so I can rebase and open the next pull request with the remaining code cleanups.

@neteler
Copy link
Member

neteler commented Nov 17, 2020

I take liberty to merge it

@neteler neteler merged commit fd0ea53 into OSGeo:master Nov 17, 2020
@neteler neteler added this to the 8.0.0/7.10 milestone Nov 17, 2020
@infrastation infrastation deleted the geomorphon_io_cleanups branch November 17, 2020 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants