diff options
Diffstat (limited to 'Geocoding')
-rw-r--r-- | Geocoding/Match.pm | 54 | ||||
-rw-r--r-- | Geocoding/Result.pm | 23 |
2 files changed, 23 insertions, 54 deletions
diff --git a/Geocoding/Match.pm b/Geocoding/Match.pm deleted file mode 100644 index b4a7675..0000000 --- a/Geocoding/Match.pm +++ /dev/null @@ -1,54 +0,0 @@ -package Geo::USCensus::Geocoding::Match; - -use strict; -use Data::Dumper; - -sub new { - my $class = shift; - my $address = shift; - my $census = shift; - - my $self = { %$address }; - bless $self, $class; -} - -sub matchedAddress { - my $self = shift; - $self->{matchedAddress}; -} - -sub coordinates { - my $self = shift; - $self->{coordinates}; -} - -sub addressComponents { - my $self = shift; - $self->{addressComponents}; -} - -sub geographies { - my $self = 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; - my $block = $self->block_info or return ''; - return $block->{STATE} . $block->{COUNTY} . $block->{TRACT}; -} - -1; diff --git a/Geocoding/Result.pm b/Geocoding/Result.pm new file mode 100644 index 0000000..e0e271a --- /dev/null +++ b/Geocoding/Result.pm @@ -0,0 +1,23 @@ +package Geo::USCensus::Geocoding::Result; + +use Moo; # just for attribute declaration + +has 'is_match' => ( is => 'rw', default => 0 ); +has [ 'content', + 'match_level', + 'address', + 'state', + 'county', + 'tract', + 'block', + 'error_message', + 'latitude', + 'longitude' + ] => ( is => 'rw', default => '' ); + +sub censustract { + my $self = shift; + return join('', $self->state, $self->county, $self->tract); +} + +1; |