From 83646ffc2d229a706bdf3f90bf3cc8834c03106f Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Sun, 30 Nov 2014 13:01:27 -0800 Subject: adjustments --- Geocoding/Match.pm | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'Geocoding') 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; -- cgit v1.2.1