Skip to content

Commit f5e6f32

Browse files
WV-3285 Pre-Caching Nearby Non-Subdaily Layers Fix (#5380)
* Cleared time on request * Prevented subdaily layers from being time-stripped
1 parent 1fb228e commit f5e6f32

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

web/js/map/layerbuilder.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ export default function mapLayerBuilder(config, cache, store) {
120120

121121
// Don't key by time if this is a static layer
122122
if (def.period) {
123-
date = util.toISOStringSeconds(util.roundTimeOneMinute(options.date));
123+
const isSubdaily = def.period === 'subdaily';
124+
date = util.toISOStringSeconds(util.roundTimeOneMinute(options.date), !isSubdaily);
124125
}
125126
if (isPaletteActive(def.id, activeGroupStr, state)) {
126127
style = getPaletteKeys(def.id, undefined, state);
@@ -373,7 +374,7 @@ export default function mapLayerBuilder(config, cache, store) {
373374
tileSize: tileSize[0],
374375
};
375376

376-
const urlParameters = `?TIME=${util.toISOStringSeconds(layerDate)}`;
377+
const urlParameters = `?TIME=${util.toISOStringSeconds(layerDate, !isSubdaily)}`;
377378
const sourceURL = def.sourceOverride || configSource.url;
378379
const sourceOptions = {
379380
url: sourceURL + urlParameters,
@@ -421,6 +422,7 @@ export default function mapLayerBuilder(config, cache, store) {
421422
let extent;
422423
let start;
423424
let res;
425+
const isSubdaily = def.period === 'subdaily';
424426

425427
const source = config.sources[def.source];
426428
extent = selectedProj.maxExtent;
@@ -459,7 +461,7 @@ export default function mapLayerBuilder(config, cache, store) {
459461
if (day && def.wrapadjacentdays) {
460462
date = util.dateAdd(date, 'day', day);
461463
}
462-
urlParameters = `?TIME=${util.toISOStringSeconds(util.roundTimeOneMinute(date))}`;
464+
urlParameters = `?TIME=${util.toISOStringSeconds(util.roundTimeOneMinute(date), !isSubdaily)}`;
463465

464466
const sourceOptions = {
465467
url: source.url + urlParameters,

web/js/util/util.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,12 @@ export default (function(self) {
232232
* @method toISOStringSeconds
233233
* @static
234234
* @param {Date} date the date to convert
235+
* @param {Boolean} shouldRemoveTime if the time should be removed from the date
235236
* @return {string} ISO string in the form of `YYYY-MM-DDThh:mm:ssZ`.
236237
*/
237-
self.toISOStringSeconds = function(date) {
238+
self.toISOStringSeconds = function(date, shouldRemoveTime = false) {
238239
const isString = typeof date === 'string' || date instanceof String;
240+
if (shouldRemoveTime) date = self.clearTimeUTC(date);
239241
const dateString = isString ? date : date.toISOString();
240242
return `${dateString.split('.')[0]}Z`;
241243
};

0 commit comments

Comments
 (0)