Geo-ShapeFile
view release on metacpan or search on metacpan
lib/Geo/ShapeFile.pm view on Meta::CPAN
package Geo::ShapeFile;
use strict;
use warnings;
use Carp;
use IO::File;
use Geo::ShapeFile::Shape;
use Config;
use List::Util qw /min max/;
use Scalar::Util qw/weaken/;
use Tree::R;
use constant ON_WINDOWS => ($^O eq 'MSWin32');
use if ON_WINDOWS, 'Win32::LongPath';
our $VERSION = '3.03';
my $little_endian_sys = unpack 'b', (pack 'S', 1 );
# Preloaded methods go here.
sub new {
my $proto = shift;
my $filebase = shift || croak "Must specify filename!";
my $args = shift || {}; # should check it's a haashref
my $class = ref($proto) || $proto;
my $self = {};
$self->{filebase} = $filebase;
# should use a proper file name handler
# so we can deal with fred.ext referring to fred.ext.shp
$self->{filebase} =~ s/\.\w{3}$//;
$self->{_enable_caching} = {
shp => 1,
dbf => 1,
shx => 1,
shapes_in_area => 1,
};
$self->{has_shx} = 0;
$self->{has_shp} = 0;
$self->{has_dbf} = 0;
bless $self, $class;
# control overall caching
if ($args->{no_cache}) {
$self->{_no_cache} = 1;
}
# not sure what this does - possible residual from early plans
$self->{_change_cache} = {
shape_type => undef,
records => undef,
shp => {},
dbf => {},
shx => {},
};
$self->{_object_cache} = {
shp => {},
dbf => {},
shx => {},
shapes_in_area => {},
};
if ($self->file_exists ($self->{filebase} . '.shx')) {
$self->_read_shx_header();
$self->{has_shx} = 1;
}
( run in 0.746 second using v1.01-cache-2.11-cpan-39bf76dae61 )