diff options
Diffstat (limited to 'Geocoding/Match.pm')
-rw-r--r-- | Geocoding/Match.pm | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/Geocoding/Match.pm b/Geocoding/Match.pm index 6584203..b4a7675 100644 --- a/Geocoding/Match.pm +++ b/Geocoding/Match.pm @@ -1,6 +1,7 @@ package Geo::USCensus::Geocoding::Match; use strict; +use Data::Dumper; sub new { my $class = shift; @@ -31,13 +32,23 @@ sub geographies { $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; |