Skip to content

Commit

Permalink
Improved logic for mz:iscurrent
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Sep 29, 2018
1 parent c1c7216 commit 39cd1da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions createdatabase.PL
Original file line number Diff line number Diff line change
Expand Up @@ -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'};
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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'};
Expand Down
16 changes: 9 additions & 7 deletions t/whosonfirst.t
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
}
}

0 comments on commit 39cd1da

Please sign in to comment.