Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Make GIF file-size reflect # of frames #1882

Benjamin King2af34e188808
diff --git a/web/js/components/animation-widget/gif-panel-grid.js b/web/js/components/animation-widget/gif-panel-grid.js
index ac4b0b778..d0fa9f38f 100644
--- a/web/js/components/animation-widget/gif-panel-grid.js
+++ b/web/js/components/animation-widget/gif-panel-grid.js
@@ -85,7 +85,7 @@ GifPanelGrid.propTypes = {
increment: PropTypes.string,
maxGifSize: PropTypes.number,
maxImageDimensionSize: PropTypes.number,
- requestSize: PropTypes.string,
+ requestSize: PropTypes.number,
speed: PropTypes.number,
startDate: PropTypes.string,
valid: PropTypes.bool,
diff --git a/web/js/components/animation-widget/gif-panel.js b/web/js/components/animation-widget/gif-panel.js
index 411529f5f..3d4ca8eb0 100644
--- a/web/js/components/animation-widget/gif-panel.js
+++ b/web/js/components/animation-widget/gif-panel.js
@@ -35,6 +35,22 @@ export default class GifPanel extends React.Component {
resolution: value
});
}
+ // calulateFileSize(numDays, imgWidth, imgHeight) {
+ // var conversionFactor;
+ // const { lonlats, projId } = this.props;
+ // const { resolution } = this.state;
+ // const lonlat1 = lonlats[0];
+ // const lonlat2 = lonlats[1];
+ // conversionFactor = imageUtilGetConversionFactor(projId);
+ // imgWidth = Math.round(
+ // Math.abs(lonlat2[0] - lonlat1[0]) / conversionFactor / Number(resolution)
+ // );
+ // imgHeight = Math.round(
+ // Math.abs(lonlat2[1] - lonlat1[1]) / conversionFactor / Number(resolution)
+ // );
+
+ // return ((imgWidth * imgHeight * 24) / 8388608).toFixed(2) * numDays;
+ // }
render() {
const {
projId,
@@ -42,13 +58,15 @@ export default class GifPanel extends React.Component {
startDate,
endDate,
onCheck,
- checked
+ checked,
+ numberOfFrames
} = this.props;
const { resolution } = this.state;
const dimensions = getDimensions(projId, lonlats, resolution);
const height = dimensions.height;
const width = dimensions.width;
- const requestSize = ((width * height * 24) / 8388608).toFixed(2);
+ const requestSize =
+ ((width * height * 24) / 8388608).toFixed(2) * numberOfFrames;
const valid = isFileSizeValid(requestSize, height, width);
return (
<div className="gif-dialog">
@@ -66,7 +84,7 @@ export default class GifPanel extends React.Component {
<GifPanelGrid
width={width}
height={height}
- requestSize={((width * height * 24) / 8388608).toFixed(2)}
+ requestSize={requestSize}
maxGifSize={MAX_GIF_SIZE}
maxImageDimensionSize={MAX_IMAGE_DIMENSION_SIZE}
valid={valid}
@@ -111,6 +129,7 @@ GifPanel.propTypes = {
lonlats: PropTypes.array,
maxGifSize: PropTypes.number,
maxImageDimensionSize: PropTypes.number,
+ numberOfFrames: PropTypes.number,
onCheck: PropTypes.func,
onClick: PropTypes.func,
onDownloadClick: PropTypes.func,
diff --git a/web/js/containers/gif.js b/web/js/containers/gif.js
index 9404bc2d3..71ad132f8 100644
--- a/web/js/containers/gif.js
+++ b/web/js/containers/gif.js
@@ -80,7 +80,8 @@ class GIF extends Component {
proj,
onClose,
endDate,
- startDate
+ startDate,
+ numberOfFrames
} = this.props;
const { boundaries, showDates } = this.state;
@@ -121,6 +122,7 @@ class GIF extends Component {
startDate={startDate}
endDate={endDate}
onClick={this.createGIF.bind(this)}
+ numberOfFrames={numberOfFrames}
/>
<Crop
@@ -350,6 +352,14 @@ function mapStateToProps(state, ownProps) {
speed,
map,
url,
+ numberOfFrames: util.getNumberOfDays(
+ startDate,
+ endDate,
+ customSelected
+ ? timeScaleFromNumberKey[customInterval]
+ : timeScaleFromNumberKey[interval],
+ customSelected ? customDelta : 1
+ ),
getImageArray: (gifComponentProps, gifComponentState, dimensions) => {
return getImageArray(
gifComponentProps,
@@ -374,6 +384,7 @@ GIF.propTypes = {
increment: PropTypes.string,
isActive: PropTypes.bool,
map: PropTypes.object,
+ numberOfFrames: PropTypes.number,
onClose: PropTypes.func,
proj: PropTypes.object,
screenHeight: PropTypes.number,
diff --git a/web/js/util/util.js b/web/js/util/util.js
index 0928ceaf2..d7bf4d1b4 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -437,12 +437,13 @@ export default (function (self) {
return newDate;
};
- self.getNumberOfDays = function(start, end, interval) {
+ self.getNumberOfDays = function(start, end, interval, increment) {
+ increment = increment || 1;
var i = 1;
var currentDate = start;
while (currentDate < end) {
i++;
- currentDate = self.dateAdd(currentDate, interval, 1);
+ currentDate = self.dateAdd(currentDate, interval, increment);
}
return i;
};