rename teleatlas to "EZLocate" and switch to our API wrapper 13763
authorMark Wells <mark@freeside.biz>
Fri, 2 Nov 2012 21:28:04 +0000 (14:28 -0700)
committerMark Wells <mark@freeside.biz>
Fri, 2 Nov 2012 21:28:04 +0000 (14:28 -0700)
FS/FS/Conf.pm
FS/FS/Misc/Geo.pm

index 43521ce..902c036 100644 (file)
@@ -4056,7 +4056,7 @@ and customer address. Include units.',
     'type'        => 'select',
     'select_hash' => [ '' => '', 
                        'usps' => 'U.S. Postal Service',
-                       'teleatlas' => 'TeleAtlas',
+                       'ezlocate' => 'EZLocate',
                      ],
   },
 
@@ -4075,24 +4075,17 @@ and customer address. Include units.',
   },
 
   {
-    'key'         => 'teleatlas-path',
+    'key'         => 'ezlocate-userid',
     'section'     => 'UI',
-    'description' => 'Path to TeleAtlas libraries on the Freeside server.',
+    'description' => 'User ID for EZ-Locate service.  See <a href="http://www.geocode.com/">the TomTom website</a> for access and pricing information.',
     'type'        => 'text',
   },
 
   {
-    'key'         => 'teleatlas-userid',
+    'key'         => 'ezlocate-password',
     'section'     => 'UI',
-    'description' => 'User ID for TeleAtlas EZ-Locate service.  See <a href="http://www.geocode.com/">the Tele Atlas website</a> for access and pricing information.',
-    'type'        => 'text',
-  },
-
-  {
-    'key'         => 'teleatlas-password',
-    'section'     => 'UI',
-    'description' => 'Password for TeleAtlas EZ-Locate service.',
-    'type'        => 'text',
+    'description' => 'Password for EZ-Locate service.',
+    'type'        => 'text'
   },
 
   {
index b727fa7..6bc71fc 100644 (file)
@@ -328,7 +328,7 @@ sub standardize_usps {
     addr_clean=> 'Y' }
 }
 
-my %teleatlas_error = ( # USA_Geo_002 documentation
+my %ezlocate_error = ( # USA_Geo_002 documentation
   10  => 'State not found',
   11  => 'City not found',
   12  => 'Invalid street address',
@@ -338,35 +338,37 @@ my %teleatlas_error = ( # USA_Geo_002 documentation
   17  => 'Intersection not found', #unused?
 );
 
-sub standardize_teleatlas {
+sub standardize_ezlocate {
   my $self = shift;
   my $location = shift;
   my $class;
-  if ( $location->{country} eq 'US' ) {
-    $class = 'USA_Geo_004Tool';
-  }
-  elsif ( $location->{country} eq 'CA' ) {
-    $class = 'CAN_Geo_001Tool';
-  }
-  else { # shouldn't be a fatal error, just pass through unverified address
-    warn "standardize_teleatlas: address lookup in '".$location->{country}.
-         "' not available\n";
-    return $location;
-  }
-
-  my $path = $conf->config('teleatlas-path') || '';
-  local @INC = (@INC, $path);
-  eval "use $class;";
-  if ( $@ ) {
-    die "Loading $class failed:\n$@".
-        "\nMake sure the TeleAtlas Perl SDK is installed correctly.\n";
-  }
-
-  my $userid = $conf->config('teleatlas-userid')
-    or die "no teleatlas-userid configured\n";
-  my $password = $conf->config('teleatlas-password')
-    or die "no teleatlas-password configured\n";
+  #if ( $location->{country} eq 'US' ) {
+  #  $class = 'USA_Geo_004Tool';
+  #}
+  #elsif ( $location->{country} eq 'CA' ) {
+  #  $class = 'CAN_Geo_001Tool';
+  #}
+  #else { # shouldn't be a fatal error, just pass through unverified address
+  #  warn "standardize_teleatlas: address lookup in '".$location->{country}.
+  #       "' not available\n";
+  #  return $location;
+  #}
+  #my $path = $conf->config('teleatlas-path') || '';
+  #local @INC = (@INC, $path);
+  #eval "use $class;";
+  #if ( $@ ) {
+  #  die "Loading $class failed:\n$@".
+  #      "\nMake sure the TeleAtlas Perl SDK is installed correctly.\n";
+  #}
+
+  $class = 'Geo::EZLocate'; # use our own library
+  eval "use $class";
+  die $@ if $@;
 
+  my $userid = $conf->config('ezlocate-userid')
+    or die "no ezlocate-userid configured\n";
+  my $password = $conf->config('ezlocate-password')
+    or die "no ezlocate-password configured\n";
   
   my $tool = $class->new($userid, $password);
   my $match = $tool->findAddress(
@@ -375,9 +377,9 @@ sub standardize_teleatlas {
     $location->{state},
     $location->{zip}, #12345-6789 format is allowed
   );
-  warn "teleatlas returned match:\n".Dumper($match) if $DEBUG > 1;
+  warn "ezlocate returned match:\n".Dumper($match) if $DEBUG > 1;
   # error handling - B codes indicate success
-  die $teleatlas_error{$match->{MAT_STAT}}."\n"
+  die $ezlocate_error{$match->{MAT_STAT}}."\n"
     unless $match->{MAT_STAT} =~ /^B\d$/;
 
   {