Skip to content

Commit

Permalink
known_locations weren't being added
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Apr 21, 2018
1 parent 4f7c9d0 commit 80a577f
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions createdatabase.PL
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ if(my $oa = $ENV{'OPENADDR_HOME'}) {
my $state = $state_fips{$row->{'State FIPS'}};
die $row->{'Name'} unless(defined($state));
my $county = uc($row->{'Name'});
$county =~ s/\s+COUNTY$//;
my $digest = hash(1, $county, $state, 'US');
$county =~ s/'/''/g; # O'Brien County, IA
my $key = city_key(undef, $county, $state, 'US');
Expand All @@ -254,7 +255,7 @@ if(my $oa = $ENV{'OPENADDR_HOME'}) {
# next unless($csv_file =~ /statewide/);
# next unless($csv_file =~ /us\/ne\/dawes/);
# next unless($csv_file =~ /us\/ca\/sonoma/);
# next unless($csv_file =~ /us\/md\/statewide/);
next unless($csv_file =~ /us\/md\/statewide/);

# Handle https://github.com/openaddresses/openaddresses/issues/3928
# TODO: It would be better to merge airdrie.csv and city_of_airdrie.csv
Expand Down Expand Up @@ -356,6 +357,7 @@ if(my $oa = $ENV{'OPENADDR_HOME'}) {

# Reclaim memory
%state_md5s = ();
%global_md5s = ();
%cities = ();

$dbh->prepare('CREATE UNIQUE INDEX sequence_index ON cities(sequence)')->execute();
Expand Down Expand Up @@ -618,16 +620,11 @@ sub insert {
$digest = hash($global, Encode::encode_utf8($digest));
# print "$digest\n";

if($columns->{'STATE'}) {
# print "Looking for digest $digest\n";
if($state_md5s{$digest} || $global_md5s{$digest}) {
# print "Ignore ", join(',', values(%{$columns})), "\n";
return;
}
$state_md5s{$digest} = 1;
} else {
die;
if(!defined($digest)) {
# print "Ignore ", join(',', values(%{$columns})), "\n";
return;
}

# my $q = "SELECT * FROM openaddresses WHERE MD5 = '$digest'";
# my $sth = $dbh->prepare($q);
# $sth->execute();
Expand Down Expand Up @@ -656,11 +653,10 @@ sub insert {
$digest .= $columns->{$column} if($columns->{$column});
}
$digest = hash($global, Encode::encode_utf8($digest));
if($state_md5s{$digest} || $global_md5s{$digest}) {
if(!defined($digest)) {
# print "Ignore ", join(',', values(%{$columns})), "\n";
return;
}
$state_md5s{$digest} = 1;
$queued_commits{$digest} = $columns;
}
}
Expand Down Expand Up @@ -722,11 +718,13 @@ sub hash

my $digest = substr Digest::MD5::md5_base64(@_), 0, 16;
# my $digest = Digest::MD5::md5_base64(@_);
return if($global_md5s{$digest} || $state_md5s{$digest});

# print join(',', @_), ": $digest\n";
if($global) {
$global_md5s{$digest} = 1;
}
$state_md5s{$digest} = 1;
return $digest;
}

Expand Down

0 comments on commit 80a577f

Please sign in to comment.