Skip to content

[Bug] g.region: inconsistent behavior of save option #5625

@petrasovaa

Description

@petrasovaa

Describe the bug

I noticed strange behavior when using save parameter, when you use it together with setting n/s/e/w/raster/vector it will apply the settings to the saved region. But, if you use rows, cols, it won't.

This is expected, n=5 in saved region:

g.region s=0 n=10 w=0 e=10 res=1
g.region n=5  save=test
g.region -pu region=test
north:      5
south:      0
west:       0
east:       10
nsres:      1
ewres:      1
rows:       5
cols:       10

Not expected, rows/cols are still 10 in saved region:

g.region s=0 n=10 w=0 e=10 res=1
g.region rows=5 cols=5 save=test
g.region -pu region=test
north:      10
south:      0
west:       0
east:       10
nsres:      1
ewres:      1
rows:       10
cols:       10

I think this is due to calling G_adjust_Cell_head3 with row_flag=0, col_flag=0 in the g.region code:

    /* save= */
    if ((name = parm.save->answer)) {
        update_file = false;
        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);
    }

This code has been there at least since version 7, but I don't see a reason for this. Any idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions