From 1f4ad19645acaf02435324239bd8e33fe833c6e5 Mon Sep 17 00:00:00 2001 From: Mike McGann Date: Mon, 3 Mar 2014 16:09:02 -0500 Subject: [PATCH] WV-784: Image download now only includes layers that are available for the selected date --- src/js/image/wv.image.panel.js | 3 ++- src/js/layers/wv.layers.model.js | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/js/image/wv.image.panel.js b/src/js/image/wv.image.panel.js index 2fc2a8a65e..9f7c61a297 100644 --- a/src/js/image/wv.image.panel.js +++ b/src/js/image/wv.image.panel.js @@ -75,7 +75,8 @@ wv.image.panel = wv.image.panel || function(models, ui, config) { var s = models.proj.selected.id; var products = models.layers.get({ visibleOnly: true, - reverse: true + reverse: true, + availableOnly: true }); // NOTE: This need to be changed back to the projection model // when the backfill removes the old projection. diff --git a/src/js/layers/wv.layers.model.js b/src/js/layers/wv.layers.model.js index fcc7392377..5678cdbaed 100644 --- a/src/js/layers/wv.layers.model.js +++ b/src/js/layers/wv.layers.model.js @@ -78,6 +78,9 @@ wv.layers.model = wv.layers.model || function(models, config) { if ( spec.visibleOnly && !self.visible[layer.id] ) { return; } + if ( spec.availableOnly && !self.available(layer.id) ) { + return; + } results.push(layer); }); if ( spec.reverse ) { @@ -93,6 +96,26 @@ wv.layers.model = wv.layers.model || function(models, config) { return baselayers.concat(overlays); }; + self.available = function(layerId) { + var layer = config.layers[layerId]; + if ( layer.period !== "daily" ) { + return true; + } + if ( layer.startDate ) { + var start = wv.util.parseDateUTC(layer.startDate); + if ( models.date.selected < start ) { + return false; + } + } + if ( layer.endDate ) { + var end = wv.util.parseDateUTC(layer.endDate); + if ( models.date.selected > end ) { + return false; + } + } + return true; + }; + self.dateRange = function(proj) { proj = proj || models.proj.selected.id; if ( config.parameters && config.parameters.debugGIBS ) {