[GRASS-dev] Re: [bug #2765] v.buffer bug??
Hamish
hamish_nospam at yahoo.com
Mon Sep 11 01:47:17 EDT 2006
Hamish wrote:
> me:
> > > Can someone provide me with a simple vector file where the
> > > buffering bug happens? or make it happen with a Speafish map?
..
> I couldn't recreate your buff=1 and 4 errors- buffering works fine for
> me there. I was however able to extract the attached problematic
> feature (area 1188), which is a fairly simple example. I reimported
> the ascii file as a new vector and got the same results, so hopefully
> others can reproduce with this too (?). I tested with buff=4 and
> buff=10.
>
> Using debug=buffer,clean didn't help, problem happens before that.
Converting to line and cleaning out excess vertices doesn't help either.
Here is a simplified version of a problematic area:
("v.in.ascii -n format=standard")
B 26
600039.02641686 5678405.3999173
600077.97320276 5678399.62882899
600086.74267773 5678396.53372018
600165.15210099 5678369.45151806
600169.2571522 5678367.86458082
600321.12416744 5678313.92598028
600329.91897615 5678321.23595115
600333.66876785 5678318.50222813
600324.59956919 5678312.02422909
600321.23100969 5678310.98774925
600167.57287245 5678364.49602132
600085.45304905 5678392.66483416
600077.19942555 5678396.27579444
600036.44715953 5678401.36982765
600030.38590477 5678402.27256772
600010.78354895 5678405.62560227
599996.21074494 5678408.39830396
599987.18334424 5678410.71963557
599979.96142368 5678412.00926424
599968.01258083 5678413.77867984
599954.94262744 5678414.84644733
599949.52618701 5678419.48911054
599968.61269136 5678418.4574076
599998.40311369 5678411.75133851
600001.62800241 5678411.19452149
600039.02641686 5678405.3999173
C 1 1
600232.43677669 5678342.9534263
1 1188
adding a few debug statements to lib/vector/Vlib/buffer.c shows:
--> npoints = 26
--> side=0, added 41 points
--> dangle=0.283079, PI=3.141593
added 11 arc points
--> side=1, added 3 points
--> dangle=0.283079, PI=3.141593
in Vect_line_parallel():
For side=1, there are 73 points created by parallel_line(), which if
plotted describe the *correct* buffered boundaries that we want.
==> After clean_parallel() there are only 3 points left. <==
So the problem is in clean_parallel().
If I comment out the clean_parallel() call, a correct looking output map
is created, but this may lead to other problems later on...?
for the last loop in side 1, sa=0. after the following sa+1 and two
npn++ calls, the number of valid points from that pass ends up as 3.
if ( point_in_buf( origPoints, px, py, d ) ){ /* is loop in buffer ? */
npn=sa+1;
here is evolution of segments sa and sb. all debug messages are in
clean_parallel(). error happens when (sb - sa) != 2, ie when the segment
wraps back to the beginning of the polygon?
nareas=1
Areas buffers ... 100%
--> side 0
D0/0: clean_parallel(): npoints = 54, d = 10.000000, rm_end = 0
D0/0: current = 1, last = 2, lcount = 1
D0/0: //> no_overlap: sa=0 sb=2 first=0 np=54
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=1 sa=0 sb=2, lcount=1
D0/0: //> just before "move points down": npn=2
D0/0: current = 4, last = 5, lcount = 1
D0/0: //> no_overlap: sa=3 sb=5 first=3 np=54
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=53 sa=3 sb=5, lcount=1
D0/0: //> just before "move points down": npn=5
D0/0: current = 13, last = 14, lcount = 1
D0/0: //> no_overlap: sa=12 sb=14 first=12 np=54
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=52 sa=12 sb=14, lcount=1
D0/0: //> just before "move points down": npn=14
D0/0: current = 15, last = 16, lcount = 1
D0/0: //> no_overlap: sa=14 sb=16 first=14 np=54
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=51 sa=14 sb=16, lcount=1
D0/0: //> just before "move points down": npn=16
D0/0: current = 15, last = 17, lcount = 1
D0/0: //> no_overlap: sa=14 sb=17 first=14 np=54
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 4
D0/0: //> loop [centroid] is in buffer npn=50 sa=14 sb=17, lcount=1
D0/0: //> just before "move points down": npn=16
D0/0: current = 18, last = 19, lcount = 1
D0/0: //> no_overlap: sa=17 sb=19 first=17 np=54
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=48 sa=17 sb=19, lcount=1
D0/0: //> just before "move points down": npn=19
D0/0: current = 22, last = 23, lcount = 1
D0/0: //> no_overlap: sa=21 sb=23 first=21 np=54
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=47 sa=21 sb=23, lcount=1
D0/0: //> just before "move points down": npn=23
D0/0: current = 23, last = 24, lcount = 1
D0/0: //> no_overlap: sa=22 sb=24 first=22 np=54
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=46 sa=22 sb=24, lcount=1
D0/0: //> just before "move points down": npn=24
D0/0: current = 24, last = 25, lcount = 1
D0/0: //> no_overlap: sa=23 sb=25 first=23 np=54
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=45 sa=23 sb=25, lcount=1
D0/0: //> just before "move points down": npn=25
D0/0: current = 25, last = 26, lcount = 1
D0/0: //> no_overlap: sa=24 sb=26 first=24 np=54
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=44 sa=24 sb=26, lcount=1
D0/0: //> just before "move points down": npn=26
D0/0: current = 32, last = 33, lcount = 1
D0/0: //> no_overlap: sa=31 sb=33 first=31 np=54
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=43 sa=31 sb=33, lcount=1
D0/0: //> just before "move points down": npn=33
D0/0: current = 35, last = 36, lcount = 1
D0/0: //> no_overlap: sa=34 sb=36 first=34 np=54
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=42 sa=34 sb=36, lcount=1
D0/0: //> just before "move points down": npn=36
D0/0: //> after: npn=41
--> side 1
D0/0: clean_parallel(): npoints = 73, d = -10.000000, rm_end = 0
D0/0: current = 1, last = 71, lcount = 1
D0/0: current = 3, last = 4, lcount = 2
D0/0: //> no_overlap: sa=2 sb=4 first=0 np=73
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=1 sa=2 sb=4, lcount=2
D0/0: //> just before "move points down": npn=4
D0/0: current = 1, last = 70, lcount = 1
D0/0: current = 6, last = 7, lcount = 2
D0/0: //> no_overlap: sa=5 sb=7 first=0 np=73
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=72 sa=5 sb=7, lcount=2
D0/0: //> just before "move points down": npn=7
D0/0: current = 1, last = 69, lcount = 1
D0/0: current = 7, last = 8, lcount = 2
D0/0: //> no_overlap: sa=6 sb=8 first=0 np=73
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=71 sa=6 sb=8, lcount=2
D0/0: //> just before "move points down": npn=8
D0/0: current = 1, last = 68, lcount = 1
D0/0: current = 29, last = 30, lcount = 2
D0/0: //> no_overlap: sa=28 sb=30 first=0 np=73
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=70 sa=28 sb=30, lcount=2
D0/0: //> just before "move points down": npn=30
D0/0: current = 1, last = 67, lcount = 1
D0/0: current = 32, last = 33, lcount = 2
D0/0: //> no_overlap: sa=31 sb=33 first=0 np=73
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=69 sa=31 sb=33, lcount=2
D0/0: //> just before "move points down": npn=33
D0/0: current = 1, last = 66, lcount = 1
D0/0: current = 41, last = 42, lcount = 2
D0/0: //> no_overlap: sa=40 sb=42 first=0 np=73
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=68 sa=40 sb=42, lcount=2
D0/0: //> just before "move points down": npn=42
D0/0: current = 1, last = 65, lcount = 1
D0/0: current = 42, last = 43, lcount = 2
D0/0: //> no_overlap: sa=41 sb=43 first=0 np=73
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=67 sa=41 sb=43, lcount=2
D0/0: //> just before "move points down": npn=43
D0/0: current = 1, last = 64, lcount = 1
D0/0: current = 43, last = 44, lcount = 2
D0/0: //> no_overlap: sa=42 sb=44 first=0 np=73
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=66 sa=42 sb=44, lcount=2
D0/0: //> just before "move points down": npn=44
D0/0: current = 1, last = 63, lcount = 1
D0/0: current = 60, last = 61, lcount = 2
D0/0: //> no_overlap: sa=59 sb=61 first=0 np=73
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=65 sa=59 sb=61, lcount=2
D0/0: //> just before "move points down": npn=61
D0/0: current = 1, last = 62, lcount = 1
D0/0: current = 61, last = 62, lcount = 2
D0/0: //> no_overlap: sa=60 sb=62 first=0 np=73
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 3
D0/0: //> loop [centroid] is in buffer npn=64 sa=60 sb=62, lcount=2
D0/0: //> just before "move points down": npn=62
D0/0: current = 1, last = 61, lcount = 1
D0/0: //> no_overlap: sa=0 sb=61 first=0 np=73
D0/0: //> add sPoint->n = 1
D0/0: //> after loop sPoint->n = 62
D0/0: //> loop [centroid] is in buffer npn=63 sa=0 sb=61, lcount=1
D0/0: //> just before "move points down": npn=2
D0/0: //> after: npn=3
nisles=0
Hamish
More information about the grass-dev
mailing list