=cut
our $VERSION = '0.01';
-our $DEBUG = 1;
+our $DEBUG = 0;
=head1 SYNOPSIS
# optional fields
benchmark => 'Public_AR_ACS2013', # default is "Public_AR_Current"
vintage => 'Census2010_ACS2013', # default is "Current_Current"
+
+ debug => 1, # will print the URL and some other info
};
my $result = Geo::USCensus::Geocoding->query($request);
sub query {
my $class = shift;
my %opt = (
- benchmark => 'Public_AR_Current',
- vintage => 'Current_Current',
+ benchmark => 'Public_AR_Census2010',
+ vintage => 'Census2010_Census2010',
);
if (ref $_[0] eq 'HASH') {
%opt = (%opt, %{ $_[0] });
%opt = (%opt, @_);
}
+ $DEBUG = $opt{debug} || 0;
$opt{format} = 'json';
foreach (qw(street city state zip)) {
package Geo::USCensus::Geocoding::Match;
use strict;
+use Data::Dumper;
sub new {
my $class = shift;
$self->{geographies};
}
+sub block_info {
+ my $self = shift;
+ my $geo = $self->{geographies};
+ my $block_info = $geo->{'2010 Census Blocks'}; # XXX change this in 2020
+ if ($block_info and exists($block_info->[0])) {
+ return $block_info->[0];
+ } else {
+ warn "2010 Census Blocks element not found in response\n";
+ warn Dumper $self->{geographies};
+ return '';
+ }
+}
+
sub censustract {
my $self = shift;
- return '' unless $self->geographies
- and exists($self->geographies->{'Census Tracts'})
- and exists($self->geographies->{'Census Tracts'}->[0]);
- my $ct = $self->geographies->{'Census Tracts'}->[0];
- return $ct->{STATE} . $ct->{COUNTY} . $ct->{TRACT};
+ my $block = $self->block_info or return '';
+ return $block->{STATE} . $block->{COUNTY} . $block->{TRACT};
}
1;
%:
dh $@
+override_dh_auto_install:
+ dh_auto_install
+ rm -f `find debian/ -name perllocal.pod`
diag( "Testing lookup of a known good address" );
my $result = Geo::USCensus::Geocoding->query(
- street => '1526 H St', # the California Governor's Mansion
+ street => '1400 J St', # the Sacramento Convention Center
city => 'Sacramento',
state => 'CA',
zip => '95814',