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

g.region: do not update WIND file when not needed #1627

Merged
merged 3 commits into from
Jun 22, 2021

Conversation

petrasovaa
Copy link
Contributor

Changes default behavior to behave more intuitively, now WIND file is written only with certain
options (e.g. raster=, n=, ...) and it is left untouched if only printing is needed.
Added force flag -o to force writing WIND file if desired.
This change help avoid issues with parallel processing.
Flag -u still makes sense for some cases (also keeps backward compatibility).

Documentation is missing, will add it soon.

For more discussion on this, see:
https://trac.osgeo.org/grass/ticket/2230

Changes default behavior to behave more intuitively, now WIND file is written only with certain
options (e.g. raster=, n=, ...) and it is left untouched if only printing is needed.
Added force flag -o to force writing WIND file if desired.
This change help avoid issues with parallel processing.
Flag -u still makes sense for some cases (also keeps backward compatibility).
@petrasovaa petrasovaa added this to the 8.0.0 milestone Jun 8, 2021
@nilason
Copy link
Contributor

nilason commented Jun 8, 2021

Looks good to me. No need to include stdbool.h though, as long as grass/gis.h is included.

temp_window = window;
G_adjust_Cell_head3(&temp_window, 0, 0, 0);
if (G_put_element_window(&temp_window, "windows", name) < 0)
G_fatal_error(_("Unable to set region <%s>"), name);
}

G_adjust_Cell_head3(&window, row_flag, col_flag, 0);
if (set_flag) {
if (flag.force->answer || (update_file && !flag.noupdate->answer)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not 100% sure I understand the logic here: if any of the conditions that set update_file to true are set and -u is not set, then the file will be updated, whatever the force flag ? Why do we need a force flag then, especially since it is mutually exclusive to noupdate ?

I seem to be misunderstanding something...

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 update_file variable determines the default behavior, so it is true only if options like res=, raster=, etc are used, otherwise it will be false. But there are cases when you want to enforce different behavior. For example you want to only print modified region but not actually update it: g.region res=1 -up
Alternatively, and this would be probably rare, you want to update the region although the new default behavior wouldn't update it, e.g. g.region res=1 -o save=myregion (you want to save the region into a named region and update the current one).

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not 100% sure I understand the logic here: if any of the conditions that set update_file to true are set and -u is not set, then the file will be updated, whatever the force flag ? Why do we need a force flag then, especially since it is mutually exclusive to noupdate ?

I seem to be misunderstanding something...

I think this is correct: with "Force update" flag even a g.region -p -o writes out the file, which g.region -p wouldn't; on the other hand e.g. g.region vector=lakes -u wouldn't make much sense (hence trigger error).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added parser rule to avoid cases you mentioned (g.region vector=lakes -u) because they can make no sense and could be misunderstood.

Copy link
Contributor

@nilason nilason left a comment

Choose a reason for hiding this comment

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

As far as I can tell this is good to go.

@petrasovaa
Copy link
Contributor Author

@mlennert unless you have any objections I plan to merge this in the next couple days...

Copy link
Contributor

@marisn marisn left a comment

Choose a reason for hiding this comment

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

Looks reasonable.

@petrasovaa petrasovaa merged commit 78d902d into OSGeo:master Jun 22, 2021
@petrasovaa petrasovaa deleted the g.region-write branch June 22, 2021 03:02
neteler pushed a commit that referenced this pull request Jun 22, 2021
Changes default behavior to behave more intuitively, now WIND file is written only with certain
options (e.g. raster=, n=, ...) and it is left untouched if only printing is needed.
Added force flag -o to force writing WIND file if desired.
This change help avoid issues with parallel processing.
Flag -u still makes sense for some cases (also keeps backward compatibility).
@neteler
Copy link
Member

neteler commented Jun 30, 2021

@petrasovaa should this be backported to G7.8?

@petrasovaa
Copy link
Contributor Author

No, it changes behavior of g.region, it's for G8.

petrasovaa added a commit that referenced this pull request May 25, 2022
Fix after g.region was broken with #1627 (78d902d). Added test for d flag.
petrasovaa added a commit that referenced this pull request May 26, 2022
Fix after g.region was broken with #1627 (78d902d). Added test for d flag.
petrasovaa added a commit that referenced this pull request May 26, 2022
Fix after g.region was broken with #1627 (78d902d). Added test for d flag.
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Oct 26, 2022
Changes default behavior to behave more intuitively, now WIND file is written only with certain
options (e.g. raster=, n=, ...) and it is left untouched if only printing is needed.
Added force flag -o to force writing WIND file if desired.
This change help avoid issues with parallel processing.
Flag -u still makes sense for some cases (also keeps backward compatibility).
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Oct 26, 2022
Fix after g.region was broken with OSGeo#1627 (78d902d). Added test for d flag.
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
Changes default behavior to behave more intuitively, now WIND file is written only with certain
options (e.g. raster=, n=, ...) and it is left untouched if only printing is needed.
Added force flag -o to force writing WIND file if desired.
This change help avoid issues with parallel processing.
Flag -u still makes sense for some cases (also keeps backward compatibility).
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
Fix after g.region was broken with OSGeo#1627 (78d902d). Added test for d flag.
neteler pushed a commit to nilason/grass that referenced this pull request Nov 7, 2023
Fix after g.region was broken with OSGeo#1627 (78d902d). Added test for d flag.
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.

5 participants