Update from http to https URL
[Geo-USCensus-Geocoding.git] / Geocoding.pm
index b1f3ea7..edc3ad7 100644 (file)
@@ -12,13 +12,9 @@ use Text::CSV;
 
 Geo::USCensus::Geocoding - The U.S. Census Bureau geocoding service
 
-=head1 VERSION
-
-Version 0.01
-
 =cut
 
-our $VERSION = '0.01';
+our $VERSION = '0.02';
 our $DEBUG = 0;
 
 =head1 SYNOPSIS
@@ -61,7 +57,7 @@ Returns an object of class Geo::USCensus::Geocoding::Result.
 =cut
 
 my $ua = LWP::UserAgent->new;
-my $url = 'http://geocoding.geo.census.gov/geocoder/geographies/addressbatch';
+my $url = 'https://geocoding.geo.census.gov/geocoder/geographies/addressbatch';
 
 my $csv = Text::CSV->new({eol => "\n", binary => 1});
 
@@ -128,15 +124,16 @@ sub query {
       $result->is_match(1);
       $result->match_level($fields[3]);
       $result->address($fields[4]);
-      my ($lat, $long) = split(',', $fields[5]);
-      $result->latitude($lat);
+      my ($long, $lat) = split(',', $fields[5]);
       $result->longitude($long);
+      $result->latitude($lat);
       $result->state($fields[8]);
       $result->county($fields[9]);
       $result->tract($fields[10]);
       $result->block($fields[11]);
     } else {
       $result->is_match(0);
+      $result->match_level($fields[2]); # "No_Match", "Tie"
     }
   } else {
     $result->error_message( $resp->status_line );
@@ -162,6 +159,7 @@ Services:
 =head1 LICENSE AND COPYRIGHT
 
 Copyright (C) 2014 Mark Wells.
+Copyright (C) 2016 Freeside Internet Services, Inc.
 
 This program is free software; you can redistribute it and/or modify it
 under the terms of either: the GNU General Public License as published