diff --git a/createdatabase.PL b/createdatabase.PL index e481258..2e80180 100755 --- a/createdatabase.PL +++ b/createdatabase.PL @@ -616,7 +616,7 @@ if(my $oa = $ENV{'OPENADDR_HOME'}) { $data = $j->decode($data); my $properties = $data->{'properties'}; next if(scalar(@{$properties->{'wof:superseded_by'}})); - next if(!$properties->{'mz:is_current'}); + next if(exists($properties->{'mz:is_current'}) && ($properties->{'mz:is_current'} == 0)); my $placetype = $properties->{'wof:placetype'}; next if($placetype eq 'country'); my $country = $properties->{'wof:country'}; @@ -846,7 +846,7 @@ if(my $oa = $ENV{'OPENADDR_HOME'}) { $data = $j->decode($data); my $properties = $data->{'properties'}; next if(scalar(@{$properties->{'wof:superseded_by'}})); - next if(!$properties->{'mz:is_current'}); + next if(exists($properties->{'mz:is_current'}) && ($properties->{'mz:is_current'} == 0)); next if($properties->{'wof:country'} ne uc($country)); my $city = $properties->{'sg:city'}; # Don't trust sg:city to be correct @@ -985,7 +985,7 @@ if(my $oa = $ENV{'OPENADDR_HOME'}) { my $properties = $data->{'properties'}; next if(scalar(@{$properties->{'wof:superseded_by'}})); - next if(!$properties->{'mz:is_current'}); + next if(exists($properties->{'mz:is_current'}) && ($properties->{'mz:is_current'} == 0)); next if($properties->{'wof:country'} ne uc($country)); my $street = $properties->{'addr:street'}; # next if(!defined($street)); @@ -1748,7 +1748,7 @@ sub get_wof { $data = JSON->new()->utf8()->decode(@{$data}); my $properties = $data->{'properties'}; return if(scalar(@{$properties->{'wof:superseded_by'}})); - return if(!$properties->{'mz:is_current'}); + return if(exists($properties->{'mz:is_current'}) && ($properties->{'mz:is_current'} == 0)); # if($properties->{'wof:name'}) { if($properties->{'wof:placetype'} eq 'region') { my $country = $properties->{'wof:country'}; diff --git a/t/whosonfirst.t b/t/whosonfirst.t index 1305622..559bc30 100644 --- a/t/whosonfirst.t +++ b/t/whosonfirst.t @@ -2,7 +2,7 @@ use warnings; use strict; -use Test::Most tests => 41; +use Test::Most tests => 45; use Test::Number::Delta; use Test::Carp; use lib 't/lib'; @@ -99,18 +99,20 @@ WHOSONFIRST: { ok(ref($location) eq 'HASH'); delta_within($location->{latitude}, 51.34, 1e-2); delta_within($location->{longitude}, 1.40, 1e-2); - # diag(Data::Dumper->new([$location])->Dump()); - # $location = $geocoder->geocode('Wickhambreaux, Kent, England'); - # ok(defined($location)); - # ok(ref($location) eq 'HASH'); + $location = $geocoder->geocode('Wickhambreaux, Kent, England'); + ok(defined($location)); + ok(ref($location) eq 'HASH'); + delta_within($location->{latitude}, 51.28, 1e-2); + delta_within($location->{longitude}, 1.18, 1e-2); + # diag(Data::Dumper->new([$location])->Dump()); } else { diag('Author tests not required for installation'); - skip('Author tests not required for installation', 40); + skip('Author tests not required for installation', 44); } } else { diag('Set WHOSONFIRST_HOME and OPENADDR_HOME to enable whosonfirst.org testing'); - skip 'WHOSONFIRST_HOME and/or OPENADDR_HOME not defined', 40; + skip 'WHOSONFIRST_HOME and/or OPENADDR_HOME not defined', 44; } } }