| 1 | package WebService::StreetMapLink::MapQuest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use Geography::States; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use base 'WebService::StreetMapLink'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | __PACKAGE__->RegisterSubclass(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 5 | my %Query = ( usa => { countryid => 'US', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | country => 'US', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | canada => { countryid => 41, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | country => 'CA', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 5 | my @Accents = ( [ qr/[\xE0-\xE2]/ => 'a' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | [ qr/[\xE8-\xEA]/ => 'e' ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | [ qr/\xE7/ => 'c' ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | [ qr/\xF4/ => 'o' ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 5 | ▶ | sub Countries { keys %Query } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Countries: called CC=1 SCAR=0.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | sub new | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 5 | ▶ | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=14 SCAR=28.6
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 5 | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 5 | my %p = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 5 | local $_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # remove accents from state names like Quebec or mapquest gets upset | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 5 | for ( grep { defined } values %p ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 26 | foreach my $p (@Accents) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 104 | s/$p->[0]/$p->[1]/g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 5 | ▶ | if ( defined $p{state} ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 5 | ▶ | if ( length $p{state} > 2 ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | $p{state} = Geography::States->new( $p{country} )->state( $p{state} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | return | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | unless ( defined $p{address} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | && | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ( ( defined $p{city} && defined $p{state} ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | || | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | defined $p{postal_code} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 5 | ▶ | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
defined $p{"address"} and defined $p{"city"} && defined $p{"state"} || defined $p{"postal_code"}
defined $p{"city"} and defined $p{"state"} or defined $p{"postal_code"}
defined $p{"city"} and defined $p{"state"}
MC/DC0%0/4
defined $p{"address"} and defined $p{"city"} && defined $p{"state"} || defined $p{"postal_code"}
defined $p{"address"}
defined $p{"city"}
defined $p{"state"}
defined $p{"postal_code"}
Truth table16%1/6
A and B and C or D
A= defined $p{"address"}B= defined $p{"city"}C= defined $p{"state"}D= defined $p{"postal_code"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 5 | ▶ | return if $p{address} =~ /p\.?o\.\s+box/i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 5 | my %query = %{ $Query{ $p{country} } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 5 | foreach my $k ( qw( address city state ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | $query{$k} = $p{$k} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 15 | ▶ | if defined $p{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | $query{zip} = $p{postal_code} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 5 | ▶ | if defined $p{postal_code}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 5 | ▶ | $query{zoom} = $p{zoom} || 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$p{'zoom'} || 8
MC/DC100%1/1
$p{'zoom'} || 8
$p{'zoom'}
Truth table100%2/2
A
A= $p{'zoom'}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 5 | return bless { host => 'www.mapquest.com', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | path => '/maps/map.adp', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | query => \%query, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | }, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 5 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | __END__ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||