Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WV-3190 Smallest Subdaily Timeline Interval #5244

Merged
merged 3 commits into from
May 30, 2024

Conversation

christof-wittreich
Copy link
Contributor

Description

This code change changes the behavior of the timeline interval for subdaily layers. Firstly, it allows for subdaily layers to set a custom interval of something other than 10 minutes, and secondly, if multiple subdaily layers are present and have multiple custom intervals, the smallest interval is chosen.

How To Test

  1. git checkout wv-3190-smallest-interval-subdaily
  2. npm ci
  3. npm run watch
  4. Open a fresh worldview instance and add a subdaily layer with a custom interval of something other than 10 minutes, like VIIRS_NOAA20_CorrectedReflectance_TrueColor_Granule.
  5. Verify that the timeline interval correctly reflects the custom interval.
  6. Add another subdaily layer, with a different custom interval than the first subdaily layer added, like Himawari_AHI_Air_Mass.
  7. Verify that the timeline interval correctly reflects the smaller of the two custom intervals.
  8. Repeat the process with the same layers in a new worldview instance, but add the second layer from before first. Verify the behavior is the same.

Copy link
Contributor

@minniewong minniewong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you add a layer that has a custom interval (like a Level 2 TEMPO layer) then remove it, the interval selector now says "1440 minutes". Would be better if it went back to "1 Day".

Screenshot 2024-05-29 at 3 51 48 PM

export function getSmallestIntervalValue(state) {
const layers = getActiveLayers(state);
let smallestDelta = 1440;
if (layers && layers.length) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would refactor this to only call lodashGet(layers[i], 'dateRanges[0].dateInterval') once.

 for (let i = 0; i < layers.length; i += 1) {
   let interval = lodashGet(layers[i], 'dateRanges[0].dateInterval');
   if (layers[i].period === 'subdaily' && interval < smallestDelta) {
     smallestDelta = Number(interval);
   }
 }
}

const subdailyInterval = customInterval > 3 || interval > 3;

if (subdailyRemoved && subdailyInterval) {
changeCustomInterval();
selectInterval(1, TIME_SCALE_TO_NUMBER.day, false);
}

if (subdailyAdded && !customSelected) {
changeCustomInterval(10, TIME_SCALE_TO_NUMBER.minute);
if (subDailyCountChanged) {
Copy link
Contributor

@Tomcariello Tomcariello May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if we clearly define the 1440 value for readability sake.

if (subDailyCountChanged) {
  const isSubDaily = newCustomDelta !== 1440; // or < 1440, if that makes more sense
  if (isSubDaily) {
    changeCustomInterval(newCustomDelta, TIME_SCALE_TO_NUMBER.minute);
  } else {
    changeCustomInterval(1, TIME_SCALE_TO_NUMBER.day);
  }
}

@christof-wittreich christof-wittreich merged commit 62f8358 into develop May 30, 2024
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants