[GRASS-dev] r.flow with barrier fails
Jáchym Čepický
jachym.cepicky at gmail.com
Tue Feb 20 07:15:44 EST 2007
Guys,
I see the main problem, that the r.flow module _does not work
properly_ with barin option. I mean, the calculation is just wrong. If
barin is specified, density output file has only one value: -1.000000
jachym
2007/2/20, Brad Douglas <rez at touchofmadness.com>:
> On Tue, 2007-02-20 at 08:53 +0100, Jáchym Čepický wrote:
> > hi glynn,
> >
> > 2007/2/19, Glynn Clements <glynn at gclements.plus.com>:
> > > >[...]
> > > Probably this:
> > >
> > > --- raster/r.flow/io.c 7 Feb 2007 05:24:40 -0000 1.14
> > > +++ raster/r.flow/io.c 19 Feb 2007 18:18:41 -0000
> > > @@ -126,7 +126,7 @@
> > > for (col = 0; col < region.cols; col++)
> > > {
> > > BM_set(bitbar, col, row, (barc[col] != 0));
> > > - if (barc[col] != 0)
> > > + if (ds.buf && barc[col] != 0)
> > > put(ds, row, col, -1);
> > > }
> > > }
> >
> > This makes it not to segfault, but it does not make r.flow work properly
>
> The problem is that it requires that the 'dsout' option be specified in
> addition to the options you already provided. The memory buffer is not
> allocated without it.
>
> I'm not sure if that's a feature or a bug. If someone can guide me to
> proper operation, I'll commit fix for it.
>
> Here's a patch that "corrects" the problem (essentially, what Glynn
> already posted), but I'm not sure if this is proper behavior. Ideally,
> it should either A) error out or B) allocate the memory if 'barin' is
> specified:
>
> RCS file: /grassrepository/grass6/raster/r.flow/io.c,v
> retrieving revision 1.14
> diff -u -r1.14 io.c
> --- io.c 7 Feb 2007 05:24:40 -0000 1.14
> +++ io.c 20 Feb 2007 08:30:36 -0000
> @@ -114,7 +114,7 @@
> G_close_cell(fd);
> }
>
> - if (parm.barin)
> + if (parm.barin && parm.dsout)
> {
> G_message(_("Reading input files: barrier"));
> barc = G_allocate_d_raster_buf();
> @@ -132,6 +132,8 @@
> }
> G_close_cell(fd);
> }
> +
> + if (barc) G_free (barc);
> }
>
>
> --
> Brad Douglas <rez touchofmadness com> KB8UYR/6
> Address: 37.493,-121.924 / WGS84 National Map Corps #TNMC-3785
>
>
--
Jachym Cepicky
e-mail: jachym.cepicky gmail com
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
More information about the grass-dev
mailing list