From: Mark Wells Date: Fri, 2 Nov 2012 21:28:04 +0000 (-0700) Subject: rename teleatlas to "EZLocate" and switch to our API wrapper X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2F13763;hp=ee3fd4e95bdc52f15b0603a32363778f72d164ef;p=freeside.git rename teleatlas to "EZLocate" and switch to our API wrapper --- diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 43521ce19..902c036d4 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -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 the TomTom website for access and pricing information.', 'type' => 'text', }, { - 'key' => 'teleatlas-userid', + 'key' => 'ezlocate-password', 'section' => 'UI', - 'description' => 'User ID for TeleAtlas EZ-Locate service. See the Tele Atlas website 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' }, { diff --git a/FS/FS/Misc/Geo.pm b/FS/FS/Misc/Geo.pm index b727fa7e9..6bc71fc84 100644 --- a/FS/FS/Misc/Geo.pm +++ b/FS/FS/Misc/Geo.pm @@ -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$/; {