[GRASS5] maps with identical name in different mapsets

Hi,

today we discovered that it is possible to generate a map (raster
map) with r.proj under a certain name even if this name is already
in use in another mapset. There is no test telling that the
map name is used.

I see a potential problem here: Which map is taken when displaying
it or doing calculations? First in the current mapset, then from
another (and which order, alphabetically?).

Eventually we should add a test to a GRASS library function to
check for existing names in current mapset search path to avoid
this problem. It is at least implemented in g.copy:
src/general/manage/cmd/copy.c

Maybe I am missing something, but we cannot be sure which map
is picked up when a map name exists several times (at least it
is not obvious to the user).

Markus

Markus Neteler wrote:

today we discovered that it is possible to generate a map (raster
map) with r.proj under a certain name even if this name is already
in use in another mapset. There is no test telling that the
map name is used.

I see a potential problem here: Which map is taken when displaying
it or doing calculations? First in the current mapset, then from
another (and which order, alphabetically?).

The default behaviour is the current mapset followed by PERMANENT.

And you should only get the default behaviour unless you explicitly
change it with g.mapsets (in which case, you are presumably aware of
the concept of a mapset search path).

Eventually we should add a test to a GRASS library function to
check for existing names in current mapset search path to avoid
this problem. It is at least implemented in g.copy:
src/general/manage/cmd/copy.c

Personally, I don't see it as a problem. In the same way that I don't
see any problem with lots of directories all containing files called
"README" or "Makefile".

Actually, I think that it's preferable to define the set of allowable
map names in absolute terms, without any kind of "... unless it
already exists in some other mapset" exclusion.

Also, if a map names were meant to be unique within a location (rather
than just within a single mapset), what's the point of the
"map@mapset" syntax?

Maybe I am missing something, but we cannot be sure which map
is picked up when a map name exists several times (at least it
is not obvious to the user).

Well, it should also be explained right at the very beginning of any
user guide or tutorial. And if a user can't grasp this concept, I'm
not sure that they are going be able to grasp the other concepts
involved.

--
Glynn Clements <glynn.clements@virgin.net>

On Wed, Mar 13, 2002 at 10:59:41AM +0000, Glynn Clements wrote:

Markus Neteler wrote:

> today we discovered that it is possible to generate a map (raster
> map) with r.proj under a certain name even if this name is already
> in use in another mapset. There is no test telling that the
> map name is used.
>
> I see a potential problem here: Which map is taken when displaying
> it or doing calculations? First in the current mapset, then from
> another (and which order, alphabetically?).

The default behaviour is the current mapset followed by PERMANENT.

And you should only get the default behaviour unless you explicitly
change it with g.mapsets (in which case, you are presumably aware of
the concept of a mapset search path).

yes, I am using that concept daily.

> Eventually we should add a test to a GRASS library function to
> check for existing names in current mapset search path to avoid
> this problem. It is at least implemented in g.copy:
> src/general/manage/cmd/copy.c

Personally, I don't see it as a problem. In the same way that I don't
see any problem with lots of directories all containing files called
"README" or "Makefile".

This is a bit different. In your example you are actively changing into
a directory. So one knows what he/she is doing.
With a mapset search path GRASS is searching the mapsets which is
not printed every time.

Actually, I think that it's preferable to define the set of allowable
map names in absolute terms, without any kind of "... unless it
already exists in some other mapset" exclusion.

Also, if a map names were meant to be unique within a location (rather
than just within a single mapset), what's the point of the
"map@mapset" syntax?

That's right.

> Maybe I am missing something, but we cannot be sure which map
> is picked up when a map name exists several times (at least it
> is not obvious to the user).

Well, it should also be explained right at the very beginning of any
user guide or tutorial. And if a user can't grasp this concept, I'm
not sure that they are going be able to grasp the other concepts
involved.

Mhhh. Ok - an example.

We have these mapsets activated with g.mapsets:

neteler PERMANENT dtm belluno

There may be a file 'dtm10' both in 'dtm' and 'belluno'. The user
may have already forgotten that it exists twice. When using d.rast,
is the mapset search path searched 1. own, 2. PERMANENT, 3. alphabetically?
If yes, will the user remember that the map exists twice (I am sure that
he/she won't remember).
Addition: In our project location here we have around 5000 maps
in 76 mapsets, 8 people are adding maps daily. Like that I would have to
always run g.list to verify that I pick the right map, perhaps a
colleage had added a map with same name yesterday in a mapset which is
in my current mapset search path ....

So this problem exists mostly for work-groups.

Hope I could illustrate the problem a bit better now.

Markus

Markus Neteler wrote:

> > Maybe I am missing something, but we cannot be sure which map
> > is picked up when a map name exists several times (at least it
> > is not obvious to the user).
>
> Well, it should also be explained right at the very beginning of any
> user guide or tutorial. And if a user can't grasp this concept, I'm
> not sure that they are going be able to grasp the other concepts
> involved.

Mhhh. Ok - an example.

We have these mapsets activated with g.mapsets:

neteler PERMANENT dtm belluno

There may be a file 'dtm10' both in 'dtm' and 'belluno'. The user
may have already forgotten that it exists twice. When using d.rast,
is the mapset search path searched 1. own, 2. PERMANENT, 3. alphabetically?
If yes, will the user remember that the map exists twice (I am sure that
he/she won't remember).

Addition: In our project location here we have around 5000 maps
in 76 mapsets, 8 people are adding maps daily. Like that I would have to
always run g.list to verify that I pick the right map, perhaps a
colleage had added a map with same name yesterday in a mapset which is
in my current mapset search path ....

So this problem exists mostly for work-groups.

Hope I could illustrate the problem a bit better now.

Basically, you get what you ask for. If you have 76 mapsets in your
search path, and GRASS were to implement "collision avoidance", I
would expect that commands would frequently fail because the name you
chose existed elsewhere. This is a minor nuisance if you're running
commands interactively, and potentially a major nuisance for scripts.

Personally, I would just leave the search path at the default, and use
"map" for my own maps (and those in PERMANENT) and "map@mapset" for
everything else.

The existing behaviour seems fine to me; if I run "r.mapcalc foo=...",
it will create a map called "foo" in the current mapset. Any
unqualified references to "foo" will then refer to the map which I've
just created. I don't need to worry about whether someone else already
has a map called "foo". And even if they have, I can access it with
"foo@mapset".

--
Glynn Clements <glynn.clements@virgin.net>

On Wed, Mar 13, 2002 at 11:33:17AM +0000, Glynn Clements wrote:

Markus Neteler wrote:

> > > Maybe I am missing something, but we cannot be sure which map
> > > is picked up when a map name exists several times (at least it
> > > is not obvious to the user).
> >
> > Well, it should also be explained right at the very beginning of any
> > user guide or tutorial. And if a user can't grasp this concept, I'm
> > not sure that they are going be able to grasp the other concepts
> > involved.
>
> Mhhh. Ok - an example.
>
> We have these mapsets activated with g.mapsets:
>
> neteler PERMANENT dtm belluno
>
> There may be a file 'dtm10' both in 'dtm' and 'belluno'. The user
> may have already forgotten that it exists twice. When using d.rast,
> is the mapset search path searched 1. own, 2. PERMANENT, 3. alphabetically?
> If yes, will the user remember that the map exists twice (I am sure that
> he/she won't remember).

> Addition: In our project location here we have around 5000 maps
> in 76 mapsets, 8 people are adding maps daily. Like that I would have to
> always run g.list to verify that I pick the right map, perhaps a
> colleage had added a map with same name yesterday in a mapset which is
> in my current mapset search path ....
>
> So this problem exists mostly for work-groups.
>
> Hope I could illustrate the problem a bit better now.

Basically, you get what you ask for. If you have 76 mapsets in your
search path, and GRASS were to implement "collision avoidance", I
would expect that commands would frequently fail because the name you
chose existed elsewhere.

Even that does not work (at least for r.proj). If I have a map
'dtm10' in a mapset which is in search path, r.proj happily generates
'dtm10' in the current mapset without notifying that dtm10 already
exists in another mapset (while g.copy complains and stops).

At least we should have identical behaviour for all modules.

This is a minor nuisance if you're running
commands interactively, and potentially a major nuisance for scripts.

Personally, I would just leave the search path at the default, and use
"map" for my own maps (and those in PERMANENT) and "map@mapset" for
everything else.

Maybe yes, but then I have to know where all the maps live. That
means heavy usage of g.list and grep. So probably I stick with
having selected mapsets in my search path.

The current behaviour of GRASS is rather nice, I only wonder about
different behaviour as pointed out for g.copy and r.proj.

The existing behaviour seems fine to me; if I run "r.mapcalc foo=...",
it will create a map called "foo" in the current mapset. Any
unqualified references to "foo" will then refer to the map which I've
just created. I don't need to worry about whether someone else already
has a map called "foo". And even if they have, I can access it with
"foo@mapset".

--
Glynn Clements <glynn.clements@virgin.net>

Markus

Markus Neteler wrote:

> Basically, you get what you ask for. If you have 76 mapsets in your
> search path, and GRASS were to implement "collision avoidance", I
> would expect that commands would frequently fail because the name you
> chose existed elsewhere.

Even that does not work (at least for r.proj). If I have a map
'dtm10' in a mapset which is in search path, r.proj happily generates
'dtm10' in the current mapset without notifying that dtm10 already
exists in another mapset (while g.copy complains and stops).

At least we should have identical behaviour for all modules.

> This is a minor nuisance if you're running
> commands interactively, and potentially a major nuisance for scripts.
>
> Personally, I would just leave the search path at the default, and use
> "map" for my own maps (and those in PERMANENT) and "map@mapset" for
> everything else.

Maybe yes, but then I have to know where all the maps live. That
means heavy usage of g.list and grep. So probably I stick with
having selected mapsets in my search path.

The current behaviour of GRASS is rather nice, I only wonder about
different behaviour as pointed out for g.copy and r.proj.

AFAIK, everything except g.copy works the same way as r.proj. g.copy
explicitly checks whether a map with that name exists in any mapset;
G_open_cell_new() doesn't do this, so programs won't get this
behaviour automatically.

This is probably as it should be; if everything behaved like g.copy,
it could cause real problems (particularly with programs which have
fixed output names; e.g. the CELL driver uses "D_cell", rgb.hsv.sh
uses "H", "S" and "V" etc).

Also, g.copy's check only prevents you from using a name which exists
in the *current* mapset path. If you subsequently add mapsets to the
path with g.mapsets, you may then have duplicates.

--
Glynn Clements <glynn.clements@virgin.net>