Skip to content

Commit

Permalink
Merge pull request #5574 from AnalyticalGraphicsInc/geometric-error-w…
Browse files Browse the repository at this point in the history
…orkaround

Workaround for undefined geometric error
  • Loading branch information
pjcozzi authored Jun 30, 2017
2 parents 20421d6 + b801b8b commit 3a4a3d8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
3 changes: 2 additions & 1 deletion Source/Scene/Cesium3DTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ define([
this.geometricError = header.geometricError;

if (!defined(this.geometricError)) {
throw new RuntimeError('geometricError must be defined');
this.geometricError = defined(parent) ? parent.geometricError : tileset._geometricError;
Cesium3DTile._deprecationWarning('geometricErrorUndefined', 'Required property geometricError is undefined for this tile. Using parent\'s geometric error instead.');
}

var refine;
Expand Down
47 changes: 29 additions & 18 deletions Specs/Scene/Cesium3DTileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ defineSuite([
var mockTileset = {
debugShowBoundingVolume : true,
debugShowViewerRequestVolume : true,
modelMatrix : Matrix4.IDENTITY
modelMatrix : Matrix4.IDENTITY,
_geometricError : 2
};

var centerLongitude = -1.31968;
Expand All @@ -141,14 +142,6 @@ defineSuite([
expect(tile.isDestroyed()).toEqual(true);
});

it('throws if geometricError is undefined', function() {
var tileWithoutGeometricError = clone(tileWithBoundingSphere, true);
delete tileWithoutGeometricError.geometricError;
expect(function() {
return new Cesium3DTile(mockTileset, '/some_url', tileWithoutGeometricError, undefined);
}).toThrowRuntimeError();
});

it('throws if boundingVolume is undefined', function() {
var tileWithoutBoundingVolume = clone(tileWithBoundingSphere, true);
delete tileWithoutBoundingVolume.boundingVolume;
Expand All @@ -165,6 +158,33 @@ defineSuite([
}).toThrowRuntimeError();
});

it('logs deprecation warning if refine is lowercase', function() {
spyOn(Cesium3DTile, '_deprecationWarning');
var header = clone(tileWithBoundingSphere, true);
header.refine = 'replace';
var tile = new Cesium3DTile(mockTileset, '/some_url', header, undefined);
expect(tile.refine).toBe(Cesium3DTileRefine.REPLACE);
expect(Cesium3DTile._deprecationWarning).toHaveBeenCalled();
});

it('logs deprecation warning if geometric error is undefined', function() {
spyOn(Cesium3DTile, '_deprecationWarning');

var geometricErrorMissing = clone(tileWithBoundingSphere, true);
delete geometricErrorMissing.geometricError;

var parent = new Cesium3DTile(mockTileset, '/some_url', tileWithBoundingSphere, undefined);
var child = new Cesium3DTile(mockTileset, '/some_url', geometricErrorMissing, parent);
expect(child.geometricError).toBe(parent.geometricError);
expect(child.geometricError).toBe(1);

var tile = new Cesium3DTile(mockTileset, '/some_url', geometricErrorMissing, undefined);
expect(tile.geometricError).toBe(mockTileset._geometricError);
expect(tile.geometricError).toBe(2);

expect(Cesium3DTile._deprecationWarning.calls.count()).toBe(2);
});

describe('bounding volumes', function() {
it('can have a bounding sphere', function() {
var tile = new Cesium3DTile(mockTileset, '/some_url', tileWithBoundingSphere, undefined);
Expand Down Expand Up @@ -297,15 +317,6 @@ defineSuite([
var newCenter = Cartesian3.fromRadians(newLongitude, newLatitude);
expect(boundingSphere.center).toEqualEpsilon(newCenter, CesiumMath.EPSILON7);
});

it('logs deprecation warning if refine is lowercase', function() {
spyOn(Cesium3DTile, '_deprecationWarning');
var header = clone(tileWithBoundingSphere, true);
header.refine = 'replace';
var tile = new Cesium3DTile(mockTileset, '/some_url', header, undefined);
expect(tile.refine).toBe(Cesium3DTileRefine.REPLACE);
expect(Cesium3DTile._deprecationWarning).toHaveBeenCalled();
});
});

describe('debug bounding volumes', function() {
Expand Down

0 comments on commit 3a4a3d8

Please sign in to comment.