Changeset 33148

Show
Ignore:
Timestamp:
11.06.2019 20:20:04 (6 days ago)
Author:
wy59
Message:

1. Untested changes to Panorama viewer related xsl and js files to incorporate Coordinate meta wherever Latitude and Longitude meta was referred to. There's no way to test as we have no existing or tutorial collection making use of the Panorama Viewer to hand, however, a lot of the code added to deal with Coordinates is identical to other Coordinate insertions where Lat Long was used in classifier.xsl, document.xsl and map-tools.xsl and map-scripts.js. 2. Added new and removed finished TODOs.

Location:
main/trunk/greenstone3/web/interfaces/default
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js

    r33147 r33148  
    373373} 
    374374 
     375// TODO: FUNCTION DUPLICATED IN panoramaViewer.js 
    375376function getLatLngForCoord(coord) { 
    376377     
  • main/trunk/greenstone3/web/interfaces/default/js/panoramaViewer.js

    r26883 r33148  
    212212    panoDocList.ids.move(panoDocList.ids.indexOf(panoramaID), 0); 
    213213 
    214     var startPanoLonLat = new THREE.Vector3(gs.documentMetadata[panoramaID].Latitude,gs.documentMetadata[panoramaID].Longitude); 
     214    var startPanoLonLat; 
     215    if(typeof gs.documentMetadata[panoramaID].Coordinate !== 'undefined'){ // we have Coordinate meta 
     216        var coordInfo = getLatLngForCoord(gs.documentMetadata[panoramaID].Coordinate); 
     217        startPanoLonLat = new THREE.Vector3(coordInfo.lat,coordInfo.lng); 
     218    } else { 
     219        startPanoLonLat = new THREE.Vector3(gs.documentMetadata[panoramaID].Latitude,gs.documentMetadata[panoramaID].Longitude); 
     220    } 
    215221 
    216222    // going through the panolist checking the distance 
    217223    for(var i = 1; i < panoDocList.ids.length; i++) { 
    218     var endPanoLonLat = new THREE.Vector3(gs.documentMetadata[panoDocList.ids[i]].Latitude,gs.documentMetadata[panoDocList.ids[i]].Longitude); 
     224    var endPanoLonLat; 
     225    if(typeof gs.documentMetadata[panoDocList.ids[i]].Coordinate !== 'undefined'){ // we have Coordinate meta 
     226        var coordInfo = getLatLngForCoord(gs.documentMetadata[panoDocList.ids[i]].Coordinate); 
     227        endPanoLonLat = new THREE.Vector3(coordInfo.lat,coordInfo.lng); 
     228    } else { 
     229        endPanoLonLat = new THREE.Vector3(gs.documentMetadata[panoDocList.ids[i]].Latitude,gs.documentMetadata[panoDocList.ids[i]].Longitude); 
     230    } 
    219231    if(calculateDistance(startPanoLonLat,endPanoLonLat) < panoSelectionRadius) { 
    220232        var bearing = calculateBearing(startPanoLonLat,endPanoLonLat);  
     
    235247    } 
    236248     
    237 }  
    238  
     249} 
     250 
     251// DUPLICATED FROM map-scripts.js 
     252function getLatLngForCoord(coord) { 
     253     
     254    // https://stackoverflow.com/questions/2559318/how-to-check-for-an-undefined-or-null-variable-in-javascript 
     255    if(!coord) { 
     256         // some_variable is either null, undefined, 0, NaN, false, or an empty string 
     257        console.log("@@@@ In panoramaViewer::getLatLngForCoord(): no or invalid coord info"); 
     258        return null; 
     259    } 
     260     
     261    // coord is of the form: "37S77 157E53" 
     262    // lat will be 37S77, lng 157E53. 
     263    var indexOfSpace = coord.indexOf(" "); 
     264    if(indexOfSpace === -1) { 
     265        console.log("@@@@ In panoramaViewer::getLatLngForCoord(): bad format for coord  " + coord); 
     266        return null; 
     267    } 
     268    var latitude = coord.substring(0, indexOfSpace); 
     269    var longitude = coord.substring(indexOfSpace+1); 
     270    return {lat: latitude, lng: longitude}; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects 
     271} 
    239272 
    240273function onWindowResize() { 
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/classifier.xsl

    r33125 r33148  
    305305    </xsl:if> 
    306306 
    307     <!-- TODO: anything equivalent for Coordinate metadata? --> 
    308307    <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'"> 
    309       <xsl:if test=" metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude'] and metadataList/metadata[@name = 'PhotoType']='Panorama'"> 
     308      <xsl:if test="metadataList/metadata[@name = 'PhotoType']='Panorama' and ( metadataList/metadata[@name = 'Coordinate'] or ( metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']))"> 
    310309    <xsl:call-template name="panoramaViewerFeaturesIcon"/> 
    311310      </xsl:if> 
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/query.xsl

    r33094 r33148  
    653653 
    654654        <xsl:if test="/page/pageResponse/format/gsf:option[@name='panoramaViewerEnabled']/@value = 'true'"> 
    655           <xsl:if test=" metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']"> 
     655          <xsl:if test=" metadataList/metadata[@name = 'Coordinate'] or ( metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude'])"> 
    656656                    <xsl:call-template name="panoramaViewerFeaturesIcon"/> 
    657657                  </xsl:if> 
  • main/trunk/greenstone3/web/interfaces/default/transform/panorama-viewer-tools.xsl

    r31550 r33148  
    1212      <xsl:text>[</xsl:text> 
    1313      <xsl:for-each select="//documentNode"> 
    14     <xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude'] and metadataList/metadata[@name = 'PhotoType']='Panorama'"> 
     14    <xsl:if test="metadataList/metadata[@name = 'PhotoType']='Panorama' and (metadataList/metadata[@name = 'Coordinate'] or (metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']))"> 
    1515      <xsl:text>{</xsl:text> 
    1616      <xsl:text disable-output-escaping="yes">"nodeID":"</xsl:text><xsl:value-of select="@nodeID"/><xsl:text disable-output-escaping="yes">",</xsl:text> 
    17       <xsl:text disable-output-escaping="yes">"source":"</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Source']"/>"<xsl:text>,</xsl:text> 
    18       <xsl:text disable-output-escaping="yes">"lat":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Latitude']"/><xsl:text>,</xsl:text> 
    19       <xsl:text disable-output-escaping="yes">"lng":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/> 
     17      <xsl:text disable-output-escaping="yes">"source":"</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Source']"/>" 
     18      <xsl:if test="metadataList/metadata[@name = 'Latitude'] and metadataList/metadata[@name = 'Longitude']"> 
     19        <xsl:text disable-output-escaping="yes">,</xsl:text> 
     20        <xsl:text disable-output-escaping="yes">"lat":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Latitude']"/><xsl:text>,</xsl:text> 
     21        <xsl:text disable-output-escaping="yes">"lng":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/> 
     22      </xsl:if> 
     23      <xsl:if test="metadataList/metadata[@name = 'Coordinate']"> 
     24        <xsl:text disable-output-escaping="yes">,</xsl:text> 
     25        <xsl:text disable-output-escaping="yes">"coords":</xsl:text> 
     26        <xsl:text>[</xsl:text> 
     27        <xsl:for-each select="metadataList/metadata[@name = 'Coordinate']"> 
     28            <xsl:text disable-output-escaping="yes">"</xsl:text> 
     29            <xsl:value-of disable-output-escaping="yes" select="current()"/> 
     30            <xsl:text disable-output-escaping="yes">"</xsl:text>             
     31            <xsl:text disable-output-escaping="yes">,</xsl:text> 
     32        </xsl:for-each> 
     33        <xsl:text>]</xsl:text> 
     34      </xsl:if>  
    2035      <xsl:text>}</xsl:text> 
    2136      <xsl:if test="not(position() = count(//documentNode))"> 
     
    2944    <gsf:metadata name="Latitude" hidden="true"/> 
    3045    <gsf:metadata name="Longitude" hidden="true"/> 
     46    <gsf:metadata name="Coordinate" hidden="true"/> 
    3147    <gsf:metadata name="Image" hidden="true"/> 
    3248    <gsf:metadata name="SourceFile" hidden="true"/>