Hi all,
one of my students (Tereza, cc'ed) started to work on simple version
of the data catalog implemented as a new tab in Layer Manager. This
tool will allow to manage maps in the current location (remove, copy,
or rename). Later could be added support for copying maps between
different locations (including automated reprojection), preview of
data and so on.
Currently we are facing to the question whether to use in her code
pyGRASS or just GRASS Python Scripting Library. pyGRASS is not
currently used in wxGUI at all (with only one exception - see
gui_core/gselect.py [1]). There are some wxGUI components which should
be rewritten using pygrass (those which already use ctypes), eg. wxGUI
vector digitizer, but it's another story.
So the question: do we start using pyGRASS in wxGUI more often even in
the code where we don't need ctypes access and calling GRASS commands
through GRASS Python Scripting Library is enough.
The sample code from data catalog (copying maps):
GRASS Python Scripting Library:
cur_mapset = grass.gisenv()['MAPSET']
grass.run_command('g.gisenv', set = 'MAPSET=%s' % dst_mapset)
grass.run_command('g.copy', rast='%s@%s,%s' % (src_map, src_mapset, dst_name))
grass.run_command('g.gisenv', set = 'MAPSET=%s' % cur_mapset)
pyGRASS:
cur_mapset = str(Mapset())
Mapset(dst_mapset).current()
g.copy(rast = '%s@%s,%s' % (src_map, src_mapset, dst_name)) # *
Mapset(cur_mapset).current()
* this could be replaced by something more fancy by modifying pyGRASS
What is you opinion?
Personally I incline to promote pyGRASS as interface for user scripts,
but in wxGUI I still prefer to use GRASS Scripting Library to call
GRASS commands on the background.
Martin
[1] http://trac.osgeo.org/grass/browser/grass/trunk/gui/wxpython/gui_core/gselect.py#L55
--
Martin Landa * http://geo.fsv.cvut.cz/gwiki/Landa