[GRASS-dev] [GRASS GIS] #36: v.generalize Assertion failed.

#36: v.generalize Assertion failed.
---------------------+------------------------------------------------------
Reporter: marisn | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: default | Version: svn-trunk
Keywords: |
---------------------+------------------------------------------------------
{{{
(gdb) run -r input=cont_4144@PERMANENT output=cont_4144_general type=line
method=hermite threshold=3 look_ahead=7 reduction=50 slide=0.5
angle_thresh=3 degree_thresh=0 closeness_thresh=0 betweeness_thresh=0
alpha=1.0 beta=1.0 iterations=1 layer=1 --overwrite
Starting program: /home/maris/soft/grass_trunk/dist.x86_64-unknown-linux-
gnu/bin/v.generalize -r input=cont_4144@PERMANENT output=cont_4144_general
type=line method=hermite threshold=3 look_ahead=7 reduction=50 slide=0.5
angle_thresh=3 degree_thresh=0 closeness_thresh=0 betweeness_thresh=0
alpha=1.0 beta=1.0 iterations=1 layer=1 --overwrite
[Thread debugging using libthread_db enabled]
[New Thread 0x2b33d27a2ce0 (LWP 16093)]
WARNING: Vector map <cont_4144_general> already exists and will be
          overwritten
Generalization (hermite)...
  100%
Building topology for vector map <cont_4144_general>...
Registering lines: v.generalize: index.c:157: RTreeInsertRect: Assertion
`r->boundary[i] <= r->boundary[3+i]' failed.

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x2b33d27a2ce0 (LWP 16093)]
0x00002b33cf082b45 in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x00002b33cf082b45 in raise () from /lib64/libc.so.6
#1 0x00002b33cf0840e0 in abort () from /lib64/libc.so.6
#2 0x00002b33cf07c07f in __assert_fail () from /lib64/libc.so.6
#3 0x00002b33ce27df3e in RTreeInsertRect (R=<value optimized out>,
Tid=<value optimized out>, Root=0x7fffddb5fa50, Level=0)
     at index.c:157
#4 0x00002b33ce075559 in dig_spidx_add_line (Plus=0x7fffddb5f840,
line=12, box=0x7fffddb5f5b0) at spindex.c:128
#5 0x00002b33ce071561 in dig_add_line (plus=0x7fffddb5f840, type=2,
Points=0x74ad50, offset=105753) at plus_line.c:133
#6 0x00002b33cd177cab in Vect_build_nat (Map=0x7fffddb5f830, build=4,
msgout=0x2b33cf391760) at build_nat.c:501
#7 0x00002b33cd1767a3 in Vect_build_partial (Map=0x7fffddb5f830, build=4,
msgout=0x2b33cf391760) at build.c:152
#8 0x0000000000404e23 in main (argc=19, argv=0xfffffffe) at main.c:489
}}}

OS: OpenSuSE 10.3 64bit
GRASS: svn-trunk rev. 29954

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/36&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

#36: v.generalize Assertion failed.
----------------------+-----------------------------------------------------
  Reporter: marisn | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords:
----------------------+-----------------------------------------------------
Comment (by wolf):

The assert happens inside Vlib (the vector library). Could you please test
v.build on a similar map, to see if it happens there too. Also can you
provide a sample map where this problem occurs.

Thank you,
--Wolf

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/36#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

#36: v.generalize Assertion failed.
----------------------+-----------------------------------------------------
  Reporter: marisn | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords:
----------------------+-----------------------------------------------------
Comment (by marisn):

1. Other vector modules run just fine (v.buid), also v.generalize runs
just fine with other methods (i.e. method=douglas) => IMHO it's a problem
within v.generalize;[[BR]]
2. Location with "guity" map:
http://www.gisnet.lv/ggmlinux/tomazio_modeli.tgz (2,6M)

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/36#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

Hello,

I just checked it and it works fine for me. I tried it with the map
and command you sent and everything was ok. What version of GRASS do
you use? As I remember, there were a few problems with hermite
interpolation some time ago, but it should be fixed now. The problem
occured when a line in the map contained two consecutive points at the
same position. If this is the case then you can remove such points
with v.generalize itself (method=reduction threshold=eps) or with
v.clean

Daniel

On Feb 5, 2008 2:12 PM, GRASS GIS <trac@osgeo.org> wrote:

#36: v.generalize Assertion failed.
---------------------+------------------------------------------------------
Reporter: marisn | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: default | Version: svn-trunk
Keywords: |
---------------------+------------------------------------------------------
{{{
(gdb) run -r input=cont_4144@PERMANENT output=cont_4144_general type=line
method=hermite threshold=3 look_ahead=7 reduction=50 slide=0.5
angle_thresh=3 degree_thresh=0 closeness_thresh=0 betweeness_thresh=0
alpha=1.0 beta=1.0 iterations=1 layer=1 --overwrite
Starting program: /home/maris/soft/grass_trunk/dist.x86_64-unknown-linux-
gnu/bin/v.generalize -r input=cont_4144@PERMANENT output=cont_4144_general
type=line method=hermite threshold=3 look_ahead=7 reduction=50 slide=0.5
angle_thresh=3 degree_thresh=0 closeness_thresh=0 betweeness_thresh=0
alpha=1.0 beta=1.0 iterations=1 layer=1 --overwrite
[Thread debugging using libthread_db enabled]
[New Thread 0x2b33d27a2ce0 (LWP 16093)]
WARNING: Vector map <cont_4144_general> already exists and will be
          overwritten
Generalization (hermite)...
  100%
Building topology for vector map <cont_4144_general>...
Registering lines: v.generalize: index.c:157: RTreeInsertRect: Assertion
`r->boundary[i] <= r->boundary[3+i]' failed.

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x2b33d27a2ce0 (LWP 16093)]
0x00002b33cf082b45 in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x00002b33cf082b45 in raise () from /lib64/libc.so.6
#1 0x00002b33cf0840e0 in abort () from /lib64/libc.so.6
#2 0x00002b33cf07c07f in __assert_fail () from /lib64/libc.so.6
#3 0x00002b33ce27df3e in RTreeInsertRect (R=<value optimized out>,
Tid=<value optimized out>, Root=0x7fffddb5fa50, Level=0)
     at index.c:157
#4 0x00002b33ce075559 in dig_spidx_add_line (Plus=0x7fffddb5f840,
line=12, box=0x7fffddb5f5b0) at spindex.c:128
#5 0x00002b33ce071561 in dig_add_line (plus=0x7fffddb5f840, type=2,
Points=0x74ad50, offset=105753) at plus_line.c:133
#6 0x00002b33cd177cab in Vect_build_nat (Map=0x7fffddb5f830, build=4,
msgout=0x2b33cf391760) at build_nat.c:501
#7 0x00002b33cd1767a3 in Vect_build_partial (Map=0x7fffddb5f830, build=4,
msgout=0x2b33cf391760) at build.c:152
#8 0x0000000000404e23 in main (argc=19, argv=0xfffffffe) at main.c:489
}}}

OS: OpenSuSE 10.3 64bit
GRASS: svn-trunk rev. 29954

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/36&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

#36: v.generalize Assertion failed.
----------------------+-----------------------------------------------------
  Reporter: marisn | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords:
----------------------+-----------------------------------------------------
Comment (by martinl):

Replying to [ticket:36 marisn]:
{{{
> (gdb) run -r input=cont_4144@PERMANENT output=cont_4144_general
type=line method=hermite threshold=3 look_ahead=7 reduction=50 slide=0.5
angle_thresh=3 degree_thresh=0 closeness_thresh=0 betweeness_thresh=0
alpha=1.0 beta=1.0 iterations=1 layer=1 --overwrite
> Starting program: /home/maris/soft/grass_trunk/dist.x86_64-unknown-
linux-gnu/bin/v.generalize -r input=cont_4144@PERMANENT
output=cont_4144_general type=line method=hermite threshold=3 look_ahead=7
reduction=50 slide=0.5 angle_thresh=3 degree_thresh=0 closeness_thresh=0
betweeness_thresh=0 alpha=1.0 beta=1.0 iterations=1 layer=1 --overwrite
> [Thread debugging using libthread_db enabled]
> [New Thread 0x2b33d27a2ce0 (LWP 16093)]
> WARNING: Vector map <cont_4144_general> already exists and will be
> overwritten
> Generalization (hermite)...
> 100%
> Building topology for vector map <cont_4144_general>...
> Registering lines: v.generalize: index.c:157: RTreeInsertRect: Assertion
`r->boundary[i] <= r->boundary[3+i]' failed.
>
> Program received signal SIGABRT, Aborted.
> [Switching to Thread 0x2b33d27a2ce0 (LWP 16093)]
> 0x00002b33cf082b45 in raise () from /lib64/libc.so.6
> (gdb) bt
> #0 0x00002b33cf082b45 in raise () from /lib64/libc.so.6
> #1 0x00002b33cf0840e0 in abort () from /lib64/libc.so.6
> #2 0x00002b33cf07c07f in __assert_fail () from /lib64/libc.so.6
> #3 0x00002b33ce27df3e in RTreeInsertRect (R=<value optimized out>,
Tid=<value optimized out>, Root=0x7fffddb5fa50, Level=0)
> at index.c:157
> #4 0x00002b33ce075559 in dig_spidx_add_line (Plus=0x7fffddb5f840,
line=12, box=0x7fffddb5f5b0) at spindex.c:128
> #5 0x00002b33ce071561 in dig_add_line (plus=0x7fffddb5f840, type=2,
Points=0x74ad50, offset=105753) at plus_line.c:133
> #6 0x00002b33cd177cab in Vect_build_nat (Map=0x7fffddb5f830, build=4,
msgout=0x2b33cf391760) at build_nat.c:501
> #7 0x00002b33cd1767a3 in Vect_build_partial (Map=0x7fffddb5f830,
build=4, msgout=0x2b33cf391760) at build.c:152
> #8 0x0000000000404e23 in main (argc=19, argv=0xfffffffe) at main.c:489
}}}

From ML by Daniel Bundala:

I just checked it and it works fine for me. I tried it with the map
and command you sent and everything was ok. What version of GRASS do
you use? As I remember, there were a few problems with hermite
interpolation some time ago, but it should be fixed now. The problem
occured when a line in the map contained two consecutive points at the
same position. If this is the case then you can remove such points
with v.generalize itself (method=reduction threshold=eps) or with
v.clean

Daniel

---

On my machine (Debian GNU/Linux, 32bit, grass-svn) I get the same error

{{{
Registering lines: v.generalize: index.c:157: RTreeInsertRect: Assertion
`r->boundary[i] <= r->boundary[3+i]' failed.
}}}

Martin

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/36#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

#36: v.generalize Assertion failed.
----------------------+-----------------------------------------------------
  Reporter: marisn | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords:
----------------------+-----------------------------------------------------
Comment (by martinl):

> On my machine (Debian GNU/Linux, 32bit, grass-svn) I get the same error
>
{{{
> Registering lines: v.generalize: index.c:157: RTreeInsertRect: Assertion
`r->boundary[i] <= r->boundary[3+i]' failed.
}}}

sorry, I forgot to add debug output

{{{
D3/5: Register node 391690.000000,392030.000000
D3/5: dig_find_node()
D3/5: node = 0
D3/5: dig_add_node(): n_nodes = 11, alloc_nodes = 1000
D3/5: dig_spidx_add_node(): node = 12, x,y,z = 391690.000000,
392030.000000, 0.000000
D3/5: new node = 12, n_nodes = 12, alloc_nodes = 1000
D3/5: Add new node: 12
D3/5: dig_node_add_line(): node = 12 line = -12
D3/5: dig_node_alloc_line(): add = 1
D5/5: dig_line_degenerate()
D3/5: angle = nan
D3/5: dig_node_add_line(): line -12 added position 1 n_lines: 1 angle nan
D3/5: dig_spidx_add_line(): line = 12
v.generalize: index.c:157: RTreeInsertRect: Assertion `r->boundary[i] <=
r->boundary[3+i]' failed.
Aborted
}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/36#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

Hello,

Finally, I had some time to look at it carefully. It seems to me that
the problem is the same as the one I mentioned earlier. I made a patch
some time ago, but for some obscure reasons, it did not propagate to
the SVN. I think that the patch should fix it as it is the only
difference between the version in SVN and on my computer.

Daniel

PS: I am not a big expert on CVS/SVN so the patch may be little out of date.....

Index: smoothing.c

RCS file: /home/grass/grassrepository/grass6/vector/v.generalize/smoothing.c,v
retrieving revision 1.2
diff -u -r1.2 smoothing.c
--- smoothing.c 3 Nov 2007 13:10:57 -0000 1.2
+++ smoothing.c 16 Dec 2007 18:35:00 -0000
@@ -258,7 +258,12 @@
void refine_tangent(POINT * p)
{
     double l = point_dist2(*p);
- point_scalar(*p, (double)1.0 / sqrt(sqrt(sqrt(l))), p);
+ if (l < 1e-12) {
+ point_scalar(*p, 0.0, p);
+ }
+ else {
+ point_scalar(*p, (double)1.0 / sqrt(sqrt(sqrt(l))), p);
+ }
     return;
}

@@ -281,7 +286,7 @@

     /* line is too short */
     if (n <= 2) {
- return 1;
+ return n;
     }

     /* convert degrees=>radians */

On Feb 5, 2008 5:49 PM, GRASS GIS <trac@osgeo.org> wrote:

#36: v.generalize Assertion failed.
----------------------+-----------------------------------------------------
  Reporter: marisn | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords:
----------------------+-----------------------------------------------------
Comment (by martinl):

> On my machine (Debian GNU/Linux, 32bit, grass-svn) I get the same error
>
{{{
> Registering lines: v.generalize: index.c:157: RTreeInsertRect: Assertion
`r->boundary[i] <= r->boundary[3+i]' failed.
}}}

sorry, I forgot to add debug output

{{{
D3/5: Register node 391690.000000,392030.000000
D3/5: dig_find_node()
D3/5: node = 0
D3/5: dig_add_node(): n_nodes = 11, alloc_nodes = 1000
D3/5: dig_spidx_add_node(): node = 12, x,y,z = 391690.000000,
392030.000000, 0.000000
D3/5: new node = 12, n_nodes = 12, alloc_nodes = 1000
D3/5: Add new node: 12
D3/5: dig_node_add_line(): node = 12 line = -12
D3/5: dig_node_alloc_line(): add = 1
D5/5: dig_line_degenerate()
D3/5: angle = nan
D3/5: dig_node_add_line(): line -12 added position 1 n_lines: 1 angle nan
D3/5: dig_spidx_add_line(): line = 12
v.generalize: index.c:157: RTreeInsertRect: Assertion `r->boundary[i] <=
r->boundary[3+i]' failed.
Aborted
}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/36#comment:4&gt;

GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

#36: v.generalize Assertion failed.
----------------------+-----------------------------------------------------
  Reporter: marisn | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords:
----------------------+-----------------------------------------------------
Comment (by hamish):

Daniel Bundala wrote on grass-dev:
> Hello,
>
> Finally, I had some time to look at it carefully. It seems to me that
> the problem is the same as the one I mentioned earlier. I made a patch
> some time ago, but for some obscure reasons, it did not propagate to
> the SVN. I think that the patch should fix it as it is the only
> difference between the version in SVN and on my computer.
>
> Daniel
>
> PS: I am not a big expert on CVS/SVN so the patch may be little out of
> date.....

The patch applied fine, now in SVN/trunk (r30050) and 6.3 release branch
(r30051). It still needs testing.

Should it use GRASS_EPSILON from include/gis.h instead of hardcoded 1e-12
?

just do:
{{{
$ svn up vector/v.generalize
# make changes
$ vi vector/v.generalize/smoothing.c
# check it
$ svn diff vector/v.generalize
$ svn diff vector/v.generalize > v.gen_fix.diff
}}}

"svn up" after changes should try and merge in any new updates which don't
directly conflict.

Hamish

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/36#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

Yes, it should use GRASS_EPSILON. Can someone please change it? And as
far as I remember, there is one more hard-coded constant just a few
lines belows.
Thanks

Daniel

On Feb 10, 2008 9:10 AM, GRASS GIS <trac@osgeo.org> wrote:

#36: v.generalize Assertion failed.
----------------------+-----------------------------------------------------
  Reporter: marisn | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords:
----------------------+-----------------------------------------------------
Comment (by hamish):

Daniel Bundala wrote on grass-dev:
> Hello,
>
> Finally, I had some time to look at it carefully. It seems to me that
> the problem is the same as the one I mentioned earlier. I made a patch
> some time ago, but for some obscure reasons, it did not propagate to
> the SVN. I think that the patch should fix it as it is the only
> difference between the version in SVN and on my computer.
>
> Daniel
>
> PS: I am not a big expert on CVS/SVN so the patch may be little out of
> date.....

The patch applied fine, now in SVN/trunk (r30050) and 6.3 release branch
(r30051). It still needs testing.

Should it use GRASS_EPSILON from include/gis.h instead of hardcoded 1e-12
?

just do:
{{{
$ svn up vector/v.generalize
# make changes
$ vi vector/v.generalize/smoothing.c
# check it
$ svn diff vector/v.generalize
$ svn diff vector/v.generalize > v.gen_fix.diff
}}}

"svn up" after changes should try and merge in any new updates which don't
directly conflict.

Hamish

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/36#comment:5&gt;

GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

#36: v.generalize Assertion failed.
----------------------+-----------------------------------------------------
  Reporter: marisn | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords:
----------------------+-----------------------------------------------------
Comment (by neteler):

Done:

http://trac.osgeo.org/grass/changeset/30055

I also fixed that no exit() needed after G_fatal_error().
The second constant I didn't find, though.
Please tell us the line number:
http://trac.osgeo.org/grass/browser/grass/trunk/vector/v.generalize/smoothing.c

Markus

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/36#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

#36: v.generalize Assertion failed.
----------------------+-----------------------------------------------------
  Reporter: marisn | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: closed
  Priority: major | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: fixed | Keywords:
----------------------+-----------------------------------------------------
Changes (by marisn):

  * status: new => closed
  * resolution: => fixed

Comment:

Seems to be fixed now. No crash here anymore :slight_smile:

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/36#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/

Thanks,

Line is 317. Very end of if-statement

Daniel

On Feb 10, 2008 3:55 PM, GRASS GIS <trac@osgeo.org> wrote:

#36: v.generalize Assertion failed.
----------------------+-----------------------------------------------------
  Reporter: marisn | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: default | Version: svn-trunk
Resolution: | Keywords:
----------------------+-----------------------------------------------------
Comment (by neteler):

Done:

http://trac.osgeo.org/grass/changeset/30055

I also fixed that no exit() needed after G_fatal_error().
The second constant I didn't find, though.
Please tell us the line number:
http://trac.osgeo.org/grass/browser/grass/trunk/vector/v.generalize/smoothing.c

Markus

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/36#comment:6&gt;

GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

> #36: v.generalize Assertion failed.

[GRASS_EPSILON]

Daniel Bundala wrote:

Thanks,

Line is 317. Very end of if-statement

How about the one on smoothing.c line 169?

Hamish

      ____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping

On Feb 10, 2008 8:03 PM, Hamish <hamish_b@yahoo.com> wrote:

> > #36: v.generalize Assertion failed.
[GRASS_EPSILON]

Daniel Bundala wrote:

> Thanks,
>
> Line is 317. Very end of if-statement

How about the one on smoothing.c line 169?

Fixed.

Markus