Interactive interface for browsing global, full-resolution satellite imagery
don't calculate all dates when max frames exceeded
Jason Kent6f18245af6bf
diff --git a/web/js/containers/animation-widget.js b/web/js/containers/animation-widget.jsindex cc1737892..a707425c7 100644--- a/web/js/containers/animation-widget.js+++ b/web/js/containers/animation-widget.js@@ -37,6 +37,7 @@ import {getQueueLength,getMaxQueueLength,snapToIntervalDelta,+ getNumberOfSteps,} from '../modules/animation/util';import {subdailyLayersActive,@@ -685,7 +686,7 @@ function mapStateToProps(state) {const useInterval = customSelected ? customInterval || 3 : interval;const subDailyInterval = useInterval > 3;const subDailyMode = subDailyInterval && hasSubdailyLayers;- const numberOfFrames = util.getNumberOfSteps(+ const numberOfFrames = getNumberOfSteps(startDate,endDate,TIME_SCALE_FROM_NUMBER[useInterval],@@ -696,7 +697,7 @@ function mapStateToProps(state) {const visibleLayersForProj = lodashFilter(activeLayersForProj, 'visible');const currentDate = getSelectedDate(state);let snappedCurrentDate;- if (numberOfFrames <= maxFrames) {+ if (numberOfFrames < maxFrames) {snappedCurrentDate = snapToIntervalDelta(currentDate,startDate,diff --git a/web/js/containers/gif.js b/web/js/containers/gif.jsindex 768210300..5ece2fc29 100644--- a/web/js/containers/gif.js+++ b/web/js/containers/gif.js@@ -10,7 +10,6 @@ import {import GifStream from '../modules/animation/gifstream';import GifPanel from '../components/animation-widget/gif-panel';import util from '../util/util';-import Crop from '../components/util/image-crop';import {resolutionsGeo,@@ -23,7 +22,7 @@ import {import { TIME_SCALE_FROM_NUMBER } from '../modules/date/constants';import GifResults from '../components/animation-widget/gif-post-creation';import getImageArray from '../modules/animation/selectors';-import { getStampProps, svgToPng } from '../modules/animation/util';+import { getStampProps, svgToPng, getNumberOfSteps } from '../modules/animation/util';import { changeCropBounds } from '../modules/animation/actions';import { subdailyLayersActive } from '../modules/layers/selectors';import { formatDisplayDate } from '../modules/date/util';@@ -410,7 +409,7 @@ function mapStateToProps(state) {speed,map,url,- numberOfFrames: util.getNumberOfSteps(+ numberOfFrames: getNumberOfSteps(startDate,endDate,customSelecteddiff --git a/web/js/modules/animation/util.js b/web/js/modules/animation/util.jsindex 09f01c668..b54d34fd8 100644--- a/web/js/modules/animation/util.js+++ b/web/js/modules/animation/util.js@@ -36,6 +36,20 @@ export function snapToIntervalDelta(currDate, startDate, endDate, interval, deltreturn currentDate || startDate;}+export function getNumberOfSteps(start, end, interval, delta = 1, maxToCheck) {+ let i = 1;+ let currentDate = start;+ while (currentDate < end) {+ i += 1;+ currentDate = util.dateAdd(currentDate, interval, delta);+ // if checking for a max number limit, break out after reaching it+ if (maxToCheck && i >= maxToCheck) {+ return i;+ }+ }+ return i;+}+export function getStampProps(stampWidthRatio,breakPoint,diff --git a/web/js/util/util.js b/web/js/util/util.jsindex 669ed9cfd..374bfed5c 100644--- a/web/js/util/util.js+++ b/web/js/util/util.js@@ -323,20 +323,6 @@ export default (function(self) {return newDate;};- self.getNumberOfSteps = function(start, end, interval, delta = 1, maxToCheck) {- let i = 1;- let currentDate = start;- while (currentDate < end) {- i += 1;- currentDate = self.dateAdd(currentDate, interval, delta);- // if checking for a max number limit, break out after reaching it- if (maxToCheck && i >= maxToCheck) {- return i;- }- }- return i;- };-self.daysInYear = function(date) {const jStart = self.parseDateUTC(`${date.getUTCFullYear()}-01-01`);const jDate = `00${Math.ceil((date.getTime() - jStart) / 86400000) + 1}`;