Details Ticket 1075


Comment | Reply | Take | Open


Serial Number 1075
Subject bug in r.mapcalc
Area bug
Queue grass
Requestors jhofier@unity.ncsu.edu
Owner none
Status resolved
Last User Contact Sat Jun 1 05:54:11 2002 (6 yr ago)
Current Priority 30
Final Priority 70
Due No date assigned
Last Action Sat Jun 1 16:22:27 2002 (6 yr ago)
Created Fri May 31 15:47:14 2002 (6 yr ago)

Transaction History Ticket 1075


Fri, May 31 2002 15:47:14    Request created by guest  
Subject: bug in r.mapcalc

Platform: GNU/Linux/i386
grass obtained from: Trento Italy site
grass binary for platform: Compiled from Sources
GRASS Version: grass50_exp_2002_04_26

Hello,

I have found that r.mapcalc doesn't work properly in a prompt/interactive mode:
GRASS:~ > r.mapcalc
mapcalc> newmap=2 * 3
mapcalc> exit
mapcalc>

GRASS:~ > d.rast newmap
ERROR: Raster map [newmap] not available

Problem #1: "exit" doesn't work, I had to use Ctrl-c
Problem #2: newmap was not created 

Problem #3 (or just a note): in a command mode, r.mapcalc behaves differently
than a few months ago. Now you must have a command without spaces around "="
while in the past this command worked OK:

GRASS:~ > r.mapcalc flow.dx = "flow * cos(aspect)"
r.mapcalc - Raster map layer data calculator

usage: r.mapcalc '<map>=<expression>'

r.mapcalc performs arithmetic on raster map layers.

New raster map layers can be created which are arithmetic expressions
involving existing raster map layers, integer or floating point constants,
and functions.

For more information use 'g.manual r.mapcalc'
---

So now I have to change my scripts, but it is not a big deal...

Best regards,

Jaro Hofierka
Fri, May 31 2002 16:57:20    Mail sent by glynn.clements@virgin.net  
Return-Path <glynn.clements@virgin.net>
Delivered-To grass-bugs@lists.intevation.de
From Glynn Clements <glynn.clements@virgin.net>
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
Message-ID <15607.36575.231140.616135@cerise.nosuchdomain.co.uk>
Date Fri, 31 May 2002 15:55:27 +0100
To Request Tracker <grass-bugs@intevation.de>
Cc grass5@grass.itc.it
Subject Re: [GRASS5] [bug #1075] (grass) bug in r.mapcalc
In-Reply-To <20020531134715.5065613A03@lists.intevation.de>
References <20020531134715.5065613A03@lists.intevation.de>
X-Mailer VM 6.94 under 21.4 (patch 4) "Artificial Intelligence (candidate #1)" XEmacs Lucid
X-Spam-Status No, hits=-4.4 required=5.0 tests=IN_REP_TO version=2.20
X-Spam-Level
Request Tracker wrote:

> I have found that r.mapcalc doesn't work properly in a
> prompt/interactive mode:
> 
> GRASS:~ > r.mapcalc
> mapcalc> newmap=2 * 3
> mapcalc> exit
> mapcalc>
> 
> GRASS:~ > d.rast newmap
> ERROR: Raster map [newmap] not available
> 
> Problem #1: "exit" doesn't work, I had to use Ctrl-c

Ctrl-C sends SIGINT to the foreground process, which kills it. If you
want to generate an end-of-file condition under Unix, type Ctrl-D. 
This will work for r.mapcalc, as does typing a blank line (this is the
method which is documented in the r.mapcalc manpage).

> Problem #2: newmap was not created 

You killed r.mapcalc while it was still reading the expression.

> Problem #3 (or just a note): in a command mode, r.mapcalc behaves
> differently than a few months ago. Now you must have a command
> without spaces around "=" while in the past this command worked OK:
> 
> GRASS:~ > r.mapcalc flow.dx = "flow * cos(aspect)"

I can implement that easily enough.

However, given that you have to quote most of the command (e.g. to
prevent '*' being expanded by the shell), you may as well just quote
the whole thing, i.e.

	r.mapcalc "flow.dx = flow * cos(aspect)"

[Actually, single quotes are preferable.]

-- 
Glynn Clements <glynn.clements@virgin.net>


Fri, May 31 2002 18:05:04    Mail sent by neteler@itc.it  
Return-Path <neteler@itc.it>
Delivered-To grass-bugs@lists.intevation.de
Date Fri, 31 May 2002 18:05:00 +0200
From Markus Neteler <neteler@itc.it>
To Glynn Clements <glynn.clements@virgin.net>
Cc Request Tracker <grass-bugs@intevation.de>, grass5@grass.itc.it
Subject Re: [GRASS5] [bug #1075] (grass) bug in r.mapcalc
Message-ID <20020531180500.B20685@itc.it>
Mail-Followup-To Glynn Clements <glynn.clements@virgin.net>, Request Tracker <grass-bugs@intevation.de>, grass5@grass.itc.it
References <20020531134715.5065613A03@lists.intevation.de> <15607.36575.231140.616135@cerise.nosuchdomain.co.uk>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
User-Agent Mutt/1.2.5.1i
In-Reply-To <15607.36575.231140.616135@cerise.nosuchdomain.co.uk>; from glynn.clements@virgin.net on Fri, May 31, 2002 at 03:55:27PM +0100
X-Spam-Status No, hits=-4.4 required=5.0 tests=IN_REP_TO version=2.20
X-Spam-Level
On Fri, May 31, 2002 at 03:55:27PM +0100, Glynn Clements wrote:
> 
> Request Tracker wrote:
[...]
> > Problem #3 (or just a note): in a command mode, r.mapcalc behaves
> > differently than a few months ago. Now you must have a command
> > without spaces around "=" while in the past this command worked OK:
> > 
> > GRASS:~ > r.mapcalc flow.dx = "flow * cos(aspect)"
> 
> I can implement that easily enough.

Thanks Glynn. This saves us from rewriting lots of scripts and
docs. I just tested:

GRASS:~/cvsgrass_exp > r.mapcalc test="34-43"
test = (sub(34,43))
   3%...
GRASS:~/cvsgrass_exp > r.mapcalc "test=34-43"
test = (sub(34,43))
   3%...

nice.

> However, given that you have to quote most of the command (e.g. to
> prevent '*' being expanded by the shell), you may as well just quote
> the whole thing, i.e.
> 
> 	r.mapcalc "flow.dx = flow * cos(aspect)"

Really? For my bash it works:

r.mapcalc test="34  * 43"
test = (mul(34,43))

> [Actually, single quotes are preferable.]

Markus


Sat, Jun 1 2002 05:54:11    Mail sent by glynn.clements@virgin.net  
Return-Path <glynn.clements@virgin.net>
Delivered-To grass-bugs@lists.intevation.de
From Glynn Clements <glynn.clements@virgin.net>
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
Message-ID <15608.17616.367149.58923@cerise.nosuchdomain.co.uk>
Date Sat, 1 Jun 2002 04:51:44 +0100
To Markus Neteler <neteler@itc.it>
Cc Request Tracker <grass-bugs@intevation.de>, grass5@grass.itc.it
Subject Re: [GRASS5] [bug #1075] (grass) bug in r.mapcalc
In-Reply-To <20020531180500.B20685@itc.it>
References <20020531134715.5065613A03@lists.intevation.de> <15607.36575.231140.616135@cerise.nosuchdomain.co.uk> <20020531180500.B20685@itc.it>
X-Mailer VM 6.94 under 21.4 (patch 4) "Artificial Intelligence (candidate #1)" XEmacs Lucid
X-Spam-Status No, hits=-4.4 required=5.0 tests=IN_REP_TO version=2.20
X-Spam-Level
Markus Neteler wrote:

> > > Problem #3 (or just a note): in a command mode, r.mapcalc behaves
> > > differently than a few months ago. Now you must have a command
> > > without spaces around "=" while in the past this command worked OK:
> > > 
> > > GRASS:~ > r.mapcalc flow.dx = "flow * cos(aspect)"
> > 
> > I can implement that easily enough.
> 
> Thanks Glynn. This saves us from rewriting lots of scripts and
> docs. I just tested:
> 
> GRASS:~/cvsgrass_exp > r.mapcalc test="34-43"
> test = (sub(34,43))
>    3%...
> GRASS:~/cvsgrass_exp > r.mapcalc "test=34-43"
> test = (sub(34,43))
>    3%...
> 
> nice.

Er, that's just shell behaviour; in both cases, r.mapcalc will get a
single argument.

> > However, given that you have to quote most of the command (e.g. to
> > prevent '*' being expanded by the shell), you may as well just quote
> > the whole thing, i.e.
> > 
> > 	r.mapcalc "flow.dx = flow * cos(aspect)"
> 
> Really? For my bash it works:
> 
> r.mapcalc test="34  * 43"
> test = (mul(34,43))

Same here, this is still a single argument.

The issue was regarding unquoted spaces in the command line, e.g.:

	r.mapcalc test = "34 * 34"

In this case, r.mapcalc would get three arguments, i.e.

	argc: 4
	argv[0]: "r.mapcalc"
	argv[1]: "test"
	argv[2]: "="
	argv[3]: "34 * 34"

The fix duplicates the behaviour of the old r.mapcalc which, when
given multiple arguments, concatenates them into a single string, then
parses that string.

-- 
Glynn Clements <glynn.clements@virgin.net>


Sat, Jun 1 2002 16:22:27    Status changed to resolved by gclements  
Comment | Reply | Take | Open

You are currently authenticated as guest.
[Show Configuration] [Login as another user]

Users Guide - Mail Commands - Homepage of RequestTracker 1.0.7 - list any request