[GRASS-dev] Re: v.buffer creates artefact - bug?

Maris Nartiss wrote:

I downloaded provided location and can confirm bug. I get same buffer
as You. Running v.clean or v.build on vector does not change anything.
v.digit fixes problem, as You wrote.

"OK". So there is something fishy here - 3 people confirmed till now.

One strange thing - v.info says, that there is one island. I can not
see any such feature in v.digit. Am I missing something?

This is as expected. A separate area is an island at the same time,
AFAIK. When there are two such areas, like on the attached screendump,
there are two islands - and so forth:

$ v.info -t checkit
nodes=4
points=0
lines=0
boundaries=2
centroids=2
areas=2
islands=2
faces=0
kernels=0
primitives=4
map3d=0

GRASS 6.2.1 and 6.3-cvs (~ week old)
Gentoo GNU/Linux on i686 (Intel P4 Celeron M)
GCC 4.1.1

I can reproduce this on a 32bit Pentium M Dothan (2.6.15-27-686) and on
a 32bit AMD K7 Barton (2.6.15-27-k7), both Ubuntu 6.06, GCC 4.0.3.

Hamish said it was not reproducible on his "Debian/Sarge, gcc 3.3.5,
linux 2.4.27-3-686 on a P4".

Maybe GCC version makes the difference? I'll try GCC 3 when possible.

Hamish,

Are you still not able to reproduce this problem on your setup?

Maciek

(attachments)

2islands.png

Note that my test (results same as Maciek) was conducted on a GCC 4.1 system.

Cheers,

dylan

On Wednesday 31 January 2007 09:27, Maciej Sieczka wrote:

Maris Nartiss wrote:
> I downloaded provided location and can confirm bug. I get same buffer
> as You. Running v.clean or v.build on vector does not change anything.
> v.digit fixes problem, as You wrote.

"OK". So there is something fishy here - 3 people confirmed till now.

> One strange thing - v.info says, that there is one island. I can not
> see any such feature in v.digit. Am I missing something?

This is as expected. A separate area is an island at the same time,
AFAIK. When there are two such areas, like on the attached screendump,
there are two islands - and so forth:

$ v.info -t checkit
nodes=4
points=0
lines=0
boundaries=2
centroids=2
areas=2
islands=2
faces=0
kernels=0
primitives=4
map3d=0

> GRASS 6.2.1 and 6.3-cvs (~ week old)
> Gentoo GNU/Linux on i686 (Intel P4 Celeron M)
> GCC 4.1.1

I can reproduce this on a 32bit Pentium M Dothan (2.6.15-27-686) and on
a 32bit AMD K7 Barton (2.6.15-27-k7), both Ubuntu 6.06, GCC 4.0.3.

Hamish said it was not reproducible on his "Debian/Sarge, gcc 3.3.5,
linux 2.4.27-3-686 on a P4".

Maybe GCC version makes the difference? I'll try GCC 3 when possible.

Hamish,

Are you still not able to reproduce this problem on your setup?

Maciek

--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

Maciej Sieczka wrote:

Hamish said it was not reproducible on his "Debian/Sarge, gcc 3.3.5,
linux 2.4.27-3-686 on a P4".

Maybe GCC version makes the difference? I'll try GCC 3 when possible.

So I did, gcc 3.3.6 on Ubunutu 6.06 32bit Pentium M. No good. Exactly
the same bug crops out as with gcc 4.03.

Hamish,

Are you still not able to reproduce this? You might be holding the key
to a fix.

Maciek

> Hamish said it was not reproducible on his "Debian/Sarge, gcc 3.3.5,
> linux 2.4.27-3-686 on a P4".
>
> Maybe GCC version makes the difference? I'll try GCC 3 when
> possible.

Maciej wrote:

So I did, gcc 3.3.6 on Ubunutu 6.06 32bit Pentium M. No good. Exactly
the same bug crops out as with gcc 4.03.

Hamish,
Are you still not able to reproduce this? You might be holding the key
to a fix.

AFAIR, we were able to isolate it to this polygon shape:

# (working in Spearfish)
GRASS> v.in.ascii out=ditch_1205 form=standard -n << EOF
B 4
600727.68682251 5677973.32091602
600739.16582305 5678137.49568095
600736.32863997 5678140.4618269
600730.63832718 5678056.67823368
B 2
600730.63832718 5678056.67823368
600725.02385533 5677974.01131491
C 1 1
600730.04890192 5678035.56666655
1 1205
B 2
600727.68682251 5677973.32091602
600725.02385533 5677974.01131491
EOF

# and then:
GRASS> v.buffer ditch_1205 out=ditch_1205_b1 type=area buffer=1
GRASS> v.buffer ditch_1205 out=ditch_1205_b4 type=area buffer=4

Doing this with current CVS both ditch_1205_b1 and ditch_1205_b4 look
totally normal for me. So I still can't recreate it. shrug.

This probably isn't it, but I use CFLAGS="-g" to compile in debug info,
which I think has the side effect of initing all memory to 0's which
changes the expression of some memory bugs.

-note there is another extant bug in v.buffer I do know the cause of-
(but not a solution)

If you have lines shaped like an "E" or an "M", the resulatant buffered
area has a good chance of placing the new area's centroid very close to
a line feature. One of the "is it real" tests v.buffer/main.c does is
to check the distance from a centroid to the line feature, and in this
case the line pokes into the middle of the area so the distance will be
very small and the test returns incorrect results.

Also note that Radim often suggested that v.buffer should be rewritten
from scratch-- doc/vector/TODO:
"
v.buffer
--------
Completely rewrite if possible or at least fix the bug which is
probably in clean_parallel() in lib/vector/Vlib/buffer.c.
"

Hamish

[I've little spare time to keep up with the mailing lists right now, so
sorry for any delayed/missed responses; be sure bug #2765 gets updated if
you find a good clue]

Hi all,

I was palying a bit with bug-trigering vector and You can see results
in attachments - setting buffer to 10m will give different buffer top,
setting buffer to 1 m will return more annoying result and stopping
buffer process before clean is visible in third image.

I also looked in v.buffer code, but my C skeelz are too lame to
undrstand it, but I noticed lot of comments with "TODO" and "Should
work like this". Also there is some stuff relaying on asumption, thath
some stuff is listed clockwise or counterclockwise, etc.

Also I was not able to create buffers for boundary, centroid. They are
listed in v.buffer man page but I do not see any code related to them
in v.buffer.

Hope more info will help,
Maris.

2007/2/5, Hamish <hamish_nospam@yahoo.com>:

> > Hamish said it was not reproducible on his "Debian/Sarge, gcc 3.3.5,
> > linux 2.4.27-3-686 on a P4".
> >
> > Maybe GCC version makes the difference? I'll try GCC 3 when
> > possible.
Maciej wrote:
> So I did, gcc 3.3.6 on Ubunutu 6.06 32bit Pentium M. No good. Exactly
> the same bug crops out as with gcc 4.03.
>
> Hamish,
> Are you still not able to reproduce this? You might be holding the key
> to a fix.

AFAIR, we were able to isolate it to this polygon shape:

# (working in Spearfish)
GRASS> v.in.ascii out=ditch_1205 form=standard -n << EOF
B 4
600727.68682251 5677973.32091602
600739.16582305 5678137.49568095
600736.32863997 5678140.4618269
600730.63832718 5678056.67823368
B 2
600730.63832718 5678056.67823368
600725.02385533 5677974.01131491
C 1 1
600730.04890192 5678035.56666655
1 1205
B 2
600727.68682251 5677973.32091602
600725.02385533 5677974.01131491
EOF

# and then:
GRASS> v.buffer ditch_1205 out=ditch_1205_b1 type=area buffer=1
GRASS> v.buffer ditch_1205 out=ditch_1205_b4 type=area buffer=4

Doing this with current CVS both ditch_1205_b1 and ditch_1205_b4 look
totally normal for me. So I still can't recreate it. shrug.

This probably isn't it, but I use CFLAGS="-g" to compile in debug info,
which I think has the side effect of initing all memory to 0's which
changes the expression of some memory bugs.

-note there is another extant bug in v.buffer I do know the cause of-
(but not a solution)

If you have lines shaped like an "E" or an "M", the resulatant buffered
area has a good chance of placing the new area's centroid very close to
a line feature. One of the "is it real" tests v.buffer/main.c does is
to check the distance from a centroid to the line feature, and in this
case the line pokes into the middle of the area so the distance will be
very small and the test returns incorrect results.

Also note that Radim often suggested that v.buffer should be rewritten
from scratch-- doc/vector/TODO:
"
v.buffer
--------
Completely rewrite if possible or at least fix the bug which is
probably in clean_parallel() in lib/vector/Vlib/buffer.c.
"

Hamish

[I've little spare time to keep up with the mailing lists right now, so
sorry for any delayed/missed responses; be sure bug #2765 gets updated if
you find a good clue]

(attachments)

vbuffer_issue_10m.png
vbuffer_issue_1m.png
vbuffer_issue_4m_clean.png

Maris Nartiss wrote:

Also I was not able to create buffers for boundary, centroid. They are
listed in v.buffer man page but I do not see any code related to them
in v.buffer.

only features with a category number will be buffered. Typically
boundaries are not assigned cats. Add with v.category.

for centroid try type=centroid.

Hamish

Maris,

Maris Nartiss wrote:

Hi all,

I was palying a bit with bug-trigering vector and You can see results
in attachments - setting buffer to 10m will give different buffer top,
setting buffer to 1 m will return more annoying result and stopping
buffer process before clean is visible in third image.

I also looked in v.buffer code, but my C skeelz are too lame to
undrstand it, but I noticed lot of comments with "TODO" and "Should
work like this". Also there is some stuff relaying on asumption, thath
some stuff is listed clockwise or counterclockwise, etc.

I suppose this last thing might matter. Please note that the following
ASCII vector is buffered bad (it's the one you have already tested, the
infamous ditch_1205):

B 4
600727.68682251 5677973.32091602
600739.16582305 5678137.49568095
600736.32863997 5678140.4618269
600730.63832718 5678056.67823368
B 2
600730.63832718 5678056.67823368
600725.02385533 5677974.01131491
C 1 1
600730.04890192 5678035.56666655
1 1205
B 2
600727.68682251 5677973.32091602
600725.02385533 5677974.01131491

While it's slightly different version (same coordinates, but a
different order of vertices - it's well visible in meld/kdif/xdiff) is
buffered fine.

B 2
600730.63832718 5678056.67823368
600725.02385533 5677974.01131491
C 1 1
600730.04890192 5678035.56666655
1 1205
B 2
600727.68682251 5677973.32091602
600725.02385533 5677974.01131491
B 4
600727.68682251 5677973.32091602
600739.16582305 5678137.49568095
600736.32863997 5678140.4618269
600730.63832718 5678056.67823368

Can you try that?

2007/2/5, Hamish <hamish_nospam@yahoo.com>:

This probably isn't it, but I use CFLAGS="-g" to compile in debug info,
which I think has the side effect of initing all memory to 0's which
changes the expression of some memory bugs.

I will try that tomorrow anyway. Who knows.

Maciek

Hi Maciej,

I imported both ascii snippets with v.in.ascii -n format=standard and
they looked like same. Created buffer with size=1 and type=area.
Results where same as in my previous tests. For first ascii snippet, I
got shrinked vector area (like removed vector from inside of area)
plus the mystic circle in middle. Second one - good order - worked as
expected - I got correct buffer.

It seems, that v.buffer expects some features to be in right
order(tm). Next thing to find is it v.buffer specific or it's a design
failure in V_lib. As I wrote already, v.* code is a bit more complex
than I can understand - no help form me, just testing.

I will recompile my GRASS too with -g CFLAG and repeat test. If result
will differ, I will report.

Maris.

2007/2/7, Maciej Sieczka <tutey@o2.pl>:

Maris,

Maris Nartiss wrote:
> Hi all,
>
> I was palying a bit with bug-trigering vector and You can see results
> in attachments - setting buffer to 10m will give different buffer top,
> setting buffer to 1 m will return more annoying result and stopping
> buffer process before clean is visible in third image.
>
> I also looked in v.buffer code, but my C skeelz are too lame to
> undrstand it, but I noticed lot of comments with "TODO" and "Should
> work like this". Also there is some stuff relaying on asumption, thath
> some stuff is listed clockwise or counterclockwise, etc.

I suppose this last thing might matter. Please note that the following
ASCII vector is buffered bad (it's the one you have already tested, the
infamous ditch_1205):

B 4
600727.68682251 5677973.32091602
600739.16582305 5678137.49568095
600736.32863997 5678140.4618269
600730.63832718 5678056.67823368
B 2
600730.63832718 5678056.67823368
600725.02385533 5677974.01131491
C 1 1
600730.04890192 5678035.56666655
1 1205
B 2
600727.68682251 5677973.32091602
600725.02385533 5677974.01131491

While it's slightly different version (same coordinates, but a
different order of vertices - it's well visible in meld/kdif/xdiff) is
buffered fine.

B 2
600730.63832718 5678056.67823368
600725.02385533 5677974.01131491
C 1 1
600730.04890192 5678035.56666655
1 1205
B 2
600727.68682251 5677973.32091602
600725.02385533 5677974.01131491
B 4
600727.68682251 5677973.32091602
600739.16582305 5678137.49568095
600736.32863997 5678140.4618269
600730.63832718 5678056.67823368

Can you try that?

> 2007/2/5, Hamish <hamish_nospam@yahoo.com>:

>> This probably isn't it, but I use CFLAGS="-g" to compile in debug info,
>> which I think has the side effect of initing all memory to 0's which
>> changes the expression of some memory bugs.

I will try that tomorrow anyway. Who knows.

Maciek