[GRASS-dev] r.mapcalc and g.remove --v/q issues
Martin Landa
landa.martin at gmail.com
Mon Oct 9 16:28:43 EDT 2006
Hi all,
please take a look at new behaviour of g.remove. If it is OK for you,
I will modify in this way g.copy/g.rename modules.
Best, Martin
2006/10/9, Martin Landa <landa.martin at gmail.com>:
> Hi,
>
> thanks Glynn!, modified patch applied in CVS.
>
> Best regards, Martin
>
> 2006/10/9, Glynn Clements <glynn at gclements.plus.com>:
> >
> > Martin Landa wrote:
> >
> > > trying to cleanup g.remove module I have prepared the patch. Is it OK
> > > for you? Any comments welcomed...
> >
> > Rather than hard-coding checks for specific entity types:
> >
> > + if (G_strcasecmp(list[n].alias, "rast") == 0 ) {
> > + if ((mapset = G_find_cell2 (old, "")) == NULL) {
> > + G_warning(_("Raster map <%s> not found"), old);
> > + result = 1;
> > + }
> > + }
> > +
> > + if (G_strcasecmp(list[n].alias, "rast3d") == 0 ) {
> > + if ((mapset = G_find_grid3 (old, "")) == NULL) {
> > + G_warning(_("Raster 3d map <%s> not found"), old);
> > + result = 1;
> > + }
> > + }
> >
> > I would add a flag which is initially cleared for each entity (map
> > etc) and set when an element is actually removed. A warning would be
> > generated if the flag is still clear when all of the elements for an
> > entity have been processed.
> >
> > E.g.:
> >
> > + removed = 0;
> > for (i = 0; i < list[n].nelem; i++) {
> > switch (G_remove (list[n].element[i], old))
> > {
> > case -1:
> > - G_warning (" %-*s %s", len, list[n].desc[i],_("COULD NOT REMOVE"));
> > + G_warning ("%s: %s", list[n].desc[i],_("couldn't be removed"));
> > result = 1;
> > break;
> > case 0:
> > - G_message (" %-*s %s", len, list[n].desc[i],_("MISSING"));
> > + G_debug (1, "%s: %s", list[n].desc[i],_("missing"));
> > break;
> > case 1:
> > - G_message (" %-*s ", len, list[n].desc[i]);
> > + G_debug (1, "%s: %s", list[n].desc[i],_("removed"));
> > + removed = 1;
> > break;
> > }
> > }
> > +
> > + if (!removed)
> > + G_warning ("%s: %s", list[n].desc[i],_("nothing removed"));
> >
> > --
> > Glynn Clements <glynn at gclements.plus.com>
> >
>
>
> --
> Martin Landa <landa.martin at gmail.com> * http://gama.fsv.cvut.cz/~landa *
>
--
Martin Landa <landa.martin at gmail.com> * http://gama.fsv.cvut.cz/~landa *
More information about the grass-dev
mailing list