summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2014-11-30 13:01:27 -0800
committerMark Wells <mark@freeside.biz>2014-11-30 13:01:27 -0800
commit83646ffc2d229a706bdf3f90bf3cc8834c03106f (patch)
tree8905058d84afd2ab8b2bee1462801a609fa7019b
parent2abefcaec0a7fbc3f320e0c251de81144ca6bd93 (diff)
adjustments
-rw-r--r--Geocoding.pm9
-rw-r--r--Geocoding/Match.pm21
-rwxr-xr-xdebian/rules3
-rw-r--r--t/01-lookup.t2
4 files changed, 26 insertions, 9 deletions
diff --git a/Geocoding.pm b/Geocoding.pm
index c64c590..a7e5ba1 100644
--- a/Geocoding.pm
+++ b/Geocoding.pm
@@ -19,7 +19,7 @@ Version 0.01
=cut
our $VERSION = '0.01';
-our $DEBUG = 1;
+our $DEBUG = 0;
=head1 SYNOPSIS
@@ -34,6 +34,8 @@ our $DEBUG = 1;
# 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);
@@ -62,8 +64,8 @@ my $api_uri = 'http://geocoding.geo.census.gov/geocoder/geographies/address';
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] });
@@ -71,6 +73,7 @@ sub query {
%opt = (%opt, @_);
}
+ $DEBUG = $opt{debug} || 0;
$opt{format} = 'json';
foreach (qw(street city state zip)) {
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;
diff --git a/debian/rules b/debian/rules
index 2d33f6a..eb511c7 100755
--- a/debian/rules
+++ b/debian/rules
@@ -2,3 +2,6 @@
%:
dh $@
+override_dh_auto_install:
+ dh_auto_install
+ rm -f `find debian/ -name perllocal.pod`
diff --git a/t/01-lookup.t b/t/01-lookup.t
index 11c8b37..ad780e2 100644
--- a/t/01-lookup.t
+++ b/t/01-lookup.t
@@ -6,7 +6,7 @@ use Geo::USCensus::Geocoding;
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',