@google/earthengine 1.7.20 → 1.7.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/image.js CHANGED
@@ -33,7 +33,7 @@ goog.require('goog.object');
33
33
  * - An ee.Image: returns the argument,
34
34
  * - Nothing: results in an empty transparent image.
35
35
  *
36
- * @param {number|string|Array.<*>|ee.Image|Object=} opt_args
36
+ * @param {number|string|!Array.<*>|!ee.Image|!Object|null=} opt_args
37
37
  * Constructor argument.
38
38
  * @constructor
39
39
  * @extends {ee.Element}
@@ -66,7 +66,7 @@ ee.Image = function(opt_args) {
66
66
  } else if (Array.isArray(opt_args)) {
67
67
  // Make an image out of each element.
68
68
  return ee.Image.combine_(goog.array.map(
69
- /** @type {Array.<*>} */ (opt_args),
69
+ /** @type {!Array.<*>} */ (opt_args),
70
70
  function(elem) {
71
71
  return new ee.Image(/** @type {?} */ (elem));
72
72
  }));
@@ -136,18 +136,19 @@ ee.Image.reset = function() {
136
136
  * An imperative function that returns information about this image via an
137
137
  * AJAX call.
138
138
  *
139
- * @param {function(ee.data.ImageDescription, string=)=} opt_callback
139
+ * @param {function(!ee.data.ImageDescription, string=)=} opt_callback
140
140
  * An optional callback. If not supplied, the call is made synchronously.
141
141
  * If supplied, will be called with the first parameter if successful and
142
142
  * the second if unsuccessful.
143
- * @return {ee.data.ImageDescription} A description of the image. Includes:
143
+ * @return {!ee.data.ImageDescription|undefined} A description of the image, or
144
+ * undefined if a callback is specified. Includes:
144
145
  * - bands - a list containing metadata about the bands in the collection.
145
146
  * - properties - a dictionary containing the image's metadata properties.
146
147
  * @export
147
148
  * @override
148
149
  */
149
150
  ee.Image.prototype.getInfo = function(opt_callback) {
150
- return /** @type {ee.data.ImageDescription} */(
151
+ return /** @type {!ee.data.ImageDescription|undefined} */(
151
152
  ee.Image.base(this, 'getInfo', opt_callback));
152
153
  };
153
154
 
@@ -215,7 +216,7 @@ ee.Image.prototype.getMap = ee.Image.prototype.getMapId;
215
216
  * 10000.
216
217
  *
217
218
  * Use getThumbURL for RGB visualization formats PNG and JPG.
218
- * @param {Object} params An object containing download options with the
219
+ * @param {!Object} params An object containing download options with the
219
220
  * following possible values:
220
221
  * <table>
221
222
  * <tr>
@@ -410,10 +411,10 @@ ee.Image.prototype.getThumbURL = function(params, opt_callback) {
410
411
  * Create a 3-band image specifically for visualization. This uses the first
411
412
  * band in each image.
412
413
  *
413
- * @param {ee.Image} r The red image.
414
- * @param {ee.Image} g The green image.
415
- * @param {ee.Image} b The blue image.
416
- * @return {ee.Image} The combined image.
414
+ * @param {!ee.Image} r The red image.
415
+ * @param {!ee.Image} g The green image.
416
+ * @param {!ee.Image} b The blue image.
417
+ * @return {!ee.Image} The combined image.
417
418
  * @export
418
419
  */
419
420
  ee.Image.rgb = function(r, g, b) {
@@ -435,8 +436,8 @@ ee.Image.rgb = function(r, g, b) {
435
436
  *
436
437
  * This function will promote constant values into constant images.
437
438
  *
438
- * @param {...ee.Image} var_args The images to be combined.
439
- * @return {ee.Image} The combined image.
439
+ * @param {...!ee.Image} var_args The images to be combined.
440
+ * @return {!ee.Image} The combined image.
440
441
  * @export
441
442
  */
442
443
  ee.Image.cat = function(var_args) {
@@ -449,14 +450,14 @@ ee.Image.cat = function(var_args) {
449
450
  * Combine all the bands from the given images into a single image, with
450
451
  * optional renaming.
451
452
  *
452
- * @param {Array.<ee.Image>} images The images to be combined.
453
- * @param {Array.<string>=} opt_names A list of names for the output bands.
454
- * @return {ee.Image} The combined image.
453
+ * @param {!Array.<!ee.Image>} images The images to be combined.
454
+ * @param {?Array.<string>=} opt_names A list of names for the output bands.
455
+ * @return {!ee.Image} The combined image.
455
456
  * @private
456
457
  */
457
458
  ee.Image.combine_ = function(images, opt_names) {
458
459
  if (images.length == 0) {
459
- return /** @type {ee.Image} */ (ee.ApiFunction._call('Image.constant', []));
460
+ return /** @type {!ee.Image} */ (ee.ApiFunction._call('Image.constant', []));
460
461
  }
461
462
 
462
463
  // Append all the bands.
@@ -542,7 +543,7 @@ ee.Image.prototype.select = function(var_args) {
542
543
  * using the '=' operator (e.g.: x = a + b).
543
544
  *
544
545
  * @param {string} expression The expression to evaluate.
545
- * @param {Object.<ee.Image>=} opt_map A map of input images available by name.
546
+ * @param {!Object.<!ee.Image>=} opt_map A map of input images available by name.
546
547
  * @return {!ee.Image} The image computed by the provided expression.
547
548
  * @export
548
549
  */
@@ -580,7 +581,7 @@ ee.Image.prototype.expression = function(expression, opt_map) {
580
581
 
581
582
  /**
582
583
  * @this {ee.Function}
583
- * @return {ee.Function.Signature}
584
+ * @return {!ee.Function.Signature}
584
585
  */
585
586
  func.getSignature = function() {
586
587
  return {
@@ -610,9 +611,9 @@ ee.Image.prototype.expression = function(expression, opt_map) {
610
611
  *
611
612
  * Use clipToCollection to clip an image to a FeatureCollection.
612
613
  *
613
- * @param {ee.Geometry|ee.Feature|Object} geometry
614
+ * @param {!ee.Geometry|!ee.Feature|!Object} geometry
614
615
  * The Geometry or Feature to clip to.
615
- * @return {ee.Image} The clipped image.
616
+ * @return {!ee.Image} The clipped image.
616
617
  * @export
617
618
  */
618
619
  ee.Image.prototype.clip = function(geometry) {
@@ -623,7 +624,7 @@ ee.Image.prototype.clip = function(geometry) {
623
624
  } catch (e) {
624
625
  // Not an ee.Geometry or GeoJSON. Just pass it along.
625
626
  }
626
- return /** @type {ee.Image} */(
627
+ return /** @type {!ee.Image} */(
627
628
  ee.ApiFunction._call('Image.clip', this, geometry));
628
629
  };
629
630
 
@@ -631,9 +632,9 @@ ee.Image.prototype.clip = function(geometry) {
631
632
  /**
632
633
  * Rename the bands of an image.
633
634
  *
634
- * @param {...string|Object|Array<string>} var_args The new names for the bands.
635
+ * @param {...string|!Object|!Array<string>} var_args The new names for the bands.
635
636
  * Must match the number of bands in the Image.
636
- * @return {ee.Image} The renamed image.
637
+ * @return {!ee.Image} The renamed image.
637
638
  * @export
638
639
  */
639
640
  ee.Image.prototype.rename = function(var_args) {
@@ -645,12 +646,15 @@ ee.Image.prototype.rename = function(var_args) {
645
646
  // Varargs list of strings.
646
647
  names = Array.from(arguments);
647
648
  }
648
- return /** @type {ee.Image} */(
649
+ return /** @type {!ee.Image} */(
649
650
  ee.ApiFunction._call('Image.rename', this, names));
650
651
  };
651
652
 
652
653
 
653
- /** @override */
654
+ /**
655
+ * @return {string}
656
+ * @override
657
+ */
654
658
  ee.Image.prototype.name = function() {
655
659
  return 'Image';
656
660
  };
package/src/images.js CHANGED
@@ -344,9 +344,9 @@ ee.data.images.applyVisualization = function(image, params) {
344
344
  * @return {!ee.data.ImageVisualizationParameters} Params for visualize()
345
345
  */
346
346
  ee.data.images.extractVisParams = function(params, outParams) {
347
- var keysToExtract = ["bands", "gain", "bias", "min", "max",
347
+ const keysToExtract = ["bands", "gain", "bias", "min", "max",
348
348
  "gamma", "palette", "opacity", "forceRgbOutput"];
349
- var visParams = {};
349
+ const visParams = {};
350
350
  goog.object.forEach(params, function(value, key) {
351
351
  if (goog.array.contains(keysToExtract, key)) {
352
352
  visParams[key] = value;
@@ -19,8 +19,6 @@ goog.require('goog.net.XhrIo');
19
19
  goog.require('goog.object');
20
20
  goog.require('goog.structs.Map');
21
21
  goog.require('goog.style');
22
- goog.requireType('ee.data.Profiler');
23
-
24
22
 
25
23
 
26
24
  /**
@@ -36,7 +34,7 @@ ee.layers.AbstractOverlay = class extends goog.events.EventTarget {
36
34
  /**
37
35
  * @param {!ee.layers.AbstractTileSource} tileSource The source of tiles
38
36
  * for this map layer.
39
- * @param {Object=} opt_options Initialization options, of the same form as a
37
+ * @param {?Object=} opt_options Initialization options, of the same form as a
40
38
  * google.maps.ImageMapTypeOptions object.
41
39
  */
42
40
  constructor(tileSource, opt_options) {
@@ -44,7 +42,7 @@ ee.layers.AbstractOverlay = class extends goog.events.EventTarget {
44
42
 
45
43
  // Public options required by the Maps API.
46
44
 
47
- var options = opt_options || {};
45
+ const options = opt_options || {};
48
46
  this.minZoom = options.minZoom || 0;
49
47
  this.maxZoom = options.maxZoom || 20;
50
48
  if (!window['google'] || !window['google']['maps']) {
@@ -63,16 +61,16 @@ ee.layers.AbstractOverlay = class extends goog.events.EventTarget {
63
61
  /** @protected {!ee.layers.AbstractOverlayStats} */
64
62
  this.stats = new ee.layers.AbstractOverlayStats(tileSource.getUniqueId());
65
63
 
66
- /** @protected {goog.structs.Map<string, ee.layers.AbstractTile>} */
64
+ /** @protected {?goog.structs.Map<string, ?ee.layers.AbstractTile>} */
67
65
  this.tilesById = new goog.structs.Map();
68
66
 
69
67
  /** @protected {number} The count of tiles that have been requested. */
70
68
  this.tileCounter = 0;
71
69
 
72
- /** @protected {ee.layers.AbstractTileSource} The overlay's tile source. */
70
+ /** @protected {?ee.layers.AbstractTileSource} The overlay's tile source. */
73
71
  this.tileSource = tileSource;
74
72
 
75
- /** @protected {goog.events.EventHandler} The overlay's event handler. */
73
+ /** @protected {?goog.events.EventHandler} The overlay's event handler. */
76
74
  this.handler = new goog.events.EventHandler(this);
77
75
 
78
76
  // MapType options required by the compiler but which we don't support.
@@ -86,7 +84,7 @@ ee.layers.AbstractOverlay = class extends goog.events.EventTarget {
86
84
 
87
85
  /**
88
86
  * Adds a callback to be fired each time a tile is loaded.
89
- * @param {function(ee.layers.TileLoadEvent)} callback The function to call.
87
+ * @param {function(!ee.layers.TileLoadEvent)} callback The function to call.
90
88
  * @return {!Object} An ID which can be passed to removeTileCallback().
91
89
  * @export
92
90
  */
@@ -101,7 +99,7 @@ ee.layers.AbstractOverlay = class extends goog.events.EventTarget {
101
99
  * @export
102
100
  */
103
101
  removeTileCallback(callbackId) {
104
- goog.events.unlistenByKey(/** @type {goog.events.Key} */ (callbackId));
102
+ goog.events.unlistenByKey(/** @type {!goog.events.Key} */ (callbackId));
105
103
  }
106
104
 
107
105
  /**
@@ -153,7 +151,7 @@ ee.layers.AbstractOverlay = class extends goog.events.EventTarget {
153
151
  * @return {?Element} Element to be displayed as a map tile.
154
152
  */
155
153
  getTile(coord, zoom, ownerDocument) {
156
- var maxCoord = 1 << zoom;
154
+ const maxCoord = 1 << zoom;
157
155
 
158
156
  // If the position is out of bounds, return an empty tile immediately.
159
157
  if (zoom < this.minZoom || coord.y < 0 || coord.y >= maxCoord) {
@@ -161,15 +159,15 @@ ee.layers.AbstractOverlay = class extends goog.events.EventTarget {
161
159
  }
162
160
 
163
161
  // Wrap longitude around.
164
- var x = coord.x % maxCoord;
162
+ let x = coord.x % maxCoord;
165
163
  if (x < 0) {
166
164
  x += maxCoord;
167
165
  }
168
- var normalizedCoord = new google.maps.Point(x, coord.y);
166
+ const normalizedCoord = new google.maps.Point(x, coord.y);
169
167
 
170
168
  // Create the tile.
171
- var uniqueId = this.getUniqueTileId_(coord, zoom);
172
- var tile = this.createTile(normalizedCoord, zoom, ownerDocument, uniqueId);
169
+ const uniqueId = this.getUniqueTileId_(coord, zoom);
170
+ const tile = this.createTile(normalizedCoord, zoom, ownerDocument, uniqueId);
173
171
  tile.tileSize = this.tileSize;
174
172
  goog.style.setOpacity(tile.div, this.opacity);
175
173
  this.tilesById.set(uniqueId, tile);
@@ -188,7 +186,7 @@ ee.layers.AbstractOverlay = class extends goog.events.EventTarget {
188
186
  // Requests for tiles that are no longer visible won't clog the queue:
189
187
  // if the map is moved around a lot, Maps API calls our releaseTile()
190
188
  // method, and the obsolete requests will be removed from the queue.
191
- var priority = new Date().getTime() / 1000;
189
+ const priority = new Date().getTime() / 1000;
192
190
 
193
191
  this.tileSource.loadTile(tile, priority);
194
192
 
@@ -200,7 +198,7 @@ ee.layers.AbstractOverlay = class extends goog.events.EventTarget {
200
198
  * Implements releaseTile() for the google.maps.MapType interface.
201
199
  */
202
200
  releaseTile(tileDiv) {
203
- var tile = this.tilesById.get(tileDiv.id);
201
+ const tile = this.tilesById.get(tileDiv.id);
204
202
  this.tilesById.delete(tileDiv.id);
205
203
  if (tile) {
206
204
  tile.abort();
@@ -210,14 +208,14 @@ ee.layers.AbstractOverlay = class extends goog.events.EventTarget {
210
208
 
211
209
  /**
212
210
  * Listen for tile status changes and respond accordingly.
213
- * @param {ee.layers.AbstractTile} tile
211
+ * @param {!ee.layers.AbstractTile} tile
214
212
  * @private
215
213
  */
216
214
  registerStatusChangeListener_(tile) {
217
215
  // Notify listeners when the tile has loaded.
218
216
  this.handler.listen(
219
217
  tile, ee.layers.AbstractTile.EventType.STATUS_CHANGED, function() {
220
- var Status = ee.layers.AbstractTile.Status;
218
+ const Status = ee.layers.AbstractTile.Status;
221
219
 
222
220
  switch (tile.getStatus()) {
223
221
  case Status.LOADED:
@@ -260,8 +258,8 @@ ee.layers.AbstractOverlay = class extends goog.events.EventTarget {
260
258
  * @private
261
259
  */
262
260
  getUniqueTileId_(coord, z) {
263
- var tileId = [coord.x, coord.y, z, this.tileCounter++].join('-');
264
- var sourceId = this.tileSource.getUniqueId();
261
+ const tileId = [coord.x, coord.y, z, this.tileCounter++].join('-');
262
+ const sourceId = this.tileSource.getUniqueId();
265
263
  return [tileId, sourceId].join('-');
266
264
  }
267
265
 
@@ -278,7 +276,7 @@ ee.layers.AbstractOverlay = class extends goog.events.EventTarget {
278
276
 
279
277
  /**
280
278
  * Returns the count of tiles with the provided status.
281
- * @param {ee.layers.AbstractTile.Status} status The tile status.
279
+ * @param {!ee.layers.AbstractTile.Status} status The tile status.
282
280
  * @return {number} The count of tiles with the provided status.
283
281
  * @private
284
282
  */
@@ -320,9 +318,9 @@ ee.layers.AbstractOverlay.DEFAULT_TILE_EDGE_LENGTH = 256;
320
318
  * Factory method to create a tile for this overlay.
321
319
  * @param {!google.maps.Point} coord The position of the tile.
322
320
  * @param {number} zoom The zoom level of the tile.
323
- * @param {Node} ownerDocument The owner document.
321
+ * @param {?Node} ownerDocument The owner document.
324
322
  * @param {string} uniqueId
325
- * @return {ee.layers.AbstractTile}
323
+ * @return {!ee.layers.AbstractTile}
326
324
  * @protected
327
325
  */
328
326
  ee.layers.AbstractOverlay.prototype.createTile = goog.abstractMethod;
@@ -449,7 +447,7 @@ ee.layers.AbstractTile = class extends goog.events.EventTarget {
449
447
  /**
450
448
  * @param {!google.maps.Point} coord The position of the tile.
451
449
  * @param {number} zoom The zoom level of the tile.
452
- * @param {Node} ownerDocument The tile's owner document.
450
+ * @param {?Node} ownerDocument The tile's owner document.
453
451
  * @param {string} uniqueId A unique ID for the tile.
454
452
  */
455
453
  constructor(coord, zoom, ownerDocument, uniqueId) {
@@ -468,7 +466,7 @@ ee.layers.AbstractTile = class extends goog.events.EventTarget {
468
466
  /** @package {number} The maximum number of tile load retries. */
469
467
  this.maxRetries = ee.layers.AbstractTile.DEFAULT_MAX_LOAD_RETRIES_;
470
468
 
471
- /** @package {google.maps.Size} The size of the tile. */
469
+ /** @package {!google.maps.Size} The size of the tile. */
472
470
  this.tileSize;
473
471
 
474
472
  /** @package {string} The URL of the tile's source data. */
@@ -477,7 +475,7 @@ ee.layers.AbstractTile = class extends goog.events.EventTarget {
477
475
  /** @package {!Blob} The source data for the tile. */
478
476
  this.sourceData;
479
477
 
480
- /** @package {Object} The response headers from the source data request. */
478
+ /** @package {!Object} The response headers from the source data request. */
481
479
  this.sourceResponseHeaders;
482
480
 
483
481
  /**
@@ -486,10 +484,10 @@ ee.layers.AbstractTile = class extends goog.events.EventTarget {
486
484
  */
487
485
  this.renderer = function() {}; // No-op by default.
488
486
 
489
- /** @private {goog.net.XhrIo} The request for the tile's source data. */
487
+ /** @private {!goog.net.XhrIo} The request for the tile's source data. */
490
488
  this.xhrIo_;
491
489
 
492
- /** @private {ee.layers.AbstractTile.Status} The tile's current status. */
490
+ /** @private {!ee.layers.AbstractTile.Status} The tile's current status. */
493
491
  this.status_ = ee.layers.AbstractTile.Status.NEW;
494
492
 
495
493
  /** @private {number} The current load retry attempt. */
@@ -593,7 +591,7 @@ ee.layers.AbstractTile = class extends goog.events.EventTarget {
593
591
  * @package
594
592
  */
595
593
  retryLoad(opt_errorMessage) {
596
- var parseError = function(error) {
594
+ const parseError = function(error) {
597
595
  try {
598
596
  error = JSON.parse(error);
599
597
  if (error['error'] && error['error']['message']) {
@@ -643,14 +641,14 @@ ee.layers.AbstractTile = class extends goog.events.EventTarget {
643
641
  return this.status_ in ee.layers.AbstractTile.DONE_STATUS_SET_;
644
642
  }
645
643
 
646
- /** @package @return {ee.layers.AbstractTile.Status} The tile's status. */
644
+ /** @package @return {!ee.layers.AbstractTile.Status} The tile's status. */
647
645
  getStatus() {
648
646
  return this.status_;
649
647
  }
650
648
 
651
649
  /**
652
650
  * Sets the tile's status.
653
- * @param {ee.layers.AbstractTile.Status} status The new status.
651
+ * @param {!ee.layers.AbstractTile.Status} status The new status.
654
652
  * @package
655
653
  */
656
654
  setStatus(status) {
@@ -701,7 +699,7 @@ ee.layers.AbstractTile.Status = {
701
699
 
702
700
 
703
701
 
704
- /** @private @const {!Object<ee.layers.AbstractTile.Status>} */
702
+ /** @private @const {!Object<!ee.layers.AbstractTile.Status>} */
705
703
  ee.layers.AbstractTile.DONE_STATUS_SET_ = goog.object.createSet(
706
704
  ee.layers.AbstractTile.Status.ABORTED, ee.layers.AbstractTile.Status.FAILED,
707
705
  ee.layers.AbstractTile.Status.LOADED,
@@ -709,5 +707,5 @@ ee.layers.AbstractTile.DONE_STATUS_SET_ = goog.object.createSet(
709
707
 
710
708
 
711
709
 
712
- /** @private {number} The default number of maximum tile load attempts. */
710
+ /** @private @const {number} The default number of maximum tile load attempts. */
713
711
  ee.layers.AbstractTile.DEFAULT_MAX_LOAD_RETRIES_ = 5;