Skip to content

Commit

Permalink
Merge pull request #4917 from nasa-gibs/wv-gitc-temp-measurement-sett…
Browse files Browse the repository at this point in the history
…ings-layers

WV GITC Fix for measurement settings layers & handle errors when adjustingStart dates on load
  • Loading branch information
ryanweiler92 authored Jan 12, 2024
2 parents d355e56 + 7be844e commit 7485dfe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions web/js/modules/layers/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -1412,16 +1412,23 @@ export function adjustStartDates(layers) {
.format('YYYY-MM-DDThh:mm:ss')}Z`;

const applyDateAdjustment = (layer) => {
const { availability, dateRanges } = layer;
const { availability, dateRanges, endDate } = layer;
if (!availability) {
return;
}
const { rollingWindow, historicalRanges } = availability;

if (Array.isArray(dateRanges) && dateRanges.length) {
const [firstDateRange] = dateRanges;
firstDateRange.startDate = adjustDate(rollingWindow);
layer.startDate = adjustDate(rollingWindow);
const adjustedDate = adjustDate(rollingWindow);

// To prevent a startDate greater than endDate for layers with a rollingWindow and specific start and end dates
if (endDate && new Date(adjustedDate) > new Date(endDate)) {
return;
}

firstDateRange.startDate = adjustedDate;
layer.startDate = adjustedDate;
} else {
console.warn(`GetCapabilities is missing the time value for ${layer.id}`);
}
Expand Down
2 changes: 1 addition & 1 deletion web/js/modules/product-picker/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const getSourcesForProjection = createSelector(
const trackGroup = currentMeasurement && currentMeasurement.id === 'orbital-track';
const sourcesForProj = sources && sources.filter(
(source) => source.settings.some((layerId) => {
if (!config.layers[layerId].projections) return;
if (!config.layers[layerId] || !config.layers[layerId].projections) return;
const { projections, layergroup } = config.layers[layerId];
const isOrbitTrack = layergroup === 'Orbital Track';
const inProj = !!projections[projection];
Expand Down

0 comments on commit 7485dfe

Please sign in to comment.