-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for image collection visualizations and animated GIF
- Loading branch information
Showing
7 changed files
with
103 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import Utils from "../utils/utils.js"; | ||
import BitmapLike from "./bitmap.js"; | ||
|
||
export default class GifFormat extends BitmapLike { | ||
constructor() { | ||
super('GIF (animated)', 'Either animated or static.'); | ||
this.removeParameter('collectionRenderer'); | ||
this.addParameter('framesPerSecond', { | ||
type: 'number', | ||
description: 'Number of images that are shown per second.', | ||
default: 1, | ||
optional: true, | ||
exclusiveMinimum: 0 | ||
}); | ||
} | ||
|
||
getFileExtension(/*parameters*/) { | ||
return '.gif'; | ||
} | ||
|
||
getFormatCode() { | ||
return 'gif'; | ||
} | ||
|
||
allowMultiple() { | ||
return true; | ||
} | ||
|
||
async retrieve(ee, dc) { | ||
const parameters = dc.getOutputFormatParameters(); | ||
const img = ee.ImageCollection(dc.getData()); | ||
|
||
let region = null; | ||
let crs = null; | ||
if (dc.hasXY()) { | ||
region = Utils.bboxToGeoJson(dc.getSpatialExtent()); | ||
crs = Utils.crsToString(dc.getCrs()); | ||
} | ||
|
||
const eeOpts = { | ||
format: this.getFormatCode(), | ||
dimensions: parameters.size || 1000, | ||
region, | ||
crs, | ||
framesPerSecond: parameters.framesPerSecond || 1 | ||
}; | ||
return await new Promise((resolve, reject) => { | ||
img.getVideoThumbURL(eeOpts, (url, err) => { | ||
if (err) { | ||
reject(err); | ||
} | ||
else if (typeof url !== 'string' || url.length === 0) { | ||
reject('Download URL provided by Google Earth Engine is empty.'); | ||
} | ||
else { | ||
resolve(url); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters