-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b32530
commit 313bda2
Showing
6 changed files
with
214 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ t/admin2.t | |
t/cities.t | ||
t/lib/MyLogger.pm | ||
t/lookup.t | ||
t/openaddr.t | ||
t/pod-cm.t | ||
t/pod.t | ||
t/spelling.t | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!perl -w | ||
|
||
use warnings; | ||
use strict; | ||
use Test::Most tests => 36; | ||
use Test::Number::Delta; | ||
use Test::Carp; | ||
|
||
BEGIN { | ||
use_ok('Geo::Coder::Free'); | ||
} | ||
|
||
OPENADDR: { | ||
SKIP: { | ||
if($ENV{'OPENADDR_HOME'}) { | ||
diag('This will take some time and memory'); | ||
|
||
my $geocoder = new_ok('Geo::Coder::Free' => [ openaddr => $ENV{'OPENADDR_HOME'} ]); | ||
|
||
my $location = $geocoder->geocode('Indianapolis, Indiana, USA'); | ||
ok(defined($location)); | ||
delta_within($location->{latitude}, 38.62, 1e-2); | ||
delta_within($location->{longitude}, -87.18, 1e-2); | ||
|
||
$location = $geocoder->geocode('Silver Spring, Maryland, USA'); | ||
ok(defined($location)); | ||
delta_within($location->{latitude}, 38.99, 1e-2); | ||
delta_within($location->{longitude}, -76.99, 1e-2); | ||
|
||
$location = $geocoder->geocode('Silver Spring, MD, USA'); | ||
ok(defined($location)); | ||
delta_within($location->{latitude}, 38.99, 1e-2); | ||
delta_within($location->{longitude}, -76.99, 1e-2); | ||
|
||
$location = $geocoder->geocode('Silver Spring, Montgomery, MD, USA'); | ||
ok(defined($location)); | ||
delta_within($location->{latitude}, 38.99, 1e-2); | ||
delta_within($location->{longitude}, -76.99, 1e-2); | ||
|
||
$location = $geocoder->geocode('Silver Spring, Maryland, United States'); | ||
ok(defined($location)); | ||
delta_within($location->{latitude}, 38.99, 1e-2); | ||
delta_within($location->{longitude}, -76.99, 1e-2); | ||
|
||
$location = $geocoder->geocode('Silver Spring, Montgomery County, Maryland, USA'); | ||
ok(defined($location)); | ||
delta_within($location->{latitude}, 38.99, 1e-2); | ||
delta_within($location->{longitude}, -76.99, 1e-2); | ||
|
||
$location = $geocoder->geocode('Rockville Pike, Rockville, Montgomery County, MD, USA'); | ||
ok(defined($location)); | ||
delta_within($location->{latitude}, 39.09, 1e-2); | ||
delta_within($location->{longitude}, -77.15, 1e-2); | ||
|
||
$location = $geocoder->geocode('Rockville Pike, Rockville, MD, USA'); | ||
ok(defined($location)); | ||
delta_within($location->{latitude}, 39.09, 1e-2); | ||
delta_within($location->{longitude}, -77.15, 1e-2); | ||
|
||
$location = $geocoder->geocode({ location => 'Rockville, Montgomery County, MD, USA' }); | ||
ok(defined($location)); | ||
delta_within($location->{latitude}, 39.08, 1e-2); | ||
delta_within($location->{longitude}, -77.14, 1e-2); | ||
|
||
$location = $geocoder->geocode(location => 'Rockville, Montgomery County, Maryland, USA'); | ||
ok(defined($location)); | ||
delta_within($location->{latitude}, 39.08, 1e-2); | ||
delta_within($location->{longitude}, -77.14, 1e-2); | ||
|
||
$location = $geocoder->geocode(location => '1600 Pennsylvania Avenue NW, Washington DC, USA'); | ||
delta_within($location->{latitude}, 38.90, 1e-2); | ||
delta_within($location->{longitude}, -77.04, 1e-2); | ||
|
||
# my $address = $geocoder->reverse_geocode(latlng => '51.50,-0.13'); | ||
# like($address->{'city'}, qr/^London$/i, 'test reverse'); | ||
|
||
does_croak(sub { | ||
$location = $geocoder->geocode(); | ||
}); | ||
|
||
does_croak(sub { | ||
$location = $geocoder->reverse_geocode(); | ||
}); | ||
} else { | ||
diag('Set OPENADDR_HOME to enable openaddresses.io testing'); | ||
skip 'OPENADDR_HOME not defined', 35; | ||
} | ||
} | ||
} |