Skip to content

Commit

Permalink
Deprecate all the things!
Browse files Browse the repository at this point in the history
Remove `loadArrayBuffer`, `loadBlob`, `loadImage`, `loadJson`, `loadJsonp`,
`loadText`, `loadXML` and `loadWithXhr` have been removed. Please use the
equivalent `fetch` functions on the `Resource` class.

Remove `proxy`, `headers` and `query` parameters from all the fuctions
that take a `Resource`.

Fixes #6119
  • Loading branch information
mramato committed Mar 24, 2018
1 parent 4e5f847 commit dfef80b
Show file tree
Hide file tree
Showing 62 changed files with 55 additions and 3,813 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Change Log

##### Breaking Changes :mega:
* `GeometryVisualizer` now requires `primitive` and `groundPrimitive` parameters. [#6316](https://github.com/AnalyticalGraphicsInc/cesium/pull/6316)
* For all classes/functions that take a `Resource` instance, all additional parameters that are part of the `Resource` class have been removed. This generally includes `proxy`, `headers` and `query` parameters.
* All low level load functions including `loadArrayBuffer`, `loadBlob`, `loadImage`, `loadJson`, `loadJsonp`, `loadText`, `loadXML` and `loadWithXhr` have been removed. Please use the equivalent `fetch` functions on the `Resource` class.

##### Deprecated :hourglass_flowing_sand:
* `ClippingPlaneCollection` is now supported in Internet Explorer, so `ClippingPlaneCollection.isSupported` has been deprecated and will be removed in Cesium 1.45.
Expand Down
8 changes: 1 addition & 7 deletions Source/Core/CesiumTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ define([
}
//>>includeEnd('debug');

if (defined(options.proxy)) {
deprecationWarning('CesiumTerrainProvider.proxy', 'The options.proxy parameter has been deprecated. Specify options.url as a Resource instance and set the proxy property there.');
}

this._tilingScheme = new GeographicTilingScheme({
numberOfLevelZeroTilesX : 2,
numberOfLevelZeroTilesY : 1,
Expand Down Expand Up @@ -152,9 +148,7 @@ define([
var overallAvailability = [];
when(options.url)
.then(function(url) {
var resource = Resource.createIfNeeded(url, {
proxy: options.proxy
});
var resource = Resource.createIfNeeded(url);
resource.appendForwardSlash();
lastResource = resource;
metadataResource = lastResource.getDerivedResource({
Expand Down
13 changes: 2 additions & 11 deletions Source/Core/GoogleEarthEnterpriseMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ define([
'./defaultValue',
'./defined',
'./defineProperties',
'./deprecationWarning',
'./GoogleEarthEnterpriseTileInformation',
'./isBitSet',
'./Math',
Expand All @@ -24,7 +23,6 @@ define([
defaultValue,
defined,
defineProperties,
deprecationWarning,
GoogleEarthEnterpriseTileInformation,
isBitSet,
CesiumMath,
Expand Down Expand Up @@ -67,23 +65,16 @@ define([
//>>includeEnd('debug');

var url = resourceOrUrl;
var proxy;

if (typeof url !== 'string' && !(url instanceof Resource)) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.string('resourceOrUrl.url', resourceOrUrl.url);
//>>includeEnd('debug');

if (defined(resourceOrUrl.proxy)) {
deprecationWarning('GoogleEarthEnterpriseMetadata', 'The options.url & options.proxy parameters have been deprecated. Specify a URL string or a Resource as the only parameter.');
}

url = resourceOrUrl.url;
proxy = resourceOrUrl.proxy;
}

var resource = Resource.createIfNeeded(url, {
proxy: proxy
});
var resource = Resource.createIfNeeded(url);
resource.appendForwardSlash();
this._resource = resource;

Expand Down
10 changes: 1 addition & 9 deletions Source/Core/GoogleEarthEnterpriseTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ define([
'./defaultValue',
'./defined',
'./defineProperties',
'./deprecationWarning',
'./DeveloperError',
'./Event',
'./GeographicTilingScheme',
Expand All @@ -27,7 +26,6 @@ define([
defaultValue,
defined,
defineProperties,
deprecationWarning,
DeveloperError,
Event,
GeographicTilingScheme,
Expand Down Expand Up @@ -126,17 +124,11 @@ define([
}
//>>includeEnd('debug');

if (defined(options.proxy)) {
deprecationWarning('GoogleEarthEnterpriseTerrainProvider.proxy', 'The options.proxy parameter has been deprecated. Specify options.url as a Resource instance and set the proxy property there.');
}

var metadata;
if (defined(options.metadata)) {
metadata = options.metadata;
} else {
var resource = Resource.createIfNeeded(options.url, {
proxy: options.proxy
});
var resource = Resource.createIfNeeded(options.url);
metadata = new GoogleEarthEnterpriseMetadata(resource);
}

Expand Down
28 changes: 11 additions & 17 deletions Source/Core/Resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,12 @@ define([
* A helper function to create a resource depending on whether we have a String or a Resource
*
* @param {Resource|String} resource A Resource or a String to use when creating a new Resource.
* @param {Object} options If resource is a String, these are the options passed to the Resource constructor. It is ignored otherwise.
*
* @returns {Resource} If resource is a String, a Resource constructed with the url and options. Otherwise the resource parameter is returned.
*
* @private
*/
Resource.createIfNeeded = function(resource, options) {
Resource.createIfNeeded = function(resource) {
if (resource instanceof Resource) {
// Keep existing request object. This function is used internally to duplicate a Resource, so that it can't
// be modified outside of a class that holds it (eg. an imagery or terrain provider). Since the Request objects
Expand All @@ -368,9 +367,9 @@ define([
return resource;
}

var args = defaultClone(options, {});
args.url = resource;
return new Resource(args);
return new Resource({
url: resource
});
};

defineProperties(Resource, {
Expand Down Expand Up @@ -848,13 +847,8 @@ define([
* @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}
* @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}
*/
Resource.prototype.fetchImage = function (preferBlob, allowCrossOrigin) {
if (defined(allowCrossOrigin)) {
deprecationWarning('Resource.fetchImage.allowCrossOrigin', 'The allowCrossOrigin parameter has been deprecated and will be removed in Cesium 1.44. It no longer needs to be specified.');
}

Resource.prototype.fetchImage = function (preferBlob) {
preferBlob = defaultValue(preferBlob, false);
allowCrossOrigin = defaultValue(allowCrossOrigin, true);

checkAndResetRequest(this.request);

Expand All @@ -864,7 +858,7 @@ define([
// 3. It's a blob URI
// 4. It doesn't have request headers and we preferBlob is false
if (!xhrBlobSupported || this.isDataUri || this.isBlobUri || (!this.hasHeaders && !preferBlob)) {
return fetchImage(this, allowCrossOrigin);
return fetchImage(this, true);
}

var blobPromise = this.fetchBlob();
Expand Down Expand Up @@ -907,21 +901,21 @@ define([
});
};

function fetchImage(resource, allowCrossOrigin) {
function fetchImage(resource) {
var request = resource.request;
request.url = resource.url;
request.requestFunction = function() {
var url = resource.url;
var crossOrigin = false;

// data URIs can't have allowCrossOrigin set.
// data URIs can't have crossorigin set.
if (!resource.isDataUri && !resource.isBlobUri) {
crossOrigin = resource.isCrossOriginUrl;
}

var deferred = when.defer();

Resource._Implementations.createImage(url, crossOrigin && allowCrossOrigin, deferred);
Resource._Implementations.createImage(url, crossOrigin, deferred);

return deferred.promise;
};
Expand All @@ -945,7 +939,7 @@ define([
request.state = RequestState.UNISSUED;
request.deferred = undefined;

return fetchImage(resource, allowCrossOrigin);
return fetchImage(resource);
}

return when.reject(e);
Expand All @@ -970,7 +964,7 @@ define([
*/
Resource.fetchImage = function (options) {
var resource = new Resource(options);
return resource.fetchImage(options.preferBlob, options.allowCrossOrigin);
return resource.fetchImage(options.preferBlob);
};

/**
Expand Down
10 changes: 1 addition & 9 deletions Source/Core/VRTheWorldTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ define([
'./defaultValue',
'./defined',
'./defineProperties',
'./deprecationWarning',
'./DeveloperError',
'./Ellipsoid',
'./Event',
Expand All @@ -22,7 +21,6 @@ define([
defaultValue,
defined,
defineProperties,
deprecationWarning,
DeveloperError,
Ellipsoid,
Event,
Expand Down Expand Up @@ -71,13 +69,7 @@ define([
}
//>>includeEnd('debug');

if (defined(options.proxy)) {
deprecationWarning('VRTheWorldTerrainProvider.proxy', 'The options.proxy parameter has been deprecated. Specify options.url as a Resource instance and set the proxy property there.');
}

var resource = Resource.createIfNeeded(options.url, {
proxy: options.proxy
});
var resource = Resource.createIfNeeded(options.url);

this._resource = resource;

Expand Down
55 changes: 0 additions & 55 deletions Source/Core/loadArrayBuffer.js

This file was deleted.

55 changes: 0 additions & 55 deletions Source/Core/loadBlob.js

This file was deleted.

18 changes: 2 additions & 16 deletions Source/Core/loadCRN.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ define([
'../ThirdParty/when',
'./CompressedTextureBuffer',
'./defined',
'./deprecationWarning',
'./DeveloperError',
'./Resource',
'./TaskProcessor'
], function(
when,
CompressedTextureBuffer,
defined,
deprecationWarning,
DeveloperError,
Resource,
TaskProcessor) {
Expand Down Expand Up @@ -48,30 +46,18 @@ define([
* @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}
* @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}
*/
function loadCRN(resourceOrUrlOrBuffer, headers, request) {
function loadCRN(resourceOrUrlOrBuffer) {
//>>includeStart('debug', pragmas.debug);
if (!defined(resourceOrUrlOrBuffer)) {
throw new DeveloperError('resourceOrUrlOrBuffer is required.');
}
//>>includeEnd('debug');

if (defined(headers)) {
deprecationWarning('loadCRN.headers', 'The headers parameter has been deprecated. Set the headers property on the Resource parameter.');
}

if (defined(request)) {
deprecationWarning('loadCRN.request', 'The request parameter has been deprecated. Set the request property on the Resource parameter.');
}

var loadPromise;
if (resourceOrUrlOrBuffer instanceof ArrayBuffer || ArrayBuffer.isView(resourceOrUrlOrBuffer)) {
loadPromise = when.resolve(resourceOrUrlOrBuffer);
} else {
var resource = Resource.createIfNeeded(resourceOrUrlOrBuffer, {
headers: headers,
request: request
});

var resource = Resource.createIfNeeded(resourceOrUrlOrBuffer);
loadPromise = resource.fetchArrayBuffer();
}

Expand Down
Loading

0 comments on commit dfef80b

Please sign in to comment.