Interactive interface for browsing global, full-resolution satellite imagery
added animation annotations
Benjamincc366c53c176
diff --git a/web/js/animation/wv.anim.gif.js b/web/js/animation/wv.anim.gif.jsindex 5ef32c609..a4088c9e4 100644--- a/web/js/animation/wv.anim.gif.js+++ b/web/js/animation/wv.anim.gif.js@@ -35,10 +35,31 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {"layer(s)?";var ROTATE_WARNING = "Image may not be downloaded when rotated. Would you like to reset rotation?";+ /*+ * sets listeners+ *+ *+ * @method init+ * @static+ *+ * @returns {void}+ *+ */self.init = function() {models.anim.events.on('gif-click', setImageCoords);};+ /*+ * Uses, frameUrl array and gifShot+ * Library to create GIF+ *+ *+ * @method createGIF+ * @static+ *+ * @returns {void}+ *+ */self.createGIF = function() {var stateObj = animModel.rangeState;var interval = stateObj.speed;@@ -82,6 +103,18 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {'progressCallback': onGifProgress}, onGifComplete);};++ /*+ * Calculates resolution of frame based+ * on zoom and projection+ *+ *+ * @func calcRes+ * @private+ *+ * @returns {void}+ *+ */var calcRes = function(mode) { //return either multiplier or string resolution//geographic has 10 zoom levels from 0 to 9, polar projections have 8 from 0 to 7var isGeographic = models.proj.selected.id === "geographic";@@ -115,6 +148,17 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {return str;}};++ /*+ * checks if rotation, changed palettes, or graticules+ * are active and ask to reset if any are active+ *+ * @method getGif+ * @static+ *+ * @returns {void}+ *+ */self.getGif = function() {var layers;//check for rotation, changed palettes, and graticule layers and ask for reset if so@@ -158,6 +202,17 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {}self.createGIF();};++ /*+ * checks if rotation, changed palettes, or graticules+ * are active and ask to reset if any are active+ *+ * @method getGif+ * @private+ *+ * @returns {void}+ *+ */var formImageURL = function() {//Gather all data to get the imagevar proj = models.proj.selected.id,@@ -191,6 +246,18 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {return wv.util.format("https://gibs.earthdata.nasa.gov/image-download?{1}&extent={2}&epsg={3}&layers={4}&opacities={5}&worldfile=false&format=image/jpeg&width={6}&height={7}", "TIME={1}", lonlat1[0]+","+lonlat1[1]+","+lonlat2[0]+","+lonlat2[1], epsg, layers.join(","), opacities.join(","), imgWidth, imgHeight);};++ /*+ * loops through dates and created image+ * download urls and pushs them to an+ * array+ *+ * @method getImageArray+ * @private+ *+ * @returns {array} array of jpg urls+ *+ */var getImageArray = function (startDate, endDate) {var url = formImageURL();var a = [];@@ -219,12 +286,33 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {return a;};+ /*+ * Thows an alert notifies the user+ * that too many frames were selected+ *+ * @method showUnavailableReason+ * @private+ *+ * @returns {void}+ *+ */var showUnavailableReason = function() {var headerMsg = "<h3 class='wv-data-unavailable-header'>GIF Not Available</h3>";var bodyMsg = 'Too many frames were selected. Please request less than 40 frames if you would like to generate a GIF';wv.ui.notify(headerMsg + bodyMsg, "Notice", 600);};++ /*+ * resets map rotation to+ * zero degrees+ *+ * @method resetRotation+ * @private+ *+ * @returns {void}+ *+ */var resetRotation = function() {ui.map.selected.beforeRender(ol.animation.rotate({duration: 400,@@ -232,6 +320,19 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {}));ui.map.selected.getView().rotate(0);};++ /*+ * Handles GIF generater conpletion+ *+ * @method onGifComplete+ * @callback+ *+ * @param obj {object} gifShot GIF-complete+ * object+ *+ * @returns {void}+ *+ */var onGifComplete = function (obj) { //callback function for when image is finishedif (obj.error === false) {$progress.remove();@@ -338,6 +439,19 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {});}};++ /*+ * uses resolution and dimension to+ * calculates size of selected area+ *+ * @method calcSize+ * @private+ *+ * @param c {object} dimension object+ *+ * @returns {number} Size of frame+ *+ */var calcSize = function(c) {var lonlat1 = ui.map.selected.getCoordinateFromPixel([Math.floor(c.x), Math.floor(c.y2)]),lonlat2 = ui.map.selected.getCoordinateFromPixel([Math.floor(c.x2), Math.floor(c.y)]);@@ -349,11 +463,35 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {return ((imgWidth * imgHeight * 24) / 8388608).toFixed(2);};++ /*+ * removes jquery JCrop+ *+ * @method removeCrop+ * @private+ *+ * @param c {object} dimension object+ *+ * @returns {void}+ *+ */var removeCrop = function() {$("#wv-map").insertAfter('#productsHolder'); //retain map element before disabling jcropanimCoords = undefined;jcropAPI.destroy();};++ /*+ * Builds selector dialog+ *+ * @method getSelectorDialog+ * @private+ *+ * @param width {number}+ *+ * @returns {JQuery} Selector diaglog element+ *+ */self.getSelectorDialog = function(width) {var $dialogBox;var $createButton;@@ -403,6 +541,19 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {});return $dialogBox;};++ /*+ * Sets diaglog width && location+ *+ * @method setDialogWidth+ * @private+ *+ * @param $dialog {Jquery} dialog+ * @param width {number} JCrop selector width+ *+ * @returns {void}+ *+ */var setDialogWidth = function($dialog, width) {var $parent;if($dialog) {@@ -415,6 +566,19 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {});}};++ /*+ * Adjusts download icon size+ *+ * @method setIconFontSize+ * @private+ *+ * @param $el {Jquery} icon element+ * @param width {number} JCrop selector width+ *+ * @returns {void}+ *+ */var setIconFontSize = function($el, width) {var fs = Math.abs(width / 4);if(!$el)@@ -424,6 +588,17 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {}$el.css('font-size', fs);};++ /*+ * Initializes and sets callbacks for+ * Jcrop selector+ *+ * @method setImageCoords+ * @private+ *+ * @returns {void}+ *+ */var setImageCoords = function() {var starterWidth;var $dlButton;diff --git a/web/js/animation/wv.anim.model.js b/web/js/animation/wv.anim.model.jsindex a77445ef6..ac47a160d 100644--- a/web/js/animation/wv.anim.model.js+++ b/web/js/animation/wv.anim.model.js@@ -26,6 +26,18 @@ wv.anim.model = wv.anim.model || function(models, config) {reverse: false};+ /*+ * Pulls state.a from permalink+ * on page load+ *+ * @method load+ * @static+ *+ * @param state {object} state object+ * @param errors {object} error object+ * @returns {void}+ *+ */self.load = function(state, errors) {//is running twice on page load?????//console.log('loading');@@ -39,6 +51,17 @@ wv.anim.model = wv.anim.model || function(models, config) {});}};++ /*+ * Toggles state object between+ * on and off+ *+ * @method toggleActive+ * @static+ *+ * @returns {void}+ *+ */self.toggleActive = function() {if(self.rangeState.state === 'off') {self.rangeState.state = 'on';@@ -46,6 +69,17 @@ wv.anim.model = wv.anim.model || function(models, config) {self.rangeState.state = 'off';}};++ /*+ * saves animation state to permalink+ *+ * @method save+ * @static+ *+ * @returns {void}+ *+ */+self.add = function(arra) {var updatedState = _.clone(self.state);arra.forEach(function(prop) {@@ -53,12 +87,16 @@ wv.anim.model = wv.anim.model || function(models, config) {});self.animationState = updatedState;};-- self.animate = function() {-- };- //update animation fields, set animation settings into an object+ /*+ * saves animation state to permalink+ *+ * @method save+ * @static+ *+ * @returns {void}+ *+ */self.save = function(state) {var activeState;var playStates;diff --git a/web/js/animation/wv.anim.rangeselect.js b/web/js/animation/wv.anim.rangeselect.jsindex c80ed52ad..9dc3746ea 100644--- a/web/js/animation/wv.anim.rangeselect.js+++ b/web/js/animation/wv.anim.rangeselect.js@@ -28,7 +28,16 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {var $timeline = $('#timeline');ui.anim.rangeOptions = ui.anim.rangeOptions || {};-+ /*+ * set listeners and initiates+ * widget+ *+ * @method init+ * @static+ *+ * @returns {void}+ *+ */self.init = function() {var startLocation;var EndLocation;@@ -71,19 +80,73 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {model.events.on('change', self.update);self.render(self.options);};++ /*+ * renders react rangeselector component+ *+ * @method render+ * @static+ *+ * @param options {object}+ * @returns {void}+ *+ */self.render = function(options) {self.reactComponent = ReactDOM.render(rangeSelectionFactory(options), $mountLocation);};++ /*+ * calculates offset of timeline+ *+ * @method getHeaderOffset+ * @static+ *+ * @returns {number} OffsetX+ *+ */self.getHeaderOffset = function() {return $header.width() + Number($timeline.css('left').replace("px", "")) + Number($footer.css('margin-left').replace("px", ""));};++ /*+ * calculates offset of date+ * on timeline+ *+ * @method getLocationFromStringDate+ * @static+ *+ * @param date {string} date string+ * @returns {number} OffsetX+ *+ */self.getLocationFromStringDate = function(date) {return timeline.x(new Date(date));};++ /*+ * updates react component state+ *+ * @method update+ * @static+ *+ * @param date {string} date string+ * @returns {void}+ *+ */self.update = function() { // being called from timeline.config.jsvar props = self.updateOptions();self.reactComponent.setState(props);};++ /*+ * returns max width of timeline+ *+ * @method getMaxWidth+ * @static+ *+ * @returns {number} max width+ *+ */self.getMaxWidth = function() {var $elWidth = $footer.width();var $dataWidth = timeline.x(timeline.data.end());@@ -92,6 +155,16 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {}return $elWidth;};++ /*+ * Gets prop updates+ *+ * @method updateOptions+ * @static+ *+ * @returns {object} props+ *+ */self.updateOptions = function() {var max;var state = model.rangeState;@@ -102,12 +175,40 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {return props;};++ /*+ * Handles click on widget:+ * switches current date to+ * date clicked+ *+ * @method onRangeClick+ * @static+ *+ * @param e {object} native event object+ *+ * @returns {object} props+ *+ */self.onRangeClick = function(e) {var headerOffset = self.getHeaderOffset();var offsetX = (e.pageX - headerOffset);var date = timeline.x.invert(offsetX);models.date.select(date);};++ /*+ * Updates start and end dates and triggers+ * change events+ *+ * @method updateRange+ * @static+ *+ * @param startLocation {number} offsetX+ * @param EndLocation {number} offsetX+ *+ * @returns {object} props+ *+ */self.updateRange = function(startLocation, EndLocation) {var startDate = timeline.x.invert(startLocation);var endDate = timeline.x.invert(EndLocation);diff --git a/web/js/animation/wv.anim.ui.js b/web/js/animation/wv.anim.ui.jsindex abf455ef3..2a8e9e6d0 100644--- a/web/js/animation/wv.anim.ui.js+++ b/web/js/animation/wv.anim.ui.js@@ -24,6 +24,16 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {var pastDates;var loader;+ /*+ * sets listeners+ *+ *+ * @method init+ * @static+ *+ * @returns {void}+ *+ */self.init = function() {self.refreshState();animModel.events.on('play', self.onPushedPlay);@@ -38,11 +48,35 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {ui.map.events.on('added-layer', self.refreshState);//map.on('moveend', self.refreshState);};++ /*+ * If there is a change of date+ * and the animiation is not playing+ * the amin.ui states will be refreshed+ *+ * @method dateChange+ * @static+ *+ * @returns {void}+ *+ */self.dateChange = function() {if(!self.state.playing) {self.refreshState();}};++ /*+ * Resets amin.ui object+ * and variable states+ *+ * @method refreshState+ * @static+ *+ * @returns {void}+ *+ */+self.refreshState = function() {preloadArray = [];preload = {};@@ -59,6 +93,18 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {wv.ui.indicator.hide(loader);wv.ui.indicator._hide(loader);};+ /*+ * Determines whether to start at+ * current date or to start at the+ * selected start date+ *+ * @method getStartDate+ * @static+ *+ * @returns {string} ISO string Date+ *+ */+self.getStartDate = function() {var state;var endDate;@@ -74,16 +120,62 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {return wv.util.toISOStringDate(startDate);};++ /*+ * Handles a play click event+ *+ * @method onPushedPlay+ * @static+ *+ * @returns {void}+ *+ */self.onPushedPlay = function() {self.checkQueue(queueLength, self.state.playIndex);self.checkShouldPlay();};++ /*+ * retrieves the current timeline zoom+ *+ * @method getInterval+ * @static+ *+ * @returns {string} Zoom increment+ *+ */self.getInterval = function() {return zooms[ui.timeline.config.currentZoom - 1];};++ /*+ * Gets next date based on current+ * increments+ *+ * @method nextDate+ * @static+ *+ * @param date {object} JS date obj+ *+ * @returns {object} JS Date+ *+ */self.nextDate = function(date) {return wv.util.dateAdd(date, self.getInterval(), 1);};++ /*+ * Gets next date based on current+ * increments+ *+ * @method nextDate+ * @static+ *+ * @param date {object} JS date obj+ *+ * @returns {object} JS Date+ *+ */self.addDate = function(date) {self.addToInQueue(date);queue.add(function () {@@ -96,16 +188,55 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {self.checkShouldPlay();});};++ /*+ * Add date to loading Queue+ * obj+ *+ * @method addToInQueue+ * @static+ *+ * @param date {object} JS date obj+ *+ * @returns {void}+ *+ */self.addToInQueue = function(date) {var strDate = wv.util.toISOStringDate(date);inQueue[strDate] = date;preloadArray.push(strDate);};++ /*+ * removes date from inQueue obj+ * and adds it to the preloaded+ * obj+ *+ * @method addDateToCache+ * @static+ *+ * @param date {object} JS date obj+ *+ * @returns {void}+ *+ */self.addDateToCache = function(date) {var strDate = wv.util.toISOStringDate(date);preload[strDate] = date;delete inQueue[strDate];};++ /*+ * removes item from cache after it has+ * been played and quelimit reached+ *+ *+ * @method shiftCache+ * @static+ *+ * @returns {void}+ *+ */self.shiftCache = function() {var key;if(preload[preloadArray[0]] &&@@ -117,6 +248,21 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {delete pastDates[key];}};++ /*+ * checks if this date is in array of+ * dates that need to play in future+ * within buffer length+ *+ *+ * @method isInToPlayGroup+ * @static+ *+ * @param testDate {string} JS date string+ *+ * @returns {boolean}+ *+ */self.isInToPlayGroup = function(testDate) {var loop = animModel.rangeState.loop;var i = 0;@@ -140,10 +286,34 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {}return false;};++ /*+ * Clears precache+ *+ * @method clearCache+ * @static+ *+ *+ * @returns {void}+ *+ */self.clearCache = function() {preload = {};preloadArray = [];};++ /*+ * Determines what dates should+ * be queued+ *+ * @method checkQueue+ * @static+ *+ * @param bufferLength {number} JS date string+ * @param index {string} Date string+ * @returns {void}+ *+ */self.checkQueue = function(bufferLength, index) {var date;var currentDate;@@ -165,8 +335,18 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {} else if(self.state.supportingCustomLayers && preloadArray[0]) {self.customQueuer(currentDate, startDate, endDate);}-};++ /*+ * Checks to see if custom layers are+ * active+ *+ * @method hasCustomLayers+ * @static+ *+ * @returns {boolean}+ *+ */self.hasCustomLayers = function() {var layer;var layers = models.layers.get();@@ -179,6 +359,21 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {}return false;};++ /*+ * Custom date queuer created for+ * custom colormaps+ *+ * @method customQueuer+ * @static+ *+ * @param currentDate {object} JS date+ * @param startDate {object} JS date+ * @param endDate {object} JS date+ *+ * @returns {void}+ *+ */self.customQueuer = function(currentDate, startDate, endDate) {var nextDateStr;var nextDate = self.nextDate(currentDate);@@ -193,6 +388,21 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {self.checkQueue(queueLength, self.state.playIndex);}};++ /*+ * adds dates to precache queuer+ *+ * @method initialPreload+ * @static+ *+ * @param currentDate {object} JS date+ * @param startDate {object} JS date+ * @param endDate {object} JS date+ * @param lastToQueue {string} date String+ *+ * @returns {void}+ *+ */self.initialPreload = function(currentDate, startDate, endDate, lastToQueue) {var day = currentDate;queueLength = self.getQueueLength(startDate, endDate);@@ -211,6 +421,21 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {}loader = wv.ui.indicator.loading();};++ /*+ * calculates buffer length if+ * date array length is less than+ * default queueLength+ *+ * @method getQueueLength+ * @static+ *+ * @param startDate {object} JS date+ * @param endDate {object} JS date+ *+ * @returns {number} new buffer length+ *+ */self.getQueueLength= function(startDate, endDate) {var day = startDate;var i = 0;@@ -223,6 +448,20 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {}return i;};++ /*+ * Verifies that date is+ * valid and adds it to queuer+ *+ * @method addItemToQueue+ * @static+ *+ * @param startDate {object} JS date+ * @param endDate {object} JS date+ *+ * @returns {void}+ *+ */self.addItemToQueue = function(currentDate, startDate, endDate) {var nextDate = self.getNextBufferDate(currentDate, startDate, endDate);var nextDateStr = wv.util.toISOStringDate(nextDate);@@ -235,6 +474,21 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {self.checkQueue(queueLength, self.state.playIndex);}};++ /*+ * gets next date to add to+ * queue+ *+ * @method addItemToQueue+ * @static+ *+ * @param currentDate {object} JS date+ * @param startDate {object} JS date+ * @param endDate {object} JS date+ *+ * @returns {object} JS Date+ *+ */self.getNextBufferDate = function(currentDate, startDate, endDate) {var lastInBuffer = wv.util.parseDateUTC(preloadArray[preloadArray.length - 1]);var nextDate = self.nextDate(lastInBuffer);@@ -243,6 +497,21 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {}return self.nextDate(lastInBuffer);};++ /*+ * Gets the last date that should be added+ * to the queuer+ *+ * @method getLastBufferDateStr+ * @static+ *+ * @param currentDate {object} JS date+ * @param startDate {object} JS date+ * @param endDate {object} JS date+ *+ * @returns {string} Date string+ *+ */self.getLastBufferDateStr = function(currentDate, startDate, endDate) {var day = currentDate;var loop = animModel.rangeState.loop;@@ -261,6 +530,20 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {}return wv.util.toISOStringDate(day);};++ /*+ * Gets the last date that should be added+ * to the queuer+ *+ * @method checkShouldLoop+ * @static+ *+ * @param playIndexJSDate {object} JS date+ * that is currently being shown+ *+ * @returns {void}+ *+ */self.checkShouldLoop = function(playIndexJSDate) {if(animModel.rangeState.loop) {self.shiftCache();@@ -273,6 +556,20 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {self.refreshState();}};++ /*+ * Gets the last date that should be added+ * to the queuer+ *+ * @method checkShouldLoop+ * @static+ *+ * @param playIndexJSDate {object} JS date+ * that is currently being shown+ *+ * @returns {void}+ *+ */self.checkShouldPlay = function() {var currentDate = wv.util.parseDateUTC(self.state.playIndex);var fps = 1000 / animModel.rangeState.speed;@@ -294,6 +591,19 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {}self.shiftCache();};++ /*+ * removes loader and starts the+ * animation+ *+ * @method play+ * @static+ *+ * @param index {string} date string+ *+ * @returns {void}+ *+ */self.play = function(index) {self.state.playing = true;wv.ui.indicator.hide(loader);@@ -301,6 +611,20 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {self.animate(index);return;};++ /*+ * Gets date to start on when animation+ * is being looped+ *+ * @method setNewDate+ * @static+ *+ * @param date {number} JS Date+ * @param newDate {number} JS Date+ *+ * @returns {void}+ *+ */self.setNewDate = function(date, newDate) {var interval = self.getInterval();var newDateDay = newDate.getDate() + 1;@@ -318,6 +642,18 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {return newDate;}};++ /*+ * function that loops through frames+ * at a specified time interval+ *+ * @method animate+ * @static+ *+ * @param index {string} Date string+ * @returns {void}+ *+ */self.animate = function(index) {var interval;var playIndex = index;