[GRASS-dev] displaying (slightly) broken raster maps in gis.m

Michael Barton Michael.Barton at asu.edu
Sat Jul 8 10:28:41 EDT 2006


Glynn and Hamish,

Checking in. It sounds like it would be good to shift most command stuff to
lists as you suggested earlier.

Most of the raster layer option just uses d.rast. However, if you want to do
a color drape and put something into the drape map field, it switches to
d.his.

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton



> From: Glynn Clements <glynn at gclements.plus.com>
> Date: Sat, 8 Jul 2006 08:49:46 +0100
> To: Michael Barton <Michael.Barton at asu.edu>
> Cc: Hamish <hamish_nospam at yahoo.com>, grass5 <grass-dev at grass.itc.it>
> Subject: Re: [GRASS-dev] displaying (slightly) broken raster maps in gis.m
> 
> 
> Michael Barton wrote:
> 
>>> We noticed gis.m will not display a raster map if the cats/ file is
>>> missing but d.rast will.
>>> 
>>> is this something to fix, or nothing to worry about?
>>> 
>>> (mapset was broken after bulk copy via FAT32 external hard drive problems)
>> 
>> Gis.m is just a wrapper for d.rast. So I'm not sure why one should display a
>> map and the other one won't.
> 
> gis.m/raster.tcl seems to do a bit more than just run d.rast.
> 
> BTW, looking at that code, I note that the failure to treat commands
> as lists appears to be a common problem within gis.m, e.g.:
> 
>     set cmd "d.rast map=$opt($id,1,map)"
> 
>     # overlay
>     if { $opt($id,1,overlay) } {
>         append cmd " -o"
>     }
> 
> [snip]
> 
>     # raster query
>     if { $opt($id,1,rastquery) != "" } {
>         append cmd " {$querytype=$opt($id,1,rastquery)}"
>     }
>     
>     # background color
>     if { $opt($id,1,bkcolor) != "" } {
>         append cmd " bg=$opt($id,1,bkcolor)"
>     }
> 
> Although this particular case should work (certainly, none of the
> arguments can contain spaces, and I don't think that they can contain
> braces), in general you should be using list operations, e.g.:
> 
>     set cmd [list d.rast map=$opt($id,1,map)]
> 
>     # overlay
>     if { $opt($id,1,overlay) } {
>         lappend cmd -o
>     }
> 
> [snip]
> 
>     # raster query
>     if { $opt($id,1,rastquery) != "" } {
>         lappend cmd $querytype=$opt($id,1,rastquery)
>     }
>     
>     # background color
>     if { $opt($id,1,bkcolor) != "" } {
>         lappend cmd bg=$opt($id,1,bkcolor)
>     }
> 
> Etc.
> 
> Whilst it is technically sufficient to use list operations only where
> necessary, that requires you to actually consider whether or not they
> are necessary. As most of the time they aren't necessary, overlooking
> the few cases where they /are/ necessary (e.g. filenames, SQL "WHERE"
> clauses etc) becomes almost inevitable.
> 
> -- 
> Glynn Clements <glynn at gclements.plus.com>





More information about the grass-dev mailing list