Skip to content

Commit

Permalink
Attempt to fix GEE issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Jun 2, 2017
1 parent 172da97 commit 6ecb6f6
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 8 deletions.
6 changes: 6 additions & 0 deletions Source/Core/CesiumTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ define([
'./OrientedBoundingBox',
'./QuantizedMeshTerrainData',
'./Request',
'./RequestState',
'./RequestType',
'./TerrainProvider',
'./TileAvailability',
Expand All @@ -47,6 +48,7 @@ define([
OrientedBoundingBox,
QuantizedMeshTerrainData,
Request,
RequestState,
RequestType,
TerrainProvider,
TileAvailability,
Expand Down Expand Up @@ -550,6 +552,10 @@ define([

var that = this;
return when(promise, function(buffer) {
if (request.state === RequestState.CANCELLED) {
// Request was cancelled due to low priority - try again later.
return;
}
if (defined(that._heightmapStructure)) {
return createHeightmapTerrainData(that, buffer, level, x, y, tmsY);
} else {
Expand Down
13 changes: 13 additions & 0 deletions Source/Core/GoogleEarthEnterpriseTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ define([
'./Math',
'./Rectangle',
'./Request',
'./RequestState',
'./RequestType',
'./RuntimeError',
'./TaskProcessor',
Expand All @@ -39,6 +40,7 @@ define([
CesiumMath,
Rectangle,
Request,
RequestState,
RequestType,
RuntimeError,
TaskProcessor,
Expand Down Expand Up @@ -458,6 +460,12 @@ define([

promise = requestPromise
.then(function(terrain) {
if (request.state === RequestState.CANCELLED) {
// Request was cancelled due to low priority - try again later.
info.terrainState = TerrainState.UNKNOWN;
return;
}

if (defined(terrain)) {
return taskProcessor.scheduleTask({
buffer : terrain,
Expand Down Expand Up @@ -505,6 +513,11 @@ define([

return promise
.then(function() {
if (request.state === RequestState.CANCELLED) {
info.terrainState = TerrainState.UNKNOWN;
// Request was cancelled due to low priority - try again later.
return;
}
var buffer = terrainCache.get(quadKey);
if (defined(buffer)) {
var credit = metadata.providers[info.terrainProvider];
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/RequestScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ define([
var active = request.state === RequestState.ACTIVE;
request.state = RequestState.CANCELLED;
++statistics.numberOfCancelledRequests;
request.deferred.reject('Cancelled');
request.deferred.resolve(undefined);

if (active) {
// Despite the Request being cancelled, the xhr request is still in flight.
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/VRTheWorldTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ define([
'./Math',
'./Rectangle',
'./Request',
'./RequestState',
'./RequestType',
'./TerrainProvider',
'./TileProviderError'
Expand Down Expand Up @@ -296,6 +297,10 @@ define([

var that = this;
return when(promise, function(image) {
if (request.state === RequestState.CANCELLED) {
// Request was cancelled due to low priority - try again later.
return;
}
return new HeightmapTerrainData({
buffer : getImagePixels(image),
width : that._heightmapWidth,
Expand Down
6 changes: 6 additions & 0 deletions Source/Scene/GoogleEarthEnterpriseImageryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ define([
'../Core/Math',
'../Core/Rectangle',
'../Core/Request',
'../Core/RequestState',
'../Core/RequestType',
'../Core/RuntimeError',
'../Core/TileProviderError',
Expand All @@ -34,6 +35,7 @@ define([
CesiumMath,
Rectangle,
Request,
RequestState,
RequestType,
RuntimeError,
TileProviderError,
Expand Down Expand Up @@ -479,6 +481,10 @@ define([

return promise
.then(function(image) {
if (request.state === RequestState.CANCELLED) {
// Request was cancelled due to low priority - try again later.
return;
}
decodeGoogleEarthEnterpriseData(metadata.key, image);
var a = new Uint8Array(image);
var type;
Expand Down
13 changes: 6 additions & 7 deletions Source/Scene/ImageryLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,12 @@ define([

function success(image) {
if (!defined(image)) {
if (imagery.request.state === RequestState.CANCELLED) {
// Cancelled due to low priority - try again later.
imagery.state = ImageryState.UNLOADED;
imagery.request = undefined;
return;
}
return failure();
}

Expand All @@ -682,13 +688,6 @@ define([
}

function failure(e) {
if (imagery.request.state === RequestState.CANCELLED) {
// Cancelled due to low priority - try again later.
imagery.state = ImageryState.UNLOADED;
imagery.request = undefined;
return;
}

// Initially assume failure. handleError may retry, in which case the state will
// change to TRANSITIONING.
imagery.state = ImageryState.FAILED;
Expand Down

0 comments on commit 6ecb6f6

Please sign in to comment.