Algorithm-SpatialIndex
view release on metacpan or search on metacpan
lib/Algorithm/SpatialIndex/Storage/DBI.pm view on Meta::CPAN
$sth->finish;
return if not defined $struct;
my $coords = $self->no_of_coords;
my $snodes = [@{$struct}[1+$coords..$coords+$self->no_of_subnodes]];
$snodes = [] if not defined $snodes->[0];
my $node = Algorithm::SpatialIndex::Node->new(
id => $struct->[0],
coords => [@{$struct}[1..$coords]],
subnode_ids => $snodes,
);
#use Data::Dumper; warn "FETCH: " . Dumper($node);
return $node;
}
sub store_node {
my $self = shift;
my $node = shift;
#use Data::Dumper;
#use Data::Dumper; warn "STORE: " . Dumper($node);
my $id = $node->id;
my $dbh = $self->dbh_rw;
my $tname = $self->table_prefix . '_nodes';
my $sth;
if (not defined $id) {
$sth = $dbh->prepare_cached($self->{_write_new_node_sql});
my $coords = $node->coords;
my $snids = $node->subnode_ids;
my @args = (
@$coords,
lib/Algorithm/SpatialIndex/Storage/DBI.pm view on Meta::CPAN
my $update_sql = qq{UPDATE $tname SET id=?, $insert_id_list};
$self->{buckets_insert_sql} = sub {
my $dbh = shift;
eval {
$dbh->do($insert_sql, {}, @_, (undef) x ($nentries-@_));
$dbh->do($update_sql, {}, @_, (undef) x ($nentries-@_));
1;
};
};
}
#use Data::Dumper;
#warn Dumper $self->{buckets_insert_sql};
}
1;
__END__
=head1 AUTHOR
Steffen Mueller, E<lt>smueller@cpan.orgE<gt>
( run in 0.226 second using v1.01-cache-2.11-cpan-4d50c553e7e )