[GRASS-dev] Access to mapset environment variable

Sören Gebbert soerengebbert at googlemail.com
Wed Sep 3 11:51:01 PDT 2014


Dear all,
I am struggling to access GRASS mapset specific environmental
variables from mapsets different than the current one in C.

I tried the following code to access temporal database settings of
other mapsets:

{{{
    G_create_alt_env();
    G__setenv("GISDBASE", gisdbase_name);
    G__setenv("LOCATION_NAME", location_name);
    G__setenv("MAPSET", mapset);

    if(contype == DATABASE_NAME) {
        if ((val = G__getenv2("TGISDB_DATABASE", G_VAR_MAPSET)))
            ret_val = G_store(val);
    } else if(contype == DRIVER_NAME) {
        if ((val = G__getenv2("TGISDB_DRIVER", G_VAR_MAPSET)))
            ret_val = G_store(val);
    }
    G_switch_env();

}}}

But it does not work, the specified TGIS driver and database strings
are not found.

Without switching the environment only the TGIS variables of the
current mapset are read, not from the ones from a mapset set with
G_setenv("MAPSET", mapset).

Is there a possibility to access mapset specific environmental
variables in C from a different mapset as the current one?


Any help is really appreciated,
best regards
Soeren


More information about the grass-dev mailing list