Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource fixes #6211

Merged
merged 11 commits into from
Feb 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -3,12 +3,20 @@ Change Log

### 1.43 - 2018-03-01

##### Deprecated :hourglass_flowing_sand:
* In the `Resource` class, `addQueryParameters` and `addTemplateValues` have been deprecated and will be removed in Cesium 1.45. Please use `setQueryParameters` and `setTemplateValues` instead.

##### Additions :tada:
* Added support for a promise to a resource for `CesiumTerrainProvider`, `createTileMapServiceImageryProvider` and `Cesium3DTileset` [#6204](https://github.com/AnalyticalGraphicsInc/cesium/pull/6204)
* `Resource` class [#6205](https://github.com/AnalyticalGraphicsInc/cesium/issues/6205)
* Added `put`, `patch`, `delete`, `options` and `head` methods, so it can be used for all XHR requests.
* Added `preserveQueryParameters` parameter to `getDerivedResource`, to allow us to append query parameters instead of always replacing them.
* Added `setQueryParameters` and `appendQueryParameters` to allow for better handling of query strings.

##### Fixes :wrench:
* Fixed bug where AxisAlignedBoundingBox did not copy over center value when cloning an undefined result. [#6183](https://github.com/AnalyticalGraphicsInc/cesium/pull/6183)
* Fixed `Resource.fetch` when called with no arguments [#6206](https://github.com/AnalyticalGraphicsInc/cesium/issues/6206)
* Fixed `Resource.clone` to clone the `Request` object, so resource can be used in parallel. [#6208](https://github.com/AnalyticalGraphicsInc/cesium/issues/6208)
* Fixed bug where 3D Tiles Point Clouds would fail in Internet Explorer. [#6220](https://github.com/AnalyticalGraphicsInc/cesium/pull/6220)

##### Additions :tada:
587 changes: 527 additions & 60 deletions Source/Core/Resource.js

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions Source/Core/loadWithXhr.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
define([
'../ThirdParty/when',
'./Check',
'./defaultValue',
'./defineProperties',
'./deprecationWarning',
'./Resource'
], function(
when,
Check,
defaultValue,
defineProperties,
deprecationWarning,
Resource) {
@@ -61,9 +63,11 @@ define([
// Take advantage that most parameters are the same
var resource = new Resource(options);

return resource.fetch({
return Resource._makeRequest(resource, {
responseType: options.responseType,
overrideMimeType: options.overrideMimeType
overrideMimeType: options.overrideMimeType,
method: defaultValue(options.method, 'GET'),
data: options.data
});
}

20 changes: 10 additions & 10 deletions Source/DataSources/KmlDataSource.js
Original file line number Diff line number Diff line change
@@ -728,10 +728,10 @@ define([
var viewFormat = defaultValue(queryStringValue(iconNode, 'viewFormat', namespaces.kml), defaultViewFormat);
var httpQuery = queryStringValue(iconNode, 'httpQuery', namespaces.kml);
if (defined(viewFormat)) {
hrefResource.addQueryParameters(queryToObject(cleanupString(viewFormat)));
hrefResource.setQueryParameters(queryToObject(cleanupString(viewFormat)));
}
if (defined(httpQuery)) {
hrefResource.addQueryParameters(queryToObject(cleanupString(httpQuery)));
hrefResource.setQueryParameters(queryToObject(cleanupString(httpQuery)));
}

processNetworkLinkQueryString(hrefResource, dataSource._camera, dataSource._canvas, viewBoundScale, dataSource._lastCameraView.bbox);
@@ -2108,7 +2108,7 @@ define([
queryString = queryString.replace('[clientName]', 'Cesium');
queryString = queryString.replace('[language]', 'English');

resource.addQueryParameters(queryToObject(queryString));
resource.setQueryParameters(queryToObject(queryString));
}

function processNetworkLink(dataSource, parent, node, entityCollection, styleCollection, sourceResource, uriResolver, promises, context) {
@@ -2145,10 +2145,10 @@ define([
var viewFormat = defaultValue(queryStringValue(link, 'viewFormat', namespaces.kml), defaultViewFormat);
var httpQuery = queryStringValue(link, 'httpQuery', namespaces.kml);
if (defined(viewFormat)) {
href.addQueryParameters(queryToObject(cleanupString(viewFormat)));
href.setQueryParameters(queryToObject(cleanupString(viewFormat)));
}
if (defined(httpQuery)) {
href.addQueryParameters(queryToObject(cleanupString(httpQuery)));
href.setQueryParameters(queryToObject(cleanupString(httpQuery)));
}

processNetworkLinkQueryString(href, dataSource._camera, dataSource._canvas, viewBoundScale, dataSource._lastCameraView.bbox);
@@ -2391,7 +2391,7 @@ define([
}

if (defined(query)) {
sourceUri.addQueryParameters(query);
sourceUri.setQueryParameters(query);
}

return when(promise)
@@ -2525,7 +2525,7 @@ define([
/**
* Creates a Promise to a new instance loaded with the provided KML data.
*
* @param {String|Document|Blob} data A url, parsed KML document, or Blob containing binary KMZ data or a parsed KML document.
* @param {Resource|String|Document|Blob} data A url, parsed KML document, or Blob containing binary KMZ data or a parsed KML document.
* @param {Object} options An object with the following properties:
* @param {Camera} options.camera The camera that is used for viewRefreshModes and sending camera properties to network links.
* @param {Canvas} options.canvas The canvas that is used for sending viewer properties to network links.
@@ -2681,9 +2681,9 @@ define([
* @param {Resource|String|Document|Blob} data A url, parsed KML document, or Blob containing binary KMZ data or a parsed KML document.
* @param {Object} [options] An object with the following properties:
* @param {Resource|String} [options.sourceUri] Overrides the url to use for resolving relative links and other KML network features.
* @returns {Promise.<KmlDataSource>} A promise that will resolve to this instances once the KML is loaded.
* @param {Boolean} [options.clampToGround=false] true if we want the geometry features (Polygons, LineStrings and LinearRings) clamped to the ground. If true, lines will use corridors so use Entity.corridor instead of Entity.polyline.
* @param {Object} [options.query] Key-value pairs which are appended to all URIs in the CZML.
*
* @returns {Promise.<KmlDataSource>} A promise that will resolve to this instances once the KML is loaded.
*/
KmlDataSource.prototype.load = function(data, options) {
//>>includeStart('debug', pragmas.debug);
@@ -2976,7 +2976,7 @@ define([
networkLink.updating = true;
var newEntityCollection = new EntityCollection();
var href = networkLink.href.clone();
href.addQueryParameters(networkLink.cookie);
href.setQueryParameters(networkLink.cookie);
processNetworkLinkQueryString(href, that._camera, that._canvas, networkLink.viewBoundScale, lastCameraView.bbox);
load(that, newEntityCollection, href, {context : entity.id})
.then(getNetworkLinkUpdateCallback(that, networkLink, newEntityCollection, newNetworkLinks, href))
2 changes: 1 addition & 1 deletion Source/Scene/ArcGisMapServerImageryProvider.js
Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ define([
resource.appendForwardSlash();

if (defined(options.token)) {
resource.addQueryParameters({
resource.setQueryParameters({
token: options.token
});
}
2 changes: 1 addition & 1 deletion Source/Scene/BingMapsImageryProvider.js
Original file line number Diff line number Diff line change
@@ -113,7 +113,7 @@ define([
proxy: options.proxy
});

urlResource.addQueryParameters({
urlResource.setQueryParameters({
key: this._key
});

2 changes: 1 addition & 1 deletion Source/Scene/Cesium3DTile.js
Original file line number Diff line number Diff line change
@@ -619,7 +619,7 @@ define([
var expired = this.contentExpired;
if (expired) {
// Append a query parameter of the tile expiration date to prevent caching
resource.addQueryParameters({
resource.setQueryParameters({
expired: this.expireDate.toString()
});
}
2 changes: 1 addition & 1 deletion Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
@@ -1261,7 +1261,7 @@ define([
v: defaultValue(asset.tilesetVersion, '0.0')
};
this._basePath += '?v=' + versionQuery.v;
tilesetResource.addQueryParameters(versionQuery);
tilesetResource.setQueryParameters(versionQuery);
}

// A tileset.json referenced from a tile may exist in a different directory than the root tileset.
9 changes: 7 additions & 2 deletions Source/Scene/GoogleEarthEnterpriseMapsProvider.js
Original file line number Diff line number Diff line change
@@ -118,9 +118,14 @@ define([

var url = options.url;
var path = defaultValue(options.path, '/default_map');
var resource = Resource.createIfNeeded(url + path, {
proxy: options.proxy

var resource = Resource.createIfNeeded(url, {
proxy : options.proxy
}).getDerivedResource({
// We used to just append path to url, so now that we do proper URI resolution, removed the /
url : (path[0] === '/') ? path.substring(1) : path
});

resource.appendForwardSlash();

this._resource = resource;
2 changes: 1 addition & 1 deletion Source/Scene/MapboxImageryProvider.js
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@ define([
templateUrl += mapId + '/{z}/{x}/{y}' + this._format;
resource.url = templateUrl;

resource.addQueryParameters({
resource.setQueryParameters({
access_token: accessToken
});

14 changes: 7 additions & 7 deletions Source/Scene/WebMapServiceImageryProvider.js
Original file line number Diff line number Diff line change
@@ -111,15 +111,15 @@ define([

var pickFeatureResource = resource.clone();

resource.addQueryParameters(WebMapServiceImageryProvider.DefaultParameters, true);
pickFeatureResource.addQueryParameters(WebMapServiceImageryProvider.GetFeatureInfoDefaultParameters, true);
resource.setQueryParameters(WebMapServiceImageryProvider.DefaultParameters, true);
pickFeatureResource.setQueryParameters(WebMapServiceImageryProvider.GetFeatureInfoDefaultParameters, true);

if (defined(options.parameters)) {
resource.addQueryParameters(objectToLowercase(options.parameters));
resource.setQueryParameters(objectToLowercase(options.parameters));
}

if (defined(options.getFeatureInfoParameters)) {
pickFeatureResource.addQueryParameters(objectToLowercase(options.getFeatureInfoParameters));
pickFeatureResource.setQueryParameters(objectToLowercase(options.getFeatureInfoParameters));
}

var parameters = {};
@@ -139,16 +139,16 @@ define([
parameters.srs = options.tilingScheme instanceof WebMercatorTilingScheme ? 'EPSG:3857' : 'EPSG:4326';
}

resource.addQueryParameters(parameters, true);
pickFeatureResource.addQueryParameters(parameters, true);
resource.setQueryParameters(parameters, true);
pickFeatureResource.setQueryParameters(parameters, true);

var pickFeatureParams = {
query_layers: options.layers,
x: '{i}',
y: '{j}',
info_format: '{format}'
};
pickFeatureResource.addQueryParameters(pickFeatureParams, true);
pickFeatureResource.setQueryParameters(pickFeatureParams, true);

this._resource = resource;
this._pickFeaturesResource = pickFeatureResource;
10 changes: 5 additions & 5 deletions Source/Scene/WebMapTileServiceImageryProvider.js
Original file line number Diff line number Diff line change
@@ -175,10 +175,10 @@ define([
TileMatrixSet : tileMatrixSetID
};

resource.addTemplateValues(templateValues);
resource.setTemplateValues(templateValues);
this._useKvp = false;
} else {
resource.addQueryParameters(defaultParameters);
resource.setQueryParameters(defaultParameters);
this._useKvp = true;
}

@@ -265,14 +265,14 @@ define([
resource = imageryProvider._resource.getDerivedResource({
request: request
});
resource.addTemplateValues(templateValues);
resource.setTemplateValues(templateValues);

if (defined(staticDimensions)) {
resource.addTemplateValues(staticDimensions);
resource.setTemplateValues(staticDimensions);
}

if (defined(dynamicIntervalData)) {
resource.addTemplateValues(dynamicIntervalData);
resource.setTemplateValues(dynamicIntervalData);
}
} else {
// build KVP request
429 changes: 418 additions & 11 deletions Specs/Core/ResourceSpec.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Specs/Scene/GoogleEarthEnterpriseMapsProviderSpec.js
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ defineSuite([
});

it('rejects readyPromise on error', function() {
var url = 'invalid.localhost';
var url = 'http://invalid.localhost';
var provider = new GoogleEarthEnterpriseMapsProvider({
url : url,
channel : 1234
@@ -292,7 +292,7 @@ defineSuite([
});

it('raises error on invalid url', function() {
var url = 'invalid.localhost';
var url = 'http://invalid.localhost';
var provider = new GoogleEarthEnterpriseMapsProvider({
url : url,
channel : 1234