[GRASS-dev] Access to mapset environment variable

Glynn Clements glynn at gclements.plus.com
Thu Sep 4 14:04:55 PDT 2014


Sören Gebbert wrote:

> > > I am struggling to access GRASS mapset specific environmental
> > > variables from mapsets different than the current one in C.
> > ...
> > > Is there a possibility to access mapset specific environmental
> > > variables in C from a different mapset as the current one?
> >
> > Hi,
> >
> > I would suggest to use the mapsets' VAR file, not gisrc (g.gisenv),
> > to store per-mapset variables like that. Since gisrc is per-session
> > and ephemeral, not per-mapset and remembered after the session is
> > closed.
> 
> Actually that is exactly what i am trying to do. So my question is how to
> convince grass to read the VAR file from a mapset other than the current
> one without invoking g.mapset.

Currently, you can't. G__gisinit() calls G_init_env() which reads both
environment files into memory. The functions which read these files
will not attempt to read them again if they're already in memory.

You would need to modify lib/gis/env.c to allow the "VAR" environment
to be forcibly re-read (and without first re-reading the "gisrc"
environment, as that will restore the original current mapset).

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list