in reply to Re^3: Geo::ShapeFile memory problem
in thread Geo::ShapeFile memory problem
Also, one thing to watch for in any plotting code is holes in the polygons. I don't think the Tiger data have holes
Ooooo they do.. found that pdf about 9 hours before you mentioned it. Im dealing with them now, at a huge cost, maybe more later.
Ill live with unzipped dirs for now, and look closer into "seek"ing on a zip file and into the format of a raw shp file. to see if my sequential reader would work for sequential access.
My cheap zip sequencer
This will probably get improvements so i can read 2 files out of the same zip at the same time without doing two my $zip=new ... $zip->read($zf) sets, havent needed it yet.package cheap::zipbyline; use strict; use warnings; use Exporter; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); our @ISA= qw( Exporter ); # these CAN be exported. our @EXPORT_OK = qw( zipbyline_start zipbyline_read zipbyline_close ); # these are exported by default. our @EXPORT = qw( ); my %zbl; sub zipbyline_start { my $zf=shift; my $mf=shift; my $zip = Archive::Zip->new(); unless ( $zip->read( $zf ) == AZ_OK ) { die 'read error';} my ( $member, $status, $bufferRef ); $member = $zip->memberNamed( $mf ); $member->desiredCompressionMethod( COMPRESSION_STORED ); $status = $member->rewindData(); die "error $status" unless $status == AZ_OK; $zbl{$member}=''; return $member; } # zbl start sub zipbyline_read { my $member=shift; my ( $status, $bufferRef ); my $nl=index($zbl{$member},"\n"); while ( ( $nl == -1) && ! $member->readIsDone() ) { ( $bufferRef, $status ) = $member->readChunk(1000); die "error $status" if $status != AZ_OK && $status != AZ_STREAM_END; # do something with $bufferRef: $zbl{$member}.=$$bufferRef; $nl=index($zbl{$member},"\n"); } # while if ($nl == -1 ) {$zbl{$member}=undef; return $zbl{$member};} my $line=substr($zbl{$member},0,$nl+1); $zbl{$member}=substr($zbl{$member},$nl+1); return $line; } # zbl sub zipbyline_close { my $member=shift; delete $zbl{$member}; } # zbl close
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Geo::ShapeFile memory problem
by pmqs (Friar) on Apr 23, 2017 at 19:33 UTC | |
by huck (Prior) on Apr 27, 2017 at 01:21 UTC | |
by pmqs (Friar) on Apr 27, 2017 at 11:14 UTC | |
by huck (Prior) on Apr 27, 2017 at 13:15 UTC | |
by swl (Prior) on Apr 24, 2017 at 22:46 UTC |