Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Nov 17, 2018
2 parents 3a05924 + e32d018 commit 5a01bb4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Revision history for Geo-Coder-Free

0.15
0.15 Thu Nov 15 21:10:51 EST 2018
Added alternatives table, for when a place could be listed elsewhere
Support lookups of British counties e.g. 'Kent, England'

Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Geo::Coder::Free - Provides a Geo-Coding functionality using free databases

# VERSION

Version 0.14
Version 0.15

# SYNOPSIS

Expand Down Expand Up @@ -120,19 +120,19 @@ There is a sample website at [https://geocode.nigelhorne.com/](https://geocode.n

# BUGS

Lots of lookups fail at the moment.
Some lookups fail at the moments, if you find one please file a bug report.

The MaxMind data only contains cities.
The openaddresses data doesn't cover the globe.
The OpenAddresses data doesn't cover the globe.

Can't parse and handle "London, England".

See [Geo::Coder::Free::OpenAddresses](https://metacpan.org/pod/Geo::Coder::Free::OpenAddresses) for instructions creating its SQLite database from
[http://results.openaddresses.io/](http://results.openaddresses.io/).

# SEE ALSO

VWF, openaddresses, MaxMind and geonames.
VWF, OpenAddresses, MaxMind and geonames.

See [Geo::Coder::Free::OpenAddresses](https://metacpan.org/pod/Geo::Coder::Free::OpenAddresses) for instructions creating the SQLite database from
[http://results.openaddresses.io/](http://results.openaddresses.io/).

# LICENSE AND COPYRIGHT

Expand All @@ -142,8 +142,8 @@ The program code is released under the following licence: GPL for personal use o
All other users (including Commercial, Charity, Educational, Government)
must apply in writing for a licence for use from Nigel Horne at \`<njh at nigelhorne.com>\`.

This product includes GeoLite2 data created by MaxMind, available from
[https://www.maxmind.com/en/home](https://www.maxmind.com/en/home).
This product uses GeoLite2 data created by MaxMind, available from
[https://www.maxmind.com/en/home](https://www.maxmind.com/en/home). See their website for licensing information.

This product includes data from Who's on First.
This product uses data from Who's on First.
See [https://github.com/whosonfirst-data/whosonfirst-data/blob/master/LICENSE.md](https://github.com/whosonfirst-data/whosonfirst-data/blob/master/LICENSE.md) for licensing information.
22 changes: 15 additions & 7 deletions lib/Geo/Coder/Free.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ Geo::Coder::Free - Provides a Geo-Coding functionality using free databases
=head1 VERSION
Version 0.14
Version 0.15
=cut

our $VERSION = '0.14';
our $VERSION = '0.15';

our $alternatives;

=head1 SYNOPSIS
Expand Down Expand Up @@ -71,11 +73,16 @@ sub new {
# Geo::Coder::Free->new not Geo::Coder::Free::new
return unless($class);

my $pos = tell(DATA);
my $alternatives = Config::Auto->new(source => <DATA>)->parse();
seek(DATA, $pos, 0); # Go back to the start so that subsequent objects also read the table
foreach my $entry(keys %{$alternatives}) {
$alternatives->{$entry} = join(', ', @{$alternatives->{$entry}});
if(!$alternatives) {
my $keep = $/;
local $/ = undef;
my $data = <DATA>;
$/ = $keep;

$alternatives = Config::Auto->new(source => $data)->parse();
foreach my $entry(keys %{$alternatives}) {
$alternatives->{$entry} = join(', ', @{$alternatives->{$entry}});
}
}

my $rc = {
Expand Down Expand Up @@ -310,3 +317,4 @@ See L<https://github.com/whosonfirst-data/whosonfirst-data/blob/master/LICENSE.m
# Would be nice to read this from somewhere on-line
__DATA__
St Lawrence, Thanet, Kent = Ramsgate, Kent
St Peters, Thanet, Kent = St Peters, Kent
4 changes: 2 additions & 2 deletions lib/Geo/Coder/Free/OpenAddresses.pm
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ Geo::Coder::Free::OpenAddresses - Provides a geocoding functionality to the data
=head1 VERSION
Version 0.05
Version 0.06
=cut

our $VERSION = '0.05';
our $VERSION = '0.06';

=head1 SYNOPSIS
Expand Down
2 changes: 1 addition & 1 deletion t/scantext.t
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ SCANTEXT: {
delta_within($location->{latitude}, 39.68, 1e-2);
delta_within($location->{longitude}, -75.76, 1e-2);
ok(defined($location->{'confidence'}));

}
ok($found == 1);

my $s = 'From the Indianapolis Star, 25/4/2013: "75, Indianapolis, died Apr. 21, 2013. Services: 1 p.m. Apr. 26 in Forest Lawn Funeral Home, Greenwood, with visitation from 11 a.m.". Obituary from Forest Lawn Funeral Home: "Sharlene C. Cloud, 75, of Indianapolis, passed away April 21, 2013. She was born May 21, 1937 in Noblesville, IN to Virgil and Josephine (Beaver) Day. She is survived by her mother; two sons, Christopher and Thomas Cloud; daughter, Marsha Cloud; three sisters, Mary Kirby, Sharon Lowery, and Doris Lyng; two grandchildren, Allison and Jamie Cloud. Funeral Services will be Friday at 1:00 pm at Forest Lawn Funeral Home, Greenwood, IN, with visitation from 11:00am till time of service Friday at the funeral home."';
@locations = $geocoder->geocode({ scantext => $s, region => 'US' });
my %found;
Expand Down

0 comments on commit 5a01bb4

Please sign in to comment.