[GRASS-dev] What is considered as valid location and valid mapset

Glynn Clements glynn at gclements.plus.com
Thu Sep 15 17:31:17 PDT 2016


Vaclav Petras wrote:

> I wonder what is a valid location and what is a valid mapset. The
> lib/init/grass.py file says:
> 
> def is_mapset_valid(full_mapset):
>     return os.access(os.path.join(full_mapset, "WIND"), os.R_OK)
> 
> def is_location_valid(gisdbase, location):
>     return os.access(os.path.join(gisdbase, location, "PERMANENT",
> "DEFAULT_WIND"), os.F_OK)
> 
> This is what I've done based on the code which was there before
> refactoring. I wonder if it is correct. If I need to switch to a mapset, I
> want the region to be editable, so I need os.W_OK in that case.

Valid for use as a source of maps and valid for use as the current
mapset are different things.

For use as the current mapset, the entire directory hierarchy should
be owned by the current user.

G_mapset_permissions() requires that the mapset directory is owned by
the current user unless you're on Windows or libgis was built with
SKIP_MAPSET_OWN_CHK defined and the environment variable
GRASS_SKIP_MAPSET_OWNER_CHECK is set to a non-empty string.

Group-writable mapsets are asking for trouble (it's quite likely that
users will end up creating maps which the mapset's owner can't
remove).

> On the other hand, is WIND file needed? Isn't it created
> automatically from DEFAULT_WIND?

No. It's created from DEFAULT_WIND by "g.region -d" and functions or
modules which create a new mapset. Most modules will fail if WIND
doesn't exist (assuming that neither GRASS_REGION nor WIND_OVERRIDE
are set).

> And further, is DEFAULT_WIND the right requirement for a valid PERMANENT
> mapset? Are some PROJ_* files needed?

Ideally, neither DEFAULT_WIND nor PROJ_INFO should be required until
you do something that actually uses them. The check is just a
heuristic; a directory containing a PERMANENT/DEFAULT_WIND file is
probably a GRASS location, while a directory lacking it probably
isn't. I'm not sure whether X-Y locations would even have a PROJ_INFO
file.

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


More information about the grass-dev mailing list