Ignore:
Timestamp:
2019-06-11T20:20:04+12:00 (5 years 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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() {
Note: See TracChangeset for help on using the changeset viewer.