Geo::UK::Postcode::CodePointOpen - Utility object to extract OS Code-Point Open data for British Postcodes
use Geo::UK::Postcode::CodePointOpen;
my $code_point_open = Geo::UK::Postcode::CodePointOpen->new( path => ... );
my $metadata = $code_point_open->metadata();
my $iterator = $code_point_open->read_iterator();
while ( my $pc = $iterator->() ) {
...;
}
my $batch_iterator = $code_point_open->batch_iterator();
while ( my @batch = $batch_iterator->() ) {
...;
}
# Just access data files (as Path::Tiny objects)
my @data_files = sort $self->data_dir->children( qr/\.csv$/ );
Util object to read OS Code-Point Open data.
Set at construction to the directory containing the contents of the OS Code-Point Open Zip file.
Path::Tiny objects for the documentation and CSV data directories.
Hashref parsed from the Doc/metadata.txt
file. Contains postcode counts
per area, date data generated, etc.
my $code_point_open = Geo::UK::Postcode::CodePointOpen->new(
path => ..., # path to Unzipped Code-Point Open directory
);
Constructor.
my $iterator = $code_point_open->read_iterator(
outcodes => [...], # specify certain outcodes
short_column_names => 1, # default is false (long names)
include_lat_long => 1, # default is false
split_postcode => 1, # split into outcode/incode
);
while ( my $pc = $iterator->() ) {
...
}
Returns a coderef iterator. Call that coderef repeatedly to get a hashref of data for each postcode in data files.
my $batch_iterator = $code_point_open->batch_iterator(
outcodes => [...], # specify certain outcodes
batch_size => 100, # number per batch (default 100)
short_column_names => 1, # default is false (long names)
include_lat_long => 1, # default is false
split_postcode => 1, # split into outcode/incode
);
while ( my @batch = $batch_iterator->() ) {
...
}
Returns a coderef iterator. Call that coderef repeatedly to get a list of postcode hashrefs.
my @data_files = $code_point_open->data_files(
qw/ AB10 AT3 WC /
);
Returns list of data files matching a supplied list of outcodes or data areas.
NOTE - doesn't check that the outcode(s) exist within the list of returned files - an invalid outcode will return a matching file, provided the area (non-digit part of outcode) is valid.
Michael Jemmeson mjemmeson@cpan.org
Copyright 2014- Michael Jemmeson
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.