@google/earthengine 0.1.414 → 0.1.416

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.414",
3
+ "version": "0.1.416",
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.414';
27
+ const API_CLIENT_VERSION = '0.1.416';
28
28
 
29
29
  exports.VERSION = apiVersion.VERSION;
30
30
  exports.API_CLIENT_VERSION = API_CLIENT_VERSION;
@@ -52,8 +52,14 @@ inspectorPanel.add(ui.Label('[Legend]'));
52
52
  * Chart setup
53
53
  */
54
54
 
55
+ // Displays the given UI component (a chart or a message) in the inspector
56
+ // panel, at the position of the chart.
57
+ var displayChart = function(component) {
58
+ inspectorPanel.widgets().set(2, component);
59
+ }
60
+
55
61
  // Generates a new time series chart of SST for the given coordinates.
56
- var generateChart = function (coords) {
62
+ var generateChart = function(coords) {
57
63
  // Update the lon/lat panel with values from the click event.
58
64
  lon.setValue('lon: ' + coords.lon.toFixed(2));
59
65
  lat.setValue('lat: ' + coords.lat.toFixed(2));
@@ -65,25 +71,35 @@ var generateChart = function (coords) {
65
71
  mapPanel.layers().set(1, dot);
66
72
 
67
73
  // Make a chart from the time series.
68
- var sstChart = ui.Chart.image.series(sst, point, ee.Reducer.mean(), 500);
69
-
70
- // Customize the chart.
71
- sstChart.setOptions({
72
- title: 'Sea surface temp: time series',
73
- vAxis: {title: 'Temp (C)'},
74
- hAxis: {title: 'Date', format: 'MM-yy', gridlines: {count: 7}},
75
- series: {
76
- 0: {
77
- color: 'blue',
78
- lineWidth: 0,
79
- pointsVisible: true,
80
- pointSize: 2,
74
+ displayChart(ui.Label('Processing location...', {'height': '200px'}));
75
+ var selectionSize = composite.sampleRegions(point).size();
76
+ selectionSize.evaluate(function(size) {
77
+ if (!size) {
78
+ var badSelection = ui.Label(
79
+ 'Invalid location. Please select a different location',
80
+ {'color': 'red', 'height': '200px'});
81
+ displayChart(badSelection);
82
+ return;
83
+ }
84
+ var sstChart = ui.Chart.image.series(sst, point, ee.Reducer.mean(), 500);
85
+
86
+ // Customize the chart.
87
+ sstChart.setOptions({
88
+ title: 'Sea surface temp: time series',
89
+ vAxis: {title: 'Temp (C)'},
90
+ hAxis: {title: 'Date', format: 'MM-yy', gridlines: {count: 7}},
91
+ series: {
92
+ 0: {
93
+ color: 'blue',
94
+ lineWidth: 0,
95
+ pointsVisible: true,
96
+ pointSize: 2,
97
+ },
81
98
  },
82
- },
83
- legend: {position: 'right'},
84
- });
85
- // Add the chart at a fixed position, so that new charts overwrite older ones.
86
- inspectorPanel.widgets().set(2, sstChart);
99
+ legend: {position: 'right'},
100
+ });
101
+ displayChart(sstChart);
102
+ })
87
103
  };
88
104
 
89
105