Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

WV-4221: Fix Historical Date Ranges for Geostationary Products (#6931)

christof-wittreich2569404d8423
diff --git a/web/js/modules/layers/util.js b/web/js/modules/layers/util.js
index fe7a36075..bb7b059c2 100644
--- a/web/js/modules/layers/util.js
+++ b/web/js/modules/layers/util.js
@@ -1523,10 +1523,12 @@ export function adjustStartDates(layers) {
console.warn(`GetCapabilities is missing the time value for ${layer.id}`);
}
- if (Array.isArray(historicalRanges) && historicalRanges.length &&
- Array.isArray(dateRanges) && dateRanges.length) {
+ if (Array.isArray(historicalRanges) && historicalRanges.length) {
layer.startDate = historicalRanges[0].startDate;
historicalRanges.reverse().forEach((range) => {
+ if (!layer.dateRanges) {
+ layer.dateRanges = [];
+ }
layer.dateRanges.unshift(range);
});
} else {
diff --git a/web/js/modules/layers/util.test.js b/web/js/modules/layers/util.test.js
index eb800c5fc..a1bf94f3a 100644
--- a/web/js/modules/layers/util.test.js
+++ b/web/js/modules/layers/util.test.js
@@ -459,6 +459,17 @@ describe('adjustStartDates', () => {
test('sets layer startDate from adjustDate when no historicalRanges [adjust-start-dates-no-historical-ranges]', () => {
const config = buildConfig();
+ delete config.layers['test-layer'].availability.historicalRanges;
+ adjustStartDates(config.layers);
+ const layer = config.layers['test-layer'];
+ expect(layer.startDate).toBeDefined();
+ expect(layer.startDate).not.toBe('2000-01-01');
+ });
+
+ test('initializes empty dateRanges when no dateRanges [adjust-start-dates-empty-date-ranges]', () => {
+ const config = buildConfig();
+ delete config.layers['test-layer'].dateRanges;
+ console.warn(config);
adjustStartDates(config.layers);
const layer = config.layers['test-layer'];
expect(layer.startDate).toBeDefined();