[GRASS-dev] G.proj requirements?

Michael Barton michael.barton at asu.edu
Fri Dec 15 11:02:56 EST 2006


Paul,

This is very helpful.

On 12/15/06 3:44 AM, "Paul Kelly" <paul-grass at stjohnspoint.co.uk> wrote:

> I *think* all it should need is a valid GISRC file, i.e. with the 3 fields
> GISDBASE, LOCATION_NAME and MAPSET. The latter two won't be relevant if no
> exising locations are there, so they can contain anything, but GISDBASE is
> important. Look at the code in Init.sh that creates a initial GISRC if
> none is there. So I think it should work if the file contains the 3 lines:
> GISDBASE: C:/grassdata
> LOCATION_NAME: <UNKNOWN>
> MAPSET: <UNKNOWN>

This is what I began to suspect.

> 
> You need to set the GISRC environment variable to point to the location of
> this file; also the GISBASE environment variable needs to point to the
> location of the GRASS installation. I think that should be all you need.
> Note that Init.sh will have created a GISRC file if none exists before
> starting gis_set.tcl (AFAICT) so you should have no trouble here at all
> and not actually need to worry about this. I think.

But given this, I'm wondering now if the .gisrc6 file is the issue at all.

> 
> Just a note that you need to pay attention to what is done by Init.sh and
> what is done by etc/set_data (text) or gis_set.tcl (GUI) and the
> interaction between the two. E.g. where Mariss was talking about failure.
> Failure should be handled in Init.sh I think - the key thing is for
> gis_set.tcl to return a proper return value so Init.sh knows it has
> failed. Of course "recoverable failures" could be handled within
> gis_set.tcl and give the user another chance to create the location.

Following your advice, I looked at what init.sh is doing with the grassrc
file at startup. I still don't understand it completely, but it looks like
it is creating a temporary GISRC file in all cases. If a .grassrc6 file
already exists, this is copied to GISRC in the tmp directory and used. If
not, a temporary GISRC is created. All this happens in init.sh before
gis_set.tcl is called. In the case of a first time user, the current working
directory (PWD in the bash script) is used as a GISDBASE initially. This is
what shows up in the GRASS entry GUI the first time you run it (or if you
run it after deleting your .grassrc6 file).

AFAICT, GRASS uses the GISRC file it creates (normally by copying .grassrc6,
but created by init.sh if needed) for all session reference to the startup
information. 

What I'm not yet sure about is when the GISDBASE environmental variable gets
set. Quite possibly, with the gui startup, this is not until you push the
start grass button, even if you have a valid GISDBASE path in the startup
gui entry widget.

If this is the case, and if this is what g.proj needs to know in order to
create its new location, it is easy to simply set GISDBASE in both the EPSG
and georeferenced file startup scripts.

While I could certainly go through the procedures of making a temporary
GISRC file, init.sh has already done this and the script will overwrite what
is already there. I could also make the fake location, but I think that is
not necessary. I don't want to copy useless code into new modules; there is
enough of that legacy already to deal with.

At a minimum, we simply need to set the GISDBASE variable. At a maximum, we
may also need to create a .grassrc6 file by copying the existing GISRC file
to the home directory. However, I'm not sure how that works in Windows. Is
there anyway to see if g.proj actually reads .grassrc6 or checks for its
existence? An intermediate step might be to replace any temporary GISDBASE
setting in the working session GISRC file with a valid path, but I'm
skeptical since it should already be making one.

I'm not quite sure how I can test this. Maybe if I rename .grassrc6 it will
simulate a new user.

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





More information about the grass-dev mailing list