[GRASS-dev] grass7: passing fullyqualified names to G_ fns

Martin Landa landa.martin at gmail.com
Fri Aug 8 03:47:38 EDT 2008


Hi,

2008/8/7 Glynn Clements <glynn at gclements.plus.com>:

[...]

> I really want to eliminate mapsets altogether from the higher-level
> functions. Modules should be able to pass opt->answer directly to most
> GRASS functions without needing to call G_find_* or know anything
> about mapsets.
>
>> Currently functions G_find_cell / G_find_cell2 return mapset name or
>> NULL. Maybe we could eliminate G_find_*2 function by adding a new
>> argument.
>>
>> G_find_cell(fname, mapset, name)
>>
>> where name is char * to not-fully qualified name (allocated by G_store())
>>
>> or just
>>
>> G_find_cell(fname, mapset, NULL) (as G_find_cell2)
>
> Ideally, modules shouldn't need to use the G_find_* functions. In most
> cases, use of G_find_* has been unnecessary since the libgis functions
> were modified to accept fully qualified names, rather than requiring
> the caller to "de-qualify" the name beforehand.
>
> It should normally be sufficient to just use e.g.:
>
>        G_open_cell_old(input->answer, "")
>
> rather than e.g.:
>
>        mapset = G_find_cell2(input->answer, "");
>        G_open_cell_old(input->answer, mapset);
>
> [error checking elided.]
>
> If all of the unnecessary G_find_* calls are eliminated, most of the
> mapset arguments will eventually become "", at which point the
> parameter can be eliminated altogether. If you need to force a
> specific mapset, you can construct a qualified name with
> G_fully_qualified_name().
>
> But first, we should track down and replace any residual uses of
> G_find_cell() (which overwrites the name argument with the unqualified
> version). If you really need to de-qualify a name (e.g. because you're
> using it as a base for generting map names[1]), use an explicit call
> to G__name_is_fully_qualified().

thanks for the clarification, +1 for eliminating G_find_* fns().

Martin

-- 
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *


More information about the grass-dev mailing list