@google/earthengine 0.1.394 → 0.1.396

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.394",
3
+ "version": "0.1.396",
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
@@ -24,7 +24,7 @@ const {trustedResourceUrl} = goog.require('safevalues');
24
24
  /** @namespace */
25
25
  const apiclient = {};
26
26
 
27
- const API_CLIENT_VERSION = '0.1.394';
27
+ const API_CLIENT_VERSION = '0.1.396';
28
28
 
29
29
  exports.VERSION = apiVersion.VERSION;
30
30
  exports.API_CLIENT_VERSION = API_CLIENT_VERSION;
package/src/data.js CHANGED
@@ -1659,14 +1659,41 @@ ee.data.getInfo = ee.data.getAsset;
1659
1659
  ee.data.makeListAssetsCall_ = function(
1660
1660
  parent, opt_params = {}, opt_callback = undefined,
1661
1661
  opt_postProcessing = goog.functions.identity) {
1662
+ /** @type {!ee.api.ProjectsAssetsListAssetsNamedParameters} */
1663
+ const params = Object.assign({}, opt_params);
1664
+ const call = new ee.apiclient.Call(opt_callback);
1662
1665
  // Detect project asset root call.
1663
1666
  const isProjectAssetRoot = ee.rpc_convert.CLOUD_ASSET_ROOT_RE.test(parent);
1664
- const call = new ee.apiclient.Call(opt_callback);
1665
1667
  const methodRoot = isProjectAssetRoot ? call.projects() : call.assets();
1666
1668
  parent = isProjectAssetRoot ? ee.rpc_convert.projectParentFromPath(parent) :
1667
1669
  ee.rpc_convert.assetIdToAssetName(parent);
1668
- return call.handle(
1669
- methodRoot.listAssets(parent, opt_params).then(opt_postProcessing));
1670
+ const getNextPageIfNeeded = (response) => {
1671
+ // We currently treat pageSize as a cap on the results, if this param was
1672
+ // provided we should break fast and not return more than the asked for
1673
+ // amount.
1674
+ if (params.pageSize != null || !response.nextPageToken) {
1675
+ return response;
1676
+ }
1677
+ const previousAssets = response.assets || [];
1678
+ params.pageToken = response.nextPageToken;
1679
+ const nextResponse = methodRoot.listAssets(parent, params)
1680
+ .then((response) => {
1681
+ // Add previous assets to front.
1682
+ response.assets = previousAssets.concat(response.assets);
1683
+ return response;
1684
+ })
1685
+ .then(getNextPageIfNeeded);
1686
+ if (opt_callback) {
1687
+ // For async, make sure we have only a single chained `call.handle` call.
1688
+ return nextResponse;
1689
+ }
1690
+ // For sync mode, the response data needs to be uplifted from the fake
1691
+ // Promise object to be returned immediately.
1692
+ return call.handle(nextResponse);
1693
+ };
1694
+ return call.handle(methodRoot.listAssets(parent, params)
1695
+ .then(getNextPageIfNeeded)
1696
+ .then(opt_postProcessing));
1670
1697
  };
1671
1698
 
1672
1699
 
@@ -1686,9 +1713,15 @@ ee.data.makeListAssetsCall_ = function(
1686
1713
  * @export
1687
1714
  */
1688
1715
  ee.data.getList = function(params, opt_callback) {
1716
+ const convertedParams = ee.rpc_convert.getListToListAssets(params);
1717
+ // Force a single page of results by explicitly specifying a page size.
1718
+ // This maintains backward compatibility, as well as compatibility with the
1719
+ // Python implementation.
1720
+ if (!convertedParams.pageSize) {
1721
+ convertedParams.pageSize = 1000;
1722
+ }
1689
1723
  return ee.data.makeListAssetsCall_(
1690
- params['id'], ee.rpc_convert.getListToListAssets(params), opt_callback,
1691
- (r) => {
1724
+ params['id'], convertedParams, opt_callback, (r) => {
1692
1725
  if (r == null) {
1693
1726
  return null;
1694
1727
  }
@@ -1709,7 +1742,7 @@ ee.data.getList = function(params, opt_callback) {
1709
1742
  * <table>
1710
1743
  * <tr>
1711
1744
  * <td><code> pageSize </code> (string) The number of results to
1712
- * return. Defaults to 1000.</td>
1745
+ * return. If not specified, all results are returned.</td>
1713
1746
  * </tr>
1714
1747
  * <tr>
1715
1748
  * <td><code> pageToken </code> (string) The token for the page of
@@ -1753,7 +1786,7 @@ ee.data.listAssets = function(
1753
1786
  * <table>
1754
1787
  * <tr>
1755
1788
  * <td><code> pageSize </code> (string) The number of results to return.
1756
- * Defaults to 1000.</td>
1789
+ * If not specified, all results are returned.</td>
1757
1790
  * </tr>
1758
1791
  * <tr>
1759
1792
  * <td><code> pageToken </code> (string) The token page of results to
@@ -69,8 +69,10 @@ var addHarmonics = function(freqs) {
69
69
  };
70
70
  };
71
71
 
72
- // Filter to the area of interest, mask clouds, add variables.
72
+ // Filter to the desired date range and area of interest, mask clouds,
73
+ // and add variables.
73
74
  var harmonicLandsat = landsatCollection
75
+ .filterDate('2015-01-01', '2020-01-01')
74
76
  .filterBounds(roi)
75
77
  .map(maskClouds)
76
78
  .map(addNDVI)