Changeset 19774

Show
Ignore:
Timestamp:
09.06.2009 14:34:05 (10 years ago)
Author:
davidb
Message:

support for reverse lookup operations

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/arcinfo.pm

    r18469 r19774  
    5555    my ($class) = @_; 
    5656    my $self = {'info'=>{}, 
     57        'reverse-info'=>{}, 
    5758        'order'=>[], 
    5859        'reverse_sort'=>0}; 
     
    103104} 
    104105 
     106 
    105107sub load_info { 
    106108    my $self = shift (@_); 
     
    151153    } 
    152154} 
     155 
     156sub load_revinfo_UNTESTED 
     157{ 
     158    my $self = shift (@_); 
     159    my ($rev_filename) = @_; 
     160 
     161    my $rev_infodb_map = {}; 
     162 
     163    &dbutil::read_infodb_file_gdbm($rev_filename,$rev_infodb_map); 
     164 
     165    foreach my $srcfile ( keys %$rev_infodb_map ) { 
     166    my $vals = $rev_infodb_map->{$srcfile}; 
     167 
     168    foreach my $OID ($vals =~ m/^<oid>(.*)$/gm) { 
     169        $self->add_revinfo($srcfile,$OID); 
     170    } 
     171    } 
     172} 
     173 
    153174 
    154175sub _save_info_txt { 
     
    209230} 
    210231 
     232sub save_revinfo_gdbm { 
     233    my $self = shift (@_); 
     234    my ($rev_filename) = @_; 
     235 
     236    # Output reverse lookup database 
     237 
     238    my $rev_infodb_map = $self->{'reverse-info'}; 
     239    my $rev_infodb_handle  
     240    = &dbutil::open_infodb_write_handle_gdbm($rev_filename,"append"); 
     241 
     242    foreach my $key ( keys %$rev_infodb_map ) { 
     243    my $val_hash = $rev_infodb_map->{$key}; 
     244    &dbutil::write_infodb_entry_gdbm($rev_infodb_handle,$key,$val_hash); 
     245    } 
     246    &dbutil::close_infodb_write_handle_gdbm($rev_infodb_handle); 
     247 
     248} 
     249 
    211250sub save_info { 
    212251    my $self = shift (@_); 
     
    308347} 
    309348 
     349 
     350sub add_reverseinfo { 
     351    my $self = shift (@_); 
     352    my ($key, $OID) = @_; 
     353 
     354    my $existing_key = $self->{'reverse-info'}->{$key}; 
     355    if (!defined $existing_key) { 
     356    $existing_key = {}; 
     357    $self->{'reverse-info'}->{$key} = $existing_key; 
     358    } 
     359 
     360    my $existing_oid = $existing_key->{'oid'};   
     361    if (!defined $existing_oid) { 
     362    $existing_oid = []; 
     363    $existing_key->{'oid'} = $existing_oid; 
     364    } 
     365 
     366    push(@$existing_oid,$OID); 
     367} 
     368 
     369 
    310370sub reverse_sort  
    311371{