[GRASS-user] [bug #2765] v.buffer bug??
Hamish
hamish_nospam at yahoo.com
Sun Oct 1 04:58:56 EDT 2006
Bug log:
> http://intevation.de/rt/webrt?serial_num=2765
Hi,
I have a patch I think gets around the famous v.buffer bug (attached),
please test.
I say "gets around" the bug more than solves it, as while I know that
the bug happens when the "sa" segment loops back to "0" and then the
total number of points is set by the final segment number(+2), I don't
really know why, or if this is the problem or the problem is the setting
of npn (total number of points) directly from the seg ID number.
[ lib/vector/Vlib/buffer.c clean_parallel() ]
So this patch just makes sure that we don't set npn from a smaller "sa"
value than was found in the data.
This fixes the buffer for the test polygon found in the bug log.
I don't know if it fixes the hole-gets-filled-in area problem.
Hamish
-------------- next part --------------
Index: lib/vector/Vlib/buffer.c
===================================================================
RCS file: /home/grass/grassrepository/grass6/lib/vector/Vlib/buffer.c,v
retrieving revision 1.7
diff -u -r1.7 buffer.c
--- lib/vector/Vlib/buffer.c 11 Sep 2006 04:35:07 -0000 1.7
+++ lib/vector/Vlib/buffer.c 1 Oct 2006 08:43:52 -0000
@@ -117,6 +117,7 @@
void clean_parallel ( struct line_pnts *Points, struct line_pnts *origPoints, double d , int rm_end )
{
int i, j, np, npn, sa, sb;
+ int sa_max = 0;
int first=0, current, last, lcount;
double *x, *y, px, py, ix, iy;
static struct line_pnts *sPoints = NULL;
@@ -148,6 +149,10 @@
G_debug (5, " current = %d, last = %d, lcount = %d", current, last, lcount);
}
if ( lcount == 0 ) { break; } /* loop not found */
+
+ /* ensure sa is monotonically increasing, so npn doesn't reset low */
+ if (sa > sa_max ) sa_max = sa;
+ if (sa < sa_max ) break;
/* remove loop if in buffer */
if ( (sb-sa) == 1 ){ /* neighbouring lines overlap */
More information about the grass-user
mailing list