From ba62e9c4abee27617618865f98be2da5afff77cb Mon Sep 17 00:00:00 2001 From: Gheric Speiginer Date: Mon, 27 Jun 2016 16:42:08 -0400 Subject: [PATCH] Remove ability to use "null" as a reference frame. Supporting a "null" reference frame is unnecessary, since `new Entity()` without a position property suffices as an arbitrary reference frame. --- Source/DataSources/CzmlDataSource.js | 4 --- Source/DataSources/OrientationProperty.js | 4 +-- Source/DataSources/PositionProperty.js | 4 +-- Specs/DataSources/PositionPropertySpec.js | 30 +++++++++++++---------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Source/DataSources/CzmlDataSource.js b/Source/DataSources/CzmlDataSource.js index f5555f88cd6d..9c8454b05b1f 100644 --- a/Source/DataSources/CzmlDataSource.js +++ b/Source/DataSources/CzmlDataSource.js @@ -167,10 +167,6 @@ define([ } function makeReferenceEntity(collection, referenceFrameString, currentReferenceFrame) { - if (referenceFrameString === null) { - return null; - } - if (referenceFrameString[0] === '#') { referenceFrameString = referenceFrameString.slice(1); } diff --git a/Source/DataSources/OrientationProperty.js b/Source/DataSources/OrientationProperty.js index c0e3ddc059fe..f6ea94e78ad1 100644 --- a/Source/DataSources/OrientationProperty.js +++ b/Source/DataSources/OrientationProperty.js @@ -82,7 +82,7 @@ define([ function frameParents(frame) { var frames = []; - while (defined(frame) && frame !== null) { + while (defined(frame)) { frames.unshift(frame); frame = frame.position && frame.position.referenceFrame; } @@ -132,7 +132,7 @@ define([ return Quaternion.clone(value, result); } - if (inputFrame === null || outputFrame === null) { + if (!defined(inputFrame) || !defined(outputFrame)) { return undefined; } diff --git a/Source/DataSources/PositionProperty.js b/Source/DataSources/PositionProperty.js index 8744827f7256..856f9ecd16e9 100644 --- a/Source/DataSources/PositionProperty.js +++ b/Source/DataSources/PositionProperty.js @@ -111,7 +111,7 @@ define([ function frameParents(frame) { var frames = []; - while (defined(frame) && frame !== null) { + while (defined(frame)) { frames.unshift(frame); frame = frame.position && frame.position.referenceFrame; } @@ -162,7 +162,7 @@ define([ return Cartesian3.clone(value, result); } - if (inputFrame === null || outputFrame === null) { + if (!defined(inputFrame) || !defined(outputFrame)) { return undefined; } diff --git a/Specs/DataSources/PositionPropertySpec.js b/Specs/DataSources/PositionPropertySpec.js index 831a6c60ae0d..a2bf5a69d686 100644 --- a/Specs/DataSources/PositionPropertySpec.js +++ b/Specs/DataSources/PositionPropertySpec.js @@ -24,7 +24,7 @@ defineSuite([ //Results of the below tests were verified against STK Components. var time = JulianDate.now(); - it('Works with custom input referenceFrame without orientation', function() { + it('Works with entity input referenceFrame without orientation', function() { var referenceFrame = new Entity(); referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000)); @@ -34,7 +34,7 @@ defineSuite([ expect(result).toEqual(new Cartesian3(100001, 200002, 300003)); }); - it('Works with custom input referenceFrame with orientation', function() { + it('Works with entity input referenceFrame with orientation', function() { var referenceFrame = new Entity(); referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000)); var orientation = new Quaternion(0, 0, 1, 1); @@ -47,7 +47,7 @@ defineSuite([ expect(result).toEqual(new Cartesian3(99998, 200001, 300003)); }); - it('Works with custom chained input reference', function() { + it('Works with custom chained input referenceFrame', function() { var referenceFrame = new Entity(); referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000)); var orientation = new Quaternion(0, 0, 1, 1); @@ -66,7 +66,7 @@ defineSuite([ expect(result).toEqual(new Cartesian3(99603, 200201, 300602)); }); - it('Works with custom output referenceFrame without orientation', function() { + it('Works with entity output referenceFrame without orientation', function() { var referenceFrame = new Entity(); referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000)); @@ -76,7 +76,7 @@ defineSuite([ expect(result).toEqual(new Cartesian3(1, 2, 3)); }); - it('Works with custom output referenceFrame with orientation', function() { + it('Works with entity output referenceFrame with orientation', function() { var referenceFrame = new Entity(); referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000)); var orientation = new Quaternion(0, 0, 1, 1); @@ -89,7 +89,7 @@ defineSuite([ expect(result).toEqualEpsilon(new Cartesian3(1, 2, 3), CesiumMath.EPSILON7); }); - it('Works with custom chained output referenceFrame', function() { + it('Works with chained output referenceFrame', function() { var referenceFrame = new Entity(); referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000)); var orientation = new Quaternion(0, 0, 1, 1); @@ -108,7 +108,7 @@ defineSuite([ expect(result).toEqualEpsilon(new Cartesian3(1, 2, 3), CesiumMath.EPSILON7); }); - it('Works with custom input and output referenceFrames', function() { + it('Works with entity input and output referenceFrame parameters', function() { var referenceFrame = new Entity(); referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000)); var orientation = new Quaternion(0, 0, 1, 1); @@ -127,9 +127,11 @@ defineSuite([ expect(result).toEqualEpsilon(new Cartesian3(201, 397, 602), CesiumMath.EPSILON7); }); - it('Works with custom input and output referenceFrames and null root referenceFrame', function() { + it('Works when input and output referenceFrame parameters have a root entity reference frame', function() { + var rootFrame = new Entity(); + var referenceFrame = new Entity(); - referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000), null); + referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000), rootFrame); var orientation = new Quaternion(0, 0, 1, 1); Quaternion.normalize(orientation, orientation); referenceFrame.orientation = new ConstantProperty(orientation); @@ -141,20 +143,22 @@ defineSuite([ referenceFrame2.orientation = new ConstantProperty(orientation); var value = new Cartesian3(1, 2, 3); - var result = PositionProperty.convertToReferenceFrame(time, value, referenceFrame2, referenceFrame); + var result = PositionProperty.convertToReferenceFrame(time, value, referenceFrame2, rootFrame); - expect(result).toEqualEpsilon(new Cartesian3(201, 397, 602), CesiumMath.EPSILON7); + expect(result).toEqualEpsilon(new Cartesian3(99603, 200201, 300602), CesiumMath.EPSILON7); }); it('returns undefined when input and output referenceFrames are disconnected', function() { + var rootEntity = new Entity(); var referenceFrame = new Entity(); - referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000), null); + referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000), rootEntity); var orientation = new Quaternion(0, 0, 1, 1); Quaternion.normalize(orientation, orientation); referenceFrame.orientation = new ConstantProperty(orientation); + var rootEntity2 = new Entity(); var referenceFrame2 = new Entity(); - referenceFrame2.position = new ConstantPositionProperty(new Cartesian3(200, 400, 600), null); + referenceFrame2.position = new ConstantPositionProperty(new Cartesian3(200, 400, 600), rootEntity2); orientation = new Quaternion(1, 0, 0, 1); Quaternion.normalize(orientation, orientation); referenceFrame2.orientation = new ConstantProperty(orientation);