Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

WV-3285 Pre-Caching Nearby Non-Subdaily Layers Fix (#5380)

christof-wittreichf5e6f32b10cf
diff --git a/web/js/map/layerbuilder.js b/web/js/map/layerbuilder.js
index 02612ce5f..17921c6c4 100644
--- a/web/js/map/layerbuilder.js
+++ b/web/js/map/layerbuilder.js
@@ -120,7 +120,8 @@ export default function mapLayerBuilder(config, cache, store) {
// Don't key by time if this is a static layer
if (def.period) {
- date = util.toISOStringSeconds(util.roundTimeOneMinute(options.date));
+ const isSubdaily = def.period === 'subdaily';
+ date = util.toISOStringSeconds(util.roundTimeOneMinute(options.date), !isSubdaily);
}
if (isPaletteActive(def.id, activeGroupStr, state)) {
style = getPaletteKeys(def.id, undefined, state);
@@ -373,7 +374,7 @@ export default function mapLayerBuilder(config, cache, store) {
tileSize: tileSize[0],
};
- const urlParameters = `?TIME=${util.toISOStringSeconds(layerDate)}`;
+ const urlParameters = `?TIME=${util.toISOStringSeconds(layerDate, !isSubdaily)}`;
const sourceURL = def.sourceOverride || configSource.url;
const sourceOptions = {
url: sourceURL + urlParameters,
@@ -421,6 +422,7 @@ export default function mapLayerBuilder(config, cache, store) {
let extent;
let start;
let res;
+ const isSubdaily = def.period === 'subdaily';
const source = config.sources[def.source];
extent = selectedProj.maxExtent;
@@ -459,7 +461,7 @@ export default function mapLayerBuilder(config, cache, store) {
if (day && def.wrapadjacentdays) {
date = util.dateAdd(date, 'day', day);
}
- urlParameters = `?TIME=${util.toISOStringSeconds(util.roundTimeOneMinute(date))}`;
+ urlParameters = `?TIME=${util.toISOStringSeconds(util.roundTimeOneMinute(date), !isSubdaily)}`;
const sourceOptions = {
url: source.url + urlParameters,
diff --git a/web/js/util/util.js b/web/js/util/util.js
index 29c70067d..ce82d4f4d 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -232,10 +232,12 @@ export default (function(self) {
* @method toISOStringSeconds
* @static
* @param {Date} date the date to convert
+ * @param {Boolean} shouldRemoveTime if the time should be removed from the date
* @return {string} ISO string in the form of `YYYY-MM-DDThh:mm:ssZ`.
*/
- self.toISOStringSeconds = function(date) {
+ self.toISOStringSeconds = function(date, shouldRemoveTime = false) {
const isString = typeof date === 'string' || date instanceof String;
+ if (shouldRemoveTime) date = self.clearTimeUTC(date);
const dateString = isString ? date : date.toISOString();
return `${dateString.split('.')[0]}Z`;
};