Ignore:
Timestamp:
2019-06-06T20:53:13+12:00 (5 years ago)
Author:
wy59
Message:

Improvements to Coordinate support AND bugfixes. BUT not all the fixes may be ideal, many marked with TODO. 1. Now we support an Array of coordinates. At present these are only displayed as Markers, but in future shapes should appear as shapes. 2. Bugfixes include: (a) expanding sections wasn't working when we had hierarchical docs with Coordinate data, because map-scripts 'overrode' the toggleSection function but no longer did any of the doc expanding behaviour that document_scripts.js used to do. This was not a problem with the ImagesGPS collection, simply because that did not have hierarchical/sectionalised documents. (b) Perl: A previous commit output duplicate Coordinates into the index. Now this doesn't happen. Fix works but may not be ideal. 3. Perl: (a) Reserved index names CD, CS for Coordinate and CoordShort. Note however that LAT and LNG were never added to reserve list for index names. (b) Now doc.pm::processCoord() takes a section parameter and works out the section-ptr from that.

File:
1 edited

Legend:

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

    r33126 r33128  
    11381138       
    11391139        if($field =~ m/^(.+\.)?Longitude$/) {
    1140             # if we are dealing with Longitude meta, we should 1. have Latitude meta; 2. already have processed Latitude meta
     1140            # if we are dealing with Longitude meta, we should 1. have Latitude meta too; 2. already have processed Latitude meta
    11411141            # in that case, add both Lat and Lng of this section as a Coordinate meta
    11421142            my $latitude = $self->get_metadata_element ($section, "Latitude");         
    11431143            # TODO: would like all Longitude info together followed by all Coordinate info, but the following will add all coord info meta and end of this function will add Longitude meta
    1144             $self->processCoordinate($section_ptr, $latitude, $value); # value is Longitude
     1144            $self->processCoordinate($section, $latitude, $value); # value is Longitude
    11451145        }
    11461146    }
    11471147
    11481148    elsif($field eq "GPS.mapOverlay") { # then the value is a JSON string
     1149   
     1150        # TODO:
     1151        # If we already have Coordinate meta for this section of the document (as can happen during buildcol.pl),
     1152        # let's ASSUME this means we've already processed GPS.mapOverlay meta into Coordinate meta for this section (can have happened during import.pl)
     1153        # to avoid adding duplicate Coordinates meta, which then end up duplicated in the index
     1154        # Of course, the assumption is not always true! We could have an image with embedded Lat and Lng meta,
     1155        # and the same image doc's section could have GPS.mapOverlay meta (from shapes) added via the doc editor.
     1156        # This very function would then have converted Lat/Lng into Coordinate meta (just in the if stmt above) and added it to the section.
     1157        # And then by the time we process this section's GPS.mapOverlay meta here, we would notice the section has Coordinate meta already,
     1158        # and therefore skip converting the GPS.mapOverlay meta into Coordinate meta! What to dooooo?
     1159        # So the return statement immediately below is a temporary solution, until we find a better one that will always work.
     1160        my $metaMap = $self->get_metadata_hashmap($section);
     1161        if($metaMap->{'Coordinate'}) {
     1162            return;
     1163        }
     1164       
    11491165        print STDERR "GPS.mapOverlay before val: " . $value . "\n";
    11501166       
     
    12141230                print STDERR "cos $centre_lat is $cos_lat\n";
    12151231
    1216                 $self->processCoordinate($section_ptr, $lat_north, $lng_east);
    1217                 $self->processCoordinate($section_ptr, $lat_south, $lng_east);
    1218                 $self->processCoordinate($section_ptr, $lat_south, $lng_west);
    1219                 $self->processCoordinate($section_ptr, $lat_north, $lng_west);
     1232                $self->processCoordinate($section, $lat_north, $lng_east);
     1233                $self->processCoordinate($section, $lat_south, $lng_east);
     1234                $self->processCoordinate($section, $lat_south, $lng_west);
     1235                $self->processCoordinate($section, $lat_north, $lng_west);
    12201236           
    12211237            }
     
    12231239                print STDERR "@@ MARKER FOUND WITH LAT: " . $shape->{"position"}->{"lat"} . "\n";
    12241240                print STDERR "@@ MARKER FOUND WITH LNG: " . $shape->{"position"}->{"lng"} . "\n";
    1225                 $self->processCoordinate($section_ptr, $shape->{"position"}->{"lat"}, $shape->{"position"}->{"lng"});               
     1241                $self->processCoordinate($section, $shape->{"position"}->{"lat"}, $shape->{"position"}->{"lng"});               
    12261242            }
    12271243            elsif ($type eq "polyline" || $type eq "polygon") {
    12281244                my $path_array = $shape->{"path"};
    12291245                foreach my $position (@$path_array) {                                   
    1230                     $self->processCoordinate($section_ptr, $position->{"lat"}, $position->{"lng"});
     1246                    $self->processCoordinate($section, $position->{"lat"}, $position->{"lng"});
    12311247                }
    12321248            }
     
    12351251                my $bounds = $shape->{"bounds"};               
    12361252           
    1237                 $self->processCoordinate($section_ptr, $bounds->{"north"}, $bounds->{"east"});
    1238                 $self->processCoordinate($section_ptr, $bounds->{"south"}, $bounds->{"east"});
    1239                 $self->processCoordinate($section_ptr, $bounds->{"south"}, $bounds->{"west"});
    1240                 $self->processCoordinate($section_ptr, $bounds->{"north"}, $bounds->{"west"});
     1253                $self->processCoordinate($section, $bounds->{"north"}, $bounds->{"east"});
     1254                $self->processCoordinate($section, $bounds->{"south"}, $bounds->{"east"});
     1255                $self->processCoordinate($section, $bounds->{"south"}, $bounds->{"west"});
     1256                $self->processCoordinate($section, $bounds->{"north"}, $bounds->{"west"});
    12411257            }   
    12421258       
     
    12801296sub processCoordinate {
    12811297    my $self = shift (@_);
    1282     my ($section_ptr, $latitude, $longitude) = @_;
     1298    my ($section, $latitude, $longitude) = @_;
     1299
     1300    my $section_ptr = $self->_lookup_section($section);
    12831301
    12841302    my $lat_direction = ($latitude =~ m/^-/) ? "S" : "N";
Note: See TracChangeset for help on using the changeset viewer.