Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

WV-61: Positioning now waits 3 hours before flipping to the next day

Mike McGann1efaeccadf24
diff --git a/js/Worldview.js b/js/Worldview.js
index 11e4d60a9..dea8783b8 100644
--- a/js/Worldview.js
+++ b/js/Worldview.js
@@ -70,11 +70,12 @@
}
ns.overrideNow = function(date) {
+ var overrideToday = date.clone().clearUTCTime();
ns.now = function() {
- return date;
+ return new Date(date.getTime());
}
ns.today = function() {
- return date;
+ return new Date(overrideToday.getTime());
}
};
diff --git a/js/Worldview/Widget/WorldviewMap.js b/js/Worldview/Widget/WorldviewMap.js
index a9d8bca18..0ec8f5460 100644
--- a/js/Worldview/Widget/WorldviewMap.js
+++ b/js/Worldview/Widget/WorldviewMap.js
@@ -119,12 +119,19 @@ Worldview.Widget.WorldviewMap = function(containerId, config) {
if ( self.productMap.projection !== "geographic" ) {
return;
}
+
+ var map = self.productMap.map;
// Map center will be placed near the leading edge of NRT data.
// Terra and Aqua cross the dateline at UTC midnight. Base calculations
// on the current hour.
var hour = Worldview.now().getUTCHours();
- var map = self.productMap.map;
+
+ // On a new day, there will not be much processed data to show. Wait
+ // on the previous day until GIBS catches up.
+ if ( hour < Worldview.GIBS_HOUR_DELAY ) {
+ hour = 24;
+ }
// On average, there are 15 swaths per day
var zones = 15;
@@ -137,11 +144,15 @@ Worldview.Widget.WorldviewMap = function(containerId, config) {
// on either side.
var buffer = 3;
- // Adjust the zone to account for delay in processing.
+ // Adjust the zone east to account for delay in processing.
zone = zone + Worldview.GIBS_HOUR_DELAY;
+ // Now that we are at the approxomiate center, move east a few zones
+ // so most of the map is filled in
+ zone += 3;
+
// Fit the zone within the buffer range
- zone = Worldview.clamp(buffer, zones - buffer, zone);
+ zone = Worldview.clamp(buffer, zones - buffer, Math.round(zone));
var lon = -180 + (zone * degreesPerSwath);
var lat = 0;
diff --git a/js/dateSpan.js b/js/dateSpan.js
index be63fb1fb..7fb65f100 100644
--- a/js/dateSpan.js
+++ b/js/dateSpan.js
@@ -81,7 +81,7 @@ SOTE.widget.DateSpan = function(containerId, config){
config.startDate = new Date(Date.UTC(2012, 4, 8, 0, 0, 0));
}
else{
- config.endDate = new Date(config.endDate);
+ config.startDate = new Date(config.startDate);
}
if(config.range === undefined){
@@ -89,7 +89,7 @@ SOTE.widget.DateSpan = function(containerId, config){
}
if(config.selected === undefined){
- config.selected = new Date(config.endDate.getTime());
+ config.selected = this.getToday();
}
if(config.slideToSelect === undefined){
@@ -103,11 +103,12 @@ SOTE.widget.DateSpan = function(containerId, config){
if(config.hasThumbnail === undefined){
config.hasThumbnail = true;
}
-
- this.value = "";
+
+
this.maps = [];
this.startDate = config.startDate;
this.endDate = config.endDate;
+ console.log("start", this.startDate.toISOString(), "end", this.endDate.toISOString());
this.range = config.range; //in milliseconds
this.isCollapsed = config.isCollapsed;
this.slideToSelect = config.slideToSelect;
@@ -126,7 +127,6 @@ SOTE.widget.DateSpan = function(containerId, config){
SOTE.widget.DateSpan.prototype = new SOTE.widget.Component;
-
/**
* Displays the selectable dateSpan in HTML containing a thumbnail for each day in the span. If the date range contains
* more days than the visible day span, create horizontal scrolling capability. All callbacks should be set. The
@@ -171,6 +171,18 @@ SOTE.widget.DateSpan.prototype.init = function(){
};
+SOTE.widget.DateSpan.prototype.getToday = function() {
+ // If at the beginning of the day, wait on the previous day until GIBS
+ // catches up.
+ var today = Worldview.today();
+ var now = Worldview.now();
+ if ( now.getUTCHours() < Worldview.GIBS_HOUR_DELAY ) {
+ today.setUTCDate(today.getUTCDate() - 1);
+ return today;
+ } else {
+ return today;
+ }
+};
SOTE.widget.DateSpan.refreshSliders = function(e){
var self = e.data.self;
@@ -462,7 +474,7 @@ SOTE.widget.DateSpan.prototype.showSliders = function(){
*/
SOTE.widget.DateSpan.prototype.setValue = function(value){
var d = value ? Date.parseISOString(value)
- : Worldview.today();
+ : this.getToday();
// Check to see if the date is valid, if not default to today
if (isNaN(d.getTime())) {
this.log.warn("Invalid time: " + value + ", using today");
@@ -472,6 +484,7 @@ SOTE.widget.DateSpan.prototype.setValue = function(value){
if(d.getTime() < this.startDate.getTime()) {
d = this.startDate;
}
+ console.log("now", d.toISOString(), "start", this.startDate.toISOString(), "end", this.endDate.toISOString());
if(d.getTime() <= this.endDate.getTime() &&
d.getTime() >= this.startDate.getTime()) {
var changed = false;
@@ -511,6 +524,8 @@ SOTE.widget.DateSpan.prototype.setValue = function(value){
"data at this time. The date has been adjusted to today.");
*/
} else if ( d.getTime() >= this.endDate.getTime() ) {
+ console.log("**********");
+ throw Error("BLAH");
SOTE.util.throwError("Data is not available for " + thisDay +
" yet. Try again later. The date has been adjusted to today.")
}