From 633ddd21618b8a9e7249b3fe11345d8c2ab8095f Mon Sep 17 00:00:00 2001 From: christof-wittreich Date: Thu, 1 Aug 2024 16:47:44 -0400 Subject: [PATCH 1/2] Cleared time on request --- web/js/map/layerbuilder.js | 6 +++--- web/js/util/util.js | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/web/js/map/layerbuilder.js b/web/js/map/layerbuilder.js index 01b6dedcac..6fc44ebd81 100644 --- a/web/js/map/layerbuilder.js +++ b/web/js/map/layerbuilder.js @@ -120,7 +120,7 @@ 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)); + date = util.toISOStringSeconds(util.roundTimeOneMinute(options.date), true); } if (isPaletteActive(def.id, activeGroupStr, state)) { style = getPaletteKeys(def.id, undefined, state); @@ -373,7 +373,7 @@ export default function mapLayerBuilder(config, cache, store) { tileSize: tileSize[0], }; - const urlParameters = `?TIME=${util.toISOStringSeconds(layerDate)}`; + const urlParameters = `?TIME=${util.toISOStringSeconds(layerDate, true)}`; const sourceURL = def.sourceOverride || configSource.url; const sourceOptions = { url: sourceURL + urlParameters, @@ -459,7 +459,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), true)}`; const sourceOptions = { url: source.url + urlParameters, diff --git a/web/js/util/util.js b/web/js/util/util.js index 29c70067dd..ce82d4f4dc 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`; }; From 23944144dc461ca7d3992b5f0d0d87868b20a3ce Mon Sep 17 00:00:00 2001 From: christof-wittreich Date: Fri, 2 Aug 2024 17:01:32 -0400 Subject: [PATCH 2/2] Prevented subdaily layers from being time-stripped --- web/js/map/layerbuilder.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/web/js/map/layerbuilder.js b/web/js/map/layerbuilder.js index 6fc44ebd81..9925694c4f 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), true); + 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, true)}`; + 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), true)}`; + urlParameters = `?TIME=${util.toISOStringSeconds(util.roundTimeOneMinute(date), !isSubdaily)}`; const sourceOptions = { url: source.url + urlParameters,