So, I was using the Tree::R module, and I ran into a strange problem, so I wrote a small unit test to test the problem, and it appears the source of the bug may be in Tree::R itself. The underlying cause seems to be that when you remove everything from a Tree::R object and then insert something back into the same Tree::R object, the resulting number of objects in the Tree is no longer correct. Here's a small unit test that reproduces the bug:
use strict; use warnings; use Test::More tests => 5; BEGIN { use_ok('Tree::R'); } my $r_tree = Tree::R->new(); isa_ok($r_tree, 'Tree::R'); my $rects = { 1 => [0, 0, 10, 20], 2 => [20, 0, 10, 20], 3 => [0, 30, 10, 20], 4 => [20, 30, 10, 20], }; for my $rect (keys %$rects) { $r_tree->insert($rect, @{$rects->{$rect}}); } { my @objects; $r_tree->objects(\...@objects); is(scalar(@objects), 4); } for my $rect (keys %$rects) { $r_tree->remove($rect); } { my @objects; $r_tree->objects(\...@objects); is(scalar(@objects), 0); } $r_tree->insert($rects->{1}, @{$rects->{1}}); { my @objects; $r_tree->objects(\...@objects); is(scalar(@objects), 1); } In this unit test, the last test fails for me. Instead of the value 1, I got 2. I don't believe that this is the intended behavior -- Brandon Forehand _______________________________________________ Freegis-list mailing list Freegis-list@intevation.de https://www.intevation.de/mailman/listinfo/freegis-list