Changeset 38357 for main/trunk/greenstone2
- Timestamp:
- 2023-11-14T10:35:07+13:00 (7 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/doc.pm
r38159 r38357 1063 1063 } 1064 1064 1065 # Does this section contain the specified field->value pair? 1066 sub contains_metadata_value { 1067 my $self = shift (@_); 1068 my ($section, $field, $value, $ignore_namespace) = @_; 1069 1070 $ignore_namespace = 0 unless defined $ignore_namespace; 1071 1072 my $section_ptr = $self->_lookup_section($section); 1073 if (!defined $section_ptr) { 1074 print STDERR "doc::get_metadata couldn't find section ", 1075 $section, "\n"; 1076 return 0; 1077 } 1078 1079 # Remove any namespace if we are being told to ignore them 1080 if($ignore_namespace) { 1081 $field =~ s/^.*\.//; 1082 } 1083 1084 my @metadata = (); 1085 foreach my $data (@{$section_ptr->{'metadata'}}) { 1086 1087 my $data_name = $data->[0]; 1088 1089 # Remove any namespace if we are being told to ignore them 1090 if($ignore_namespace) { 1091 $data_name =~ s/^.*\.//; 1092 } 1093 # we always remove ex. (but not any subsequent namespace) - ex. maybe there in doc_obj, but we will never ask for it. 1094 $data_name =~ s/^ex\.([^.]+)$/$1/; 1095 if ($data_name eq $field && $data->[1] eq $value) { 1096 return 1; 1097 } 1098 } 1099 # if we get here, we haven't found it. 1100 return 0; 1101 1102 } 1103 1065 1104 # $value is optional 1066 1105 sub delete_metadata { … … 1175 1214 1176 1215 my $direction; 1177 # TODO does the following work, with eq latitude? the above code implies can be xxxxx.Latitude. should use metaname??1216 # TODO does the following work, with eq xx.Latitude? the above code implies can be xxxxx.Latitude. should use metaname?? 1178 1217 if($value =~ m/^-/) 1179 1218 { … … 1188 1227 if(defined $beforeDec && defined $afterDec) 1189 1228 { 1190 my $name = ($field eq "Latitude") ? "LatShort" : "LngShort"; 1229 my $name = ($field eq "Latitude") ? "LatShort" : "LngShort"; 1230 # only do the following if we haven't already done it 1231 if (!$self->contains_metadata_value($section, $name, $beforeDec . $direction)) { 1191 1232 push (@{$section_ptr->{'metadata'}}, [$name, $beforeDec . $direction]); 1192 1233 … … 1198 1239 } 1199 1240 } 1200 1241 } 1201 1242 # what is this???? completely does nothing... 1202 1243 #Only add the metadata if it has not already been added … … 1402 1443 #push (@{$section_ptr->{'metadata'}}, ["Longitude", $longitude]); 1403 1444 1445 if ($self->contains_metadata_value($section, "Coordinate", "$latitude $longitude")) { 1446 # it looks like we have already processed these values 1447 return; 1448 } 1404 1449 push (@{$section_ptr->{'metadata'}}, ["Coordinate", "$latitude $longitude"]); # "$latitude$lat_direction $longitude$lng_direction" 1405 1450
Note:
See TracChangeset
for help on using the changeset viewer.