@google/earthengine 0.1.378 → 0.1.381

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/earthengine",
3
- "version": "0.1.378",
3
+ "version": "0.1.381",
4
4
  "description": "JavaScript client for Google Earth Engine API.",
5
5
  "author": "Google LLC",
6
6
  "license": "Apache-2.0",
package/src/apiclient.js CHANGED
@@ -6,7 +6,6 @@ goog.module.declareLegacyNamespace();
6
6
 
7
7
  const GoogConst = goog.require('goog.string.Const');
8
8
  const Throttle = goog.require('goog.async.Throttle');
9
- const TrustedResourceUrl = goog.require('goog.html.TrustedResourceUrl');
10
9
  const Uri = goog.require('goog.Uri');
11
10
  const XhrIo = goog.require('goog.net.XhrIo');
12
11
  const XhrLike = goog.requireType('goog.net.XhrLike');
@@ -21,11 +20,12 @@ const jsloader = goog.require('goog.net.jsloader');
21
20
  const {MakeRequestParams, processParams} = goog.require('eeapiclient.request_params');
22
21
  const {NULL_VALUE, Serializable, SerializableCtor, deserialize, serialize} = goog.require('eeapiclient.domain_object');
23
22
  const {PromiseRequestService} = goog.require('eeapiclient.promise_request_service');
23
+ const {trustedResourceUrl} = goog.require('safevalues');
24
24
 
25
25
  /** @namespace */
26
26
  const apiclient = {};
27
27
 
28
- const API_CLIENT_VERSION = '0.1.378';
28
+ const API_CLIENT_VERSION = '0.1.381';
29
29
 
30
30
  exports.VERSION = apiVersion.VERSION;
31
31
  exports.API_CLIENT_VERSION = API_CLIENT_VERSION;
@@ -1147,8 +1147,9 @@ apiclient.ensureAuthLibLoaded_ = function(callback) {
1147
1147
  delete goog.global[callbackName];
1148
1148
  done();
1149
1149
  };
1150
- jsloader.safeLoad(TrustedResourceUrl.format(
1151
- apiclient.AUTH_LIBRARY_URL_, {'onload': callbackName}));
1150
+ jsloader.safeLoad(
1151
+ trustedResourceUrl`https://apis.google.com/js/client.js?onload=${
1152
+ callbackName}`);
1152
1153
  }
1153
1154
  };
1154
1155
 
package/src/ee.js CHANGED
@@ -378,8 +378,7 @@ ee.promote_ = function(arg, klass) {
378
378
  return new ee.Image(/** @type {Object} */ (arg));
379
379
  case 'Feature':
380
380
  if (arg instanceof ee.Collection) {
381
- // TODO(user): Decide whether we want to leave this in. It can be
382
- // quite dangerous on large collections.
381
+ // This can be quite dangerous on large collections.
383
382
  return ee.ApiFunction._call(
384
383
  'Feature', ee.ApiFunction._call('Collection.geometry', arg));
385
384
  } else {
@@ -1,3 +1,4 @@
1
+ // g3-format-clang
1
2
  import {Serializable, serialize} from './domain_object';
2
3
  import {GeneratedRequestParams} from './generated_types';
3
4
  import {MultipartRequest} from './multipart_request';
@@ -1,3 +1,4 @@
1
+ // g3-format-clang
1
2
  import {GeneratedRequestParams} from './generated_types';
2
3
 
3
4
  export interface ApiClientRequestHook {
@@ -1,4 +1,5 @@
1
1
  /**
2
+ * g3-format-clang
2
3
  * Utility map for ClassMetadata to describe how to create instances of child
3
4
  * properties.
4
5
  */
@@ -1,3 +1,4 @@
1
+ // g3-format-clang
1
2
  import {Serializable, SerializableCtor} from './domain_object';
2
3
  import {MultipartRequest} from './multipart_request';
3
4
 
@@ -1,3 +1,4 @@
1
+ // g3-format-clang
1
2
  import {Serializable, serialize} from './domain_object';
2
3
 
3
4
  export class MultipartRequest {
@@ -1,3 +1,4 @@
1
+ // g3-format-clang
1
2
  import {ApiClient, toMakeRequestParams, toMultipartMakeRequestParams} from './api_client';
2
3
  import {ApiClientHookFactory, getRequestHook} from './api_request_hook';
3
4
  import {Serializable} from './domain_object';
@@ -1,3 +1,4 @@
1
+ // g3-format-clang
1
2
  import {deserialize, Serializable, SerializableCtor} from './domain_object';
2
3
  import {MakeRequestParams, processParams} from './request_params';
3
4
 
@@ -1,3 +1,4 @@
1
+ // g3-format-clang
1
2
  import * as httpCors from 'goog:goog.net.rpc.HttpCors';
2
3
 
3
4
  import {GeneratedQueryParams} from './generated_types';
@@ -1,3 +1,4 @@
1
+ // g3-format-clang
1
2
  import 'jasmine';
2
3
 
3
4
  import {buildQueryParams, bypassCorsPreflight, MakeRequestParams} from './request_params';
@@ -0,0 +1,35 @@
1
+ // This example demonstrates how to use Cloud Score+ QA bands to generate a
2
+ // clear median composite for a specified date range.
3
+
4
+ // Harmonized Sentinel-2 Level 2A collection.
5
+ var s2 = ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED');
6
+
7
+ // Cloud Score+ image collection. Note Cloud Score+ is produced from Sentinel-2
8
+ // Level 1C data and can be applied to either L1C or L2A collections.
9
+ var csPlus = ee.ImageCollection('GOOGLE/CLOUD_SCORE_PLUS/V1/S2_HARMONIZED');
10
+
11
+ // Region of interest.
12
+ var ROI = ee.Geometry.Point(-119.9087, 37.4159);
13
+
14
+ // Use 'cs' or 'cs_cdf', depending on your use-case; see docs for guidance.
15
+ var QA_BAND = 'cs_cdf';
16
+
17
+ // The threshold for masking; values between 0.50 and 0.65 generally work well.
18
+ // Higher values will remove thin clouds, haze & cirrus shadows.
19
+ var CLEAR_THRESHOLD = 0.60;
20
+
21
+ // Make composite.
22
+ var composite = s2
23
+ .filterBounds(ROI)
24
+ .filterDate('2023-01-01', '2023-02-01')
25
+ .linkCollection(csPlus, [QA_BAND])
26
+ .map(function(img) {
27
+ return img.updateMask(img.select(QA_BAND).gte(CLEAR_THRESHOLD));
28
+ })
29
+ .median();
30
+
31
+ // Sentinel-2 visualization parameters.
32
+ var s2Viz = {bands: ['B4', 'B3', 'B2'], min: 0, max: 2500};
33
+
34
+ Map.addLayer(composite, s2Viz, 'median composite');
35
+ Map.centerObject(ROI, 11);
package/src/feature.js CHANGED
@@ -135,8 +135,8 @@ ee.Feature.prototype.getInfo = function(opt_callback) {
135
135
  * generating a Map overlay.
136
136
  *
137
137
  * @param {?Object=} opt_visParams The visualization parameters. Currently only
138
- * one parameter, 'color', containing an RGB color string is user. If
139
- * vis_params is null, black ("000000") is used.
138
+ * one parameter, 'color', containing an RGB color string is allowed. If
139
+ * visParams is not specified, black ("000000") is used.
140
140
  * @param {function(!Object, string=)=} opt_callback An async callback.
141
141
  * @return {!ee.data.MapId|undefined} An object which may be passed to
142
142
  * ee.data.getTileUrl or ui.Map.addLayer, including an additional 'image'
@@ -144,15 +144,33 @@ ee.Feature.prototype.getInfo = function(opt_callback) {
144
144
  * containing this feature. Undefined if a callback was specified.
145
145
  * @export
146
146
  */
147
- ee.Feature.prototype.getMap = function(opt_visParams, opt_callback) {
148
- var args =
147
+ ee.Feature.prototype.getMapId = function(opt_visParams, opt_callback) {
148
+ const args =
149
149
  ee.arguments.extractFromFunction(ee.Feature.prototype.getMap, arguments);
150
- var collection = ee.ApiFunction._call('Collection', [this]);
151
- return /** @type {ee.FeatureCollection} */(collection)
152
- .getMap(args['visParams'], args['callback']);
150
+ const collection = ee.ApiFunction._call('Collection', [this]);
151
+ return /** @type {!ee.FeatureCollection} */(collection)
152
+ .getMapId(args['visParams'], args['callback']);
153
153
  };
154
154
 
155
155
 
156
+ /**
157
+ * An imperative function that returns a map ID and optional token, suitable for
158
+ * generating a Map overlay.
159
+ *
160
+ * @deprecated Use getMapId() instead.
161
+ * @param {?Object=} opt_visParams The visualization parameters. Currently only
162
+ * one parameter, 'color', containing an RGB color string is allowed. If
163
+ * visParams is not specified, black ("000000") is used.
164
+ * @param {function(!Object, string=)=} opt_callback An async callback.
165
+ * @return {!ee.data.MapId|undefined} An object which may be passed to
166
+ * ee.data.getTileUrl or ui.Map.addLayer, including an additional 'image'
167
+ * field, containing a Collection.draw image wrapping a FeatureCollection
168
+ * containing this feature. Undefined if a callback was specified.
169
+ * @export
170
+ */
171
+ ee.Feature.prototype.getMap = ee.Feature.prototype.getMapId;
172
+
173
+
156
174
  /** @override */
157
175
  ee.Feature.prototype.name = function() {
158
176
  return 'Feature';
@@ -132,38 +132,56 @@ ee.FeatureCollection.reset = function() {
132
132
 
133
133
 
134
134
  /**
135
- * An imperative function that returns a map id and token, suitable for
135
+ * An imperative function that returns a map ID and optional token, suitable for
136
136
  * generating a Map overlay.
137
137
  *
138
138
  * @param {?Object=} opt_visParams The visualization parameters. Currently only
139
- * one parameter, 'color', containing an RGB color string is allowed. If
140
- * vis_params isn't specified, then the color #000000 is used.
139
+ * one parameter, 'color', containing an RGB color string is allowed. If
140
+ * visParams is not specified, black ("000000") is used.
141
141
  * @param {function(!Object, string=)=} opt_callback An async callback.
142
- * If not supplied, the call is made synchronously.
143
142
  * @return {!ee.data.MapId|undefined} An object which may be passed to
144
143
  * ee.data.getTileUrl or ui.Map.addLayer, including an additional 'image'
145
144
  * field, containing a Collection.draw image wrapping a FeatureCollection
146
145
  * containing this feature. Undefined if a callback was specified.
147
146
  * @export
148
147
  */
149
- ee.FeatureCollection.prototype.getMap = function(opt_visParams, opt_callback) {
150
- var args = ee.arguments.extractFromFunction(
151
- ee.FeatureCollection.prototype.getMap, arguments);
148
+ ee.FeatureCollection.prototype.getMapId = function(
149
+ opt_visParams, opt_callback) {
150
+ const args = ee.arguments.extractFromFunction(
151
+ ee.FeatureCollection.prototype.getMapId, arguments);
152
152
 
153
- var painted = /** @type {!ee.Image} */(
154
- ee.ApiFunction._apply('Collection.draw', {
153
+ const painted =
154
+ /** @type {!ee.Image} */ (ee.ApiFunction._apply('Collection.draw', {
155
155
  'collection': this,
156
156
  'color': (args['visParams'] || {})['color'] || '000000'
157
157
  }));
158
158
 
159
159
  if (args['callback']) {
160
- painted.getMap(undefined, args['callback']);
160
+ painted.getMapId(undefined, args['callback']);
161
161
  } else {
162
- return painted.getMap();
162
+ return painted.getMapId();
163
163
  }
164
164
  };
165
165
 
166
166
 
167
+ /**
168
+ * An imperative function that returns a map ID and optional token, suitable for
169
+ * generating a Map overlay.
170
+ *
171
+ * @deprecated Use getMapId() instead.
172
+ * @param {?Object=} opt_visParams The visualization parameters. Currently only
173
+ * one parameter, 'color', containing an RGB color string is allowed. If
174
+ * visParams is not specified, black ("000000") is used.
175
+ * @param {function(!Object, string=)=} opt_callback An async callback.
176
+ * @return {!ee.data.MapId|undefined} An object which may be passed to
177
+ * ee.data.getTileUrl or ui.Map.addLayer, including an additional 'image'
178
+ * field, containing a Collection.draw image wrapping a FeatureCollection
179
+ * containing this feature. Undefined if a callback was specified.
180
+ * @export
181
+ */
182
+ ee.FeatureCollection.prototype.getMap = ee.FeatureCollection.prototype.getMapId;
183
+
184
+
167
185
  /**
168
186
  * An imperative function that returns all the known information about this
169
187
  * collection via an AJAX call.
package/src/image.js CHANGED
@@ -153,7 +153,7 @@ ee.Image.prototype.getInfo = function(opt_callback) {
153
153
 
154
154
 
155
155
  /**
156
- * An imperative function that returns a map id and optional token, suitable for
156
+ * An imperative function that returns a map ID and optional token, suitable for
157
157
  * generating a Map overlay.
158
158
  *
159
159
  * @param {!ee.data.ImageVisualizationParameters=} opt_visParams
@@ -165,7 +165,7 @@ ee.Image.prototype.getInfo = function(opt_callback) {
165
165
  * specified.
166
166
  * @export
167
167
  */
168
- ee.Image.prototype.getMap = function(opt_visParams, opt_callback) {
168
+ ee.Image.prototype.getMapId = function(opt_visParams, opt_callback) {
169
169
  const args = ee.arguments.extractFromFunction(
170
170
  ee.Image.prototype.getMap, arguments);
171
171
 
@@ -192,6 +192,22 @@ ee.Image.prototype.getMap = function(opt_visParams, opt_callback) {
192
192
  }
193
193
  };
194
194
 
195
+ /**
196
+ * An imperative function that returns a map ID and optional token, suitable for
197
+ * generating a Map overlay.
198
+ *
199
+ * @deprecated Use getMapId() instead.
200
+ * @param {!ee.data.ImageVisualizationParameters=} opt_visParams
201
+ * The visualization parameters.
202
+ * @param {function(!ee.data.MapId, string=)=} opt_callback An async callback.
203
+ * If not supplied, the call is made synchronously.
204
+ * @return {!ee.data.MapId|undefined} An object which may be passed to
205
+ * ee.data.getTileUrl or ui.Map.addLayer. Undefined if a callback was
206
+ * specified.
207
+ * @export
208
+ */
209
+ ee.Image.prototype.getMap = ee.Image.prototype.getMapId;
210
+
195
211
 
196
212
  /**
197
213
  * Get a download URL for small chunks of image data in GeoTIFF or NumPy
@@ -255,31 +255,48 @@ ee.ImageCollection.prototype.getThumbURL_ = function(
255
255
 
256
256
 
257
257
  /**
258
- * An imperative function that returns a mapid via a synchronous AJAX call.
258
+ * An imperative function that returns a map ID via a synchronous AJAX call.
259
259
  *
260
- * This mosaics the collection to a single image and return a mapid suitable
260
+ * This mosaics the collection to a single image and return a map ID suitable
261
261
  * for building a Google Maps overlay.
262
262
  *
263
263
  * @param {?Object=} opt_visParams The visualization parameters.
264
264
  * @param {function(!Object, string=)=} opt_callback An async callback.
265
265
  * If not supplied, the call is made synchronously.
266
- * @return {!ee.data.MapId|undefined} Returns a mapid and optional token, which
266
+ * @return {!ee.data.MapId|undefined} Returns a map ID and optional token, which
267
267
  * may be passed to ee.data.getTileUrl or ui.Map.addLayer. Undefined if
268
268
  * a callback was specified.
269
269
  * @export
270
270
  */
271
- ee.ImageCollection.prototype.getMap = function(opt_visParams, opt_callback) {
271
+ ee.ImageCollection.prototype.getMapId = function(opt_visParams, opt_callback) {
272
272
  var args = ee.arguments.extractFromFunction(
273
- ee.ImageCollection.prototype.getMap, arguments);
273
+ ee.ImageCollection.prototype.getMapId, arguments);
274
274
  var mosaic = /** @type {!ee.Image} */(
275
275
  ee.ApiFunction._call('ImageCollection.mosaic', this));
276
276
  if (args['callback']) {
277
- mosaic.getMap(args['visParams'], args['callback']);
277
+ mosaic.getMapId(args['visParams'], args['callback']);
278
278
  } else {
279
- return mosaic.getMap(args['visParams']);
279
+ return mosaic.getMapId(args['visParams']);
280
280
  }
281
281
  };
282
282
 
283
+ /**
284
+ * An imperative function that returns a map ID via a synchronous AJAX call.
285
+ *
286
+ * This mosaics the collection to a single image and return a map ID suitable
287
+ * for building a Google Maps overlay.
288
+ *
289
+ * @deprecated Use getMapId() instead.
290
+ * @param {?Object=} opt_visParams The visualization parameters.
291
+ * @param {function(!Object, string=)=} opt_callback An async callback.
292
+ * If not supplied, the call is made synchronously.
293
+ * @return {!ee.data.MapId|undefined} Returns a map ID and optional token, which
294
+ * may be passed to ee.data.getTileUrl or ui.Map.addLayer. Undefined if
295
+ * a callback was specified.
296
+ * @export
297
+ */
298
+ ee.ImageCollection.prototype.getMap = ee.ImageCollection.prototype.getMapId;
299
+
283
300
 
284
301
  /**
285
302
  * An imperative function that returns all the known information about this
package/test/ee_test.js CHANGED
@@ -14,13 +14,13 @@ describe('ee', function() {
14
14
 
15
15
  it('retrieves a map ID synchronously', function() {
16
16
  const image = new ee.Image('srtm90_v4');
17
- const map = image.getMap({'min': 0, 'max': 1000});
17
+ const map = image.getMapId({'min': 0, 'max': 1000});
18
18
  expect(map.mapid).toMatch(/\w+/);
19
19
  });
20
20
 
21
21
  it('retrieves a map ID asynchronously', function(done) {
22
22
  const image = new ee.Image('srtm90_v4');
23
- image.getMap({'min': 0, 'max': 1000}, ({mapid}) => {
23
+ image.getMapId({'min': 0, 'max': 1000}, ({mapid}) => {
24
24
  expect(mapid).toMatch(/\w+/);
25
25
  done();
26
26
  });