Changeset 34276 for main/trunk


Ignore:
Timestamp:
2020-07-21T14:09:10+12:00 (4 years ago)
Author:
kjdon
Message:

modified the code that added Coordinate metadata when we have got both Latitude and Longitude. The previous code assumed you were alsways going to see these in the order Latitude then Longitude. Why? paradice gardens coll has them in the reverse order. so instead of assuming we have latitude when we are processing longitude, now for each one, if we have got the other, then add coords.

File:
1 edited

Legend:

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

    r34105 r34276  
    11611161
    11621162        my $direction;
     1163        # TODO does the following work, with eq latitude? the above code implies can be xxxxx.Latitude. should use metaname??
    11631164        if($value =~ m/^-/)
    11641165        {
     
    11831184                }
    11841185            }
    1185            
     1186
     1187            # what is this???? completely does nothing...
    11861188            #Only add the metadata if it has not already been added
    11871189            my $metaMap = $self->get_metadata_hashmap($section); # metaMap not used and called function has no apparent side-effects,
     
    11891191                                                                 # in the section. Also for LatShort, Longitude, LngShort.
    11901192        }
     1193
     1194        # if we have both Latitude and Longitude, then add coordinate metadata (not sure why, but someone else added it)
     1195        my $latitude;
     1196        my $longitude;
     1197        if($field =~ m/^(.+\.)?Longitude$/) {
     1198            # if we are dealing with Longitude meta, and we have already seen Latitude, then add Coordinate metadata
     1199            $latitude = $self->get_metadata_element ($section, "Latitude");
     1200            if (defined $latitude) {
     1201            $longitude = $value;
     1202            }
     1203        } else {
     1204            # we are dealing with Latitude - if we have already seen Longitude, then add both as Coordinate metadata
     1205            $longitude = $self->get_metadata_element ($section, "Longitude");
     1206            if (defined $longitude) {
     1207            $latitude = $value;
     1208            }
     1209        }
     1210        if (defined $latitude && defined $longitude) {
     1211            ##rint STDERR "adding coords for $section, $latitude, $longitude\n";
     1212            $self->processCoordinate($section, $latitude, $longitude);
     1213        } else {
     1214            ##rint STDERR "lat or long not defined, not adding coords for $section\n";
     1215        }
    11911216       
    1192         if($field =~ m/^(.+\.)?Longitude$/) {
    1193             # if we are dealing with Longitude meta, we should 1. have Latitude meta too; 2. already have processed Latitude meta
    1194             # in that case, add both Lat and Lng of this section as a Coordinate meta
    1195             my $latitude = $self->get_metadata_element ($section, "Latitude");
    1196             my $longitude = $value;
    1197             # TODO: would like all Longitude meta placed together, followed by all Coordinate meta,
    1198             # but the following will add all such coord meta to the doc object and the end of this function will add Longitude meta
    1199             $self->processCoordinate($section, $latitude, $longitude);
    1200         }
    12011217    }
    12021218   
Note: See TracChangeset for help on using the changeset viewer.