Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Added another function to generate daily product layers for (full) WMS layers

Ryan Boller8db58720c30f
diff --git a/js/util.js b/js/util.js
index 437c9e301..e58738785 100644
--- a/js/util.js
+++ b/js/util.js
@@ -235,4 +235,49 @@ SOTE.util.generateProductLayersForDateRangeNoOversample = function(displayNameSt
}
+/**
+ * Generates an array of OpenLayers layers for the specified product: one for each
+ * day starting from the current day, working backwards for a total of numDays.
+ *
+ * This version of the function is for full (i.e., non-tiled) WMS layers
+ *
+ *
+ * @param displayNameStr name shown in OL layer list; mostly for debugging at this point
+ * @param wmsProductNameStr the product name recognized by the WMS server
+ * @param formatStr the type of image format expected in return, e.g., "image/jpeg"
+ * @param urlsArr an array containing a set of URLs to the WMS; multiple array entries can be provided to allow more parallel access to WMS server
+ * @param projectionStr string containing the projection, e.g., "EPSG:4326"
+ * @param preferredOpacity preferred opacity for this layer [0.0, 1.0]
+ * @param singleTile boolean if WMS single tile flag should be set
+ * @param numDays number of days to generate; i.e., a value of 3 would generate today, yesterday, and two days ago
+ *
+ * @returns an array whose elements contain a single day of the specified product
+ *
+ */
+SOTE.util.generateWmsProductLayersForDateRange = function(displayNameStr, wmsProductNameStr, formatStr, urlsArr, projectionStr, preferredOpacityFloat, isSingleTile, numDays)
+{
+
+ // Get current date
+ var curDate = new Date();
+
+ // Generate layer for each day
+ var returnArr = new Array(numDays);
+ for (var i=0; i<numDays; i++)
+ {
+ // Generate YYYY-MM-DD string
+ var dateStr = curDate.getUTCFullYear() + "-" + SOTE.util.zeroPad(eval(curDate.getUTCMonth()+1),2) + "-" +
+ SOTE.util.zeroPad(curDate.getUTCDate(),2);
+
+ // Generate layer entry
+ returnArr[i] = {displayName: (displayNameStr + "__" + dateStr), wmsProductName: wmsProductNameStr,
+ time: dateStr, format: formatStr, urls: urlsArr, projection: projectionStr,
+ preferredOpacity: preferredOpacityFloat, singleTile: isSingleTile };
+
+ // Compute next date value by subtracting one day (in ms) from currently stored value
+ curDate = new Date(curDate - (1000*60*60*24));
+ }
+
+
+ return returnArr;
+}