Opened 5 years ago

Closed 3 years ago

#2445 closed defect (fixed)

r.mask -r removal not working in GRASS 7.1 svn r.62210

Reported by: baharmon Owned by: grass-dev@…
Priority: normal Milestone: 7.2.0
Component: Raster Version: svn-trunk
Keywords: r.mask Cc:
CPU: Unspecified Platform: MSWindows 8

Description

r.mask -r doesn't seem to work.

Attachments (1)

rmask_windows.diff (851 bytes) - added by mlennert 3 years ago.
patch to make removal of 'MASK' raster map case insensitive on Windows

Download all attachments as: .zip

Change History (16)

comment:1 Changed 5 years ago by martinl

Component: DefaultRaster
Keywords: r.mask added

comment:2 Changed 5 years ago by neteler

I check on Linux, no problem:

GRASS 7.1.svn (nc_spm_08_grass7):~ > r.mask zipcodes 
All subsequent raster operations will be limited to the MASK area. Removing
or renaming raster map named 'MASK' will restore raster operations to
normal.
[Raster MASK present]

GRASS 7.1.svn (nc_spm_08_grass7):~ > r.mask -r
Raster MASK removed

GRASS 7.1.svn (nc_spm_08_grass7):~ > g.version -g
version=7.1.svn
date=2014
revision=62126M
build_date=2014-09-28
build_platform=x86_64-unknown-linux-gnu

Which operating system are you using? And: what is the error?

comment:3 Changed 5 years ago by baharmon

Platform: UnspecifiedMSWindows 8

comment:4 Changed 5 years ago by baharmon

I'm using Windows 8.1. There was no error message.

r.mask -r Raster MASK removed (Thu Oct 09 17:34:34 2014) Command finished (0 sec)

The map display however still shows the mask and the there is the red 'MASK' tag in the lower right corner of the display. After re-rendering there is still the mask.

comment:5 Changed 5 years ago by annakrat

It's because the mask was created from raster map 'mask' (lowercase). So on Windows, there is I guess no way how to distinguish it. Wontfix? Should we put it in r.mask manual?

comment:6 in reply to:  5 ; Changed 5 years ago by glynn

Replying to annakrat:

Wontfix?

No. If a map is recognised as a mask by Rast__check_for_auto_masking(), then r.mask -r should remove it.

On Windows, remove("MASK") will remove a file named "MASK", "mask", "Mask", "MaSK" or any other variation (you can't have more than one of those in any given directory).

Does g.remove type=rast pattern=MASK remove the file? If not, that's a bug in g.remove. Indeed, this appears to be the problem.

Looking at source:grass/trunk/lib/gis/ls_filter.c#L151, regcomp() should probably be using REG_ICASE on Windows (and also on Unix if GISDBASE is on a case-insensitive filesystem, but that's easier said than done).

IOW, this bug is a consequence of replacing g.remove with g.mremove; the former doesn't care about case, the latter does.

comment:7 in reply to:  6 Changed 5 years ago by annakrat

Replying to glynn:

Replying to annakrat:

Wontfix?

No. If a map is recognised as a mask by Rast__check_for_auto_masking(), then r.mask -r should remove it.

On Windows, remove("MASK") will remove a file named "MASK", "mask", "Mask", "MaSK" or any other variation (you can't have more than one of those in any given directory).

Does g.remove type=rast pattern=MASK remove the file? If not, that's a bug in g.remove. Indeed, this appears to be the problem.

I haven't tested specifically this command but r.mask is using it for removing the mask.

comment:8 Changed 4 years ago by neteler

Milestone: 7.1.07.2.0

Milestone renamed

comment:9 Changed 3 years ago by mlennert

Could anyone test this on Windows, i.e. create a raster file named mask (lowercase) and then attempt 'g.remove type=rast pattern=MASK -f' and 'g.remove -i type=rast pattern=MASK' ?

And if the first doesn't work, but the second does could the following lines in r.mask:

            grass.run_command('g.remove', flags='f', quiet=True,
                              type='raster', name='MASK')

be replaced by

            grass.run_command('g.remove', flags='fi', quiet=True,
                              type='raster', name='MASK')

if we are in Windows ?

comment:10 Changed 3 years ago by sbl

Confirmed on Win7.

g.remove type=rast pattern=MASK -f does not remove a map "mask" on Windows, while g.remove -fi type=rast pattern=MASK does.

Changed 3 years ago by mlennert

Attachment: rmask_windows.diff added

patch to make removal of 'MASK' raster map case insensitive on Windows

comment:11 in reply to:  10 Changed 3 years ago by mlennert

Replying to sbl:

Confirmed on Win7.

g.remove type=rast pattern=MASK -f does not remove a map "mask" on Windows, while g.remove -fi type=rast pattern=MASK does.

Ok. I've attached a patch that AFAICT should check for Windows and then make the g.remove call case insensitive.

Please test.

Moritz

comment:12 Changed 3 years ago by annakrat

I applied the patch in r69607.

comment:13 in reply to:  12 ; Changed 3 years ago by mlennert

Replying to annakrat:

I applied the patch in r69607.

Thanks. So it works ? ;-)

comment:14 in reply to:  13 Changed 3 years ago by annakrat

Replying to mlennert:

Replying to annakrat:

I applied the patch in r69607.

Thanks. So it works ? ;-)

On Linux yes, I haven't tried yet on Windows. But I don't see why it wouldn't.

comment:15 Changed 3 years ago by annakrat

Resolution: fixed
Status: newclosed

Tested and backported in r69778 and r69779.

Note: See TracTickets for help on using tickets.