Subject: | Geo::Shapefile - Caching |
Hi,
I have a list of million points, which I need to match against a big
shapefile of polygons. For starters I tried just 2000 points. The job
took me above 17 hrs.
In the hopes of some improvements, I looked through the source code and
found that the author has already though about Caching, but it didn't
seem to be working.
I did a small fix (locally) in the "cache" method and the same 2000
points matching too just 15 mins.
#
# In the following if condition .. replace (@_) instead of ($@)
# clearly a typo.
#
if($@) {
$self->{_object_cache}->{$type}->{$obj} = shift;
}
Thanks for the module, it has helped me a big time.
- Saver
----------------------------------------------------
Original code:
package Geo::ShapeFile;
sub cache {
my $self = shift;
my $type = shift;
my $obj = shift;
if($self->{_change_cache}->{$type} &&
$self->{_change_cache}->{$type}->{$obj}) {
return $self->{_change_cache}->{$type}->{$obj};
}
return unless $self->caching($type);
if($@) {
$self->{_object_cache}->{$type}->{$obj} = shift;
}
return $self->{_object_cache}->{$type}->{$obj};
}