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

Upend resource loading approach #6035

Merged
merged 54 commits into from
Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
973cfe3
load functions
Dec 6, 2017
9ccb83c
core
Dec 6, 2017
acedbdb
renderer, most of scene
Dec 6, 2017
388869e
Merge branch 'master' into upend-resource-loading
Dec 7, 2017
6188fd7
templating [ci skip]
Dec 8, 2017
b0f4281
Merge branch 'master' into upend-resource-loading
Dec 18, 2017
18f9d51
remaining imagery providers [ci skip]
Dec 18, 2017
5d92dd9
Got ArcGisMapServerImageryProvider, BingMapsImageryProvider and Model…
Jan 5, 2018
2b7fafc
Fixed a bunch more resource code.
Jan 8, 2018
9e66863
Fixed UrlTemplateImageryProvider
Jan 8, 2018
9fb5bfd
Got almost all imagery working and fixed Core/load*.js functions.
Jan 9, 2018
dc77bbd
Fixed Terrain providers.
Jan 9, 2018
c9d1f6d
Finished Model, ModelInstanceCollection, SingleTileImageryProvider, G…
Jan 10, 2018
b68a1e8
Most of KML is done.
Jan 11, 2018
56ce327
Trying to fix sourceUri's for Datasources.
Jan 11, 2018
811982f
Cleanup of resource and finished KML.
Jan 11, 2018
6eaee54
Got tests passing.
Jan 12, 2018
5255195
Cleanup and eslint fixes.
Jan 12, 2018
e4bf6dd
Got all tests passing. Added some doc.
Jan 12, 2018
ef42d79
Added retry logic.
Jan 12, 2018
9849fc8
Fixed tests, KML and WMTS.
Jan 13, 2018
194d522
Merged in master.
Jan 13, 2018
c507b39
Fixed tests.
Jan 13, 2018
bdd5fe6
Added error to retry logic and fixed entity models.
Jan 13, 2018
ad0266c
Hooked up loadImage for retries.
Jan 14, 2018
31dd337
Doc update.
Jan 15, 2018
a23c79a
Cleanup
Jan 15, 2018
04dacf0
Added handling for document.baseUri in getAbsoluteUri.
Jan 15, 2018
6254154
Fixes
Jan 15, 2018
c5a5914
Fixed crash.
Jan 15, 2018
791cc38
Fixed bad terrain provider paths.
Jan 15, 2018
fb0f73a
Deprecated unneeded parameters for imagery, terrain, models
Jan 15, 2018
dd9866e
Finished up deprecations.
Jan 15, 2018
546f2a5
Removed joinUrls.
Jan 15, 2018
cd547d1
Made Resource.retryOnError async.
Jan 15, 2018
ad19d90
More tweaks.
Jan 15, 2018
779b41f
Added Resource tests.
Jan 16, 2018
064418c
Merge branch 'upend-resource-loading' into deprecation-for-resources
Jan 16, 2018
081b1ea
Added tests.
Jan 16, 2018
7d24af5
Removed deprecated options from private classes.
Jan 16, 2018
d5ca40f
Merge pull request #6120 from AnalyticalGraphicsInc/deprecation-for-r…
Jan 16, 2018
335fa61
eslint fix.
Jan 16, 2018
389fe6d
More tests.
Jan 16, 2018
7e2771a
More test fixes.
Jan 16, 2018
389f963
Added deprecation and tests for createTileMapServiceImageryProvider
Jan 16, 2018
fda9e3c
Added workaround for broken tilesets.
Jan 17, 2018
ca33f8c
Merge pull request #6125 from AnalyticalGraphicsInc/root-tiles-hack
mramato Jan 18, 2018
998f293
Fixes from PR comments.
Jan 18, 2018
abd04ab
More cleanup from PR comments.
Jan 18, 2018
b4edc87
Removed isDirectory property.
Jan 18, 2018
9a528e9
Fixed CesiumTerrainProvider parentUrl resolving.
Jan 18, 2018
a9e489e
Update CHANGES.md
Jan 18, 2018
303eef6
Reverted request changes that aren't needed.
Jan 19, 2018
366db6d
Reverted request changes that aren't needed.
Jan 19, 2018
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
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Change Log

* Breaking changes
*
* Deprecated
* For all classes/functions that can now take a `Resource` instance, all additional parameters that are part of the `Resource` class have been deprecated and will be removed in Cesium 1.44. This generally includes `proxy`, `headers` and `query` parameters.
* Major refactor of URL handling. All classes that take a url parameter, can now take a Resource or a String. This includes all imagery providers, all terrain providers, `Cesium3DTileset`, `KMLDataSource`, `CZMLDataSource`, `GeoJsonDataSource`, `Model`, `Billboard`, along with all the low level `load*()` functions.
* Added `ClippingPlaneCollection.isSupported` function for checking if rendering with clipping planes is supported.
* Improved CZML Custom Properties sandcastle example [#6086](https://github.com/AnalyticalGraphicsInc/cesium/pull/6086)
* Added `Plane.projectPointOntoPlane` for projecting a `Cartesian3` position onto a `Plane` [#6092](https://github.com/AnalyticalGraphicsInc/cesium/pull/6092)
Expand Down
26 changes: 16 additions & 10 deletions Source/Core/BingMapsGeocoderService.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ define([
'./defined',
'./defineProperties',
'./loadJsonp',
'./Rectangle'
'./Rectangle',
'./Resource'
], function(
BingMapsApi,
Check,
defaultValue,
defined,
defineProperties,
loadJsonp,
Rectangle) {
Rectangle,
Resource) {
'use strict';

var url = 'https://dev.virtualearth.net/REST/v1/Locations';
Expand Down Expand Up @@ -42,6 +44,13 @@ define([
options.scene._frameState.creditDisplay.addDefaultCredit(errorCredit);
}
}

this._resource = new Resource({
url: url,
queryParameters: {
key: this._key
}
});
}

defineProperties(BingMapsGeocoderService.prototype, {
Expand Down Expand Up @@ -81,16 +90,13 @@ define([
Check.typeOf.string('query', query);
//>>includeEnd('debug');

var key = this.key;
var promise = loadJsonp(url, {
parameters : {
query : query,
key : key
},
callbackParameterName : 'jsonp'
var resource = this._resource.getDerivedResource({
queryParameters: {
query: query
}
});

return promise.then(function(result) {
return loadJsonp(resource, 'jsonp').then(function(result) {
if (result.resourceSets.length === 0) {
return [];
}
Expand Down
80 changes: 44 additions & 36 deletions Source/Core/CesiumTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ define([
'./defaultValue',
'./defined',
'./defineProperties',
'./deprecationWarning',
'./DeveloperError',
'./Event',
'./GeographicTilingScheme',
'./HeightmapTerrainData',
'./IndexDatatype',
'./joinUrls',
'./loadArrayBuffer',
'./loadJson',
'./Math',
'./OrientedBoundingBox',
'./QuantizedMeshTerrainData',
'./Resource',
'./RuntimeError',
'./TerrainProvider',
'./TileAvailability',
Expand All @@ -33,24 +34,27 @@ define([
defaultValue,
defined,
defineProperties,
deprecationWarning,
DeveloperError,
Event,
GeographicTilingScheme,
HeightmapTerrainData,
IndexDatatype,
joinUrls,
loadArrayBuffer,
loadJson,
CesiumMath,
OrientedBoundingBox,
QuantizedMeshTerrainData,
Resource,
RuntimeError,
TerrainProvider,
TileAvailability,
TileProviderError) {
'use strict';

function LayerInformation(layer) {
this.resource = layer.resource;
this.version = layer.version;
this.isHeightmap = layer.isHeightmap;
this.tileUrlTemplates = layer.tileUrlTemplates;
this.availability = layer.availability;
Expand All @@ -68,8 +72,7 @@ define([
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {String} options.url The URL of the Cesium terrain server.
* @param {Proxy} [options.proxy] A proxy to use for requests. This object is expected to have a getURL function which returns the proxied URL, if needed.
* @param {Resource|String} options.url The URL of the Cesium terrain server.
* @param {Boolean} [options.requestVertexNormals=false] Flag that indicates if the client should request additional lighting information from the server, in the form of per vertex normals if available.
* @param {Boolean} [options.requestWaterMask=false] Flag that indicates if the client should request per tile water masks from the server, if available.
* @param {Ellipsoid} [options.ellipsoid] The ellipsoid. If not specified, the WGS84 ellipsoid is used.
Expand Down Expand Up @@ -109,8 +112,14 @@ define([
}
//>>includeEnd('debug');

this._url = options.url;
this._proxy = options.proxy;
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.');
}

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

this._tilingScheme = new GeographicTilingScheme({
numberOfLevelZeroTilesX : 2,
Expand Down Expand Up @@ -154,11 +163,10 @@ define([
this._ready = false;
this._readyPromise = when.defer();

var lastUrl = this._url;
var metadataUrl = joinUrls(this._url, 'layer.json');
if (defined(this._proxy)) {
metadataUrl = this._proxy.getURL(metadataUrl);
}
var lastResource = resource;
var metadataResource = lastResource.getDerivedResource({
url: 'layer.json'
});

var that = this;
var metadataError;
Expand Down Expand Up @@ -209,15 +217,6 @@ define([
}

var tileUrlTemplates = data.tiles;
for (var i = 0; i < tileUrlTemplates.length; ++i) {
var template = new Uri(tileUrlTemplates[i]);
var baseUri = new Uri(lastUrl);
if (template.authority && !baseUri.authority) {
baseUri.authority = template.authority;
baseUri.scheme = template.scheme;
}
tileUrlTemplates[i] = joinUrls(baseUri, template).toString().replace('{version}', data.version);
}

var availableTiles = data.available;
var availability;
Expand Down Expand Up @@ -267,6 +266,8 @@ define([
}

layers.push(new LayerInformation({
resource: lastResource,
version: data.version,
isHeightmap: isHeightmap,
tileUrlTemplates: tileUrlTemplates,
availability: availability,
Expand All @@ -281,20 +282,22 @@ define([
console.log('A layer.json can\'t have a parentUrl if it does\'t have an available array.');
return when.resolve();
}
lastUrl = joinUrls(lastUrl, parentUrl);
metadataUrl = joinUrls(lastUrl, 'layer.json');
if (defined(that._proxy)) {
metadataUrl = that._proxy.getURL(metadataUrl);
}
var parentMetadata = loadJson(metadataUrl);
lastResource = lastResource.getDerivedResource({
url: parentUrl
});
lastResource.appendForwardSlash(); // Terrain always expects a directory
metadataResource = lastResource.getDerivedResource({
url: 'layer.json'
});
var parentMetadata = loadJson(metadataResource);
return when(parentMetadata, parseMetadataSuccess, parseMetadataFailure);
}

return when.resolve();
}

function parseMetadataFailure(data) {
var message = 'An error occurred while accessing ' + metadataUrl + '.';
var message = 'An error occurred while accessing ' + metadataResource.url + '.';
metadataError = TileProviderError.handleError(metadataError, that, that._errorEvent, message, undefined, undefined, undefined, requestMetadata);
}

Expand Down Expand Up @@ -344,7 +347,7 @@ define([
}

function requestMetadata() {
var metadata = loadJson(metadataUrl);
var metadata = loadJson(metadataResource);
when(metadata, metadataSuccess, metadataFailure);
}

Expand Down Expand Up @@ -600,13 +603,6 @@ define([

var tmsY = (yTiles - y - 1);

var url = urlTemplates[(x + tmsY + level) % urlTemplates.length].replace('{z}', level).replace('{x}', x).replace('{y}', tmsY);

var proxy = this._proxy;
if (defined(proxy)) {
url = proxy.getURL(url);
}

var extensionList = [];
if (this._requestVertexNormals && layerToUse.hasVertexNormals) {
extensionList.push(layerToUse.littleEndianExtensionSize ? 'octvertexnormals' : 'vertexnormals');
Expand All @@ -615,7 +611,19 @@ define([
extensionList.push('watermask');
}

var promise = loadArrayBuffer(url, getRequestHeader(extensionList), request);
var resource = layerToUse.resource.getDerivedResource({
url: urlTemplates[(x + tmsY + level) % urlTemplates.length],
templateValues: {
version: layerToUse.version,
z: level,
x: x,
y: tmsY
},
headers: getRequestHeader(extensionList),
request: request
});

var promise = loadArrayBuffer(resource);

if (!defined(promise)) {
return undefined;
Expand Down
10 changes: 7 additions & 3 deletions Source/Core/EarthOrientationParameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ define([
'./JulianDate',
'./LeapSecond',
'./loadJson',
'./Resource',
'./RuntimeError',
'./TimeConstants',
'./TimeStandard'
Expand All @@ -21,6 +22,7 @@ define([
JulianDate,
LeapSecond,
loadJson,
Resource,
RuntimeError,
TimeConstants,
TimeStandard) {
Expand All @@ -36,7 +38,7 @@ define([
* @constructor
*
* @param {Object} [options] Object with the following properties:
* @param {String} [options.url] The URL from which to obtain EOP data. If neither this
* @param {Resource|String} [options.url] The URL from which to obtain EOP data. If neither this
* parameter nor options.data is specified, all EOP values are assumed
* to be 0.0. If options.data is specified, this parameter is
* ignored.
Expand Down Expand Up @@ -93,12 +95,14 @@ define([
// Use supplied EOP data.
onDataReady(this, options.data);
} else if (defined(options.url)) {
var resource = Resource.createIfNeeded(options.url);

// Download EOP data.
var that = this;
this._downloadPromise = when(loadJson(options.url), function(eopData) {
this._downloadPromise = when(loadJson(resource), function(eopData) {
onDataReady(that, eopData);
}, function() {
that._dataError = 'An error occurred while retrieving the EOP data from the URL ' + options.url + '.';
that._dataError = 'An error occurred while retrieving the EOP data from the URL ' + resource.url + '.';
});
} else {
// Use all zeros for EOP data.
Expand Down
Loading