- Timestamp:
- 2019-06-06T20:53:13+12:00 (5 years ago)
- Location:
- main/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/doc.pm
r33126 r33128 1138 1138 1139 1139 if($field =~ m/^(.+\.)?Longitude$/) { 1140 # if we are dealing with Longitude meta, we should 1. have Latitude meta ; 2. already have processed Latitude meta1140 # if we are dealing with Longitude meta, we should 1. have Latitude meta too; 2. already have processed Latitude meta 1141 1141 # in that case, add both Lat and Lng of this section as a Coordinate meta 1142 1142 my $latitude = $self->get_metadata_element ($section, "Latitude"); 1143 1143 # 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 Longitude1144 $self->processCoordinate($section, $latitude, $value); # value is Longitude 1145 1145 } 1146 1146 } 1147 1147 1148 1148 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 1149 1165 print STDERR "GPS.mapOverlay before val: " . $value . "\n"; 1150 1166 … … 1214 1230 print STDERR "cos $centre_lat is $cos_lat\n"; 1215 1231 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); 1220 1236 1221 1237 } … … 1223 1239 print STDERR "@@ MARKER FOUND WITH LAT: " . $shape->{"position"}->{"lat"} . "\n"; 1224 1240 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"}); 1226 1242 } 1227 1243 elsif ($type eq "polyline" || $type eq "polygon") { 1228 1244 my $path_array = $shape->{"path"}; 1229 1245 foreach my $position (@$path_array) { 1230 $self->processCoordinate($section _ptr, $position->{"lat"}, $position->{"lng"});1246 $self->processCoordinate($section, $position->{"lat"}, $position->{"lng"}); 1231 1247 } 1232 1248 } … … 1235 1251 my $bounds = $shape->{"bounds"}; 1236 1252 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"}); 1241 1257 } 1242 1258 … … 1280 1296 sub processCoordinate { 1281 1297 my $self = shift (@_); 1282 my ($section_ptr, $latitude, $longitude) = @_; 1298 my ($section, $latitude, $longitude) = @_; 1299 1300 my $section_ptr = $self->_lookup_section($section); 1283 1301 1284 1302 my $lat_direction = ($latitude =~ m/^-/) ? "S" : "N"; -
main/trunk/greenstone3/web/interfaces/default/js/classifier_scripts.js
r33127 r33128 11 11 } 12 12 return false; 13 } 14 15 // TODO: Is there a better solution 16 function _basicToggleSection(sectionID) { 17 // Leave this function here, even though it's empty. 18 // This function is here because: 19 // - it mirrors the identically named version in document_scripts 20 // - and this allows map_scripts to override it without knowing whether it's 21 // overriding classifier_scripts::toggleSection() or document_scripts::toggleSection(). 22 23 // This method is not meant to call toggleSection. If anything it would be the other way around 24 // (as occurs in doc_scripts.js). But this method has to remain empty for classifier_scripts.js 25 // since map_scripts largely repeats classifier_scripts.js::toggleSection() code. 13 26 } 14 27 … … 111 124 if(!inProgress[sectionID]) 112 125 { 113 inProgress[sectionID] = true; 126 inProgress[sectionID] = true; 114 127 115 128 var sectionToggle = gs.jqGet("toggle" + sectionID); -
main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js
r33016 r33128 1 1 /** Javascript file for viewing documents */ 2 3 //-------TODO--------// 4 // map-scripts.js needs these, but non-map viewing does not. Yet if we add these to map_scripts, 5 // then in classifier mode, map_scripts will use classifier_scripts.js which already has these 6 // So for now, we add them into this file for when map_scripts is in doc view mode and includes document_scripts.js. 7 // It seems suboptimal, as these variables and function will be wasted when in regular non-map mode. 8 // But unable to think of any other solution at present. 9 var inProgress = new Array(); 10 var openClassifiers = new Array(); 11 var busy = false; 12 13 14 15 function updateOpenClassifiers() 16 { 17 var oc = ""; 18 var first = true; 19 for(var key in openClassifiers) 20 { 21 if(first) 22 { 23 first = false; 24 } 25 else 26 { 27 oc += ","; 28 } 29 30 oc += key; 31 } 32 33 if(oc != undefined) 34 { 35 window.location.hash = oc; 36 } 37 } 38 39 //---------------// 2 40 3 41 /** NOTE, this file uses inline templates which look for httpPath, assocfilepath, Source, Thumb, Title metadata. These need to be added into any xsl file that uses this javascript (using <gsf:metadata name="xx" hidden="true"/> if they are not already being collected. */ … … 66 104 url += "&ck=" + gs.cgiParams.ck; 67 105 } 68 69 106 107 70 108 71 109 $.ajax(url) … … 82 120 } 83 121 84 var text = response.substring(textStart, textEnd); 122 var text = response.substring(textStart, textEnd); 85 123 callback(text); 86 124 } … … 133 171 return; 134 172 } 135 136 var sections = response.substring(sectionsStart, sectionsEnd); 137 callback(sections); 173 else { 174 var sections = response.substring(sectionsStart, sectionsEnd); 175 callback(sections); 176 } 138 177 } 139 178 else … … 145 184 { 146 185 callback(null); 147 }); 148 } 149 186 }); 187 } 188 189 // TODO: 190 // DO NOT "MERGE" _basicToggleSection into toggleSection! 191 // map_scripts.js calls _basicToggleSection as it redefines toggleSection() to do (more) stuff. 150 192 function toggleSection(sectionID, callback, tocDisabled) 193 { 194 _basicToggleSection(sectionID, callback, tocDisabled); 195 } 196 function _basicToggleSection(sectionID, callback, tocDisabled) 151 197 { 152 198 var docElem = gs.jqGet("doc" + sectionID); … … 173 219 { 174 220 if(text) 175 { 221 { 176 222 var nodeID = sectionID.replace(/\./g, "_"); 177 223 if(text.search("wrap" + nodeID) != -1) … … 193 239 if(callback) 194 240 { 195 callback(true); 241 callback(true); 196 242 } 197 243 … … 219 265 } 220 266 } 221 }); 222 223 docToggleElem.attr("src", gs.imageURLs.loading); 267 }); 268 269 docToggleElem.attr("src", gs.imageURLs.loading); 224 270 } 225 271 else … … 310 356 { 311 357 expandAndExecute(sectionID, level, tocDisabled, function() 312 { 358 { 313 359 var topVal = $(document.getElementById("doc" + sectionID)).offset().top - 50; 314 360 $('html, body').stop().animate({scrollTop: topVal}, 1000); … … 332 378 if(!level) 333 379 { 334 level = 0; 380 level = 0; 335 381 } 336 382 var parts = sectionID.split("."); … … 360 406 toggleSection(idToExpand, function(success) 361 407 { 362 if(success)363 {364 expandAndExecute(sectionID, level + 1, tocDisabled, executeAfter);365 }366 }, tocDisabled);408 if(success) 409 { 410 expandAndExecute(sectionID, level + 1, tocDisabled, executeAfter); 411 } 412 }, tocDisabled); 367 413 } 368 414 else … … 534 580 { 535 581 var docElem = gs.jqGet("doc" + sectionID); 536 if(docElem.css("display") == "block") 582 583 if(docElem.css("display") === "block") 537 584 { 538 585 return true; -
main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js
r33127 r33128 24 24 if(jsonNodeDiv.length) 25 25 { 26 console.log("@@@ JSON node div html: " + jsonNodeDiv.html());26 //console.log("@@@ JSON node div html: " + jsonNodeDiv.html()); 27 27 var jsonNodes = eval(jsonNodeDiv.html()); 28 28 … … 32 32 { 33 33 _docList[jsonNodes[i].nodeID] = jsonNodes[i]; 34 _docList.ids.push(jsonNodes[i].nodeID); 35 console.log("@@@ JSON node: " + jsonNodes[i]); 36 createMarker(jsonNodes[i], true); 34 _docList.ids.push(jsonNodes[i].nodeID); 35 createMarkers(jsonNodes[i], true); 37 36 } 38 37 updateMap(); … … 40 39 else 41 40 { 41 //hiding the map 42 42 //$("#map_canvas").css({visibility:"hidden", height:"0px"}); 43 $("#map_canvas").css({visibility:"hidden"}); 44 //console.log("suppressing hiding the map"); 43 $("#map_canvas").css({visibility:"hidden"}); // if you comment this out, add a log message saying "suppressing hiding map" 45 44 } 46 45 } … … 97 96 98 97 if ($map_canvas.length > 0) { 99 console.log("### map-scripts::setUpMap: map_canvas.exists");100 98 _map = new google.maps.Map($map_canvas[0], myOptions); 101 99 google.maps.event.addListener(_map, 'bounds_changed', performSearchForMarkers); … … 254 252 var endIndex = responseText.indexOf("</"); 255 253 256 console.log("@@@@ performSearch, got response: " + responseText);254 //console.log("@@@@ performSearch, got response: " + responseText); 257 255 258 256 var jsonNodes = eval(responseText.substring(startIndex+1, endIndex)); … … 271 269 _docList.ids.push(doc.nodeID); 272 270 273 createMarker (doc, false);271 createMarkers(doc, false); 274 272 } 275 273 } … … 337 335 } 338 336 339 if(doc.coord) { 340 var coordInfo = getLatLngForCoord(doc.coord); 341 bounds.extend(new google.maps.LatLng(coordInfo.lat, coordInfo.lng)); 337 338 if(doc.coords) { 339 for(var x = 0; x < doc.coords.length; x++) { 340 var coord = doc.coords[x]; 341 var coordInfo = getLatLngForCoord(doc.coords[x]); 342 bounds.extend(new google.maps.LatLng(coordInfo.lat, coordInfo.lng)); 343 } 342 344 } 343 345 else { … … 463 465 clearInterval(_intervalHandle); 464 466 _intervalHandle = null; 465 if(doc.coord) { 466 var coordInfo = getLatLngForCoord(doc.coord); 467 _map.panTo(new google.maps.LatLng(coordInfo.lat, coordInfo.lng)); 467 if(doc.coords) { 468 for(var x = 0; x < doc.coords.length; x++) { 469 var coord = doc.coords[x]; 470 var coordInfo = getLatLngForCoord(doc.coords[x]); 471 _map.panTo(new google.maps.LatLng(coordInfo.lat, coordInfo.lng)); 472 } 468 473 } else { 469 474 _map.panTo(new google.maps.LatLng(doc.lat, doc.lng)); … … 488 493 } 489 494 490 function createMarker(doc, mainMarker) 491 { 492 var pos; 493 if(doc.coord) { 494 var coordInfo = getLatLngForCoord(doc.coord); 495 pos = new google.maps.LatLng(coordInfo.lat,coordInfo.lng); 495 function createMarkers(doc, mainMarker) { 496 if(doc.coords) { 497 for(var x = 0; x < doc.coords.length; x++) { 498 var coord = doc.coords[x]; 499 var coordInfo = getLatLngForCoord(doc.coords[x]); 500 pos = new google.maps.LatLng(coordInfo.lat,coordInfo.lng); 501 createMarker(doc, pos, mainMarker); 502 } 496 503 } else { 497 504 pos = new google.maps.LatLng(doc.lat,doc.lng); 498 } 499 500 505 createMarker(doc, pos, mainMarker); 506 } 507 } 508 509 510 // Param mainMarker: if set to true, marker is red. If false, marker is blue 511 function createMarker(doc, pos, mainMarker) 512 { 501 513 var docEdit = (("docEdit" in gs.cgiParams) && (gs.cgiParams['docEdit'])); 502 514 //var draggable_val = (docEdit) ? true : false; … … 609 621 _docList.ids.push(doc.nodeID); 610 622 611 createMarker (doc, false);623 createMarkers(doc, false); 612 624 } 613 625 … … 825 837 function modifyFunctions() 826 838 { 827 toggleSection = function(sectionID) 828 { 839 // This function "overrides" toggleSection in both classifier_scripts.js and document_scripts.js 840 // However, classifier_scripts.js::toggleSection() only took one parameter, sectionID, whereas 841 // document_scripts.js::toggleSection() took 3 params (sectionID, callback, tocDisabled). 842 // So to be compatible with both, need map-scripts::toggleSection() here to support all 3 in that order. 843 toggleSection = function(sectionID, callback, tocDisabled) 844 { 845 _basicToggleSection(sectionID, callback, tocDisabled); 846 829 847 var section = gs.jqGet("div" + sectionID); 830 var sectionToggle = gs.jqGet("toggle" + sectionID); 831 848 var sectionToggle = gs.jqGet("toggle" + sectionID); 849 832 850 if(sectionToggle == undefined) 833 { 851 { 834 852 return; 835 } 853 } 836 854 837 855 // Test if 'section' exists. … … 839 857 // http://stackoverflow.com/questions/920236/how-can-i-detect-if-a-selector-returns-null 840 858 if(section.length !== 0) 841 { 859 { 842 860 if(isExpanded(sectionID)) 843 861 { … … 862 880 { 863 881 httpRequest(sectionID); 864 } 882 } 883 865 884 } 866 885 … … 901 920 checkout(); 902 921 } 922 /*else if(gs.cgiParams.documentbasket == "on") // TODO: copied from classifier_scripts.js - should this else block be included here (and happen when mapEnabled) or not? 923 { 924 dmcheckout(); 925 }*/ 903 926 updateOpenClassifiers(); 904 927 getSubClassifier(sectionID); -
main/trunk/greenstone3/web/interfaces/default/transform/map-tools.xsl
r33126 r33128 39 39 <xsl:if test="metadataList/metadata[@name = 'Coordinate']"> 40 40 <xsl:text disable-output-escaping="yes">,</xsl:text> 41 <xsl:text disable-output-escaping="yes">"coord":"</xsl:text> 42 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Coordinate']"/> 43 <xsl:text disable-output-escaping="yes">"</xsl:text> 41 <xsl:text disable-output-escaping="yes">"coords":</xsl:text> 42 <xsl:text>[</xsl:text> 43 <xsl:for-each select="metadataList/metadata[@name = 'Coordinate']"> 44 <xsl:text disable-output-escaping="yes">"</xsl:text> 45 <xsl:value-of disable-output-escaping="yes" select="current()"/> 46 <xsl:text disable-output-escaping="yes">"</xsl:text> 47 <xsl:text disable-output-escaping="yes">,</xsl:text> 48 </xsl:for-each> 49 <xsl:text>]</xsl:text> 44 50 </xsl:if> 45 51 <xsl:text>}</xsl:text> -
main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl
r33126 r33128 140 140 <xsl:if test="not(/page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='sectionExpandCollapse']/@value) or /page/pageResponse/format[@type='display' or @type='browse' or @type='search']/gsf:option[@name='sectionExpandCollapse']/@value = 'true'"> 141 141 <td class="headerTD"> 142 <img id="dtoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon"> 142 <img id="dtoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon"> 143 143 <xsl:attribute name="src"> 144 144 <xsl:choose> … … 856 856 <xsl:if test="metadataList/metadata[@name = 'Coordinate']"> 857 857 <xsl:text disable-output-escaping="yes">,</xsl:text> 858 <xsl:text disable-output-escaping="yes">"coord":"</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Coordinate']"/> 859 <xsl:text disable-output-escaping="yes">"</xsl:text> 858 <xsl:text disable-output-escaping="yes">"coords":</xsl:text> 859 <xsl:text>[</xsl:text> 860 <xsl:for-each select="metadataList/metadata[@name = 'Coordinate']"> 861 <xsl:text disable-output-escaping="yes">"</xsl:text> 862 <xsl:value-of disable-output-escaping="yes" select="current()"/> 863 <xsl:text disable-output-escaping="yes">"</xsl:text> 864 <xsl:text disable-output-escaping="yes">,</xsl:text> 865 </xsl:for-each> 866 <xsl:text>]</xsl:text> 860 867 </xsl:if> 861 868 <xsl:text>}</xsl:text> … … 881 888 <xsl:if test="metadataList/metadata[@name = 'Coordinate']"> 882 889 <xsl:text disable-output-escaping="yes">,</xsl:text> 883 <xsl:text disable-output-escaping="yes">"coord":"</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Coordinate']"/> 884 <xsl:text disable-output-escaping="yes">"</xsl:text> 890 <xsl:text disable-output-escaping="yes">"coords":</xsl:text> 891 <xsl:text>[</xsl:text> 892 <xsl:for-each select="metadataList/metadata[@name = 'Coordinate']"> 893 <xsl:text disable-output-escaping="yes">"</xsl:text> 894 <xsl:value-of disable-output-escaping="yes" select="current()"/> 895 <xsl:text disable-output-escaping="yes">"</xsl:text> 896 <xsl:text disable-output-escaping="yes">,</xsl:text> 897 </xsl:for-each> 898 <xsl:text>]</xsl:text> 885 899 </xsl:if> 886 900 <xsl:text>}</xsl:text> … … 891 905 <xsl:text>]</xsl:text> 892 906 </div> 907 908 <!-- TODO: Why do we have to do this to see Coordinate appear in extraMetadataList on o=xml page, when Lat and Lng appear without doing the same??? --> 909 <gsf:metadata name="Coordinate" hidden="true"/> 893 910 </xsl:template> 894 911 … … 914 931 <xsl:if test="metadataList/metadata[@name = 'Coordinate']"> 915 932 <div style="background:#BBFFBB; padding: 5px; margin:0px auto; width:890px;"> 916 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.map_nearby_docs')"/> 917 <img id="nearbyDocumentsToggle" style="margin-left:5px;" src="interfaces/{$interface_name}/images/expand.png"> 918 <xsl:attribute name="onclick"> 919 <xsl:text>performDistanceSearchWithCoordinates('</xsl:text> 920 <xsl:value-of select="@nodeID"/> 921 <xsl:text>', '</xsl:text> 922 <gsf:metadata name="Coordinate"/> 923 <xsl:text>', 2);</xsl:text> 924 </xsl:attribute> 925 </img> 926 <div id="nearbyDocuments"><xsl:text> </xsl:text></div> 933 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.map_nearby_docs')"/> 934 <xsl:for-each select="metadataList/metadata[@name = 'Coordinate']"> 935 936 <xsl:variable name="coordinate"><xsl:value-of select="current()"/></xsl:variable> 937 938 939 <img id="nearbyDocumentsToggle" style="margin-left:5px;" src="interfaces/{$interface_name}/images/expand.png"> 940 <xsl:attribute name="onclick"> 941 <xsl:text>performDistanceSearchWithCoordinates('</xsl:text> 942 <xsl:value-of select="@nodeID"/> 943 <xsl:text>', '</xsl:text> 944 <xsl:value-of select="$coordinate"/><!--<gsf:metadata name="Coordinate"/>--> 945 <xsl:text>', 2);</xsl:text> 946 </xsl:attribute> 947 </img> 948 </xsl:for-each> 949 <div id="nearbyDocuments"><xsl:text> </xsl:text></div> 927 950 </div> 928 951 </xsl:if>
Note:
See TracChangeset
for help on using the changeset viewer.