[GRASS-dev] [GRASS GIS] #326: g.findfile element=colr2

#326: g.findfile element=colr2
--------------------------------+-------------------------------------------
Reporter: martinl | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: default | Version: svn-develbranch6
Keywords: colr2, color table | Platform: All
      Cpu: All |
--------------------------------+-------------------------------------------
Module g.findfile doesn't support 'colr2' element. The attached patch adds
this support. 'colr2' element can be searched only in the current mapset
and file needs to be given as fully qualified, e.g.

{{{
g.findfile element=colr2 file=tm1@PERMANENT
name='tm1@PERMANENT'
mapset='landa'
fullname='tm1@PERMANENT'
file='/home/martin/grassdata/zod/landa/colr2/PERMANENT/tm1'
}}}

Martin

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/326&gt;
GRASS GIS <http://grass.osgeo.org>

#326: g.findfile element=colr2
--------------------------+-------------------------------------------------
  Reporter: martinl | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: svn-develbranch6
Resolution: | Keywords: colr2, color table
  Platform: All | Cpu: All
--------------------------+-------------------------------------------------
Changes (by glynn):

  * type: defect => enhancement

Comment:

Replying to [ticket:326 martinl]:

> Module g.findfile doesn't support 'colr2' element. The attached patch
adds this support. 'colr2' element can be searched only in the current
mapset and file needs to be given as fully qualified, e.g.

The suggested fix is bogus. G!__file_name() does not need and should not
have a hard-coded hack for the colr2 directory.

The correct way to handle colr2 is to first determine the mapset of the
map in question, then specify the "element" parameter as "colr2/<mapset>".
This correctly handles the case where the mapset search path isn't just
the current mapset plus PERMANENT, i.e. it will find a colr2 file for the
map in any mapset in the search path, not just the current mapset.

While an extension to g.findfile might be useful, it isn't strictly
necessary. You can perform the lookup described above using g.findfile:

{{{
$ eval `g.findfile element=cell file=elevation.dem`
$ eval `g.findfile element=colr2/$mapset file=elevation.dem`
$ echo "$file"
/opt/grass-data/spearfish57/glynn/colr2/PERMANENT/elevation.dem
}}}

What would be useful is a misc= option to allow the use of
G_find_file2_misc(), so that you can find cell_misc elements, subgroup
elements, etc.

BTW, why would you be using g.findfile to locate colour tables in the
first place?
You shouldn't normally need to know whether a map gets its colour table
from colr, colr2, or uses the default rainbow table.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/326#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#326: g.findfile element=colr2
--------------------------+-------------------------------------------------
  Reporter: martinl | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: closed
  Priority: major | Milestone: 6.4.0
Component: default | Version: svn-develbranch6
Resolution: invalid | Keywords: colr2, color table
  Platform: All | Cpu: All
--------------------------+-------------------------------------------------
Changes (by martinl):

  * status: new => closed
  * resolution: => invalid

Comment:

Replying to [comment:1 glynn]:
{{{
$ eval `g.findfile element=cell file=elevation.dem`
$ eval `g.findfile element=colr2/$mapset file=elevation.dem`
$ echo "$file"
/opt/grass-data/spearfish57/glynn/colr2/PERMANENT/elevation.dem
}}}

Ops, I have overlooked this possibility... Thanks for pointing it out.

> BTW, why would you be using g.findfile to locate colour tables in the
first place?
> You shouldn't normally need to know whether a map gets its colour table
from colr, colr2, or uses the default rainbow table.

It's used in wxGUI colorrules.py module for "replace current color table"
check.

Martin

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/326#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>