Changeset 25557

Show
Ignore:
Timestamp:
09.05.2012 14:46:30 (7 years ago)
Author:
sjm84
Message:

Add in subsets of Latitude and Longitude metadata if the collection has it

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/doc.pm

    r24404 r25557  
    956956    my $self = shift (@_); 
    957957    my ($section, $field, $value) = @_; 
    958  
     958     
    959959    $self->delete_metadata ($section, $field); 
    960960    $self->add_utf8_metadata ($section, $field, $value); 
     
    968968    my $self = shift (@_); 
    969969    my ($section, $field, $value) = @_; 
    970  
     970     
    971971    $self->add_utf8_metadata ($section, $field, 
    972972                  &unicode::ascii2utf8(\$value)); 
     
    976976    my $self = shift (@_); 
    977977    my ($section, $field, $value) = @_; 
    978  
    979 #    my ($cpackage,$cfilename,$cline,$csubr,$chas_args,$cwantarray) = caller(1); 
    980 #    my ($lcfilename) = ($cfilename =~ m/([^\\\/]*)$/); 
    981 #    print STDERR "** Calling method: $lcfilename:$cline $cpackage->$csubr\n"; 
     978     
     979    #    my ($cpackage,$cfilename,$cline,$csubr,$chas_args,$cwantarray) = caller(1); 
     980    #    my ($lcfilename) = ($cfilename =~ m/([^\\\/]*)$/); 
     981    #    print STDERR "** Calling method: $lcfilename:$cline $cpackage->$csubr\n"; 
    982982 
    983983    my $section_ptr = $self->_lookup_section($section); 
     
    10041004 
    10051005    # double check that the value is utf-8 
    1006 #    if (!&unicode::check_is_utf8($value)) { 
    1007 #   print STDERR "doc::add_utf8_metadata - warning: '$field''s value $value wasn't utf8."; 
    1008 #   &unicode::ensure_utf8(\$value); 
    1009 #   print STDERR " Tried converting to utf8: $value\n"; 
    1010 #    } 
     1006    #    if (!&unicode::check_is_utf8($value)) { 
     1007    #   print STDERR "doc::add_utf8_metadata - warning: '$field''s value $value wasn't utf8."; 
     1008    #   &unicode::ensure_utf8(\$value); 
     1009    #   print STDERR " Tried converting to utf8: $value\n"; 
     1010    #    } 
     1011 
     1012    #If the metadata value is either a latitude or a longitude value then we want to save a shortened version for spacial searching purposes 
     1013    if($field eq "Latitude" || $field eq "Longitude") 
     1014    { 
     1015        my $direction; 
     1016        if($value =~ m/^-/) 
     1017        { 
     1018            $direction = ($field eq "Latitude") ? "S" : "W";  
     1019        } 
     1020        else 
     1021        { 
     1022            $direction = ($field eq "Latitude") ? "N" : "E";  
     1023        } 
     1024         
     1025        my ($beforeDec, $afterDec) = ($value =~ m/^-?([0-9]+)\.([0-9]+)$/); 
     1026        if(defined $beforeDec && defined $afterDec) 
     1027        { 
     1028            my $name = ($field eq "Latitude") ? "LatShort" : "LngShort"; 
     1029            push (@{$section_ptr->{'metadata'}}, [$name, $beforeDec . $direction]); 
     1030             
     1031            for(my $i = 2; $i <= 4; $i++) 
     1032            { 
     1033                if(length($afterDec) >= $i) 
     1034                { 
     1035                    push (@{$section_ptr->{'metadata'}}, [$name, substr($afterDec, 0, $i)]); 
     1036                } 
     1037            } 
     1038             
     1039            #Only add the metadata if it has not already been added 
     1040            my $metaMap = $self->get_metadata_hashmap($section); 
     1041        } 
     1042    } 
    10111043 
    10121044    push (@{$section_ptr->{'metadata'}}, [$field, $value]);