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

Add readyPromise to ImageryProviders #3175

Merged
merged 4 commits into from
Nov 9, 2015
Merged
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions Source/Core/ArcGisImageServerTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ define([
credit = new Credit(credit);
}
this._credit = credit;
this._readyPromise = when.resolve(true);
};

defineProperties(ArcGisImageServerTerrainProvider.prototype, {
Expand Down Expand Up @@ -151,6 +152,18 @@ define([
}
},

/**
* Gets a promise that resolves to true when the provider is ready for use.
* @memberof ArcGisImageServerTerrainProvider.prototype
* @type {Promise.<Boolean>}
* @readonly
*/
readyPromise : {
get : function() {
return this._readyPromise;
}
},

/**
* Gets a value indicating whether or not the provider includes a water mask. The water mask
* indicates which areas of the globe are water rather than land, so they can be rendered
Expand Down
14 changes: 14 additions & 0 deletions Source/Core/CesiumTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ define([
this._credit = credit;

this._ready = false;
this._readyPromise = when.defer();

var metadataUrl = joinUrls(this._url, 'layer.json');
if (defined(this._proxy)) {
Expand Down Expand Up @@ -222,6 +223,7 @@ define([
}

that._ready = true;
that._readyPromise.resolve(true);
}

function metadataFailure(data) {
Expand Down Expand Up @@ -600,6 +602,18 @@ define([
}
},

/**
* Gets a promise that resolves to true when the provider is ready for use.
* @memberof CesiumTerrainProvider.prototype
* @type {Promise.<Boolean>}
* @readonly
*/
readyPromise : {
get : function() {
return this._readyPromise.promise;
}
},

/**
* Gets a value indicating whether or not the provider includes a water mask. The water mask
* indicates which areas of the globe are water rather than land, so they can be rendered
Expand Down
15 changes: 15 additions & 0 deletions Source/Core/EllipsoidTerrainProvider.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*global define*/
define([
'../ThirdParty/when',
'./defaultValue',
'./defined',
'./defineProperties',
Expand All @@ -9,6 +10,7 @@ define([
'./HeightmapTerrainData',
'./TerrainProvider'
], function(
when,
defaultValue,
defined,
defineProperties,
Expand Down Expand Up @@ -59,6 +61,7 @@ define([
});

this._errorEvent = new Event();
this._readyPromise = when.resolve(true);
};

defineProperties(EllipsoidTerrainProvider.prototype, {
Expand Down Expand Up @@ -110,6 +113,18 @@ define([
}
},

/**
* Gets a promise that resolves to true when the provider is ready for use.
* @memberof EllipsoidTerrainProvider.prototype
* @type {Promise.<Boolean>}
* @readonly
*/
readyPromise : {
get : function() {
return this._readyPromise;
}
},

/**
* Gets a value indicating whether or not the provider includes a water mask. The water mask
* indicates which areas of the globe are water rather than land, so they can be rendered
Expand Down
10 changes: 10 additions & 0 deletions Source/Core/TerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ define([
get : DeveloperError.throwInstantiationError
},

/**
* Gets a promise that resolves to true when the provider is ready for use.
* @memberof TerrainProvider.prototype
* @type {Promise.<Boolean>}
* @readonly
*/
readyPromise : {
get : DeveloperError.throwInstantiationError
},

/**
* Gets a value indicating whether or not the provider includes a water mask. The water mask
* indicates which areas of the globe are water rather than land, so they can be rendered
Expand Down
14 changes: 14 additions & 0 deletions Source/Core/VRTheWorldTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ define([

this._errorEvent = new Event();
this._ready = false;
this._readyPromise = when.defer();

this._proxy = options.proxy;

Expand Down Expand Up @@ -133,6 +134,7 @@ define([
}

that._ready = true;
that._readyPromise.resolve(true);
}

function metadataFailure(e) {
Expand Down Expand Up @@ -200,6 +202,18 @@ define([
}
},

/**
* Gets a promise that resolves to true when the provider is ready for use.
* @memberof VRTheWorldTerrainProvider.prototype
* @type {Promise.<Boolean>}
* @readonly
*/
readyPromise : {
get : function() {
return this._readyPromise.promise;
}
},

/**
* Gets a value indicating whether or not the provider includes a water mask. The water mask
* indicates which areas of the globe are water rather than land, so they can be rendered
Expand Down
18 changes: 18 additions & 0 deletions Source/Scene/ArcGisMapServerImageryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ define([
'../Core/loadJsonp',
'../Core/Math',
'../Core/Rectangle',
'../Core/RuntimeError',
'../Core/TileProviderError',
'../Core/WebMercatorProjection',
'../Core/WebMercatorTilingScheme',
Expand All @@ -38,6 +39,7 @@ define([
loadJsonp,
CesiumMath,
Rectangle,
RuntimeError,
TileProviderError,
WebMercatorProjection,
WebMercatorTilingScheme,
Expand Down Expand Up @@ -135,6 +137,7 @@ define([
this._errorEvent = new Event();

this._ready = false;
this._readyPromise = when.defer();

// Grab the details of this MapServer.
var that = this;
Expand Down Expand Up @@ -198,12 +201,14 @@ define([
}

that._ready = true;
that._readyPromise.resolve(true);
TileProviderError.handleSuccess(metadataError);
}

function metadataFailure(e) {
var message = 'An error occurred while accessing ' + that._url + '.';
metadataError = TileProviderError.handleError(metadataError, that, that._errorEvent, message, undefined, undefined, undefined, requestMetadata);
that._readyPromise.reject(new RuntimeError(message));
}

function requestMetadata() {
Expand All @@ -226,6 +231,7 @@ define([
requestMetadata();
} else {
this._ready = true;
this._readyPromise.resolve(true);
}
};

Expand Down Expand Up @@ -469,6 +475,18 @@ define([
}
},

/**
* Gets a promise that resolves to true when the provider is ready for use.
* @memberof ArcGisMapServerImageryProvider.prototype
* @type {Promise.<Boolean>}
* @readonly
*/
readyPromise : {
get : function() {
return this._readyPromise.promise;
}
},

/**
* Gets the credit to display when this imagery provider is active. Typically this is used to credit
* the source of the imagery. This function should not be called before {@link ArcGisMapServerImageryProvider#ready} returns true.
Expand Down
17 changes: 17 additions & 0 deletions Source/Scene/BingMapsImageryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ define([
'../Core/loadJsonp',
'../Core/Math',
'../Core/Rectangle',
'../Core/RuntimeError',
'../Core/TileProviderError',
'../Core/WebMercatorTilingScheme',
'../ThirdParty/when',
Expand All @@ -29,6 +30,7 @@ define([
loadJsonp,
CesiumMath,
Rectangle,
RuntimeError,
TileProviderError,
WebMercatorTilingScheme,
when,
Expand Down Expand Up @@ -140,6 +142,7 @@ define([
this._errorEvent = new Event();

this._ready = false;
this._readyPromise = when.defer();

var metadataUrl = this._url + '/REST/v1/Imagery/Metadata/' + this._mapStyle + '?incl=ImageryProviders&key=' + this._key;
var that = this;
Expand Down Expand Up @@ -196,12 +199,14 @@ define([
}

that._ready = true;
that._readyPromise.resolve(true);
TileProviderError.handleSuccess(metadataError);
}

function metadataFailure(e) {
var message = 'An error occurred while accessing ' + metadataUrl + '.';
metadataError = TileProviderError.handleError(metadataError, that, that._errorEvent, message, undefined, undefined, undefined, requestMetadata);
that._readyPromise.reject(new RuntimeError(message));
}

function requestMetadata() {
Expand Down Expand Up @@ -441,6 +446,18 @@ define([
}
},

/**
* Gets a promise that resolves to true when the provider is ready for use.
* @memberof BingMapsImageryProvider.prototype
* @type {Promise.<Boolean>}
* @readonly
*/
readyPromise : {
get : function() {
return this._readyPromise.promise;
}
},

/**
* Gets the credit to display when this imagery provider is active. Typically this is used to credit
* the source of the imagery. This function should not be called before {@link BingMapsImageryProvider#ready} returns true.
Expand Down
15 changes: 15 additions & 0 deletions Source/Scene/GoogleEarthImageryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ define([
this._errorEvent = new Event();

this._ready = false;
this._readyPromise = when.defer();

var metadataUrl = this._url + this._path + '/query?request=Json&vars=geeServerDefs&is2d=t';
var that = this;
Expand Down Expand Up @@ -204,12 +205,14 @@ define([
.replace('{channel}', that._channel).replace('{version}', that._version);

that._ready = true;
that._readyPromise.resolve(true);
TileProviderError.handleSuccess(metadataError);
}

function metadataFailure(e) {
var message = 'An error occurred while accessing ' + metadataUrl + '.';
metadataError = TileProviderError.handleError(metadataError, that, that._errorEvent, message, undefined, undefined, undefined, requestMetadata);
that._readyPromise.reject(new RuntimeError(message));
}

function requestMetadata() {
Expand Down Expand Up @@ -470,6 +473,18 @@ define([
}
},

/**
* Gets a promise that resolves to true when the provider is ready for use.
* @memberof GoogleEarthImageryProvider.prototype
* @type {Promise.<Boolean>}
* @readonly
*/
readyPromise : {
get : function() {
return this._readyPromise.promise;
}
},

/**
* Gets the credit to display when this imagery provider is active. Typically this is used to credit
* the source of the imagery. This function should not be called before {@link GoogleEarthImageryProvider#ready} returns true.
Expand Down
20 changes: 18 additions & 2 deletions Source/Scene/GridImageryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ define([
'../Core/defined',
'../Core/defineProperties',
'../Core/Event',
'../Core/GeographicTilingScheme'
'../Core/GeographicTilingScheme',
'../ThirdParty/when'
], function(
Color,
defaultValue,
defined,
defineProperties,
Event,
GeographicTilingScheme) {
GeographicTilingScheme,
when) {
"use strict";

var defaultColor = new Color(1.0, 1.0, 1.0, 0.4);
Expand Down Expand Up @@ -60,6 +62,8 @@ define([

// We only need a single canvas since all tiles will be the same
this._canvas = this._createGridCanvas();

this._readyPromise = when.resolve(true);
};

defineProperties(GridImageryProvider.prototype, {
Expand Down Expand Up @@ -194,6 +198,18 @@ define([
}
},

/**
* Gets a promise that resolves to true when the provider is ready for use.
* @memberof GridImageryProvider.prototype
* @type {Promise.<Boolean>}
* @readonly
*/
readyPromise : {
get : function() {
return this._readyPromise;
}
},

/**
* Gets the credit to display when this imagery provider is active. Typically this is used to credit
* the source of the imagery. This function should not be called before {@link GridImageryProvider#ready} returns true.
Expand Down
10 changes: 10 additions & 0 deletions Source/Scene/ImageryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ define([
get : DeveloperError.throwInstantiationError
},

/**
* Gets a promise that resolves to true when the provider is ready for use.
* @memberof ImageryProvider.prototype
* @type {Promise.<Boolean>}
* @readonly
*/
readyPromise : {
get : DeveloperError.throwInstantiationError
},

/**
* Gets the rectangle, in radians, of the imagery provided by the instance. This function should
* not be called before {@link ImageryProvider#ready} returns true.
Expand Down
Loading