Interactive interface for browsing global, full-resolution satellite imagery
adjusted GIF frame source to retrieve active layers from each day
Benjamin4d68d721c9e3
diff --git a/web/js/animation/wv.anim.gif.js b/web/js/animation/wv.anim.gif.jsindex 026d49fd2..e4c9b559d 100644--- a/web/js/animation/wv.anim.gif.js+++ b/web/js/animation/wv.anim.gif.js@@ -99,9 +99,13 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {'gifWidth': animCoords.w,'gifHeight': animCoords.h,'images': imageArra,- 'fontColor' : '#000',+ 'fontColor' : '#fff','interval': 1 / interval,- 'progressCallback': onGifProgress+ 'progressCallback': onGifProgress,+ 'stroke': {+ 'color': '#000',+ 'pixels': 2+ }}, onGifComplete);};@@ -205,59 +209,97 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {};/*- * checks if rotation, changed palettes, or graticules- * are active and ask to reset if any are active- *- * @method getGif+ * Retieves avtive layers by day+ *+ * @method getLayersForDay* @private*- * @returns {void}+ * @param {array} array of layers+ *+ * @returns {array} array of layer ids**/- var formImageURL = function() {- //Gather all data to get the image- var host, path;- var proj = models.proj.selected.id,- products = models.layers.get({- reverse: true,- renderable: true- }),- epsg = ( models.proj.change ) ? models.proj.change.epsg : models.proj.selected.epsg,- opacities = [], layers = [];- var lonlat1 = ui.map.selected.getCoordinateFromPixel([Math.floor(animCoords.x), Math.floor(animCoords.y2)]);- var lonlat2 = ui.map.selected.getCoordinateFromPixel([Math.floor(animCoords.x2), Math.floor(animCoords.y)]);-- var conversionFactor = proj === "geographic" ? 0.002197 : 256, res = calcRes(0);-- var imgWidth = Math.round((Math.abs(lonlat2[0] - lonlat1[0]) / conversionFactor) / Number(res)),- imgHeight = Math.round((Math.abs(lonlat2[1] - lonlat1[1]) / conversionFactor) / Number(res));- if ( config.features.imageDownload ) {- host = config.features.imageDownload.host;- path = config.parameters.imagegen || config.features.imageDownload.path;- } else {- host = 'https://gibs.earthdata.nasa.gov';- path = 'image-download';- }- _(products).each( function(product){- opacities.push( ( _.isUndefined(product.opacity) ) ? 1: product.opacity );- });-+ var getLayersForDay = function(products, date, proj) {+ var layers = [];_.each(products, function(layer) {- if ( layer.projections[proj].layer ) {- layers.push(layer.projections[proj].layer);- } else {- layers.push(layer.id);+ if(layer.visible && new Date(layer.startDate > date)) {+ if ( layer.projections[proj].layer ) {+ layers.push(layer.projections[proj].layer);+ } else {+ layers.push(layer.id);+ }}});- return wv.util.format(host + '/' + path + "?{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);+ return layers;+ };+ /*+ * retrieves renderable layers+ *+ * @method getProducts+ * @private+ *+ * @returns {array} array of layer objects+ *+ */+ var getProducts = function() {+ return models.layers.get({reverse: true, renderable: true });};+ /*+ * Retieves opacities from palettes+ *+ * @method getOpacities+ * @private+ *+ * @param {array} array of layers+ *+ * @returns {array} array of opacities+ *+ */+ var getOpacities = function(products) {+ var opacities = [];+ _.each(products, function(product) {+ opacities.push( ( _.isUndefined(product.opacity) ) ? 1: product.opacity );+ });+ return opacities;+ };+ /*+ * Retieves coordinates from pixel+ *+ * @method getCoords+ * @private+ *+ * @returns {array} array of coords+ *+ */+ var getCoords = function() {+ return [ui.map.selected.getCoordinateFromPixel([Math.floor(animCoords.x), Math.floor(animCoords.y2)]),+ ui.map.selected.getCoordinateFromPixel([Math.floor(animCoords.x2), Math.floor(animCoords.y)])];+ };+ /*+ * Dimenions from zoom & projection+ *+ * @method getDimensions+ * @private+ *+ * @returns {array} array with dimensions+ *+ */+ var getDimensions = function(lonlat, proj) {++ var conversionFactor = proj === "geographic" ? 0.002197 : 256;+ var res = calcRes(0);+ return [+ Math.round((Math.abs(lonlat[1][0] - lonlat[0][0]) / conversionFactor) / Number(res)),// width+ Math.round((Math.abs(lonlat[1][1] - lonlat[0][1]) / conversionFactor) / Number(res))// height+ ];+ };/** loops through dates and created image* download urls and pushs them to an* array- *+ ** @method getImageArray* @private*@@ -265,18 +307,38 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {**/var getImageArray = function (startDate, endDate) {- var url = formImageURL();+ var url;var a = [];var fromDate = new Date(startDate);var toDate = new Date(endDate);var current = fromDate;+ var host;+ var path;var j = 0;var src;var strDate;+ var lonlat = getCoords();+ var proj = models.proj.selected.id;+ var dimensions = getDimensions(lonlat, proj);+ var opacities;+ var epsg = ( models.proj.change ) ? models.proj.change.epsg : models.proj.selected.epsg;+ var products = getProducts();+++ if ( config.features.imageDownload ) {+ host = config.features.imageDownload.host;+ path = config.parameters.imagegen || config.features.imageDownload.path;+ } else {+ host = 'https://gibs.earthdata.nasa.gov';+ path = 'image-download';+ }while(current <= toDate) {j++;+ opacities = getOpacities(products);strDate = wv.util.toISOStringDate(current);+ layers = getLayersForDay(products, current, proj);+ url = wv.util.format(host + '/' + path + "?{1}&extent={2}&epsg={3}&layers={4}&opacities={5}&worldfile=false&format=image/jpeg&width={6}&height={7}", "TIME={1}", lonlat[0][0]+","+lonlat[0][1]+","+lonlat[1][0]+","+lonlat[1][1], epsg, layers.join(","), opacities.join(","), dimensions[0], dimensions[1]);src = wv.util.format(url, strDate);a.push({src: src, text: strDate});current = wv.util.dateAdd(current, ui.anim.ui.getInterval(), 1);