summaryrefslogtreecommitdiff
path: root/FS/FS
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-11-06 12:14:34 -0800
committerMark Wells <mark@freeside.biz>2013-11-06 12:14:34 -0800
commite269e80233f594ce1387bdfcdba7dbf4861345c2 (patch)
tree0140d4f76ef8fc517f7b213315b8fe8f2043073a /FS/FS
parent68ea5044ea3a83aaa2e9ba0ac3a3ae6908e6f439 (diff)
TomTom: return a definite error on incomplete matches, #25261
Diffstat (limited to 'FS/FS')
-rw-r--r--FS/FS/Misc/Geo.pm11
1 files changed, 9 insertions, 2 deletions
diff --git a/FS/FS/Misc/Geo.pm b/FS/FS/Misc/Geo.pm
index f3263f6d8..aa755643f 100644
--- a/FS/FS/Misc/Geo.pm
+++ b/FS/FS/Misc/Geo.pm
@@ -447,6 +447,12 @@ sub standardize_tomtom {
my ($address1, $address2) = ($location->{address1}, $location->{address2});
my $subloc = '';
+ # trim whitespace
+ $address1 =~ s/^\s+//;
+ $address1 =~ s/\s+$//;
+ $address2 =~ s/^\s+//;
+ $address2 =~ s/\s+$//;
+
# try to fix some cases of the address fields being switched
if ( $address2 =~ /^\d/ and $address1 !~ /^\d/ ) {
$address2 = $address1;
@@ -487,8 +493,8 @@ sub standardize_tomtom {
}
}
- if (!$match) {
- die "Location not found.\n";
+ if ( !$match or !$clean ) { # partial matches are not useful
+ die "Address not found\n";
}
my $tract = '';
if ( defined $match->{censusTract} ) {
@@ -642,6 +648,7 @@ sub subloc_address2 {
warn "normalizing '$addr2' to '$result'\n" if $DEBUG > 1;
$addr2 = $result;
}
+ $addr2 = '' if $addr2 eq $subloc; # if it was entered redundantly
($subloc, $addr2);
}