Opened 10 years ago

Closed 8 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 8 years ago.
patch to make removal of 'MASK' raster map case insensitive on Windows

Download all attachments as: .zip

Change History (16)

comment:1 by martinl, 10 years ago

Component: DefaultRaster
Keywords: r.mask added

comment:2 by neteler, 10 years ago

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 by baharmon, 10 years ago

Platform: UnspecifiedMSWindows 8

comment:4 by baharmon, 10 years ago

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 by annakrat, 10 years ago

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?

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

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.

in reply to:  6 comment:7 by annakrat, 10 years ago

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 by neteler, 8 years ago

Milestone: 7.1.07.2.0

Milestone renamed

comment:9 by mlennert, 8 years ago

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 by sbl, 8 years ago

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.

by mlennert, 8 years ago

Attachment: rmask_windows.diff added

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

in reply to:  10 comment:11 by mlennert, 8 years ago

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 by annakrat, 8 years ago

I applied the patch in r69607.

in reply to:  12 ; comment:13 by mlennert, 8 years ago

Replying to annakrat:

I applied the patch in r69607.

Thanks. So it works ? ;-)

in reply to:  13 comment:14 by annakrat, 8 years ago

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 by annakrat, 8 years ago

Resolution: fixed
Status: newclosed

Tested and backported in r69778 and r69779.

Note: See TracTickets for help on using tickets.