Changeset 33185
- Timestamp:
- 2019-06-21T20:37:49+12:00 (5 years ago)
- Location:
- main/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/doc.pm
r33171 r33185 1110 1110 # print STDERR " Tried converting to utf8: $value\n"; 1111 1111 # } 1112 1113 1114 # for every GPS.mapOverlay/sectionID (but sadly not for every doc, let alone every collection), 1115 # we use a map to ensure uniqueness of CoordShorts for optimisation purposes 1116 # That way we don't end up with the same CoordShort values a large number of times in the index 1117 # We only get any savings with GPS.mapOverlay when using this map, not for "Latitude" and "Longitude" metadata 1118 my $unique_coordshort_map = {}; 1119 1112 1120 1113 1121 #If the metadata value is either a latitude or a longitude value then we want to save a shortened version for spacial searching purposes … … 1153 1161 my $latitude = $self->get_metadata_element ($section, "Latitude"); 1154 1162 # 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 1155 $self->processCoordinate($section, $latitude, $value ); # value is Longitude1163 $self->processCoordinate($section, $latitude, $value, $unique_coordshort_map); # value is Longitude 1156 1164 } 1157 1165 } … … 1159 1167 elsif($field eq "GPS.mapOverlay") { # then the value is a JSON string 1160 1168 1161 # TODO: 1162 # If we already have Coordinate meta for this section of the document (as can happen during buildcol.pl), 1163 # let's ASSUME this means we've already processed GPS.mapOverlay meta into Coordinate meta for this section (can have happened during import.pl) 1164 # to avoid adding duplicate Coordinates meta, which then end up duplicated in the index 1165 # Of course, the assumption is not always true! We could have an image with embedded Lat and Lng meta, 1166 # and the same image doc's section could have GPS.mapOverlay meta (from shapes) added via the doc editor. 1167 # This very function would then have converted Lat/Lng into Coordinate meta (just in the if stmt above) and added it to the section. 1168 # And then by the time we process this section's GPS.mapOverlay meta here, we would notice the section has Coordinate meta already, 1169 # and therefore skip converting the GPS.mapOverlay meta into Coordinate meta! What to dooooo? 1170 # So the return statement immediately below is a temporary solution, until we find a better one that will always work. 1169 # TODO: How can we prevent GPS.mapOverlay from being processed 4 or so times by buildcol.pl?? 1170 # Once for each pass (dummy, sidx, didx for lucene, info db pass) 1171 1171 1172 if($cmd_line_mode eq "buildcol") { 1172 1173 #my $metaMap = $self->get_metadata_hashmap($section); ## TODO: Check if necessary to avoid duplication of <Coordinate> meta in index\text\<coll>.jdb … … 1176 1177 1177 1178 1178 print STDERR "GPS.mapOverlay before val: " . $value . "\n";1179 print STDERR "GPS.mapOverlay before decode, val: " . $value . "\n"; 1179 1180 1180 1181 # TODO html decode? … … 1182 1183 $value =~ s@]@]@g; 1183 1184 $value =~ s@"@"@g; 1184 print STDERR "GPS.mapOverlay after val: " . $value . "\n";1185 print STDERR "GPS.mapOverlay after decode, val: " . $value . "\n"; 1185 1186 1186 1187 my $json_array = decode_json $value; … … 1196 1197 #print STDERR "Found a circle:\n" . &printShape($json, $shape); 1197 1198 1198 # work out bounding box 1199 # SCARY! 1199 # Work out bounding box 1200 1200 # want the inverse of this useful page: 1201 1201 # https://stackoverflow.com/questions/639695/how-to-convert-latitude-or-longitude-to-meters … … 1243 1243 print STDERR "cos $centre_lat is $cos_lat\n"; 1244 1244 1245 $self->processCoordinate($section, $lat_north, $lng_east );1246 $self->processCoordinate($section, $lat_south, $lng_east );1247 $self->processCoordinate($section, $lat_south, $lng_west );1248 $self->processCoordinate($section, $lat_north, $lng_west );1245 $self->processCoordinate($section, $lat_north, $lng_east, $unique_coordshort_map); 1246 $self->processCoordinate($section, $lat_south, $lng_east, $unique_coordshort_map); 1247 $self->processCoordinate($section, $lat_south, $lng_west, $unique_coordshort_map); 1248 $self->processCoordinate($section, $lat_north, $lng_west, $unique_coordshort_map); 1249 1249 1250 1250 } … … 1252 1252 print STDERR "@@ MARKER FOUND WITH LAT: " . $shape->{"position"}->{"lat"} . "\n"; 1253 1253 print STDERR "@@ MARKER FOUND WITH LNG: " . $shape->{"position"}->{"lng"} . "\n"; 1254 $self->processCoordinate($section, $shape->{"position"}->{"lat"}, $shape->{"position"}->{"lng"} );1254 $self->processCoordinate($section, $shape->{"position"}->{"lat"}, $shape->{"position"}->{"lng"}, $unique_coordshort_map); 1255 1255 } 1256 1256 elsif ($type eq "polyline" || $type eq "polygon") { 1257 1257 my $path_array = $shape->{"path"}; 1258 1258 foreach my $position (@$path_array) { 1259 $self->processCoordinate($section, $position->{"lat"}, $position->{"lng"} );1259 $self->processCoordinate($section, $position->{"lat"}, $position->{"lng"}, $unique_coordshort_map); 1260 1260 } 1261 1261 } … … 1263 1263 1264 1264 my $bounds = $shape->{"bounds"}; 1265 $self->processCoordinate($section, $bounds->{"north"}, $bounds->{"east"} );1266 $self->processCoordinate($section, $bounds->{"south"}, $bounds->{"east"} );1267 $self->processCoordinate($section, $bounds->{"south"}, $bounds->{"west"} );1268 $self->processCoordinate($section, $bounds->{"north"}, $bounds->{"west"} );1265 $self->processCoordinate($section, $bounds->{"north"}, $bounds->{"east"}, $unique_coordshort_map); 1266 $self->processCoordinate($section, $bounds->{"south"}, $bounds->{"east"}, $unique_coordshort_map); 1267 $self->processCoordinate($section, $bounds->{"south"}, $bounds->{"west"}, $unique_coordshort_map); 1268 $self->processCoordinate($section, $bounds->{"north"}, $bounds->{"west"}, $unique_coordshort_map); 1269 1269 } 1270 1270 … … 1272 1272 #} 1273 1273 } 1274 1275 # We haven't yet written out any Coordshort meta! Write those out now, 1276 # since we've now finally ensured they're all unique CoordShort meta for this GPS.mapOverlay at least. 1277 foreach my $coordshort (keys %$unique_coordshort_map) { 1278 1279 #print STDERR "@@@@ creating new coordshort: $coordshort\n"; 1280 push (@{$section_ptr->{'metadata'}}, ["CoordShort", $coordshort ]); 1281 } 1282 1274 1283 } # end GPS.mapOverlay meta 1275 1284 … … 1305 1314 } 1306 1315 1307 } 1308 1316 } 1317 1318 # Beware: this method now ONLY writes out the Coordinate meta, but not the CoordShorts 1319 # At method's end, the CoordShorts are stored in the $unique_coordshort_map (for optimisation), 1320 # ready to be added to the doc section's meta once all Coordinates in a GPS.mapOverlay are done being processed. 1309 1321 sub processCoordinate { 1310 1322 my $self = shift (@_); 1311 my ($section, $latitude, $longitude ) = @_;1323 my ($section, $latitude, $longitude, $unique_coordshort_map) = @_; 1312 1324 1313 1325 my $section_ptr = $self->_lookup_section($section); … … 1338 1350 } 1339 1351 1340 #if(defined $beforeDec && defined $afterDec) 1341 #{ 1342 my $name = "CoordShort"; 1343 push (@{$section_ptr->{'metadata'}}, [$name, "$latBeforeDec$lat_direction $lngBeforeDec$lng_direction"]); 1352 # We have to deal with 0 decimal places for either lat or lng, or no dec places for only one of them 1353 # And we have to store all combinations of lats and lngs as CoordShort. 1354 1355 #my $name = "CoordShort"; 1356 #push (@{$section_ptr->{'metadata'}}, [$name, "$latBeforeDec$lat_direction $lngBeforeDec$lng_direction"]); 1357 1358 my @lat_array = ("$latBeforeDec$lat_direction"); 1359 my @lng_array = ("$lngBeforeDec$lng_direction"); 1360 1361 for(my $i = 2; $i <= 4; $i++) 1362 { 1363 my $latDecPlaces = (length($latAfterDec) >= $i) ? substr($latAfterDec, 0, $i) : ""; 1364 my $lngDecPlaces = (length($lngAfterDec) >= $i) ? substr($lngAfterDec, 0, $i) : ""; 1365 1366 push(@lat_array, $latBeforeDec . $lat_direction. $latDecPlaces) unless $latDecPlaces eq ""; 1367 push(@lng_array, $lngBeforeDec . $lng_direction. $lngDecPlaces) unless $lngDecPlaces eq ""; 1368 1369 #push (@{$section_ptr->{'metadata'}}, [$name, 1370 # $latBeforeDec . $lat_direction. $latDecPlaces . " " . $lngBeforeDec . $lng_direction. $lngDecPlaces]); 1371 1372 } 1373 1374 for(my $i = 0; $i < scalar(@lat_array); $i++) { 1375 for(my $j = 0; $j < scalar(@lng_array); $j++) { 1376 #push (@{$section_ptr->{'metadata'}}, [$name, $lat_array[$i] . " " . $lng_array[$j] ]); 1377 my $coordshort = $lat_array[$i] . " " . $lng_array[$j]; 1378 $unique_coordshort_map->{$coordshort} = "1"; # just store it 1344 1379 1345 for(my $i = 2; $i <= 4; $i++) 1346 { 1347 my $latDecPlaces = (length($latAfterDec) >= $i) ? substr($latAfterDec, 0, $i) : ""; 1348 my $lngDecPlaces = (length($lngAfterDec) >= $i) ? substr($lngAfterDec, 0, $i) : ""; 1349 1350 push (@{$section_ptr->{'metadata'}}, [$name, 1351 $latBeforeDec . $lat_direction. $latDecPlaces . " " . $lngBeforeDec . $lng_direction. $lngDecPlaces]); 1380 #print STDERR "@@@@ pushed new value: " . $coordshort . " into map\n"; 1352 1381 1353 1382 } 1354 1355 #Only add the metadata if it has not already been added1356 #my $metaMap = $self->get_metadata_hashmap($section); ### TODO: metaMap not used. Unnecesssary step? (Called function has no side-effects.)1357 #}1358 1359 1383 } 1384 1385 1386 1387 #Only add the metadata if it has not already been added 1388 #my $metaMap = $self->get_metadata_hashmap($section); ### TODO: metaMap not used. Unnecesssary step? (Called function has no side-effects.) 1360 1389 } 1361 1390 -
main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js
r33184 r33185 150 150 //Check which increment to use for longitude (i.e. 0.001, 0.01, 0.1 or 1 degree increments) 151 151 var lngDelta; 152 var lngPrecision; 152 153 for(var i = 3; i >= 0; i--) 153 154 { … … 205 206 var query = ""; 206 207 var iMax = Math.floor(latDistance / latDelta) + 1; 207 var jMax = Math.floor(lngDistance / lngDelta) + 1; ;208 var jMax = Math.floor(lngDistance / lngDelta) + 1; 208 209 for(var i = 0; i <= iMax; i++) //for(var i = 0; i <= Math.floor(latDistance / latDelta) + 1; i++) 209 210 { … … 355 356 { 356 357 if(doc.shapes) { 357 //console.log("@@@ making doc.shapes["+x+"] visible");358 358 for(var x = 0; x < doc.shapes.length; x++) { 359 359 doc.shapes[x].setVisible(true); … … 369 369 if(doc.shapes) { 370 370 console.log("@@@@ HERE IN doc.shapes"); 371 bounds = ShapesUtil.overlayBounds(doc.shapes); 371 var docSection_overlay_bounds = ShapesUtil.overlayBounds(doc.shapes); 372 // We now have the current document or document subsection's bounds. 373 // Use this to extend the overall bounds (the cumulative bounds for all nearby documents, 374 // or at least the cumulative bounds for this document with all its subsections). 375 bounds.extend(docSection_overlay_bounds.getNorthEast()); 376 bounds.extend(docSection_overlay_bounds.getSouthWest()); 372 377 } 373 378 else {
Note:
See TracChangeset
for help on using the changeset viewer.