Skip to content

Commit

Permalink
v0.1.55
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfdewitt committed Jun 1, 2015
1 parent f4c0d64 commit c2058ef
Show file tree
Hide file tree
Showing 19 changed files with 457 additions and 135 deletions.
196 changes: 97 additions & 99 deletions javascript/build/ee_api_js.js

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions javascript/build/ee_api_js_debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -3125,7 +3125,7 @@ goog.dom.getDocumentScrollElement = function() {
return goog.dom.getDocumentScrollElement_(document);
};
goog.dom.getDocumentScrollElement_ = function(doc) {
return !goog.userAgent.WEBKIT && goog.dom.isCss1CompatMode_(doc) ? doc.documentElement : doc.body || doc.documentElement;
return doc.scrollingElement ? doc.scrollingElement : !goog.userAgent.WEBKIT && goog.dom.isCss1CompatMode_(doc) ? doc.documentElement : doc.body || doc.documentElement;
};
goog.dom.getWindow = function(opt_doc) {
return opt_doc ? goog.dom.getWindow_(opt_doc) : window;
Expand Down Expand Up @@ -8095,7 +8095,6 @@ ee.data.getXsrfToken = function() {
return ee.data.xsrfToken_;
};
ee.data.getInfo = function(id, opt_callback) {
goog.global.console && goog.global.console.error && goog.global.console.error("ee.data.getInfo is DEPRECATED. Use ee.data.getValue() instead.");
return ee.data.send_("/info", (new goog.Uri.QueryData).add("id", id), opt_callback);
};
ee.data.getList = function(params, opt_callback) {
Expand Down Expand Up @@ -8238,7 +8237,7 @@ ee.data.send_ = function(path, params, opt_callback$$0, opt_method) {
ee.data.initialize();
var method = opt_method || "POST", headers = {"Content-Type":"application/x-www-form-urlencoded"};
goog.isDefAndNotNull(ee.data.authToken_) && (headers.Authorization = ee.data.authToken_);
goog.isDefAndNotNull(ee.data.xsrfToken_) && ("GET" == method ? (path += goog.string.contains(path, "?") ? "&" : "?", path += "xsrfToken=" + ee.data.xsrfToken_) : (params || (params = new goog.Uri.QueryData), params.add("xsrfToken", ee.data.xsrfToken_)));
goog.isDefAndNotNull(ee.data.xsrfToken_) && (headers["X-XSRF-Token"] = ee.data.xsrfToken_);
var handleResponse = function(status, contentType, responseText, opt_callback) {
var response, data, errorMessage;
contentType = contentType ? contentType.replace(/;.*/, "") : "application/json";
Expand Down Expand Up @@ -10480,6 +10479,9 @@ goog.math.Rect.prototype.clone = function() {
goog.math.Rect.prototype.toBox = function() {
return new goog.math.Box(this.top, this.left + this.width, this.top + this.height, this.left);
};
goog.math.Rect.createFromPositionAndSize = function(position, size) {
return new goog.math.Rect(position.x, position.y, size.width, size.height);
};
goog.math.Rect.createFromBox = function(box) {
return new goog.math.Rect(box.left, box.top, box.right - box.left, box.bottom - box.top);
};
Expand Down Expand Up @@ -10965,10 +10967,10 @@ goog.style.setUnselectable = function(el, unselectable, opt_noRecurse) {
var descendants = opt_noRecurse ? null : el.getElementsByTagName("*"), name = goog.style.unselectableStyle_;
if (name) {
var value = unselectable ? "none" : "";
el.style[name] = value;
el.style && (el.style[name] = value);
if (descendants) {
for (var i = 0, descendant;descendant = descendants[i];i++) {
descendant.style[name] = value;
descendant.style && (descendant.style[name] = value);
}
}
} else {
Expand Down
63 changes: 41 additions & 22 deletions javascript/src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ goog.provide('ee.data.Band');
goog.provide('ee.data.BandDescription');
goog.provide('ee.data.DownloadId');
goog.provide('ee.data.FeatureCollectionDescription');
goog.provide('ee.data.FeatureVisualizationParameters');
goog.provide('ee.data.FileSource');
goog.provide('ee.data.Fileset');
goog.provide('ee.data.FolderDescription');
Expand All @@ -26,6 +27,7 @@ goog.provide('ee.data.GeoJSONGeometry');
goog.provide('ee.data.ImageCollectionDescription');
goog.provide('ee.data.ImageDescription');
goog.provide('ee.data.ImageTaskConfig');
goog.provide('ee.data.ImageVisualizationParameters');
goog.provide('ee.data.IngestionRequest');
goog.provide('ee.data.MapId');
goog.provide('ee.data.PixelTypeDescription');
Expand Down Expand Up @@ -66,7 +68,7 @@ ee.data.tileBaseUrl_ = null;


/**
* @type {string?} A string to pass in the "xsrfToken" parameter of XHRs.
* @type {string?} A string to pass in the X-XSRF-Token header of XHRs.
* @private
*/
ee.data.xsrfToken_ = null;
Expand Down Expand Up @@ -151,8 +153,8 @@ ee.data.TaskUpdateActions = {
* endpoint.
* @param {string?=} opt_tileBaseUrl The (unproxied) EarthEngine REST tile
* endpoint.
* @param {string?=} opt_xsrfToken A string to pass in the "xsrfToken"
* parameter of XHRs.
* @param {string?=} opt_xsrfToken A string to pass in the X-XSRF-Token header
* of XHRs.
*/
ee.data.initialize = function(opt_apiBaseUrl, opt_tileBaseUrl, opt_xsrfToken) {
// If already initialized, only replace the explicitly specified parts.
Expand Down Expand Up @@ -275,7 +277,7 @@ ee.data.getTileBaseUrl = function() {
/**
* Returns the current XSRF token.
*
* @return {string?} A string to pass in the "xsrfToken" parameter of XHRs.
* @return {string?} A string to pass in the X-XSRF-Token header of XHRs.
* @export
*/
ee.data.getXsrfToken = function() {
Expand All @@ -290,14 +292,9 @@ ee.data.getXsrfToken = function() {
* @param {function(Object, string=)=} opt_callback An optional callback.
* If not supplied, the call is made synchronously.
* @return {?Object} The value call results, or null if a callback is specified.
* @deprecated Use ee.data.getValue().
* @export
*/
ee.data.getInfo = function(id, opt_callback) {
if (goog.global.console && goog.global.console.error) {
goog.global.console.error(
'ee.data.getInfo is DEPRECATED. Use ee.data.getValue() instead.');
}
return ee.data.send_('/info',
new goog.Uri.QueryData().add('id', id),
opt_callback);
Expand Down Expand Up @@ -328,8 +325,8 @@ ee.data.getList = function(params, opt_callback) {

/**
* Get a Map ID for a given asset
* @param {Object} params An object containing visualization
* options with the following possible values:
* @param {ee.data.ImageVisualizationParameters} params
* The visualization parameters. For Images and ImageCollections:
* - image (JSON string) The image to render.
* - version (number) Version number of image (or latest).
* - bands (comma-seprated strings) Comma-delimited list of
Expand All @@ -346,6 +343,7 @@ ee.data.getList = function(params, opt_callback) {
* factor (or one per band)
* - palette (comma-separated strings) List of CSS-style color
* strings (single-band previews only).
* - opacity (number) a number between 0 and 1 for opacity.
* - format (string) Either "jpg" or "png".
* @param {function(ee.data.RawMapId, string=)=} opt_callback
* An optional callback. If not supplied, the call is made synchronously.
Expand All @@ -354,7 +352,8 @@ ee.data.getList = function(params, opt_callback) {
* @export
*/
ee.data.getMapId = function(params, opt_callback) {
params = goog.object.clone(params);
params = /** @type {ee.data.ImageVisualizationParameters} */ (
goog.object.clone(params));
return /** @type {?ee.data.RawMapId} */ (
ee.data.send_('/mapid', ee.data.makeRequest_(params), opt_callback));
};
Expand Down Expand Up @@ -398,7 +397,7 @@ ee.data.getValue = function(params, opt_callback) {

/**
* Get a Thumbnail Id for a given asset.
* @param {Object} params Parameters identical to those for the vizOptions for
* @param {Object} params Parameters identical to those for the visParams for
* getMapId with the following additions:
* - size (a number or pair of numbers in format WIDTHxHEIGHT) Maximum
* dimensions of the thumbnail to render, in pixels. If only one
Expand Down Expand Up @@ -904,15 +903,7 @@ ee.data.send_ = function(path, params, opt_callback, opt_method) {

// XSRF protection for a server-side API proxy.
if (goog.isDefAndNotNull(ee.data.xsrfToken_)) {
if (method == 'GET') {
path += goog.string.contains(path, '?') ? '&' : '?';
path += 'xsrfToken=' + ee.data.xsrfToken_;
} else {
if (!params) {
params = new goog.Uri.QueryData();
}
params.add('xsrfToken', ee.data.xsrfToken_);
}
headers['X-XSRF-Token'] = ee.data.xsrfToken_;
}

// Handle processing and dispatching a callback response.
Expand Down Expand Up @@ -1237,6 +1228,16 @@ ee.data.FolderDescription;
ee.data.FeatureCollectionDescription;


/**
* An object describing ee.Feature visualization parameters. Color is
* a 6-character hex string in the RRGGBB format.
* @typedef {{
* color: (string|undefined)
* }}
*/
ee.data.FeatureVisualizationParameters;


/**
* An object that depicts a GME Project that the user may export to with
* attribution ids for each project.
Expand Down Expand Up @@ -1309,6 +1310,24 @@ ee.data.ImageCollectionDescription;
ee.data.ImageDescription;


/**
* An object describing ee.Image visualization parameters. See ee.data.getMapId.
* @typedef {{
* image: ee.Image,
* bands: (string|Array<string>|undefined),
* gain: (number|Array<number>|undefined),
* bias: (number|Array<number>|undefined),
* min: (number|Array<number>|undefined),
* max: (number|Array<number>|undefined),
* gamma: (number|Array<number>|undefined),
* palette: (string|Array<string>|undefined),
* opacity: (number|undefined),
* format: (string|undefined)
* }}
*/
ee.data.ImageVisualizationParameters;


/**
* An object describing an Image band, as returned by getValue.
* The dimensions field is [width, height].
Expand Down
2 changes: 1 addition & 1 deletion javascript/src/deps.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions javascript/src/ee_api_js.externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ ee.Image.prototype.getDownloadURL = function(params, opt_callback) {
ee.Image.prototype.getInfo = function(opt_callback) {
};
/**
* @param {(Object|null)=} opt_visParams
* @param {{bands: (Array<string>|null|string|undefined), bias: (Array<number>|null|number|undefined), format: (string|undefined), gain: (Array<number>|null|number|undefined), gamma: (Array<number>|null|number|undefined), image: (ee.Image|null), max: (Array<number>|null|number|undefined), min: (Array<number>|null|number|undefined), opacity: (number|undefined), palette: (Array<string>|null|string|undefined)}=} opt_visParams
* @param {function ((Object|null), string=): ?=} opt_callback
* @return {(undefined|{image: (ee.Image|null), mapid: string, token: string})}
*/
Expand Down Expand Up @@ -891,7 +891,7 @@ ee.data.getInfo = function(id, opt_callback) {
ee.data.getList = function(params, opt_callback) {
};
/**
* @param {(Object|null)} params
* @param {{bands: (Array<string>|null|string|undefined), bias: (Array<number>|null|number|undefined), format: (string|undefined), gain: (Array<number>|null|number|undefined), gamma: (Array<number>|null|number|undefined), image: (ee.Image|null), max: (Array<number>|null|number|undefined), min: (Array<number>|null|number|undefined), opacity: (number|undefined), palette: (Array<string>|null|string|undefined)}} params
* @param {function ({mapid: string, token: string}, string=): ?=} opt_callback
* @return {(ee.data.RawMapId|null)}
*/
Expand Down
36 changes: 36 additions & 0 deletions javascript/src/examples/faq/gettingStarted01.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @fileoverview Earth Engine Developer's Guide examples
* from 'Earth Engine Algorithms' section.
*/

// placeholded imports
var dem = ee.Image('USGS/SRTMGL1_003');
var collection1 = ee.ImageCollection('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS');

// dummy variables
var image1 = ee.Image(1);
var image2 = ee.Image(2);

// [START image_add_method]
var image3 = image1.add(image2);
// [END image_add_method]

// [START ee_algo]
var terrainImage = ee.Algorithms.Terrain(dem);
// [END ee_algo]

// [START user_function]
var myFunction = function(args) {
// do something
return something;
};
// [END user_function]

// dummy function
var aFunction = function(image) {
return image;
};

// [START collection_map]
var collection2 = collection1.map(aFunction);
// [END collection_map]
12 changes: 12 additions & 0 deletions javascript/src/examples/faq/gettingStarted02.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @fileoverview Earth Engine Developer's Guide examples
* from '"Hello world!" JavaScript' section
*/

// [START js_hello]
print('Hello world!');
// [END js_hello]

// [START ee_hello]
print(ee.Image('LANDSAT/LC8_L1T/LC80440342014077LGN00'));
// [END ee_hello]
23 changes: 23 additions & 0 deletions javascript/src/examples/faq/gettingStarted03.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @fileoverview Earth Engine Developer's Guide examples
* from 'Adding data to the map' section
*/

// [START image_display]
var image = ee.Image('LANDSAT/LC8_L1T/LC80440342014077LGN00');
Map.centerObject(image, 9);
Map.addLayer(image);
// [END image_display]

// [START image_visualization]
var image = ee.Image('LANDSAT/LC8_L1T/LC80440342014077LGN00');
// define visualization parameters in an object literal
var vizParams = {bands: ['B5', 'B4', 'B3'], min: 5000, max: 15000, gamma: 1.3};
Map.centerObject(image, 9);
Map.addLayer(image, vizParams, 'Landsat 8 false color');
// [END image_visualization]

// [START fc_display]
var counties = ee.FeatureCollection('ft:1S4EB6319wWW2sWQDPhDvmSBIVrD3iEmCLYB7nMM');
Map.addLayer(counties, {}, 'counties');
// [END fc_display]
38 changes: 38 additions & 0 deletions javascript/src/examples/faq/gettingStarted04.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @fileoverview Earth Engine Developer's Guide examples
* from 'Finding ImageCollections and FeatureCollections' and
* 'Filtering and Sorting' sections
*/

// [START collection_load]
var collection = ee.ImageCollection('LANDSAT/LC8_L1T');
// [END collection_load]
print(collection.first());

// [START make_point]
var point = ee.Geometry.Point(-122.262, 37.8719);
// [END make_point]

// [START date_range]
var start = ee.Date('2014-06-01');
var finish = ee.Date('2014-10-01');
// [END date_range]

// [START filter_ic]
var filteredCollection = ee.ImageCollection('LANDSAT/LC8_L1T')
.filterBounds(point)
.filterDate(start, finish)
.sort('CLOUD_COVER', true);
// [END filter_ic]
print(filteredCollection);

// [START get_first]
var first = filteredCollection.first();
// [END get_first]
print(first);

// [START filter_fc]
var featureCollection = ee.FeatureCollection('ft:1fRY18cjsHzDgGiJiS2nnpUU3v9JPDc2HNaR7Xk8');
var filteredFC = featureCollection.filter(ee.Filter.eq('Name', 'California'));
Map.addLayer(filteredFC, {}, 'California');
// [END filter_fc]
37 changes: 37 additions & 0 deletions javascript/src/examples/faq/gettingStarted05.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @fileoverview Earth Engine Developer's Guide examples
* from 'Band Math' and 'Masking' sections
*/

// [START band_math]
// function to get NDVI from Landsat 5 imagery
var getNDVI = function(image) {
return image.normalizedDifference(['B4', 'B3']);
};

// two Landsat 5 images, 20 years apart
var image1 = ee.Image('LT5_L1T_TOA/LT50440341990155XXX03');
var image2 = ee.Image('LT5_L1T_TOA/LT50440342010162EDC00');

// compute NDVI from the scenes
var ndvi1 = getNDVI(image1);
var ndvi2 = getNDVI(image2);

// compute the difference in NDVI
var ndviDifference = ndvi2.subtract(ndvi1);
// [END band_math]

// [START masking]

// land mask from the SRTM DEM
var landMask = ee.Image('CGIAR/SRTM90_V4').mask();
// combine the land mask with the original image mask
var mask = ndviDifference.mask().and(landMask);
// apply the mask to the NDVI difference
var maskedDifference = ndviDifference.mask(mask);

// display the masked result
var vizParams = {min: -0.5, max: 0.5, palette: ['FF0000', 'FFFFFF', '0000FF']};
Map.setCenter(-122.2531, 37.6295, 9);
Map.addLayer(maskedDifference, vizParams, 'NDVI difference');
// [END masking]
Loading

0 comments on commit c2058ef

Please sign in to comment.