Skip to content

Commit

Permalink
WV-784: Image download now only includes layers that are available fo…
Browse files Browse the repository at this point in the history
…r the selected date
  • Loading branch information
mike-mcgann committed Mar 3, 2014
1 parent 9cbbe18 commit 1f4ad19
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/js/image/wv.image.panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 23 additions & 0 deletions src/js/layers/wv.layers.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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 ) {
Expand Down

0 comments on commit 1f4ad19

Please sign in to comment.