@google/earthengine 1.7.19 → 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/build/browser.js +80 -44
- package/build/ee_api_js.js +598 -595
- package/build/ee_api_js_debug.js +57 -21
- package/build/ee_api_js_npm.js +80 -44
- package/build/main.js +80 -44
- package/package.json +1 -1
- package/src/abstractoverlay.js +7 -7
- package/src/apiclient.js +11 -3
- package/src/apifunction.js +60 -5
- package/src/collection.js +23 -20
- package/src/computedobject.js +16 -12
- package/src/customfunction.js +17 -10
- package/src/date.js +8 -7
- package/src/deserializer.js +12 -2
- package/src/dictionary.js +9 -5
- package/src/ee.js +18 -16
- package/src/element.js +16 -13
- package/src/feature.js +10 -7
- package/src/featurecollection.js +18 -11
- package/src/filter.js +49 -46
- package/src/floattileoverlay.js +15 -15
- package/src/image.js +29 -25
- package/src/images.js +2 -2
- package/src/layers/abstractoverlay.js +31 -33
- package/src/list.js +4 -1
- package/src/maplayeroverlay.js +23 -23
- package/src/maptilemanager.js +39 -31
- package/src/number.js +4 -1
- package/src/profiler.js +4 -2
- package/src/string.js +10 -3
- package/src/types.js +5 -5
package/src/collection.js
CHANGED
|
@@ -69,12 +69,12 @@ ee.Collection.reset = function() {
|
|
|
69
69
|
/**
|
|
70
70
|
* Apply a filter to this collection.
|
|
71
71
|
*
|
|
72
|
-
* @param {ee.Filter} filter A filter to apply to this collection.
|
|
73
|
-
* @return {ee.Collection} The filtered collection.
|
|
72
|
+
* @param {?ee.Filter} filter A filter to apply to this collection.
|
|
73
|
+
* @return {!ee.Collection} The filtered collection.
|
|
74
74
|
* @export
|
|
75
75
|
*/
|
|
76
76
|
ee.Collection.prototype.filter = function(filter) {
|
|
77
|
-
|
|
77
|
+
const args = ee.arguments.extractFromFunction(
|
|
78
78
|
ee.Collection.prototype.filter, arguments);
|
|
79
79
|
filter = args['filter'];
|
|
80
80
|
if (!filter) {
|
|
@@ -96,12 +96,12 @@ ee.Collection.prototype.filter = function(filter) {
|
|
|
96
96
|
* "ends_with", "not_starts_with", "not_ends_with", "contains",
|
|
97
97
|
* "not_contains".
|
|
98
98
|
* @param {*} value - The value to compare against.
|
|
99
|
-
* @return {ee.Collection} The filtered collection.
|
|
99
|
+
* @return {!ee.Collection} The filtered collection.
|
|
100
100
|
* @export
|
|
101
101
|
* @deprecated Use filter() with ee.Filter.eq(), ee.Filter.gte(), etc.
|
|
102
102
|
*/
|
|
103
103
|
ee.Collection.prototype.filterMetadata = function(name, operator, value) {
|
|
104
|
-
|
|
104
|
+
const args = ee.arguments.extractFromFunction(
|
|
105
105
|
ee.Collection.prototype.filterMetadata, arguments);
|
|
106
106
|
return this.filter(ee.Filter.metadata(
|
|
107
107
|
args['name'], args['operator'], args['value']));
|
|
@@ -121,7 +121,7 @@ ee.Collection.prototype.filterMetadata = function(name, operator, value) {
|
|
|
121
121
|
* achieve the desired outcome.
|
|
122
122
|
* @param {!ee.Geometry|!ee.ComputedObject|!ee.FeatureCollection} geometry
|
|
123
123
|
* The geometry, feature or collection to intersect with.
|
|
124
|
-
* @return {ee.Collection} The filtered collection.
|
|
124
|
+
* @return {!ee.Collection} The filtered collection.
|
|
125
125
|
* @export
|
|
126
126
|
*/
|
|
127
127
|
ee.Collection.prototype.filterBounds = function(geometry) {
|
|
@@ -144,7 +144,7 @@ ee.Collection.prototype.filterBounds = function(geometry) {
|
|
|
144
144
|
* @export
|
|
145
145
|
*/
|
|
146
146
|
ee.Collection.prototype.filterDate = function(start, opt_end) {
|
|
147
|
-
|
|
147
|
+
const args = ee.arguments.extractFromFunction(
|
|
148
148
|
ee.Collection.prototype.filterDate, arguments);
|
|
149
149
|
return this.filter(ee.Filter.date(args['start'], args['end']));
|
|
150
150
|
};
|
|
@@ -158,11 +158,11 @@ ee.Collection.prototype.filterDate = function(start, opt_end) {
|
|
|
158
158
|
* @param {string=} opt_property The property to sort by, if sorting.
|
|
159
159
|
* @param {boolean=} opt_ascending Whether to sort in ascending or
|
|
160
160
|
* descending order. The default is true (ascending).
|
|
161
|
-
* @return {ee.Collection} The limited collection.
|
|
161
|
+
* @return {!ee.Collection} The limited collection.
|
|
162
162
|
* @export
|
|
163
163
|
*/
|
|
164
164
|
ee.Collection.prototype.limit = function(max, opt_property, opt_ascending) {
|
|
165
|
-
|
|
165
|
+
const args = ee.arguments.extractFromFunction(
|
|
166
166
|
ee.Collection.prototype.limit, arguments);
|
|
167
167
|
return this.castInternal(ee.ApiFunction._call(
|
|
168
168
|
'Collection.limit', this,
|
|
@@ -176,11 +176,11 @@ ee.Collection.prototype.limit = function(max, opt_property, opt_ascending) {
|
|
|
176
176
|
* @param {string} property The property to sort by.
|
|
177
177
|
* @param {boolean=} opt_ascending Whether to sort in ascending or descending
|
|
178
178
|
* order. The default is true (ascending).
|
|
179
|
-
* @return {ee.Collection} The sorted collection.
|
|
179
|
+
* @return {!ee.Collection} The sorted collection.
|
|
180
180
|
* @export
|
|
181
181
|
*/
|
|
182
182
|
ee.Collection.prototype.sort = function(property, opt_ascending) {
|
|
183
|
-
|
|
183
|
+
const args = ee.arguments.extractFromFunction(
|
|
184
184
|
ee.Collection.prototype.sort, arguments);
|
|
185
185
|
return this.castInternal(ee.ApiFunction._call(
|
|
186
186
|
'Collection.limit', this,
|
|
@@ -188,7 +188,10 @@ ee.Collection.prototype.sort = function(property, opt_ascending) {
|
|
|
188
188
|
};
|
|
189
189
|
|
|
190
190
|
|
|
191
|
-
/**
|
|
191
|
+
/**
|
|
192
|
+
* @return {string}
|
|
193
|
+
* @override
|
|
194
|
+
*/
|
|
192
195
|
ee.Collection.prototype.name = function() {
|
|
193
196
|
return 'Collection';
|
|
194
197
|
};
|
|
@@ -207,7 +210,7 @@ ee.Collection.prototype.elementType = function() {
|
|
|
207
210
|
/**
|
|
208
211
|
* Maps an algorithm over a collection.
|
|
209
212
|
*
|
|
210
|
-
* @param {function(Object)
|
|
213
|
+
* @param {function(!Object):?Object} algorithm The operation to map over
|
|
211
214
|
* the images or features of the collection. A JavaScript function that
|
|
212
215
|
* receives an image or features and returns one. The function is called
|
|
213
216
|
* only once and the result is captured as a description, so it cannot
|
|
@@ -215,12 +218,12 @@ ee.Collection.prototype.elementType = function() {
|
|
|
215
218
|
* @param {boolean=} opt_dropNulls If true, the mapped algorithm is allowed
|
|
216
219
|
* to return nulls, and the elements for which it returns nulls will be
|
|
217
220
|
* dropped.
|
|
218
|
-
* @return {ee.Collection} The mapped collection.
|
|
221
|
+
* @return {!ee.Collection} The mapped collection.
|
|
219
222
|
* @export
|
|
220
223
|
*/
|
|
221
224
|
ee.Collection.prototype.map = function(algorithm, opt_dropNulls) {
|
|
222
|
-
|
|
223
|
-
|
|
225
|
+
const elementType = this.elementType();
|
|
226
|
+
const withCast = function(e) { return algorithm(new elementType(e)); };
|
|
224
227
|
return this.castInternal(ee.ApiFunction._call(
|
|
225
228
|
'Collection.map', this, withCast, opt_dropNulls));
|
|
226
229
|
};
|
|
@@ -233,7 +236,7 @@ ee.Collection.prototype.map = function(algorithm, opt_dropNulls) {
|
|
|
233
236
|
* for the first iteration. The result is the value returned by the final
|
|
234
237
|
* call to the user-supplied function.
|
|
235
238
|
*
|
|
236
|
-
* @param {function(Object, Object)
|
|
239
|
+
* @param {function(!Object, ?Object):?Object} algorithm The function to apply
|
|
237
240
|
* to each element. Must take two arguments: an element of the collection
|
|
238
241
|
* and the value from the previous iteration.
|
|
239
242
|
* @param {*=} opt_first The initial state.
|
|
@@ -241,8 +244,8 @@ ee.Collection.prototype.map = function(algorithm, opt_dropNulls) {
|
|
|
241
244
|
* @export
|
|
242
245
|
*/
|
|
243
246
|
ee.Collection.prototype.iterate = function(algorithm, opt_first) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
+
const first = (opt_first !== undefined) ? opt_first : null;
|
|
248
|
+
const elementType = this.elementType();
|
|
249
|
+
const withCast = function(e, p) { return algorithm(new elementType(e), p); };
|
|
247
250
|
return ee.ApiFunction._call('Collection.iterate', this, withCast, first);
|
|
248
251
|
};
|
package/src/computedobject.js
CHANGED
|
@@ -121,7 +121,11 @@ ee.ComputedObject.prototype.getInfo = function(opt_callback) {
|
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
|
|
124
|
-
/**
|
|
124
|
+
/**
|
|
125
|
+
* @override
|
|
126
|
+
* @param {function(*): *} encoder The encoder function.
|
|
127
|
+
* @return {*} The encoded form of the object.
|
|
128
|
+
*/
|
|
125
129
|
ee.ComputedObject.prototype.encode = function(encoder) {
|
|
126
130
|
if (this.isVariable()) {
|
|
127
131
|
return {
|
|
@@ -129,17 +133,17 @@ ee.ComputedObject.prototype.encode = function(encoder) {
|
|
|
129
133
|
'value': this.varName
|
|
130
134
|
};
|
|
131
135
|
} else {
|
|
132
|
-
|
|
133
|
-
for (
|
|
136
|
+
const encodedArgs = {};
|
|
137
|
+
for (const name in this.args) {
|
|
134
138
|
if (this.args[name] !== undefined) {
|
|
135
139
|
encodedArgs[name] = encoder(this.args[name]);
|
|
136
140
|
}
|
|
137
141
|
}
|
|
138
|
-
|
|
142
|
+
const result = {
|
|
139
143
|
'type': 'Invocation',
|
|
140
144
|
'arguments': encodedArgs
|
|
141
145
|
};
|
|
142
|
-
|
|
146
|
+
const func = encoder(this.func);
|
|
143
147
|
result[typeof func === 'string' ? 'functionName' : 'function'] = func;
|
|
144
148
|
return result;
|
|
145
149
|
}
|
|
@@ -230,13 +234,13 @@ ee.ComputedObject.prototype.name = function() {
|
|
|
230
234
|
* .aside(Map.addLayer, {min: 0, max: 142}, 'Filtered')
|
|
231
235
|
* .select('a', 'b');
|
|
232
236
|
*
|
|
233
|
-
* @param {Function} func The function to call.
|
|
237
|
+
* @param {!Function} func The function to call.
|
|
234
238
|
* @param {...*} var_args Any extra arguments to pass to the function.
|
|
235
239
|
* @return {!ee.ComputedObject} The same object, for chaining.
|
|
236
240
|
* @export
|
|
237
241
|
*/
|
|
238
242
|
ee.ComputedObject.prototype.aside = function(func, var_args) {
|
|
239
|
-
|
|
243
|
+
const args = Array.from(arguments);
|
|
240
244
|
args[0] = this;
|
|
241
245
|
func.apply(goog.global, args);
|
|
242
246
|
return this;
|
|
@@ -245,7 +249,7 @@ ee.ComputedObject.prototype.aside = function(func, var_args) {
|
|
|
245
249
|
|
|
246
250
|
/**
|
|
247
251
|
* Cast a ComputedObject to a new instance of the same class as this.
|
|
248
|
-
* @param {ee.ComputedObject} obj The object to cast.
|
|
252
|
+
* @param {!ee.ComputedObject} obj The object to cast.
|
|
249
253
|
* @return {?} The converted instance.
|
|
250
254
|
* @protected
|
|
251
255
|
*/
|
|
@@ -257,9 +261,9 @@ ee.ComputedObject.prototype.castInternal = function(obj) {
|
|
|
257
261
|
* Avoid Object.create() for browser compatibility.
|
|
258
262
|
* @constructor
|
|
259
263
|
*/
|
|
260
|
-
|
|
264
|
+
const klass = function() {};
|
|
261
265
|
klass.prototype = this.constructor.prototype;
|
|
262
|
-
|
|
266
|
+
const result = new klass();
|
|
263
267
|
result.func = obj.func;
|
|
264
268
|
result.args = obj.args;
|
|
265
269
|
result.varName = obj.varName;
|
|
@@ -271,8 +275,8 @@ ee.ComputedObject.prototype.castInternal = function(obj) {
|
|
|
271
275
|
/**
|
|
272
276
|
* A helper function to construct a class with variable args.
|
|
273
277
|
*
|
|
274
|
-
* @param {Function} constructor The constructor to construct.
|
|
275
|
-
* @param {IArrayLike} argsArray The args array.
|
|
278
|
+
* @param {!Function} constructor The constructor to construct.
|
|
279
|
+
* @param {!IArrayLike} argsArray The args array.
|
|
276
280
|
* @return {!Object} The newly constructed object.
|
|
277
281
|
*/
|
|
278
282
|
ee.ComputedObject.construct = function(constructor, argsArray) {
|
package/src/customfunction.js
CHANGED
|
@@ -22,10 +22,10 @@ goog.requireType('ee.api');
|
|
|
22
22
|
* The expression is created by evaluating the given JavaScript function
|
|
23
23
|
* using variables as placeholders.
|
|
24
24
|
*
|
|
25
|
-
* @param {ee.Function.Signature} signature The function's signature. If any of
|
|
25
|
+
* @param {!ee.Function.Signature} signature The function's signature. If any of
|
|
26
26
|
* the argument names are null, their names will be generated
|
|
27
27
|
* deterministically, based on the body.
|
|
28
|
-
* @param {Function} body The JavaScript function to evaluate.
|
|
28
|
+
* @param {!Function} body The JavaScript function to evaluate.
|
|
29
29
|
*
|
|
30
30
|
* @constructor
|
|
31
31
|
* @extends {ee.Function}
|
|
@@ -51,7 +51,7 @@ ee.CustomFunction = function(signature, body) {
|
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* The signature of the function.
|
|
54
|
-
* @
|
|
54
|
+
* @const {!ee.Function.Signature}
|
|
55
55
|
* @private
|
|
56
56
|
*/
|
|
57
57
|
this.signature_ = ee.CustomFunction.resolveNamelessArgs_(
|
|
@@ -59,7 +59,7 @@ ee.CustomFunction = function(signature, body) {
|
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* The function evaluated using placeholders.
|
|
62
|
-
* @
|
|
62
|
+
* @const {*}
|
|
63
63
|
* @private
|
|
64
64
|
*/
|
|
65
65
|
this.body_ = body.apply(null, vars);
|
|
@@ -69,7 +69,11 @@ goog.inherits(ee.CustomFunction, ee.Function);
|
|
|
69
69
|
goog.exportSymbol('ee.CustomFunction', ee.CustomFunction);
|
|
70
70
|
|
|
71
71
|
|
|
72
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* @param {function(*): *} encoder
|
|
74
|
+
* @return {{type: string, argumentNames: !Array<string>, body: *}}
|
|
75
|
+
* @override
|
|
76
|
+
*/
|
|
73
77
|
ee.CustomFunction.prototype.encode = function(encoder) {
|
|
74
78
|
return {
|
|
75
79
|
'type': 'Function',
|
|
@@ -96,7 +100,10 @@ ee.CustomFunction.prototype.encodeCloudInvocation = function(
|
|
|
96
100
|
};
|
|
97
101
|
|
|
98
102
|
|
|
99
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* @return {!ee.Function.Signature}
|
|
105
|
+
* @override
|
|
106
|
+
*/
|
|
100
107
|
ee.CustomFunction.prototype.getSignature = function() {
|
|
101
108
|
return this.signature_;
|
|
102
109
|
};
|
|
@@ -106,7 +113,7 @@ ee.CustomFunction.prototype.getSignature = function() {
|
|
|
106
113
|
* Returns a placeholder variable with a given name that implements a given
|
|
107
114
|
* EE type.
|
|
108
115
|
*
|
|
109
|
-
* @param {Function} type A type to mimic.
|
|
116
|
+
* @param {?Function} type A type to mimic.
|
|
110
117
|
* @param {string?} name The name of the variable as it will appear in the
|
|
111
118
|
* arguments of the custom functions that use this variable. If null, a
|
|
112
119
|
* name will be auto-generated in resolveNamelessArgs_().
|
|
@@ -148,10 +155,10 @@ ee.CustomFunction.variable = function(type, name) {
|
|
|
148
155
|
* Creates a CustomFunction calling a given native function with the specified
|
|
149
156
|
* return type and argument types and auto-generated argument names.
|
|
150
157
|
*
|
|
151
|
-
* @param {Function} func The native function to wrap.
|
|
152
|
-
* @param {string
|
|
158
|
+
* @param {!Function} func The native function to wrap.
|
|
159
|
+
* @param {string|!Function} returnType The type of the return value, either
|
|
153
160
|
* as a string or a constructor/class reference.
|
|
154
|
-
* @param {Array
|
|
161
|
+
* @param {!Array<string|!Function>} arg_types The types of the arguments,
|
|
155
162
|
* either as strings or constructor/class references.
|
|
156
163
|
* @return {!ee.CustomFunction} The constructed CustomFunction.
|
|
157
164
|
*/
|
package/src/date.js
CHANGED
|
@@ -17,7 +17,7 @@ goog.require('ee.arguments');
|
|
|
17
17
|
/**
|
|
18
18
|
* Constructs a new Date object.
|
|
19
19
|
*
|
|
20
|
-
* @param {number|
|
|
20
|
+
* @param {number|string|!ee.ComputedObject|!Date} date The date to convert,
|
|
21
21
|
* one of:
|
|
22
22
|
* a number (number of milliseconds since the epoch),
|
|
23
23
|
* an ISO Date string,
|
|
@@ -43,13 +43,13 @@ ee.Date = function(date, opt_tz) {
|
|
|
43
43
|
|
|
44
44
|
ee.Date.initialize();
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
const jsArgs = ee.arguments.extractFromFunction(ee.Date, arguments);
|
|
47
47
|
date = jsArgs['date'];
|
|
48
|
-
|
|
48
|
+
const tz = jsArgs['tz'];
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
let func = new ee.ApiFunction('Date');
|
|
51
|
+
let args = {};
|
|
52
|
+
let varName = null;
|
|
53
53
|
if (ee.Types.isString(date)) {
|
|
54
54
|
args['value'] = date;
|
|
55
55
|
if (tz) {
|
|
@@ -63,7 +63,7 @@ ee.Date = function(date, opt_tz) {
|
|
|
63
63
|
} else if (ee.Types.isNumber(date)) {
|
|
64
64
|
args['value'] = date;
|
|
65
65
|
} else if (goog.isDateLike(date)) {
|
|
66
|
-
args['value'] = Math.floor(/** @type {Date} */(date).getTime());
|
|
66
|
+
args['value'] = Math.floor(/** @type {!Date} */(date).getTime());
|
|
67
67
|
} else if (date instanceof ee.ComputedObject) {
|
|
68
68
|
if (date.func && date.func.getSignature()['returns'] == 'Date') {
|
|
69
69
|
// If it's a call that's already returning a Date, just cast.
|
|
@@ -107,6 +107,7 @@ ee.Date.reset = function() {
|
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* @override
|
|
110
|
+
* @return {string}
|
|
110
111
|
*/
|
|
111
112
|
ee.Date.prototype.name = function() {
|
|
112
113
|
return 'Date';
|
package/src/deserializer.js
CHANGED
|
@@ -181,10 +181,20 @@ ee.Deserializer.decodeValue_ = function(json, namedValues) {
|
|
|
181
181
|
*/
|
|
182
182
|
ee.Deserializer.roundTrip_ = function(node, value) {
|
|
183
183
|
class Reencoder extends ee.Encodable {
|
|
184
|
-
/**
|
|
184
|
+
/**
|
|
185
|
+
* @param {function(*):*} encoder
|
|
186
|
+
* @return {*}
|
|
187
|
+
* @override
|
|
188
|
+
*/
|
|
189
|
+
encode(encoder) {
|
|
185
190
|
return value;
|
|
186
191
|
}
|
|
187
|
-
/**
|
|
192
|
+
/**
|
|
193
|
+
* @param {!ee.Encodable.Serializer} serializer
|
|
194
|
+
* @return {!ee.api.ValueNode}
|
|
195
|
+
* @override
|
|
196
|
+
*/
|
|
197
|
+
encodeCloudValue(serializer) {
|
|
188
198
|
return node;
|
|
189
199
|
}
|
|
190
200
|
}
|
package/src/dictionary.js
CHANGED
|
@@ -15,7 +15,7 @@ goog.requireType('ee.api');
|
|
|
15
15
|
/**
|
|
16
16
|
* Constructs a new Dictionary.
|
|
17
17
|
*
|
|
18
|
-
* @param {Object|ee.ComputedObject=} opt_dict An object to convert to
|
|
18
|
+
* @param {!Object|null|!ee.ComputedObject=} opt_dict An object to convert to
|
|
19
19
|
* a dictionary. This constructor accepts the following types:
|
|
20
20
|
* 1) Another dictionary.
|
|
21
21
|
* 2) A list of key/value pairs.
|
|
@@ -38,7 +38,7 @@ ee.Dictionary = function(opt_dict) {
|
|
|
38
38
|
/**
|
|
39
39
|
* The internal rerpresentation of this dictionary.
|
|
40
40
|
*
|
|
41
|
-
* @type {Object}
|
|
41
|
+
* @type {?Object}
|
|
42
42
|
* @private
|
|
43
43
|
*/
|
|
44
44
|
this.dict_;
|
|
@@ -46,7 +46,7 @@ ee.Dictionary = function(opt_dict) {
|
|
|
46
46
|
if (ee.Types.isRegularObject(opt_dict)) {
|
|
47
47
|
// Cast to a dictionary.
|
|
48
48
|
ee.Dictionary.base(this, 'constructor', null, null);
|
|
49
|
-
this.dict_ = /** @type {Object} */ (opt_dict);
|
|
49
|
+
this.dict_ = /** @type {!Object} */ (opt_dict);
|
|
50
50
|
} else {
|
|
51
51
|
if (opt_dict instanceof ee.ComputedObject && opt_dict.func &&
|
|
52
52
|
opt_dict.func.getSignature()['returns'] == 'Dictionary') {
|
|
@@ -89,12 +89,15 @@ ee.Dictionary.reset = function() {
|
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* @override
|
|
92
|
+
* @param {function(*):*} encoder
|
|
93
|
+
* @return {!Object}
|
|
92
94
|
*/
|
|
93
95
|
ee.Dictionary.prototype.encode = function(encoder) {
|
|
94
96
|
if (this.dict_ !== null) {
|
|
95
|
-
return encoder(this.dict_);
|
|
97
|
+
return /** @type {!Object} */ (encoder(this.dict_));
|
|
96
98
|
} else {
|
|
97
|
-
return
|
|
99
|
+
return /** @type {!Object} */ (
|
|
100
|
+
ee.Dictionary.base(this, 'encode', encoder));
|
|
98
101
|
}
|
|
99
102
|
};
|
|
100
103
|
|
|
@@ -112,6 +115,7 @@ ee.Dictionary.prototype.encodeCloudValue = function(
|
|
|
112
115
|
|
|
113
116
|
/**
|
|
114
117
|
* @override
|
|
118
|
+
* @return {string}
|
|
115
119
|
*/
|
|
116
120
|
ee.Dictionary.prototype.name = function() {
|
|
117
121
|
return 'Dictionary';
|
package/src/ee.js
CHANGED
|
@@ -63,7 +63,7 @@ goog.require('goog.object');
|
|
|
63
63
|
* @param {function()?=} opt_successCallback An optional callback to be invoked
|
|
64
64
|
* when the initialization is successful. If not provided, the
|
|
65
65
|
* initialization is done synchronously. (JavaScript only)
|
|
66
|
-
* @param {function(Error)?=} opt_errorCallback An optional callback to be
|
|
66
|
+
* @param {function(?Error)?=} opt_errorCallback An optional callback to be
|
|
67
67
|
* invoked with an error if the initialization fails. (JavaScript only)
|
|
68
68
|
* @param {string?=} opt_xsrfToken A string to pass in the "xsrfToken"
|
|
69
69
|
* parameter of EE API XHRs. (JavaScript only)
|
|
@@ -147,6 +147,8 @@ ee.reset = function() {
|
|
|
147
147
|
// Can't simply reassign ee.Algorithms to {} since it's been exported by
|
|
148
148
|
// reference.
|
|
149
149
|
goog.object.clear(ee.Algorithms);
|
|
150
|
+
ee.successCallbacks_ = [];
|
|
151
|
+
ee.errorCallbacks_ = [];
|
|
150
152
|
};
|
|
151
153
|
|
|
152
154
|
|
|
@@ -171,7 +173,7 @@ goog.exportSymbol('ee.InitState.READY', ee.InitState.READY);
|
|
|
171
173
|
|
|
172
174
|
/**
|
|
173
175
|
* A flag to indicate the initialization state.
|
|
174
|
-
* @type {ee.InitState}
|
|
176
|
+
* @type {!ee.InitState}
|
|
175
177
|
* @private
|
|
176
178
|
*/
|
|
177
179
|
ee.ready_ = ee.InitState.NOT_READY;
|
|
@@ -181,7 +183,7 @@ ee.ready_ = ee.InitState.NOT_READY;
|
|
|
181
183
|
* The list of callbacks to call on successful initialization. Added by
|
|
182
184
|
* initialize() and cleared by initializationSuccess_() and
|
|
183
185
|
* initializationFailure_().
|
|
184
|
-
* @type {Array.<function()?>}
|
|
186
|
+
* @type {!Array.<function()?>}
|
|
185
187
|
* @private
|
|
186
188
|
*/
|
|
187
189
|
ee.successCallbacks_ = [];
|
|
@@ -191,7 +193,7 @@ ee.successCallbacks_ = [];
|
|
|
191
193
|
* The list of callbacks to call on failed initialization. Added by
|
|
192
194
|
* initialize() and cleared by initializationSuccess_() and
|
|
193
195
|
* initializationFailure_().
|
|
194
|
-
* @type {Array.<function(Error)>}
|
|
196
|
+
* @type {!Array.<function(!Error)>}
|
|
195
197
|
* @private
|
|
196
198
|
*/
|
|
197
199
|
ee.errorCallbacks_ = [];
|
|
@@ -207,7 +209,7 @@ ee.TILE_SIZE = 256;
|
|
|
207
209
|
|
|
208
210
|
/**
|
|
209
211
|
* The list of auto-generated class names.
|
|
210
|
-
* @type {Array.<string>}
|
|
212
|
+
* @type {!Array.<string>}
|
|
211
213
|
* @private
|
|
212
214
|
*/
|
|
213
215
|
ee.generatedClasses_ = [];
|
|
@@ -216,14 +218,14 @@ ee.generatedClasses_ = [];
|
|
|
216
218
|
/**
|
|
217
219
|
* A dictionary of algorithms that are not bound to a specific class. Can
|
|
218
220
|
* contain nested namespaces (e.g. ee.Algorithms.Landsat.SimpleComposite).
|
|
219
|
-
* @type {Object
|
|
221
|
+
* @type {!Object.<!Object|!Function>}
|
|
220
222
|
* @export
|
|
221
223
|
*/
|
|
222
224
|
ee.Algorithms = {};
|
|
223
225
|
|
|
224
226
|
|
|
225
227
|
/**
|
|
226
|
-
* @return {ee.InitState} The initialization status.
|
|
228
|
+
* @return {!ee.InitState} The initialization status.
|
|
227
229
|
*/
|
|
228
230
|
ee.ready = function() {
|
|
229
231
|
return ee.ready_;
|
|
@@ -233,7 +235,7 @@ ee.ready = function() {
|
|
|
233
235
|
/**
|
|
234
236
|
* Call a function with the given positional arguments.
|
|
235
237
|
*
|
|
236
|
-
* @param {ee.Function|string} func The function to call. Either an
|
|
238
|
+
* @param {!ee.Function|string} func The function to call. Either an
|
|
237
239
|
* ee.Function object or the name of an API function.
|
|
238
240
|
* @param {...*} var_args Positional arguments to pass to the function.
|
|
239
241
|
* @return {!ee.ComputedObject} An object representing the called function.
|
|
@@ -255,9 +257,9 @@ ee.call = function(func, var_args) {
|
|
|
255
257
|
/**
|
|
256
258
|
* Call a function with a dictionary of named arguments.
|
|
257
259
|
*
|
|
258
|
-
* @param {ee.Function|string} func The function to call. Either an
|
|
260
|
+
* @param {!ee.Function|string} func The function to call. Either an
|
|
259
261
|
* ee.Function object or the name of an API function.
|
|
260
|
-
* @param {Object} namedArgs A dictionary of arguments to the function.
|
|
262
|
+
* @param {!Object} namedArgs A dictionary of arguments to the function.
|
|
261
263
|
* @return {!ee.ComputedObject} An object representing the called function.
|
|
262
264
|
* If the signature specifies a recognized return type, the returned
|
|
263
265
|
* value will be cast to that type.
|
|
@@ -327,7 +329,7 @@ ee.initializationSuccess_ = function() {
|
|
|
327
329
|
|
|
328
330
|
/**
|
|
329
331
|
* Reports initialization failure.
|
|
330
|
-
* @param {Error} e The cause of the failure.
|
|
332
|
+
* @param {!Error} e The cause of the failure.
|
|
331
333
|
* @private
|
|
332
334
|
*/
|
|
333
335
|
ee.initializationFailure_ = function(e) {
|
|
@@ -377,14 +379,14 @@ ee.promote_ = function(arg, klass) {
|
|
|
377
379
|
|
|
378
380
|
switch (klass) {
|
|
379
381
|
case 'Image':
|
|
380
|
-
return new ee.Image(/** @type {Object} */ (arg));
|
|
382
|
+
return new ee.Image(/** @type {!Object} */ (arg));
|
|
381
383
|
case 'Feature':
|
|
382
384
|
if (arg instanceof ee.Collection) {
|
|
383
385
|
// This can be quite dangerous on large collections.
|
|
384
386
|
return ee.ApiFunction._call(
|
|
385
387
|
'Feature', ee.ApiFunction._call('Collection.geometry', arg));
|
|
386
388
|
} else {
|
|
387
|
-
return new ee.Feature(/** @type {Object} */ (arg));
|
|
389
|
+
return new ee.Feature(/** @type {!Object} */ (arg));
|
|
388
390
|
}
|
|
389
391
|
case 'Element':
|
|
390
392
|
if (arg instanceof ee.Element) {
|
|
@@ -392,10 +394,10 @@ ee.promote_ = function(arg, klass) {
|
|
|
392
394
|
return arg;
|
|
393
395
|
} else if (arg instanceof ee.Geometry) {
|
|
394
396
|
// Geometries get promoted to Features.
|
|
395
|
-
return new ee.Feature(/** @type {ee.Geometry} */ (arg));
|
|
397
|
+
return new ee.Feature(/** @type {!ee.Geometry} */ (arg));
|
|
396
398
|
} else if (arg instanceof ee.ComputedObject) {
|
|
397
399
|
// Try a cast.
|
|
398
|
-
const co = /** @type {ee.ComputedObject} */ (arg);
|
|
400
|
+
const co = /** @type {!ee.ComputedObject} */ (arg);
|
|
399
401
|
return new ee.Element(co.func, co.args, co.varName);
|
|
400
402
|
} else {
|
|
401
403
|
// No way to convert.
|
|
@@ -417,7 +419,7 @@ ee.promote_ = function(arg, klass) {
|
|
|
417
419
|
case 'ImageCollection':
|
|
418
420
|
return new ee.ImageCollection(/** @type {?} */ (arg));
|
|
419
421
|
case 'Filter':
|
|
420
|
-
return new ee.Filter(/** @type {Object} */ (arg));
|
|
422
|
+
return new ee.Filter(/** @type {!Object} */ (arg));
|
|
421
423
|
case 'Algorithm':
|
|
422
424
|
if (typeof arg === 'string') {
|
|
423
425
|
// An API function name.
|
package/src/element.js
CHANGED
|
@@ -16,8 +16,8 @@ goog.requireType('ee.Function');
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* A ComputedObject that can be stored in a collection.
|
|
19
|
-
* @param {ee.Function} func The same argument as in ee.ComputedObject().
|
|
20
|
-
* @param {Object} args The same argument as in ee.ComputedObject().
|
|
19
|
+
* @param {?ee.Function} func The same argument as in ee.ComputedObject().
|
|
20
|
+
* @param {?Object} args The same argument as in ee.ComputedObject().
|
|
21
21
|
* @param {string?=} opt_varName The same argument as in ee.ComputedObject().
|
|
22
22
|
* @constructor
|
|
23
23
|
* @extends {ee.ComputedObject}
|
|
@@ -59,7 +59,10 @@ ee.Element.reset = function() {
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* @return {string}
|
|
64
|
+
* @override
|
|
65
|
+
*/
|
|
63
66
|
ee.Element.prototype.name = function() {
|
|
64
67
|
return 'Element';
|
|
65
68
|
};
|
|
@@ -68,30 +71,30 @@ ee.Element.prototype.name = function() {
|
|
|
68
71
|
/**
|
|
69
72
|
* Overrides one or more metadata properties of an Element.
|
|
70
73
|
*
|
|
71
|
-
* @param {
|
|
74
|
+
* @param {...!Object} var_args Either a dictionary of properties, or a
|
|
72
75
|
* vararg sequence of properties, e.g. key1, value1, key2, value2, ...
|
|
73
|
-
* @return {ee.Element} The element with the specified properties overridden.
|
|
76
|
+
* @return {!ee.Element} The element with the specified properties overridden.
|
|
74
77
|
* @export
|
|
75
78
|
*/
|
|
76
79
|
ee.Element.prototype.set = function(var_args) {
|
|
77
|
-
|
|
80
|
+
let result;
|
|
78
81
|
if (arguments.length <= 1) {
|
|
79
|
-
|
|
82
|
+
let properties = arguments[0];
|
|
80
83
|
|
|
81
84
|
// If this is a keyword call, unwrap it.
|
|
82
85
|
if (ee.Types.isRegularObject(properties) &&
|
|
83
86
|
goog.array.equals(goog.object.getKeys(properties), ['properties']) &&
|
|
84
87
|
goog.isObject(properties['properties'])) {
|
|
85
88
|
// Looks like a call with keyword parameters. Extract them.
|
|
86
|
-
properties = /** @type {Object.<*>} */(properties['properties']);
|
|
89
|
+
properties = /** @type {!Object.<*>} */(properties['properties']);
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
if (ee.Types.isRegularObject(properties)) {
|
|
90
93
|
// Still a plain object. Extract its keys. Setting the keys separately
|
|
91
94
|
// allows filter propagation.
|
|
92
95
|
result = this;
|
|
93
|
-
for (
|
|
94
|
-
|
|
96
|
+
for (const key in properties) {
|
|
97
|
+
const value = properties[key];
|
|
95
98
|
result = ee.ApiFunction._call('Element.set', result, key, value);
|
|
96
99
|
}
|
|
97
100
|
} else if (properties instanceof ee.ComputedObject &&
|
|
@@ -109,9 +112,9 @@ ee.Element.prototype.set = function(var_args) {
|
|
|
109
112
|
'must be an even number of them.');
|
|
110
113
|
}
|
|
111
114
|
result = this;
|
|
112
|
-
for (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
for (let i = 0; i < arguments.length; i += 2) {
|
|
116
|
+
const key = arguments[i];
|
|
117
|
+
const value = arguments[i + 1];
|
|
115
118
|
result = ee.ApiFunction._call('Element.set', result, key, value);
|
|
116
119
|
}
|
|
117
120
|
}
|
package/src/feature.js
CHANGED
|
@@ -23,9 +23,9 @@ goog.requireType('ee.data');
|
|
|
23
23
|
* - A computed object: reinterpreted as a geometry if properties
|
|
24
24
|
* are specified, and as a feature if they aren't.
|
|
25
25
|
*
|
|
26
|
-
* @param {ee.Geometry
|
|
26
|
+
* @param {!ee.Geometry|!ee.Feature|!ee.ComputedObject|!Object|null} geometry
|
|
27
27
|
* A geometry or feature.
|
|
28
|
-
* @param {Object=} opt_properties A dictionary of metadata properties. If the
|
|
28
|
+
* @param {!Object=} opt_properties A dictionary of metadata properties. If the
|
|
29
29
|
* first parameter is a Feature (instead of a geometry), this is unused.
|
|
30
30
|
* @constructor
|
|
31
31
|
* @extends {ee.Element}
|
|
@@ -60,7 +60,7 @@ ee.Feature = function(geometry, opt_properties) {
|
|
|
60
60
|
ee.Feature.base(this, 'constructor', geometry.func, geometry.args, geometry.varName);
|
|
61
61
|
} else if (geometry['type'] == 'Feature') {
|
|
62
62
|
// Try to convert a GeoJSON Feature.
|
|
63
|
-
|
|
63
|
+
let properties = geometry['properties'] || {};
|
|
64
64
|
if ('id' in geometry) {
|
|
65
65
|
if ('system:index' in properties) {
|
|
66
66
|
throw Error('Can\'t specify both "id" and "system:index".');
|
|
@@ -116,16 +116,16 @@ ee.Feature.reset = function() {
|
|
|
116
116
|
* An imperative function that returns information about this feature via an
|
|
117
117
|
* AJAX call.
|
|
118
118
|
*
|
|
119
|
-
* @param {function(ee.data.GeoJSONFeature, string=)=} opt_callback
|
|
119
|
+
* @param {function(!ee.data.GeoJSONFeature, string=)=} opt_callback
|
|
120
120
|
* An optional callback. If not supplied, the call is made synchronously.
|
|
121
121
|
* If supplied, will be called with the first parameter if successful and
|
|
122
122
|
* the second if unsuccessful.
|
|
123
|
-
* @return {ee.data.GeoJSONFeature} A description of the feature.
|
|
123
|
+
* @return {!ee.data.GeoJSONFeature} A description of the feature.
|
|
124
124
|
* @export
|
|
125
125
|
* @override
|
|
126
126
|
*/
|
|
127
127
|
ee.Feature.prototype.getInfo = function(opt_callback) {
|
|
128
|
-
return /** @type {ee.data.GeoJSONFeature} */(
|
|
128
|
+
return /** @type {!ee.data.GeoJSONFeature} */(
|
|
129
129
|
ee.Feature.base(this, 'getInfo', opt_callback));
|
|
130
130
|
};
|
|
131
131
|
|
|
@@ -171,7 +171,10 @@ ee.Feature.prototype.getMapId = function(opt_visParams, opt_callback) {
|
|
|
171
171
|
ee.Feature.prototype.getMap = ee.Feature.prototype.getMapId;
|
|
172
172
|
|
|
173
173
|
|
|
174
|
-
/**
|
|
174
|
+
/**
|
|
175
|
+
* @return {string}
|
|
176
|
+
* @override
|
|
177
|
+
*/
|
|
175
178
|
ee.Feature.prototype.name = function() {
|
|
176
179
|
return 'Feature';
|
|
177
180
|
};
|