diff --git a/Source/DataSources/CzmlDataSource.js b/Source/DataSources/CzmlDataSource.js index 50e147bfa285..eee6518fc964 100644 --- a/Source/DataSources/CzmlDataSource.js +++ b/Source/DataSources/CzmlDataSource.js @@ -84,6 +84,7 @@ define([ './StripeOrientation', './TimeIntervalCollectionPositionProperty', './TimeIntervalCollectionProperty', + './VelocityOrientationProperty', './VelocityVectorProperty', './WallGraphics' ], function( @@ -172,23 +173,53 @@ define([ StripeOrientation, TimeIntervalCollectionPositionProperty, TimeIntervalCollectionProperty, + VelocityOrientationProperty, VelocityVectorProperty, WallGraphics) { 'use strict'; + // A marker type to distinguish CZML properties where we need to end up with a unit vector. + // The data is still loaded into Cartesian3 objects but they are normalized. + function UnitCartesian3() {} + UnitCartesian3.packedLength = Cartesian3.packedLength; + UnitCartesian3.unpack = Cartesian3.unpack; + UnitCartesian3.pack = Cartesian3.pack; + + // As a side note, for the purposes of CZML, Quaternion always indicates a unit quaternion. + var currentId; - function makeReference(collection, referenceString) { + function createReferenceProperty(entityCollection, referenceString) { if (referenceString[0] === '#') { referenceString = currentId + referenceString; } - return ReferenceProperty.fromString(collection, referenceString); + return ReferenceProperty.fromString(entityCollection, referenceString); + } + + function createSpecializedProperty(type, entityCollection, packetData) { + if (defined(packetData.reference)) { + return createReferenceProperty(entityCollection, packetData.reference); + } + + if (defined(packetData.velocityReference)) { + var referenceProperty = createReferenceProperty(entityCollection, packetData.velocityReference); + switch (type) { + case Cartesian3: + case UnitCartesian3: + return new VelocityVectorProperty(referenceProperty, type === UnitCartesian3); + case Quaternion: + return new VelocityOrientationProperty(referenceProperty); + } + } + + throw new RuntimeError(JSON.stringify(packetData) + ' is not valid CZML.'); } var scratchCartesian = new Cartesian3(); var scratchSpherical = new Spherical(); var scratchCartographic = new Cartographic(); var scratchTimeInterval = new TimeInterval(); + var scratchQuaternion = new Quaternion(); function unwrapColorInterval(czmlInterval) { var rgbaf = czmlInterval.rgbaf; @@ -398,17 +429,30 @@ define([ throw new RuntimeError(JSON.stringify(czmlInterval) + ' is not a valid CZML interval.'); } + function normalizePackedCartesianArray(array, startingIndex) { + Cartesian3.unpack(array, startingIndex, scratchCartesian); + Cartesian3.normalize(scratchCartesian, scratchCartesian); + Cartesian3.pack(scratchCartesian, array, startingIndex); + } + + function unwrapUnitCartesianInterval(czmlInterval) { + var cartesian = unwrapCartesianInterval(czmlInterval); + if (cartesian.length === 3) { + normalizePackedCartesianArray(cartesian, 0); + return cartesian; + } + + for (var i = 1; i < cartesian.length; i += 4) { + normalizePackedCartesianArray(cartesian, i); + } + + return cartesian; + } + function normalizePackedQuaternionArray(array, startingIndex) { - var x = array[startingIndex]; - var y = array[startingIndex + 1]; - var z = array[startingIndex + 2]; - var w = array[startingIndex + 3]; - - var inverseMagnitude = 1.0 / Math.sqrt(x * x + y * y + z * z + w * w); - array[startingIndex] = x * inverseMagnitude; - array[startingIndex + 1] = y * inverseMagnitude; - array[startingIndex + 2] = z * inverseMagnitude; - array[startingIndex + 3] = w * inverseMagnitude; + Quaternion.unpack(array, startingIndex, scratchQuaternion); + Quaternion.normalize(scratchQuaternion, scratchQuaternion); + Quaternion.pack(scratchQuaternion, array, startingIndex); } function unwrapQuaternionInterval(czmlInterval) { @@ -452,12 +496,13 @@ define([ } else if (czmlInterval.hasOwnProperty('cartesian2')) { return Cartesian2; } else if (czmlInterval.hasOwnProperty('cartesian') || - czmlInterval.hasOwnProperty('unitCartesian') || - czmlInterval.hasOwnProperty('unitSpherical') || czmlInterval.hasOwnProperty('spherical') || czmlInterval.hasOwnProperty('cartographicRadians') || czmlInterval.hasOwnProperty('cartographicDegrees')) { return Cartesian3; + } else if (czmlInterval.hasOwnProperty('unitCartesian') || + czmlInterval.hasOwnProperty('unitSpherical')) { + return UnitCartesian3; } else if (czmlInterval.hasOwnProperty('rgba') || czmlInterval.hasOwnProperty('rgbaf')) { return Color; @@ -514,6 +559,8 @@ define([ return czmlInterval.cartesian2; case Cartesian3: return unwrapCartesianInterval(czmlInterval); + case UnitCartesian3: + return unwrapUnitCartesianInterval(czmlInterval); case Color: return unwrapColorInterval(czmlInterval); case ColorBlendMode: @@ -614,10 +661,17 @@ define([ var isSampled; var unwrappedInterval; var unwrappedIntervalLength; - var isReference = defined(packetData.reference); + + // CZML properties can be defined in many ways. Most ways represent a structure for + // encoding a single value (number, string, cartesian, etc.) Regardless of the value type, + // if it encodes a single value it will get loaded into a ConstantProperty eventually. + // Alternatively, there are ways of defining a property that require specialized + // client-side representation. Currently, these are ReferenceProperty, + // and client-side velocity computation properties such as VelocityVectorProperty. + var isValue = !defined(packetData.reference) && !defined(packetData.velocityReference); var hasInterval = defined(combinedInterval) && !combinedInterval.equals(Iso8601.MAXIMUM_INTERVAL); - if (!isReference) { + if (isValue) { unwrappedInterval = unwrapInterval(type, packetData, sourceUri, query); packedLength = defaultValue(type.packedLength, 1); unwrappedIntervalLength = defaultValue(unwrappedInterval.length, 1); @@ -630,12 +684,10 @@ define([ //Any time a constant value is assigned, it completely blows away anything else. if (!isSampled && !hasInterval) { - if (isReference) { - object[propertyName] = makeReference(entityCollection, packetData.reference); - } else if (needsUnpacking) { - object[propertyName] = new ConstantProperty(type.unpack(unwrappedInterval, 0)); + if (isValue) { + object[propertyName] = new ConstantProperty(needsUnpacking ? type.unpack(unwrappedInterval, 0) : unwrappedInterval); } else { - object[propertyName] = new ConstantProperty(unwrappedInterval); + object[propertyName] = createSpecializedProperty(type, entityCollection, packetData); } return; } @@ -668,30 +720,30 @@ define([ if (!isSampled && hasInterval) { //Create a new interval for the constant value. combinedInterval = combinedInterval.clone(); - if (isReference) { - combinedInterval.data = makeReference(entityCollection, packetData.reference); - } else if (needsUnpacking) { - combinedInterval.data = type.unpack(unwrappedInterval, 0); + if (isValue) { + combinedInterval.data = needsUnpacking ? type.unpack(unwrappedInterval, 0) : unwrappedInterval; } else { - combinedInterval.data = unwrappedInterval; + combinedInterval.data = createSpecializedProperty(type, entityCollection, packetData); } //If no property exists, simply use a new interval collection if (!defined(property)) { - if (isReference) { - property = new CompositeProperty(); - } else { + if (isValue) { property = new TimeIntervalCollectionProperty(); + } else { + property = new CompositeProperty(); } object[propertyName] = property; } - if (!isReference && property instanceof TimeIntervalCollectionProperty) { + if (isValue && property instanceof TimeIntervalCollectionProperty) { //If we create a collection, or it already existed, use it. property.intervals.addInterval(combinedInterval); } else if (property instanceof CompositeProperty) { //If the collection was already a CompositeProperty, use it. - combinedInterval.data = isReference ? combinedInterval.data : new ConstantProperty(combinedInterval.data); + if (isValue) { + combinedInterval.data = new ConstantProperty(combinedInterval.data); + } property.intervals.addInterval(combinedInterval); } else { //Otherwise, create a CompositeProperty but preserve the existing data. @@ -708,7 +760,9 @@ define([ property.intervals.addInterval(interval); //Change the new data to a ConstantProperty and add it. - combinedInterval.data = isReference ? combinedInterval.data : new ConstantProperty(combinedInterval.data); + if (isValue) { + combinedInterval.data = new ConstantProperty(combinedInterval.data); + } property.intervals.addInterval(combinedInterval); } @@ -781,10 +835,10 @@ define([ var unwrappedIntervalLength; var numberOfDerivatives = defined(packetData.cartesianVelocity) ? 1 : 0; var packedLength = Cartesian3.packedLength * (numberOfDerivatives + 1); - var isReference = defined(packetData.reference); + var isValue = !defined(packetData.reference); var hasInterval = defined(combinedInterval) && !combinedInterval.equals(Iso8601.MAXIMUM_INTERVAL); - if (!isReference) { + if (isValue) { if (defined(packetData.referenceFrame)) { referenceFrame = ReferenceFrame[packetData.referenceFrame]; } @@ -796,10 +850,10 @@ define([ //Any time a constant value is assigned, it completely blows away anything else. if (!isSampled && !hasInterval) { - if (isReference) { - object[propertyName] = makeReference(entityCollection, packetData.reference); - } else { + if (isValue) { object[propertyName] = new ConstantPositionProperty(Cartesian3.unpack(unwrappedInterval), referenceFrame); + } else { + object[propertyName] = createReferenceProperty(entityCollection, packetData.reference); } return; } @@ -832,28 +886,30 @@ define([ if (!isSampled && hasInterval) { //Create a new interval for the constant value. combinedInterval = combinedInterval.clone(); - if (isReference) { - combinedInterval.data = makeReference(entityCollection, packetData.reference); - } else { + if (isValue) { combinedInterval.data = Cartesian3.unpack(unwrappedInterval); + } else { + combinedInterval.data = createReferenceProperty(entityCollection, packetData.reference); } //If no property exists, simply use a new interval collection if (!defined(property)) { - if (isReference) { - property = new CompositePositionProperty(referenceFrame); - } else { + if (isValue) { property = new TimeIntervalCollectionPositionProperty(referenceFrame); + } else { + property = new CompositePositionProperty(referenceFrame); } object[propertyName] = property; } - if (!isReference && property instanceof TimeIntervalCollectionPositionProperty && (defined(referenceFrame) && property.referenceFrame === referenceFrame)) { + if (isValue && property instanceof TimeIntervalCollectionPositionProperty && (defined(referenceFrame) && property.referenceFrame === referenceFrame)) { //If we create a collection, or it already existed, use it. property.intervals.addInterval(combinedInterval); } else if (property instanceof CompositePositionProperty) { //If the collection was already a CompositePositionProperty, use it. - combinedInterval.data = isReference ? combinedInterval.data : new ConstantPositionProperty(combinedInterval.data, referenceFrame); + if (isValue) { + combinedInterval.data = new ConstantPositionProperty(combinedInterval.data, referenceFrame); + } property.intervals.addInterval(combinedInterval); } else { //Otherwise, create a CompositePositionProperty but preserve the existing data. @@ -870,7 +926,9 @@ define([ property.intervals.addInterval(interval); //Change the new data to a ConstantPositionProperty and add it. - combinedInterval.data = isReference ? combinedInterval.data : new ConstantPositionProperty(combinedInterval.data, referenceFrame); + if (isValue) { + combinedInterval.data = new ConstantPositionProperty(combinedInterval.data, referenceFrame); + } property.intervals.addInterval(combinedInterval); } @@ -1117,7 +1175,7 @@ define([ var references = packetData.references; if (defined(references)) { var properties = references.map(function(reference) { - return makeReference(entityCollection, reference); + return createReferenceProperty(entityCollection, reference); }); var iso8601Interval = packetData.interval; @@ -1154,7 +1212,7 @@ define([ function processPositionsPacketData(object, propertyName, positionsData, entityCollection) { if (defined(positionsData.references)) { var properties = positionsData.references.map(function(reference) { - return makeReference(entityCollection, reference); + return createReferenceProperty(entityCollection, reference); }); var iso8601Interval = positionsData.interval; @@ -1230,11 +1288,7 @@ define([ return; } - if (defined(packetData.velocityReference)) { - billboard.alignedAxis = new VelocityVectorProperty(makeReference(entityCollection, packetData.velocityReference), true); - } else { - processPacketData(Cartesian3, billboard, 'alignedAxis', packetData, interval, sourceUri, entityCollection, query); - } + processPacketData(UnitCartesian3, billboard, 'alignedAxis', packetData, interval, sourceUri, entityCollection, query); } function processBillboard(entity, packet, entityCollection, sourceUri, query) { diff --git a/Specs/DataSources/CzmlDataSourceSpec.js b/Specs/DataSources/CzmlDataSourceSpec.js index ca23bc64af48..5768b37c2ae9 100644 --- a/Specs/DataSources/CzmlDataSourceSpec.js +++ b/Specs/DataSources/CzmlDataSourceSpec.js @@ -23,6 +23,7 @@ defineSuite([ 'Core/RuntimeError', 'Core/Spherical', 'Core/TimeInterval', + 'Core/Transforms', 'Core/TranslationRotationScale', 'DataSources/CompositeEntityCollection', 'DataSources/EntityCollection', @@ -60,6 +61,7 @@ defineSuite([ RuntimeError, Spherical, TimeInterval, + Transforms, TranslationRotationScale, CompositeEntityCollection, EntityCollection, @@ -191,53 +193,59 @@ defineSuite([ it('name returns CZML defined name', function() { var dataSource = new CzmlDataSource(); - dataSource.load(nameCzml); - expect(dataSource.name).toEqual('czmlName'); + return dataSource.load(nameCzml).then(function(dataSource) { + expect(dataSource.name).toEqual('czmlName'); + }); }); it('name uses source name if CZML name is undefined', function() { var dataSource = new CzmlDataSource(); - dataSource.load(clockCzml, { - sourceUri : 'Gallery/simple.czml?asd=true' + return dataSource.load(clockCzml, { + sourceUri: 'Gallery/simple.czml?asd=true' + }).then(function(dataSource) { + expect(dataSource.name).toEqual('simple.czml'); }); - expect(dataSource.name).toEqual('simple.czml'); }); it('does not overwrite existing name if CZML name is undefined', function() { var dataSource = new CzmlDataSource('myName'); - dataSource.load(clockCzml, { - sourceUri : 'Gallery/simple.czml' + return dataSource.load(clockCzml, { + sourceUri: 'Gallery/simple.czml' + }).then(function(dataSource) { + expect(dataSource.name).toEqual('myName'); }); - expect(dataSource.name).toEqual('myName'); }); it('clock returns undefined for static CZML', function() { var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(staticCzml)); - expect(dataSource.clock).toBeUndefined(); + return dataSource.load(makePacket(staticCzml)).then(function(dataSource) { + expect(dataSource.clock).toBeUndefined(); + }); }); it('clock returns CZML defined clock', function() { var dataSource = new CzmlDataSource(); - dataSource.load(clockCzml); - - var clock = dataSource.clock; - expect(clock).toBeDefined(); - expect(clock.startTime).toEqual(parsedClock.interval.start); - expect(clock.stopTime).toEqual(parsedClock.interval.stop); - expect(clock.currentTime).toEqual(parsedClock.currentTime); - expect(clock.clockRange).toEqual(parsedClock.range); - expect(clock.clockStep).toEqual(parsedClock.step); - expect(clock.multiplier).toEqual(parsedClock.multiplier); - - dataSource.process(clockCzml2); - expect(clock).toBeDefined(); - expect(clock.startTime).toEqual(parsedClock2.interval.start); - expect(clock.stopTime).toEqual(parsedClock2.interval.stop); - expect(clock.currentTime).toEqual(parsedClock2.currentTime); - expect(clock.clockRange).toEqual(parsedClock2.range); - expect(clock.clockStep).toEqual(parsedClock2.step); - expect(clock.multiplier).toEqual(parsedClock2.multiplier); + return dataSource.load(clockCzml).then(function(dataSource) { + var clock = dataSource.clock; + expect(clock).toBeDefined(); + expect(clock.startTime).toEqual(parsedClock.interval.start); + expect(clock.stopTime).toEqual(parsedClock.interval.stop); + expect(clock.currentTime).toEqual(parsedClock.currentTime); + expect(clock.clockRange).toEqual(parsedClock.range); + expect(clock.clockStep).toEqual(parsedClock.step); + expect(clock.multiplier).toEqual(parsedClock.multiplier); + + return dataSource.process(clockCzml2); + }).then(function(dataSource) { + var clock = dataSource.clock; + expect(clock).toBeDefined(); + expect(clock.startTime).toEqual(parsedClock2.interval.start); + expect(clock.stopTime).toEqual(parsedClock2.interval.stop); + expect(clock.currentTime).toEqual(parsedClock2.currentTime); + expect(clock.clockRange).toEqual(parsedClock2.range); + expect(clock.clockStep).toEqual(parsedClock2.step); + expect(clock.multiplier).toEqual(parsedClock2.multiplier); + }); }); it('clock returns data interval if no clock defined', function() { @@ -246,39 +254,45 @@ defineSuite([ }); var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(dynamicCzml)); - var clock = dataSource.clock; - expect(clock).toBeDefined(); - expect(clock.startTime).toEqual(interval.start); - expect(clock.stopTime).toEqual(interval.stop); - expect(clock.currentTime).toEqual(interval.start); - expect(clock.clockRange).toEqual(ClockRange.LOOP_STOP); - expect(clock.clockStep).toEqual(ClockStep.SYSTEM_CLOCK_MULTIPLIER); - expect(clock.multiplier).toEqual(JulianDate.secondsDifference(interval.stop, interval.start) / 120.0); + return dataSource.load(makePacket(dynamicCzml)).then(function(dataSource) { + var clock = dataSource.clock; + expect(clock).toBeDefined(); + expect(clock.startTime).toEqual(interval.start); + expect(clock.stopTime).toEqual(interval.stop); + expect(clock.currentTime).toEqual(interval.start); + expect(clock.clockRange).toEqual(ClockRange.LOOP_STOP); + expect(clock.clockStep).toEqual(ClockStep.SYSTEM_CLOCK_MULTIPLIER); + expect(clock.multiplier).toEqual(JulianDate.secondsDifference(interval.stop, interval.start) / 120.0); + }); }); it('process loads expected data', function() { var dataSource = new CzmlDataSource(); - dataSource.process(simple); - expect(dataSource.entities.values.length).toEqual(10); + return dataSource.process(simple).then(function(dataSource) { + expect(dataSource.entities.values.length).toEqual(10); + }); }); it('process loads data on top of existing', function() { var dataSource = new CzmlDataSource(); - dataSource.process(simple); - expect(dataSource.entities.values.length === 10); + return dataSource.process(simple).then(function(dataSource) { + expect(dataSource.entities.values.length === 10); - dataSource.process(vehicle, vehicleUrl); - expect(dataSource.entities.values.length === 11); + return dataSource.process(vehicle, vehicleUrl); + }).then(function(dataSource) { + expect(dataSource.entities.values.length === 11); + }); }); it('load replaces data', function() { var dataSource = new CzmlDataSource(); - dataSource.process(simple); - expect(dataSource.entities.values.length).toEqual(10); + return dataSource.process(simple).then(function(dataSource) { + expect(dataSource.entities.values.length).toEqual(10); - dataSource.load(vehicle, vehicleUrl); - expect(dataSource.entities.values.length).toEqual(1); + return dataSource.load(vehicle, vehicleUrl); + }).then(function(dataSource) { + expect(dataSource.entities.values.length).toEqual(1); + }); }); it('process throws with undefined CZML', function() { @@ -301,48 +315,49 @@ defineSuite([ var spy = jasmine.createSpy('changedEvent'); dataSource.changedEvent.addEventListener(spy); - dataSource.load(clockCzml); - - expect(spy).toHaveBeenCalledWith(dataSource); + return dataSource.load(clockCzml).then(function(dataSource) { + expect(spy).toHaveBeenCalledWith(dataSource); + }); }); it('raises changed event when name changes in CZML', function() { var dataSource = new CzmlDataSource(); + var spy = jasmine.createSpy('changedEvent'); var originalCzml = { id : 'document', version : '1.0', name : 'czmlName' }; - dataSource.load(originalCzml); - var spy = jasmine.createSpy('changedEvent'); - dataSource.changedEvent.addEventListener(spy); + return dataSource.load(originalCzml).then(function(dataSource) { + dataSource.changedEvent.addEventListener(spy); - var newCzml = { - id : 'document', - name : 'newCzmlName' - }; - dataSource.process(newCzml); - - expect(spy).toHaveBeenCalledWith(dataSource); + var newCzml = { + id : 'document', + name : 'newCzmlName' + }; + return dataSource.process(newCzml); + }).then(function(dataSource) { + expect(spy).toHaveBeenCalledWith(dataSource); + }); }); it('does not raise changed event when name does not change in CZML', function() { var dataSource = new CzmlDataSource(); - - dataSource.load(nameCzml); - var spy = jasmine.createSpy('changedEvent'); - dataSource.changedEvent.addEventListener(spy); - - dataSource.load(nameCzml); - expect(spy).not.toHaveBeenCalled(); + return dataSource.load(nameCzml).then(function(dataSource) { + dataSource.changedEvent.addEventListener(spy); + return dataSource.load(nameCzml); + }).then(function(dataSource) { + expect(spy).not.toHaveBeenCalled(); + }); }); it('raises changed event when clock changes in CZML', function() { var dataSource = new CzmlDataSource(); + var spy = jasmine.createSpy('changedEvent'); var originalCzml = { id : 'document', @@ -355,38 +370,38 @@ defineSuite([ step : 'SYSTEM_CLOCK_MULTIPLIER' } }; - dataSource.load(originalCzml); - - var spy = jasmine.createSpy('changedEvent'); - dataSource.changedEvent.addEventListener(spy); - - var newCzml = { - id : 'document', - version : '1.0', - clock : { - interval : '2013-03-15T10:00:00Z/2013-03-16T10:00:00Z', - currentTime : '2012-03-15T10:00:00Z', - multiplier : 60.0, - range : 'LOOP_STOP', - step : 'SYSTEM_CLOCK_MULTIPLIER' - } - }; - dataSource.load(newCzml); - expect(spy).toHaveBeenCalledWith(dataSource); + return dataSource.load(originalCzml).then(function(dataSource) { + dataSource.changedEvent.addEventListener(spy); + + var newCzml = { + id: 'document', + version: '1.0', + clock : { + interval : '2013-03-15T10:00:00Z/2013-03-16T10:00:00Z', + currentTime : '2012-03-15T10:00:00Z', + multiplier : 60.0, + range : 'LOOP_STOP', + step : 'SYSTEM_CLOCK_MULTIPLIER' + } + }; + return dataSource.load(newCzml); + }).then(function(dataSource) { + expect(spy).toHaveBeenCalledWith(dataSource); + }); }); it('does not raise changed event when clock does not change in CZML', function() { var dataSource = new CzmlDataSource(); - - dataSource.load(clockCzml); - var spy = jasmine.createSpy('changedEvent'); - dataSource.changedEvent.addEventListener(spy); - dataSource.load(clockCzml); + return dataSource.load(clockCzml).then(function(dataSource) { + dataSource.changedEvent.addEventListener(spy); - expect(spy).not.toHaveBeenCalled(); + return dataSource.load(clockCzml); + }).then(function(dataSource) { + expect(spy).not.toHaveBeenCalled(); + }); }); it('raises error when an error occurs in load', function() { @@ -410,7 +425,7 @@ defineSuite([ dataSource.errorEvent.addEventListener(spy); // Blue.png is not JSON - dataSource.process('Data/Images/Blue.png').then(function() { + return dataSource.process('Data/Images/Blue.png').then(function() { fail('should not be called'); }).otherwise(function() { expect(spy).toHaveBeenCalledWith(dataSource, jasmine.any(Error)); @@ -459,30 +474,31 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(billboardPacket), { - sourceUri : sourceUri + return dataSource.load(makePacket(billboardPacket), { + sourceUri: sourceUri + }).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.billboard).toBeDefined(); + expect(entity.billboard.image.getValue(Iso8601.MINIMUM_VALUE)).toEqual(sourceUri + 'image.png'); + expect(entity.billboard.rotation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(billboardPacket.billboard.rotation); + expect(entity.billboard.scale.getValue(Iso8601.MINIMUM_VALUE)).toEqual(billboardPacket.billboard.scale); + expect(entity.billboard.heightReference.getValue(Iso8601.MINIMUM_VALUE)).toEqual(HeightReference.CLAMP_TO_GROUND); + expect(entity.billboard.horizontalOrigin.getValue(Iso8601.MINIMUM_VALUE)).toEqual(HorizontalOrigin.CENTER); + expect(entity.billboard.verticalOrigin.getValue(Iso8601.MINIMUM_VALUE)).toEqual(VerticalOrigin.CENTER); + expect(entity.billboard.color.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(1.0, 1.0, 1.0, 1.0)); + expect(entity.billboard.eyeOffset.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(3.0, 4.0, 5.0)); + expect(entity.billboard.pixelOffset.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian2(1.0, 2.0)); + expect(entity.billboard.alignedAxis.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(1.0, 0.0, 0.0)); + expect(entity.billboard.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + expect(entity.billboard.sizeInMeters.getValue(Iso8601.MINIMUM_VALUE)).toEqual(false); + expect(entity.billboard.width.getValue(Iso8601.MINIMUM_VALUE)).toEqual(10); + expect(entity.billboard.height.getValue(Iso8601.MINIMUM_VALUE)).toEqual(11); + expect(entity.billboard.scaleByDistance.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new NearFarScalar(1.0, 2.0, 10000.0, 3.0)); + expect(entity.billboard.translucencyByDistance.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new NearFarScalar(1.0, 1.0, 10000.0, 0.0)); + expect(entity.billboard.pixelOffsetScaleByDistance.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new NearFarScalar(1.0, 20.0, 10000.0, 30.0)); + expect(entity.billboard.imageSubRegion.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new BoundingRectangle(20, 30, 10, 11)); }); - var entity = dataSource.entities.values[0]; - - expect(entity.billboard).toBeDefined(); - expect(entity.billboard.image.getValue(Iso8601.MINIMUM_VALUE)).toEqual(sourceUri + 'image.png'); - expect(entity.billboard.rotation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(billboardPacket.billboard.rotation); - expect(entity.billboard.scale.getValue(Iso8601.MINIMUM_VALUE)).toEqual(billboardPacket.billboard.scale); - expect(entity.billboard.heightReference.getValue(Iso8601.MINIMUM_VALUE)).toEqual(HeightReference.CLAMP_TO_GROUND); - expect(entity.billboard.horizontalOrigin.getValue(Iso8601.MINIMUM_VALUE)).toEqual(HorizontalOrigin.CENTER); - expect(entity.billboard.verticalOrigin.getValue(Iso8601.MINIMUM_VALUE)).toEqual(VerticalOrigin.CENTER); - expect(entity.billboard.color.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(1.0, 1.0, 1.0, 1.0)); - expect(entity.billboard.eyeOffset.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(3.0, 4.0, 5.0)); - expect(entity.billboard.pixelOffset.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian2(1.0, 2.0)); - expect(entity.billboard.alignedAxis.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(1.0, 0.0, 0.0)); - expect(entity.billboard.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); - expect(entity.billboard.sizeInMeters.getValue(Iso8601.MINIMUM_VALUE)).toEqual(false); - expect(entity.billboard.width.getValue(Iso8601.MINIMUM_VALUE)).toEqual(10); - expect(entity.billboard.height.getValue(Iso8601.MINIMUM_VALUE)).toEqual(11); - expect(entity.billboard.scaleByDistance.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new NearFarScalar(1.0, 2.0, 10000.0, 3.0)); - expect(entity.billboard.translucencyByDistance.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new NearFarScalar(1.0, 1.0, 10000.0, 0.0)); - expect(entity.billboard.pixelOffsetScaleByDistance.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new NearFarScalar(1.0, 20.0, 10000.0, 30.0)); - expect(entity.billboard.imageSubRegion.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new BoundingRectangle(20, 30, 10, 11)); }); it('can handle aligned axis expressed as a cartesian', function() { @@ -498,11 +514,12 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(billboardPacket)); - var entity = dataSource.entities.values[0]; + return dataSource.load(makePacket(billboardPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; - expect(entity.billboard).toBeDefined(); - expect(entity.billboard.alignedAxis.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(1.0, 0.0, 0.0)); + expect(entity.billboard).toBeDefined(); + expect(entity.billboard.alignedAxis.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(1.0, 0.0, 0.0)); + }); }); it('can handle aligned axis expressed as a velocity reference', function() { @@ -520,15 +537,58 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.values[0]; - var property = entity.billboard.alignedAxis; + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + var property = entity.billboard.alignedAxis; - var expectedVelocity = new Cartesian3(1.0, 2.0, 3.0); - var expectedVelocityDirection = Cartesian3.normalize(expectedVelocity, new Cartesian3()); + var expectedVelocity = new Cartesian3(1.0, 2.0, 3.0); + var expectedVelocityDirection = Cartesian3.normalize(expectedVelocity, new Cartesian3()); - expect(property.getValue(JulianDate.fromIso8601('2016-06-17T12:00:00Z'))).toEqualEpsilon(expectedVelocityDirection, CesiumMath.EPSILON15); - expect(property.getValue(JulianDate.fromIso8601('2016-06-17T12:00:30Z'))).toEqualEpsilon(expectedVelocityDirection, CesiumMath.EPSILON15); + expect(property.getValue(JulianDate.fromIso8601('2016-06-17T12:00:00Z'))).toEqualEpsilon(expectedVelocityDirection, CesiumMath.EPSILON15); + expect(property.getValue(JulianDate.fromIso8601('2016-06-17T12:00:30Z'))).toEqualEpsilon(expectedVelocityDirection, CesiumMath.EPSILON15); + }); + }); + + it('can handle aligned axis expressed as a velocity reference within an interval', function() { + var packet = { + "position": { + "epoch": "2016-06-17T12:00:00Z", + "cartesian": [0, 1, 2, 3, + 60, 61, 122, 183] + }, + "billboard": { + "alignedAxis": [ + { + "interval": "2016-06-17T12:00:00Z/2016-06-17T12:00:30Z", + "unitCartesian": [ + 0, + 1, + 0 + ] + }, + { + "interval": "2016-06-17T12:00:30Z/2016-06-17T12:01:00Z", + "velocityReference": "#position" + } + ] + } + }; + + var dataSource = new CzmlDataSource(); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + var property = entity.billboard.alignedAxis; + + var expected = new Cartesian3(0, 1, 0); + expect(property.getValue(JulianDate.fromIso8601('2016-06-17T12:00:00Z'))).toEqual(expected); + expect(property.getValue(JulianDate.fromIso8601('2016-06-17T12:00:29Z'))).toEqual(expected); + + var expectedVelocity = new Cartesian3(1.0, 2.0, 3.0); + var expectedVelocityDirection = Cartesian3.normalize(expectedVelocity, new Cartesian3()); + + expect(property.getValue(JulianDate.fromIso8601('2016-06-17T12:00:30Z'))).toEqualEpsilon(expectedVelocityDirection, CesiumMath.EPSILON15); + expect(property.getValue(JulianDate.fromIso8601('2016-06-17T12:01:00Z'))).toEqualEpsilon(expectedVelocityDirection, CesiumMath.EPSILON12); + }); }); it('can handle image intervals both of type uri and image', function() { @@ -546,13 +606,14 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet), { - sourceUri : source + return dataSource.load(makePacket(packet), { + sourceUri: source + }).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + var imageProperty = entity.billboard.image; + expect(imageProperty.getValue(JulianDate.fromIso8601('2013-01-01T00:00:00Z'))).toEqual(source + 'image.png'); + expect(imageProperty.getValue(JulianDate.fromIso8601('2013-01-01T01:00:00Z'))).toEqual(source + 'image2.png'); }); - var entity = dataSource.entities.values[0]; - var imageProperty = entity.billboard.image; - expect(imageProperty.getValue(JulianDate.fromIso8601('2013-01-01T00:00:00Z'))).toEqual(source + 'image.png'); - expect(imageProperty.getValue(JulianDate.fromIso8601('2013-01-01T01:00:00Z'))).toEqual(source + 'image2.png'); }); it('appends query to all uri', function() { @@ -570,17 +631,18 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet), { - sourceUri : source, - query : { - token : 34570, - password : "Passw0rd" + return dataSource.load(makePacket(packet), { + sourceUri: source, + query: { + token: 34570, + password: "Passw0rd" } + }).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + var imageProperty = entity.billboard.image; + expect(imageProperty.getValue(JulianDate.fromIso8601('2013-01-01T00:00:00Z'))).toEqual(source + 'image.png' + '?token=34570&password=Passw0rd'); + expect(imageProperty.getValue(JulianDate.fromIso8601('2013-01-01T01:00:00Z'))).toEqual(source + 'image2.png' + '?token=34570&password=Passw0rd'); }); - var entity = dataSource.entities.values[0]; - var imageProperty = entity.billboard.image; - expect(imageProperty.getValue(JulianDate.fromIso8601('2013-01-01T00:00:00Z'))).toEqual(source + 'image.png' + '?token=34570&password=Passw0rd'); - expect(imageProperty.getValue(JulianDate.fromIso8601('2013-01-01T01:00:00Z'))).toEqual(source + 'image2.png' + '?token=34570&password=Passw0rd'); }); it('appends query tokens to source URL', function() { @@ -592,10 +654,12 @@ defineSuite([ deferred.reject(); }); - dataSource.process(simpleUrl, { query : { - "token" : 30203, - "pass" : "passw0rd" - }}); + dataSource.process(simpleUrl, { + query: { + "token": 30203, + "pass": "passw0rd" + } + }); return requestNetworkLink.promise.then(function(url) { expect(url).toEqual(simpleUrl + '?token=30203&pass=passw0rd'); }); @@ -628,29 +692,30 @@ defineSuite([ var invalidTime = JulianDate.addSeconds(validTime, -1, new JulianDate()); var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(billboardPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.billboard).toBeDefined(); - expect(entity.billboard.image.getValue(validTime)).toEqual(billboardPacket.billboard.image); - expect(entity.billboard.scale.getValue(validTime)).toEqual(billboardPacket.billboard.scale); - expect(entity.billboard.horizontalOrigin.getValue(validTime)).toEqual(HorizontalOrigin.CENTER); - expect(entity.billboard.verticalOrigin.getValue(validTime)).toEqual(VerticalOrigin.CENTER); - expect(entity.billboard.color.getValue(validTime)).toEqual(new Color(1.0, 1.0, 1.0, 1.0)); - expect(entity.billboard.eyeOffset.getValue(validTime)).toEqual(new Cartesian3(3.0, 4.0, 5.0)); - expect(entity.billboard.pixelOffset.getValue(validTime)).toEqual(new Cartesian2(1.0, 2.0)); - - expect(entity.billboard.show.getValue(validTime)).toEqual(true); - - expect(entity.billboard).toBeDefined(); - expect(entity.billboard.image.getValue(invalidTime)).toBeUndefined(); - expect(entity.billboard.scale.getValue(invalidTime)).toBeUndefined(); - expect(entity.billboard.horizontalOrigin.getValue(invalidTime)).toBeUndefined(); - expect(entity.billboard.verticalOrigin.getValue(invalidTime)).toBeUndefined(); - expect(entity.billboard.color.getValue(invalidTime)).toBeUndefined(); - expect(entity.billboard.eyeOffset.getValue(invalidTime)).toBeUndefined(); - expect(entity.billboard.pixelOffset.getValue(invalidTime)).toBeUndefined(); - expect(entity.billboard.show.getValue(invalidTime)).toBeUndefined(); + return dataSource.load(makePacket(billboardPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.billboard).toBeDefined(); + expect(entity.billboard.image.getValue(validTime)).toEqual(billboardPacket.billboard.image); + expect(entity.billboard.scale.getValue(validTime)).toEqual(billboardPacket.billboard.scale); + expect(entity.billboard.horizontalOrigin.getValue(validTime)).toEqual(HorizontalOrigin.CENTER); + expect(entity.billboard.verticalOrigin.getValue(validTime)).toEqual(VerticalOrigin.CENTER); + expect(entity.billboard.color.getValue(validTime)).toEqual(new Color(1.0, 1.0, 1.0, 1.0)); + expect(entity.billboard.eyeOffset.getValue(validTime)).toEqual(new Cartesian3(3.0, 4.0, 5.0)); + expect(entity.billboard.pixelOffset.getValue(validTime)).toEqual(new Cartesian2(1.0, 2.0)); + + expect(entity.billboard.show.getValue(validTime)).toEqual(true); + + expect(entity.billboard).toBeDefined(); + expect(entity.billboard.image.getValue(invalidTime)).toBeUndefined(); + expect(entity.billboard.scale.getValue(invalidTime)).toBeUndefined(); + expect(entity.billboard.horizontalOrigin.getValue(invalidTime)).toBeUndefined(); + expect(entity.billboard.verticalOrigin.getValue(invalidTime)).toBeUndefined(); + expect(entity.billboard.color.getValue(invalidTime)).toBeUndefined(); + expect(entity.billboard.eyeOffset.getValue(invalidTime)).toBeUndefined(); + expect(entity.billboard.pixelOffset.getValue(invalidTime)).toBeUndefined(); + expect(entity.billboard.show.getValue(invalidTime)).toBeUndefined(); + }); }); it('can handle sampled billboard pixelOffset.', function() { @@ -667,16 +732,17 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(billboardPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.billboard).toBeDefined(); - var date1 = epoch; - var date2 = JulianDate.addSeconds(epoch, 0.5, new JulianDate()); - var date3 = JulianDate.addSeconds(epoch, 1.0, new JulianDate()); - expect(entity.billboard.pixelOffset.getValue(date1)).toEqual(new Cartesian2(1.0, 2.0)); - expect(entity.billboard.pixelOffset.getValue(date2)).toEqual(new Cartesian2(2.0, 3.0)); - expect(entity.billboard.pixelOffset.getValue(date3)).toEqual(new Cartesian2(3.0, 4.0)); + return dataSource.load(makePacket(billboardPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.billboard).toBeDefined(); + var date1 = epoch; + var date2 = JulianDate.addSeconds(epoch, 0.5, new JulianDate()); + var date3 = JulianDate.addSeconds(epoch, 1.0, new JulianDate()); + expect(entity.billboard.pixelOffset.getValue(date1)).toEqual(new Cartesian2(1.0, 2.0)); + expect(entity.billboard.pixelOffset.getValue(date2)).toEqual(new Cartesian2(2.0, 3.0)); + expect(entity.billboard.pixelOffset.getValue(date3)).toEqual(new Cartesian2(3.0, 4.0)); + }); }); it('can handle interval billboard scaleByDistance.', function() { @@ -693,12 +759,13 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(billboardPacket)); - var entity = dataSource.entities.values[0]; + return dataSource.load(makePacket(billboardPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; - expect(entity.billboard).toBeDefined(); - expect(entity.billboard.scaleByDistance.getValue(JulianDate.fromIso8601('2013-01-01T00:00:00Z'))).toEqual(new NearFarScalar(1.0, 2.0, 10000.0, 3.0)); - expect(entity.billboard.scaleByDistance.getValue(JulianDate.fromIso8601('2013-01-01T01:00:00Z'))).toEqual(new NearFarScalar(2.0, 3.0, 20000.0, 4.0)); + expect(entity.billboard).toBeDefined(); + expect(entity.billboard.scaleByDistance.getValue(JulianDate.fromIso8601('2013-01-01T00:00:00Z'))).toEqual(new NearFarScalar(1.0, 2.0, 10000.0, 3.0)); + expect(entity.billboard.scaleByDistance.getValue(JulianDate.fromIso8601('2013-01-01T01:00:00Z'))).toEqual(new NearFarScalar(2.0, 3.0, 20000.0, 4.0)); + }); }); it('can handle sampled billboard scaleByDistance.', function() { @@ -717,16 +784,17 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(billboardPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.billboard).toBeDefined(); - var date1 = epoch; - var date2 = JulianDate.addSeconds(epoch, 1.0, new JulianDate()); - var date3 = JulianDate.addSeconds(epoch, 2.0, new JulianDate()); - expect(entity.billboard.scaleByDistance.getValue(date1)).toEqual(new NearFarScalar(1.0, 2.0, 10000.0, 3.0)); - expect(entity.billboard.scaleByDistance.getValue(date2)).toEqual(new NearFarScalar(1.5, 2.5, 15000.0, 3.5)); - expect(entity.billboard.scaleByDistance.getValue(date3)).toEqual(new NearFarScalar(2.0, 3.0, 20000.0, 4.0)); + return dataSource.load(makePacket(billboardPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.billboard).toBeDefined(); + var date1 = epoch; + var date2 = JulianDate.addSeconds(epoch, 1.0, new JulianDate()); + var date3 = JulianDate.addSeconds(epoch, 2.0, new JulianDate()); + expect(entity.billboard.scaleByDistance.getValue(date1)).toEqual(new NearFarScalar(1.0, 2.0, 10000.0, 3.0)); + expect(entity.billboard.scaleByDistance.getValue(date2)).toEqual(new NearFarScalar(1.5, 2.5, 15000.0, 3.5)); + expect(entity.billboard.scaleByDistance.getValue(date3)).toEqual(new NearFarScalar(2.0, 3.0, 20000.0, 4.0)); + }); }); it('can handle sampled billboard color rgba.', function() { @@ -743,16 +811,17 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(billboardPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.billboard).toBeDefined(); - var date1 = epoch; - var date2 = JulianDate.addSeconds(epoch, 1.0, new JulianDate()); - var date3 = JulianDate.addSeconds(epoch, 2.0, new JulianDate()); - expect(entity.billboard.color.getValue(date1)).toEqual(Color.fromBytes(200, 202, 204, 206)); - expect(entity.billboard.color.getValue(date2)).toEqual(Color.fromBytes(100, 101, 102, 103)); - expect(entity.billboard.color.getValue(date3)).toEqual(Color.fromBytes(0, 0, 0, 0)); + return dataSource.load(makePacket(billboardPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.billboard).toBeDefined(); + var date1 = epoch; + var date2 = JulianDate.addSeconds(epoch, 1.0, new JulianDate()); + var date3 = JulianDate.addSeconds(epoch, 2.0, new JulianDate()); + expect(entity.billboard.color.getValue(date1)).toEqual(Color.fromBytes(200, 202, 204, 206)); + expect(entity.billboard.color.getValue(date2)).toEqual(Color.fromBytes(100, 101, 102, 103)); + expect(entity.billboard.color.getValue(date3)).toEqual(Color.fromBytes(0, 0, 0, 0)); + }); }); it('can handle clock data.', function() { @@ -777,15 +846,16 @@ defineSuite([ var step = ClockStep[clockPacket.clock.step]; var dataSource = new CzmlDataSource(); - dataSource.load(clockPacket); - - expect(dataSource.clock).toBeDefined(); - expect(dataSource.clock.startTime).toEqual(interval.start); - expect(dataSource.clock.stopTime).toEqual(interval.stop); - expect(dataSource.clock.currentTime).toEqual(currentTime); - expect(dataSource.clock.clockRange).toEqual(range); - expect(dataSource.clock.clockStep).toEqual(step); - expect(dataSource.clock.multiplier).toEqual(multiplier); + return dataSource.load(clockPacket).then(function(dataSource) { + + expect(dataSource.clock).toBeDefined(); + expect(dataSource.clock.startTime).toEqual(interval.start); + expect(dataSource.clock.stopTime).toEqual(interval.stop); + expect(dataSource.clock.currentTime).toEqual(currentTime); + expect(dataSource.clock.clockRange).toEqual(range); + expect(dataSource.clock.clockStep).toEqual(step); + expect(dataSource.clock.multiplier).toEqual(multiplier); + }); }); it('can handle position specified as constant cartographicsDegrees.', function() { @@ -796,11 +866,11 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(czml)); - - var entity = dataSource.entities.values[0]; - var resultCartesian = entity.position.getValue(JulianDate.now()); - expect(resultCartesian).toEqual(Cartesian3.fromDegrees(34, 117, 10000)); + return dataSource.load(makePacket(czml)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + var resultCartesian = entity.position.getValue(JulianDate.now()); + expect(resultCartesian).toEqual(Cartesian3.fromDegrees(34, 117, 10000)); + }); }); it('can handle position specified as sampled cartographicsDegrees.', function() { @@ -815,14 +885,14 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(czml)); - - var entity = dataSource.entities.values[0]; - var resultCartesian = entity.position.getValue(epoch); - expect(resultCartesian).toEqual(Cartesian3.fromDegrees(34, 117, 10000)); + return dataSource.load(makePacket(czml)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + var resultCartesian = entity.position.getValue(epoch); + expect(resultCartesian).toEqual(Cartesian3.fromDegrees(34, 117, 10000)); - resultCartesian = entity.position.getValue(JulianDate.addSeconds(epoch, 1, new JulianDate())); - expect(resultCartesian).toEqual(Cartesian3.fromDegrees(34, 117, 20000)); + resultCartesian = entity.position.getValue(JulianDate.addSeconds(epoch, 1, new JulianDate())); + expect(resultCartesian).toEqual(Cartesian3.fromDegrees(34, 117, 20000)); + }); }); it('can handle position specified as sampled cartographicDegrees without epoch.', function() { @@ -837,14 +907,14 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(czml)); - - var entity = dataSource.entities.values[0]; - var resultCartesian = entity.position.getValue(firstDate); - expect(resultCartesian).toEqual(Cartesian3.fromDegrees(34, 117, 10000)); + return dataSource.load(makePacket(czml)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + var resultCartesian = entity.position.getValue(firstDate); + expect(resultCartesian).toEqual(Cartesian3.fromDegrees(34, 117, 10000)); - resultCartesian = entity.position.getValue(lastDate); - expect(resultCartesian).toEqual(Cartesian3.fromDegrees(34, 117, 20000)); + resultCartesian = entity.position.getValue(lastDate); + expect(resultCartesian).toEqual(Cartesian3.fromDegrees(34, 117, 20000)); + }); }); it('can handle position specified as constant cartographicRadians.', function() { @@ -855,11 +925,11 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(czml)); - - var entity = dataSource.entities.values[0]; - var resultCartesian = entity.position.getValue(JulianDate.now()); - expect(resultCartesian).toEqual(Cartesian3.fromRadians(1, 2, 10000)); + return dataSource.load(makePacket(czml)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + var resultCartesian = entity.position.getValue(JulianDate.now()); + expect(resultCartesian).toEqual(Cartesian3.fromRadians(1, 2, 10000)); + }); }); it('can handle position specified as sampled cartographicRadians.', function() { @@ -874,14 +944,14 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(czml)); - - var entity = dataSource.entities.values[0]; - var resultCartesian = entity.position.getValue(epoch); - expect(resultCartesian).toEqual(Cartesian3.fromRadians(2, 0.3, 10000)); + return dataSource.load(makePacket(czml)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + var resultCartesian = entity.position.getValue(epoch); + expect(resultCartesian).toEqual(Cartesian3.fromRadians(2, 0.3, 10000)); - resultCartesian = entity.position.getValue(JulianDate.addSeconds(epoch, 1, new JulianDate())); - expect(resultCartesian).toEqual(Cartesian3.fromRadians(0.2, 0.5, 20000)); + resultCartesian = entity.position.getValue(JulianDate.addSeconds(epoch, 1, new JulianDate())); + expect(resultCartesian).toEqual(Cartesian3.fromRadians(0.2, 0.5, 20000)); + }); }); it('Can set reference frame', function() { @@ -896,21 +966,23 @@ defineSuite([ } }; - dataSource.load(makePacket(czml)); - var entity = dataSource.entities.values[0]; - expect(entity.position.referenceFrame).toBe(ReferenceFrame.INERTIAL); + return dataSource.load(makePacket(czml)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.position.referenceFrame).toBe(ReferenceFrame.INERTIAL); - czml = { - position : { - referenceFrame : 'FIXED', - epoch : JulianDate.toIso8601(epoch), - cartesian : [1.0, 2.0, 3.0] - } - }; + czml = { + position: { + referenceFrame: 'FIXED', + epoch: JulianDate.toIso8601(epoch), + cartesian: [1.0, 2.0, 3.0] + } + }; - dataSource.load(makePacket(czml)); - entity = dataSource.entities.values[0]; - expect(entity.position.referenceFrame).toBe(ReferenceFrame.FIXED); + return dataSource.load(makePacket(czml)); + }).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.position.referenceFrame).toBe(ReferenceFrame.FIXED); + }); }); it('uses FIXED as default if not specified in CZML', function() { @@ -924,9 +996,10 @@ defineSuite([ } }; - dataSource.load(makePacket(czml)); - var entity = dataSource.entities.values[0]; - expect(entity.position.referenceFrame).toBe(ReferenceFrame.FIXED); + return dataSource.load(makePacket(czml)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.position.referenceFrame).toBe(ReferenceFrame.FIXED); + }); }); it('Default reference frame on existing interval does not reset value to FIXED.', function() { @@ -941,19 +1014,21 @@ defineSuite([ } }; - dataSource.process(makePacket(czml)); - var entity = dataSource.entities.values[0]; - expect(entity.position.referenceFrame).toBe(ReferenceFrame.INERTIAL); + return dataSource.process(makePacket(czml)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.position.referenceFrame).toBe(ReferenceFrame.INERTIAL); - var czml2 = { - position : { - epoch : JulianDate.toIso8601(epoch), - cartesian : [1.0, 2.0, 3.0] - } - }; - dataSource.process(czml2); - - expect(entity.position.referenceFrame).toBe(ReferenceFrame.INERTIAL); + var czml2 = { + position: { + epoch: JulianDate.toIso8601(epoch), + cartesian: [1.0, 2.0, 3.0] + } + }; + return dataSource.process(czml2); + }).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.position.referenceFrame).toBe(ReferenceFrame.INERTIAL); + }); }); it('can handle a number specified as sampled values without epoch.', function() { @@ -971,13 +1046,14 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(ellipsePacket)); - var entity = dataSource.entities.values[0]; + return dataSource.load(makePacket(ellipsePacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; - expect(entity.ellipse).toBeDefined(); - expect(entity.ellipse.semiMajorAxis.getValue(firstDate)).toEqual(0); - expect(entity.ellipse.semiMajorAxis.getValue(midDate)).toEqual(5); - expect(entity.ellipse.semiMajorAxis.getValue(lastDate)).toEqual(10); + expect(entity.ellipse).toBeDefined(); + expect(entity.ellipse.semiMajorAxis.getValue(firstDate)).toEqual(0); + expect(entity.ellipse.semiMajorAxis.getValue(midDate)).toEqual(5); + expect(entity.ellipse.semiMajorAxis.getValue(lastDate)).toEqual(10); + }); }); it('can handle a direction specified as constant unitSpherical', function() { @@ -990,11 +1066,11 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(czml)); - - var entity = dataSource.entities.values[0]; - var resultCartesian = entity.billboard.alignedAxis.getValue(JulianDate.now()); - expect(resultCartesian).toEqual(Cartesian3.fromSpherical(new Spherical(1.0, 2.0))); + return dataSource.load(makePacket(czml)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + var resultCartesian = entity.billboard.alignedAxis.getValue(JulianDate.now()); + expect(resultCartesian).toEqual(Cartesian3.fromSpherical(new Spherical(1.0, 2.0))); + }); }); it('can handle a direction specified as sampled unitSpherical.', function() { @@ -1011,14 +1087,14 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(czml)); + return dataSource.load(makePacket(czml)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + var resultCartesian = entity.billboard.alignedAxis.getValue(epoch); + expect(resultCartesian).toEqual(Cartesian3.fromSpherical(new Spherical(1.0, 2.0))); - var entity = dataSource.entities.values[0]; - var resultCartesian = entity.billboard.alignedAxis.getValue(epoch); - expect(resultCartesian).toEqual(Cartesian3.fromSpherical(new Spherical(1.0, 2.0))); - - resultCartesian = entity.billboard.alignedAxis.getValue(JulianDate.addSeconds(epoch, 1, new JulianDate())); - expect(resultCartesian).toEqual(Cartesian3.fromSpherical(new Spherical(-1.0, -2.0))); + resultCartesian = entity.billboard.alignedAxis.getValue(JulianDate.addSeconds(epoch, 1, new JulianDate())); + expect(resultCartesian).toEqual(Cartesian3.fromSpherical(new Spherical(-1.0, -2.0))); + }); }); it('can handle a direction specified as constant spherical', function() { @@ -1031,11 +1107,13 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(czml)); - - var entity = dataSource.entities.values[0]; - var resultCartesian = entity.billboard.alignedAxis.getValue(JulianDate.now()); - expect(resultCartesian).toEqual(Cartesian3.fromSpherical(new Spherical(1.0, 2.0, 30.0))); + return dataSource.load(makePacket(czml)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + var resultCartesian = entity.billboard.alignedAxis.getValue(JulianDate.now()); + var expected = Cartesian3.fromSpherical(new Spherical(1.0, 2.0, 30.0)); + Cartesian3.normalize(expected, expected); + expect(resultCartesian).toEqual(expected); + }); }); it('can handle a direction specified as sampled spherical.', function() { @@ -1052,14 +1130,18 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(czml)); - - var entity = dataSource.entities.values[0]; - var resultCartesian = entity.billboard.alignedAxis.getValue(epoch); - expect(resultCartesian).toEqual(Cartesian3.fromSpherical(new Spherical(1.0, 2.0, 30.0))); - - resultCartesian = entity.billboard.alignedAxis.getValue(JulianDate.addSeconds(epoch, 1, new JulianDate())); - expect(resultCartesian).toEqual(Cartesian3.fromSpherical(new Spherical(-1.0, -2.0, 40.0))); + return dataSource.load(makePacket(czml)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + var resultCartesian = entity.billboard.alignedAxis.getValue(epoch); + var expected = Cartesian3.fromSpherical(new Spherical(1.0, 2.0, 30.0)); + Cartesian3.normalize(expected, expected); + expect(resultCartesian).toEqual(expected); + + resultCartesian = entity.billboard.alignedAxis.getValue(JulianDate.addSeconds(epoch, 1, new JulianDate())); + expected = Cartesian3.fromSpherical(new Spherical(-1.0, -2.0, 40.0)); + Cartesian3.normalize(expected, expected); + expect(resultCartesian).toEqual(expected); + }); }); it('CZML adds data for infinite ellipse.', function() { @@ -1078,17 +1160,18 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(ellipsePacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.ellipse).toBeDefined(); - expect(entity.ellipse.semiMajorAxis.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ellipsePacket.ellipse.semiMajorAxis); - expect(entity.ellipse.semiMinorAxis.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ellipsePacket.ellipse.semiMinorAxis); - expect(entity.ellipse.rotation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ellipsePacket.ellipse.rotation); - expect(entity.ellipse.outline.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); - expect(entity.ellipse.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); - expect(entity.ellipse.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); - expect(entity.ellipse.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + return dataSource.load(makePacket(ellipsePacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.ellipse).toBeDefined(); + expect(entity.ellipse.semiMajorAxis.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ellipsePacket.ellipse.semiMajorAxis); + expect(entity.ellipse.semiMinorAxis.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ellipsePacket.ellipse.semiMinorAxis); + expect(entity.ellipse.rotation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ellipsePacket.ellipse.rotation); + expect(entity.ellipse.outline.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + expect(entity.ellipse.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); + expect(entity.ellipse.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); + expect(entity.ellipse.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + }); }); it('CZML adds data for constrained ellipse.', function() { @@ -1103,24 +1186,25 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(ellipsePacketInterval)); - var entity = dataSource.entities.values[0]; - - var validTime = TimeInterval.fromIso8601({ - iso8601 : ellipsePacketInterval.ellipse.interval - }).start; - var invalidTime = JulianDate.addSeconds(validTime, -1, new JulianDate()); - - expect(entity.ellipse).toBeDefined(); - expect(entity.ellipse.semiMajorAxis.getValue(validTime)).toEqual(ellipsePacketInterval.ellipse.semiMajorAxis); - expect(entity.ellipse.semiMinorAxis.getValue(validTime)).toEqual(ellipsePacketInterval.ellipse.semiMinorAxis); - expect(entity.ellipse.rotation.getValue(validTime)).toEqual(ellipsePacketInterval.ellipse.rotation); - expect(entity.ellipse.shadows.getValue(validTime)).toEqual(ShadowMode.ENABLED); - - expect(entity.ellipse.semiMajorAxis.getValue(invalidTime)).toBeUndefined(); - expect(entity.ellipse.semiMinorAxis.getValue(invalidTime)).toBeUndefined(); - expect(entity.ellipse.rotation.getValue(invalidTime)).toBeUndefined(); - expect(entity.ellipse.shadows.getValue(invalidTime)).toBeUndefined(); + return dataSource.load(makePacket(ellipsePacketInterval)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + var validTime = TimeInterval.fromIso8601({ + iso8601: ellipsePacketInterval.ellipse.interval + }).start; + var invalidTime = JulianDate.addSeconds(validTime, -1, new JulianDate()); + + expect(entity.ellipse).toBeDefined(); + expect(entity.ellipse.semiMajorAxis.getValue(validTime)).toEqual(ellipsePacketInterval.ellipse.semiMajorAxis); + expect(entity.ellipse.semiMinorAxis.getValue(validTime)).toEqual(ellipsePacketInterval.ellipse.semiMinorAxis); + expect(entity.ellipse.rotation.getValue(validTime)).toEqual(ellipsePacketInterval.ellipse.rotation); + expect(entity.ellipse.shadows.getValue(validTime)).toEqual(ShadowMode.ENABLED); + + expect(entity.ellipse.semiMajorAxis.getValue(invalidTime)).toBeUndefined(); + expect(entity.ellipse.semiMinorAxis.getValue(invalidTime)).toBeUndefined(); + expect(entity.ellipse.rotation.getValue(invalidTime)).toBeUndefined(); + expect(entity.ellipse.shadows.getValue(invalidTime)).toBeUndefined(); + }); }); it('CZML adds data for infinite ellipsoid.', function() { @@ -1152,20 +1236,21 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(ellipsoidPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.ellipsoid).toBeDefined(); - expect(entity.ellipsoid.radii.getValue(Iso8601.MINIMUM_VALUE)).toEqual(expectedRadii); - expect(entity.ellipsoid.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ellipsoidPacket.ellipsoid.show); - expect(entity.ellipsoid.material.getValue(Iso8601.MINIMUM_VALUE).color).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); - expect(entity.ellipsoid.outline.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); - expect(entity.ellipsoid.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); - expect(entity.ellipsoid.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); - expect(entity.ellipsoid.stackPartitions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(25); - expect(entity.ellipsoid.slicePartitions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(26); - expect(entity.ellipsoid.subdivisions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(27); - expect(entity.ellipsoid.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + return dataSource.load(makePacket(ellipsoidPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.ellipsoid).toBeDefined(); + expect(entity.ellipsoid.radii.getValue(Iso8601.MINIMUM_VALUE)).toEqual(expectedRadii); + expect(entity.ellipsoid.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ellipsoidPacket.ellipsoid.show); + expect(entity.ellipsoid.material.getValue(Iso8601.MINIMUM_VALUE).color).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); + expect(entity.ellipsoid.outline.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + expect(entity.ellipsoid.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); + expect(entity.ellipsoid.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); + expect(entity.ellipsoid.stackPartitions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(25); + expect(entity.ellipsoid.slicePartitions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(26); + expect(entity.ellipsoid.subdivisions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(27); + expect(entity.ellipsoid.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + }); }); it('CZML adds data for constrained ellipsoid.', function() { @@ -1190,24 +1275,25 @@ defineSuite([ }; var validTime = TimeInterval.fromIso8601({ - iso8601 : ellipsoidPacketInterval.ellipsoid.interval + iso8601: ellipsoidPacketInterval.ellipsoid.interval }).start; var invalidTime = JulianDate.addSeconds(validTime, -1, new JulianDate()); var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(ellipsoidPacketInterval)); - var entity = dataSource.entities.values[0]; - - expect(entity.ellipsoid).toBeDefined(); - expect(entity.ellipsoid.radii.getValue(validTime)).toEqual(expectedRadii); - expect(entity.ellipsoid.show.getValue(validTime)).toEqual(ellipsoidPacketInterval.ellipsoid.show); - expect(entity.ellipsoid.material.getValue(validTime).color).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); - expect(entity.ellipsoid.shadows.getValue(validTime)).toEqual(ShadowMode.ENABLED); - - expect(entity.ellipsoid.radii.getValue(invalidTime)).toBeUndefined(); - expect(entity.ellipsoid.show.getValue(invalidTime)).toBeUndefined(); - expect(entity.ellipsoid.material.getValue(invalidTime)).toBeUndefined(); - expect(entity.ellipsoid.shadows.getValue(invalidTime)).toBeUndefined(); + return dataSource.load(makePacket(ellipsoidPacketInterval)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.ellipsoid).toBeDefined(); + expect(entity.ellipsoid.radii.getValue(validTime)).toEqual(expectedRadii); + expect(entity.ellipsoid.show.getValue(validTime)).toEqual(ellipsoidPacketInterval.ellipsoid.show); + expect(entity.ellipsoid.material.getValue(validTime).color).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); + expect(entity.ellipsoid.shadows.getValue(validTime)).toEqual(ShadowMode.ENABLED); + + expect(entity.ellipsoid.radii.getValue(invalidTime)).toBeUndefined(); + expect(entity.ellipsoid.show.getValue(invalidTime)).toBeUndefined(); + expect(entity.ellipsoid.material.getValue(invalidTime)).toBeUndefined(); + expect(entity.ellipsoid.shadows.getValue(invalidTime)).toBeUndefined(); + }); }); it('CZML adds data for infinite label.', function() { @@ -1243,24 +1329,25 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(labelPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.label).toBeDefined(); - expect(entity.label.text.getValue(Iso8601.MINIMUM_VALUE)).toEqual(labelPacket.label.text); - expect(entity.label.font.getValue(Iso8601.MINIMUM_VALUE)).toEqual(labelPacket.label.font); - expect(entity.label.style.getValue(Iso8601.MINIMUM_VALUE)).toEqual(LabelStyle.FILL); - expect(entity.label.fillColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); - expect(entity.label.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); - expect(entity.label.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(labelPacket.label.outlineWidth); - expect(entity.label.horizontalOrigin.getValue(Iso8601.MINIMUM_VALUE)).toEqual(HorizontalOrigin.LEFT); - expect(entity.label.verticalOrigin.getValue(Iso8601.MINIMUM_VALUE)).toEqual(VerticalOrigin.CENTER); - expect(entity.label.eyeOffset.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(1.0, 2.0, 3.0)); - expect(entity.label.pixelOffset.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian2(4.0, 5.0)); - expect(entity.label.scale.getValue(Iso8601.MINIMUM_VALUE)).toEqual(labelPacket.label.scale); - expect(entity.label.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(labelPacket.label.show); - expect(entity.label.translucencyByDistance.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new NearFarScalar(1.0, 1.0, 10000.0, 0.0)); - expect(entity.label.pixelOffsetScaleByDistance.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new NearFarScalar(1.0, 20.0, 10000.0, 30.0)); + return dataSource.load(makePacket(labelPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.label).toBeDefined(); + expect(entity.label.text.getValue(Iso8601.MINIMUM_VALUE)).toEqual(labelPacket.label.text); + expect(entity.label.font.getValue(Iso8601.MINIMUM_VALUE)).toEqual(labelPacket.label.font); + expect(entity.label.style.getValue(Iso8601.MINIMUM_VALUE)).toEqual(LabelStyle.FILL); + expect(entity.label.fillColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); + expect(entity.label.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); + expect(entity.label.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(labelPacket.label.outlineWidth); + expect(entity.label.horizontalOrigin.getValue(Iso8601.MINIMUM_VALUE)).toEqual(HorizontalOrigin.LEFT); + expect(entity.label.verticalOrigin.getValue(Iso8601.MINIMUM_VALUE)).toEqual(VerticalOrigin.CENTER); + expect(entity.label.eyeOffset.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(1.0, 2.0, 3.0)); + expect(entity.label.pixelOffset.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian2(4.0, 5.0)); + expect(entity.label.scale.getValue(Iso8601.MINIMUM_VALUE)).toEqual(labelPacket.label.scale); + expect(entity.label.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(labelPacket.label.show); + expect(entity.label.translucencyByDistance.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new NearFarScalar(1.0, 1.0, 10000.0, 0.0)); + expect(entity.label.pixelOffsetScaleByDistance.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new NearFarScalar(1.0, 20.0, 10000.0, 30.0)); + }); }); it('CZML adds data for constrained label.', function() { @@ -1291,39 +1378,40 @@ defineSuite([ }; var validTime = TimeInterval.fromIso8601({ - iso8601 : labelPacket.label.interval + iso8601: labelPacket.label.interval }).start; var invalidTime = JulianDate.addSeconds(validTime, -1, new JulianDate()); var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(labelPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.label).toBeDefined(); - expect(entity.label.text.getValue(validTime)).toEqual(labelPacket.label.text); - expect(entity.label.font.getValue(validTime)).toEqual(labelPacket.label.font); - expect(entity.label.style.getValue(validTime)).toEqual(LabelStyle.FILL); - expect(entity.label.fillColor.getValue(validTime)).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); - expect(entity.label.outlineColor.getValue(validTime)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); - expect(entity.label.outlineWidth.getValue(validTime)).toEqual(labelPacket.label.outlineWidth); - expect(entity.label.horizontalOrigin.getValue(validTime)).toEqual(HorizontalOrigin.LEFT); - expect(entity.label.verticalOrigin.getValue(validTime)).toEqual(VerticalOrigin.CENTER); - expect(entity.label.eyeOffset.getValue(validTime)).toEqual(new Cartesian3(1.0, 2.0, 3.0)); - expect(entity.label.pixelOffset.getValue(validTime)).toEqual(new Cartesian2(4.0, 5.0)); - expect(entity.label.scale.getValue(validTime)).toEqual(labelPacket.label.scale); - expect(entity.label.show.getValue(validTime)).toEqual(labelPacket.label.show); - expect(entity.label.text.getValue(invalidTime)).toBeUndefined(); - expect(entity.label.font.getValue(invalidTime)).toBeUndefined(); - expect(entity.label.style.getValue(invalidTime)).toBeUndefined(); - expect(entity.label.fillColor.getValue(invalidTime)).toBeUndefined(); - expect(entity.label.outlineColor.getValue(invalidTime)).toBeUndefined(); - expect(entity.label.outlineWidth.getValue(invalidTime)).toBeUndefined(); - expect(entity.label.horizontalOrigin.getValue(invalidTime)).toBeUndefined(); - expect(entity.label.verticalOrigin.getValue(invalidTime)).toBeUndefined(); - expect(entity.label.eyeOffset.getValue(invalidTime)).toBeUndefined(); - expect(entity.label.pixelOffset.getValue(invalidTime)).toBeUndefined(); - expect(entity.label.scale.getValue(invalidTime)).toBeUndefined(); - expect(entity.label.show.getValue(invalidTime)).toBeUndefined(); + return dataSource.load(makePacket(labelPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.label).toBeDefined(); + expect(entity.label.text.getValue(validTime)).toEqual(labelPacket.label.text); + expect(entity.label.font.getValue(validTime)).toEqual(labelPacket.label.font); + expect(entity.label.style.getValue(validTime)).toEqual(LabelStyle.FILL); + expect(entity.label.fillColor.getValue(validTime)).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); + expect(entity.label.outlineColor.getValue(validTime)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); + expect(entity.label.outlineWidth.getValue(validTime)).toEqual(labelPacket.label.outlineWidth); + expect(entity.label.horizontalOrigin.getValue(validTime)).toEqual(HorizontalOrigin.LEFT); + expect(entity.label.verticalOrigin.getValue(validTime)).toEqual(VerticalOrigin.CENTER); + expect(entity.label.eyeOffset.getValue(validTime)).toEqual(new Cartesian3(1.0, 2.0, 3.0)); + expect(entity.label.pixelOffset.getValue(validTime)).toEqual(new Cartesian2(4.0, 5.0)); + expect(entity.label.scale.getValue(validTime)).toEqual(labelPacket.label.scale); + expect(entity.label.show.getValue(validTime)).toEqual(labelPacket.label.show); + expect(entity.label.text.getValue(invalidTime)).toBeUndefined(); + expect(entity.label.font.getValue(invalidTime)).toBeUndefined(); + expect(entity.label.style.getValue(invalidTime)).toBeUndefined(); + expect(entity.label.fillColor.getValue(invalidTime)).toBeUndefined(); + expect(entity.label.outlineColor.getValue(invalidTime)).toBeUndefined(); + expect(entity.label.outlineWidth.getValue(invalidTime)).toBeUndefined(); + expect(entity.label.horizontalOrigin.getValue(invalidTime)).toBeUndefined(); + expect(entity.label.verticalOrigin.getValue(invalidTime)).toBeUndefined(); + expect(entity.label.eyeOffset.getValue(invalidTime)).toBeUndefined(); + expect(entity.label.pixelOffset.getValue(invalidTime)).toBeUndefined(); + expect(entity.label.scale.getValue(invalidTime)).toBeUndefined(); + expect(entity.label.show.getValue(invalidTime)).toBeUndefined(); + }); }); it('can handle sampled label pixelOffset.', function() { @@ -1339,14 +1427,15 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(labelPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.label).toBeDefined(); - var date1 = epoch; - var date2 = JulianDate.addSeconds(epoch, 1.0, new JulianDate()); - expect(entity.label.pixelOffset.getValue(date1)).toEqual(new Cartesian2(1.0, 2.0)); - expect(entity.label.pixelOffset.getValue(date2)).toEqual(new Cartesian2(3.0, 4.0)); + return dataSource.load(makePacket(labelPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.label).toBeDefined(); + var date1 = epoch; + var date2 = JulianDate.addSeconds(epoch, 1.0, new JulianDate()); + expect(entity.label.pixelOffset.getValue(date1)).toEqual(new Cartesian2(1.0, 2.0)); + expect(entity.label.pixelOffset.getValue(date2)).toEqual(new Cartesian2(3.0, 4.0)); + }); }); it('CZML Position works.', function() { @@ -1357,9 +1446,10 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.values[0]; - expect(entity.position.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(1.0, 2.0, 3.0)); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.position.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(1.0, 2.0, 3.0)); + }); }); it('CZML Orientation works.', function() { @@ -1370,9 +1460,10 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.values[0]; - expect(entity.orientation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Quaternion(0.0, 0.0, 0.0, 1.0)); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.orientation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Quaternion(0.0, 0.0, 0.0, 1.0)); + }); }); it('CZML Orientation is normalized on load.', function() { @@ -1386,9 +1477,10 @@ defineSuite([ Quaternion.normalize(expected, expected); var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.values[0]; - expect(entity.orientation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(expected); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.orientation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(expected); + }); }); it('CZML Orientation is normalized on load.', function() { @@ -1407,10 +1499,40 @@ defineSuite([ Quaternion.normalize(expected2, expected2); var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.values[0]; - expect(entity.orientation.getValue(JulianDate.fromIso8601(time1))).toEqual(expected1); - expect(entity.orientation.getValue(JulianDate.fromIso8601(time2))).toEqual(expected2); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.orientation.getValue(JulianDate.fromIso8601(time1))).toEqual(expected1); + expect(entity.orientation.getValue(JulianDate.fromIso8601(time2))).toEqual(expected2); + }); + }); + + it('can handle orientation expressed as a velocity reference', function() { + var packet = { + "position" : { + "epoch" : "2016-06-17T12:00:00Z", + "cartesian" : [0, 1, 2, 3, + 60, 61, 122, 183] + }, + "orientation": { + "velocityReference": "#position" + } + }; + + var dataSource = new CzmlDataSource(); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + var property = entity.orientation; + + var expectedVelocity = new Cartesian3(1.0, 2.0, 3.0); + var expectedVelocityDirection = Cartesian3.normalize(expectedVelocity, new Cartesian3()); + + var expectedPosition = new Cartesian3(1, 2, 3); + var expectedRotation = Transforms.rotationMatrixFromPositionVelocity(expectedPosition, expectedVelocityDirection); + var expectedOrientation = Quaternion.fromRotationMatrix(expectedRotation); + + expect(property.getValue(JulianDate.fromIso8601('2016-06-17T12:00:00Z'))).toEqualEpsilon(expectedOrientation, CesiumMath.EPSILON15); + expect(property.getValue(JulianDate.fromIso8601('2016-06-17T12:00:30Z'))).toEqualEpsilon(expectedOrientation, CesiumMath.EPSILON15); + }); }); it('positions work with cartesians.', function() { @@ -1425,9 +1547,10 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.values[0]; - expect(entity.polyline.positions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(expectedResult); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.polyline.positions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(expectedResult); + }); }); it('positions work with cartographicRadians.', function() { @@ -1443,9 +1566,10 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.values[0]; - expect(entity.polyline.positions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(expectedResult); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.polyline.positions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(expectedResult); + }); }); it('positions work with cartographicDegrees.', function() { @@ -1463,9 +1587,10 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.values[0]; - expect(entity.polyline.positions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(expectedResult); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.polyline.positions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(expectedResult); + }); }); it('CZML ViewFrom works.', function() { @@ -1476,9 +1601,10 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.values[0]; - expect(entity.viewFrom.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(1.0, 2.0, 3.0)); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.viewFrom.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(1.0, 2.0, 3.0)); + }); }); it('CZML description works.', function() { @@ -1487,9 +1613,10 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.values[0]; - expect(entity.description.getValue(Iso8601.MINIMUM_VALUE)).toEqual(packet.description); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.description.getValue(Iso8601.MINIMUM_VALUE)).toEqual(packet.description); + }); }); it('works with properties that are constant.', function() { @@ -1514,12 +1641,13 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.values[0]; - expect(entity.properties.constant_name.getValue(Iso8601.MINIMUM_VALUE)).toEqual(packet.properties.constant_name); - expect(entity.properties.constant_height.getValue(Iso8601.MINIMUM_VALUE)).toEqual(packet.properties.constant_height); - expect(entity.properties.constant_object.getValue(Iso8601.MINIMUM_VALUE)).toEqual(testObject); - expect(entity.properties.constant_array.getValue(Iso8601.MINIMUM_VALUE)).toEqual(testArray); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.properties.constant_name.getValue(Iso8601.MINIMUM_VALUE)).toEqual(packet.properties.constant_name); + expect(entity.properties.constant_height.getValue(Iso8601.MINIMUM_VALUE)).toEqual(packet.properties.constant_height); + expect(entity.properties.constant_object.getValue(Iso8601.MINIMUM_VALUE)).toEqual(testObject); + expect(entity.properties.constant_array.getValue(Iso8601.MINIMUM_VALUE)).toEqual(testArray); + }); }); it('works with properties which are constant with specified type.', function() { @@ -1548,12 +1676,13 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.values[0]; - expect(entity.properties.constant_name.getValue(Iso8601.MINIMUM_VALUE)).toEqual(packet.properties.constant_name.string); - expect(entity.properties.constant_height.getValue(Iso8601.MINIMUM_VALUE)).toEqual(packet.properties.constant_height.number); - expect(entity.properties.constant_object.getValue(Iso8601.MINIMUM_VALUE)).toEqual(testObject); - expect(entity.properties.constant_array.getValue(Iso8601.MINIMUM_VALUE)).toEqual(testArray); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.properties.constant_name.getValue(Iso8601.MINIMUM_VALUE)).toEqual(packet.properties.constant_name.string); + expect(entity.properties.constant_height.getValue(Iso8601.MINIMUM_VALUE)).toEqual(packet.properties.constant_height.number); + expect(entity.properties.constant_object.getValue(Iso8601.MINIMUM_VALUE)).toEqual(testObject); + expect(entity.properties.constant_array.getValue(Iso8601.MINIMUM_VALUE)).toEqual(testArray); + }); }); it('works with properties with one interval.', function() { @@ -1567,14 +1696,15 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.values[0]; + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; - var time1 = JulianDate.fromIso8601('2013'); - var time2 = JulianDate.fromIso8601('2015'); + var time1 = JulianDate.fromIso8601('2013'); + var time2 = JulianDate.fromIso8601('2015'); - expect(entity.properties.changing_name.getValue(time1)).toEqual('ABC'); - expect(entity.properties.changing_name.getValue(time2)).toBeUndefined(); + expect(entity.properties.changing_name.getValue(time1)).toEqual('ABC'); + expect(entity.properties.changing_name.getValue(time2)).toBeUndefined(); + }); }); it('works with properties with one interval with specified type.', function() { @@ -1588,14 +1718,15 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.values[0]; + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; - var time1 = JulianDate.fromIso8601('2013'); - var time2 = JulianDate.fromIso8601('2015'); + var time1 = JulianDate.fromIso8601('2013'); + var time2 = JulianDate.fromIso8601('2015'); - expect(entity.properties.changing_name.getValue(time1)).toEqual('ABC'); - expect(entity.properties.changing_name.getValue(time2)).toBeUndefined(); + expect(entity.properties.changing_name.getValue(time1)).toEqual('ABC'); + expect(entity.properties.changing_name.getValue(time2)).toBeUndefined(); + }); }); it('works with properties with multiple intervals.', function() { @@ -1617,14 +1748,15 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.values[0]; + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; - var time1 = JulianDate.fromIso8601('2012-06-01'); - var time2 = JulianDate.fromIso8601('2013-06-01'); + var time1 = JulianDate.fromIso8601('2012-06-01'); + var time2 = JulianDate.fromIso8601('2013-06-01'); - expect(entity.properties.changing_array.getValue(time1)).toEqual(array1); - expect(entity.properties.changing_array.getValue(time2)).toEqual(array2); + expect(entity.properties.changing_array.getValue(time1)).toEqual(array1); + expect(entity.properties.changing_array.getValue(time2)).toEqual(array2); + }); }); it('handles boolean custom properties with intervals.', function() { @@ -1649,15 +1781,16 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.getById('MyID'); - expect(entity).toBeDefined(); - expect(entity.properties).toBeDefined(); - expect(entity.properties.custom_boolean).toBeDefined(); - - expect(entity.properties.custom_boolean.getValue(JulianDate.fromIso8601('2012-04-02T12:00:00Z'))).toEqual(true); - expect(entity.properties.custom_boolean.getValue(JulianDate.fromIso8601('2012-04-02T12:00:01Z'))).toEqual(false); - expect(entity.properties.custom_boolean.getValue(JulianDate.fromIso8601('2012-04-02T12:00:02Z'))).toEqual(true); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.getById('MyID'); + expect(entity).toBeDefined(); + expect(entity.properties).toBeDefined(); + expect(entity.properties.custom_boolean).toBeDefined(); + + expect(entity.properties.custom_boolean.getValue(JulianDate.fromIso8601('2012-04-02T12:00:00Z'))).toEqual(true); + expect(entity.properties.custom_boolean.getValue(JulianDate.fromIso8601('2012-04-02T12:00:01Z'))).toEqual(false); + expect(entity.properties.custom_boolean.getValue(JulianDate.fromIso8601('2012-04-02T12:00:02Z'))).toEqual(true); + }); }); it('works with properties with multiple intervals with specified type.', function() { @@ -1679,14 +1812,15 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.values[0]; + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; - var time1 = JulianDate.fromIso8601('2012-06-01'); - var time2 = JulianDate.fromIso8601('2013-06-01'); + var time1 = JulianDate.fromIso8601('2012-06-01'); + var time2 = JulianDate.fromIso8601('2013-06-01'); - expect(entity.properties.changing_array.getValue(time1)).toEqual(array1); - expect(entity.properties.changing_array.getValue(time2)).toEqual(array2); + expect(entity.properties.changing_array.getValue(time1)).toEqual(array1); + expect(entity.properties.changing_array.getValue(time2)).toEqual(array2); + }); }); it('handles sampled custom properties.', function() { @@ -1705,18 +1839,19 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.getById('MyID'); - expect(entity).toBeDefined(); - expect(entity.properties).toBeDefined(); - expect(entity.properties.custom_cartesian).toBeDefined(); - - expect(entity.properties.custom_cartesian.getValue(JulianDate.fromIso8601('2012-04-02T12:00:00Z'))).toBeInstanceOf(Cartesian3); - expect(entity.properties.custom_cartesian.getValue(JulianDate.fromIso8601('2012-04-02T12:00:00Z'))).toEqual(new Cartesian3(1, 2, 3)); - // halfway between two samples, linearly interpolated - expect(entity.properties.custom_cartesian.getValue(JulianDate.fromIso8601('2012-04-02T12:00:30Z'))).toEqual(new Cartesian3((1 + 4) / 2, (2 + 5) / 2, (3 + 6) / 2)); - expect(entity.properties.custom_cartesian.getValue(JulianDate.fromIso8601('2012-04-02T12:01:00Z'))).toEqual(new Cartesian3(4, 5, 6)); - expect(entity.properties.custom_cartesian.getValue(JulianDate.fromIso8601('2012-04-02T12:02:00Z'))).toEqual(new Cartesian3(7, 8, 9)); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.getById('MyID'); + expect(entity).toBeDefined(); + expect(entity.properties).toBeDefined(); + expect(entity.properties.custom_cartesian).toBeDefined(); + + expect(entity.properties.custom_cartesian.getValue(JulianDate.fromIso8601('2012-04-02T12:00:00Z'))).toBeInstanceOf(Cartesian3); + expect(entity.properties.custom_cartesian.getValue(JulianDate.fromIso8601('2012-04-02T12:00:00Z'))).toEqual(new Cartesian3(1, 2, 3)); + // halfway between two samples, linearly interpolated + expect(entity.properties.custom_cartesian.getValue(JulianDate.fromIso8601('2012-04-02T12:00:30Z'))).toEqual(new Cartesian3((1 + 4) / 2, (2 + 5) / 2, (3 + 6) / 2)); + expect(entity.properties.custom_cartesian.getValue(JulianDate.fromIso8601('2012-04-02T12:01:00Z'))).toEqual(new Cartesian3(4, 5, 6)); + expect(entity.properties.custom_cartesian.getValue(JulianDate.fromIso8601('2012-04-02T12:02:00Z'))).toEqual(new Cartesian3(7, 8, 9)); + }); }); it('handles various types of custom properties.', function() { @@ -1848,94 +1983,95 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.getById('MyID'); - expect(entity).toBeDefined(); - expect(entity.properties).toBeDefined(); - - var time1 = JulianDate.fromIso8601('2012-06-01'); - var time2 = JulianDate.fromIso8601('2013-06-01'); - - expect(entity.properties.custom_array_constant).toBeDefined(); - expect(entity.properties.custom_array_constant.getValue(time1)).toBeInstanceOf(Array); - expect(entity.properties.custom_array_constant.getValue(time1)).toEqual(packet.properties.custom_array_constant.array); - - expect(entity.properties.custom_array_interval).toBeDefined(); - expect(entity.properties.custom_array_interval.getValue(time1)).toBeInstanceOf(Array); - expect(entity.properties.custom_array_interval.getValue(time1)).toEqual(packet.properties.custom_array_interval[0].array); - expect(entity.properties.custom_array_interval.getValue(time2)).toEqual(packet.properties.custom_array_interval[1].array); - - expect(entity.properties.custom_boolean_constant).toBeDefined(); - expect(entity.properties.custom_boolean_constant.getValue(time1)).toEqual(packet.properties.custom_boolean_constant.boolean); - - expect(entity.properties.custom_boolean_interval).toBeDefined(); - expect(entity.properties.custom_boolean_interval.getValue(time1)).toEqual(packet.properties.custom_boolean_interval[0].boolean); - expect(entity.properties.custom_boolean_interval.getValue(time2)).toEqual(packet.properties.custom_boolean_interval[1].boolean); - - expect(entity.properties.custom_boundingRectangle_constant).toBeDefined(); - expect(entity.properties.custom_boundingRectangle_constant.getValue(time1)).toBeInstanceOf(BoundingRectangle); - expect(entity.properties.custom_boundingRectangle_constant.getValue(time1)).toEqual(BoundingRectangle.unpack(packet.properties.custom_boundingRectangle_constant.boundingRectangle)); - - expect(entity.properties.custom_boundingRectangle_interval).toBeDefined(); - expect(entity.properties.custom_boundingRectangle_interval.getValue(time1)).toBeInstanceOf(BoundingRectangle); - expect(entity.properties.custom_boundingRectangle_interval.getValue(time1)).toEqual(BoundingRectangle.unpack(packet.properties.custom_boundingRectangle_interval[0].boundingRectangle)); - expect(entity.properties.custom_boundingRectangle_interval.getValue(time2)).toEqual(BoundingRectangle.unpack(packet.properties.custom_boundingRectangle_interval[1].boundingRectangle)); - - expect(entity.properties.custom_boundingRectangle_sampled).toBeDefined(); - expect(entity.properties.custom_boundingRectangle_sampled.getValue(time1)).toBeInstanceOf(BoundingRectangle); - expect(entity.properties.custom_boundingRectangle_sampled.getValue(time1)).toEqual(BoundingRectangle.unpack(packet.properties.custom_boundingRectangle_sampled.boundingRectangle, 0 + 1)); - expect(entity.properties.custom_boundingRectangle_sampled.getValue(JulianDate.addSeconds(time1, 60, new JulianDate()))).toEqual(BoundingRectangle.unpack(packet.properties.custom_boundingRectangle_sampled.boundingRectangle, 4 + 2)); - - expect(entity.properties.custom_cartesian2_constant).toBeDefined(); - expect(entity.properties.custom_cartesian2_constant.getValue(time1)).toBeInstanceOf(Cartesian2); - expect(entity.properties.custom_cartesian2_constant.getValue(time1)).toEqual(Cartesian2.unpack(packet.properties.custom_cartesian2_constant.cartesian2)); - - expect(entity.properties.custom_cartesian2_interval).toBeDefined(); - expect(entity.properties.custom_cartesian2_interval.getValue(time1)).toBeInstanceOf(Cartesian2); - expect(entity.properties.custom_cartesian2_interval.getValue(time1)).toEqual(Cartesian2.unpack(packet.properties.custom_cartesian2_interval[0].cartesian2)); - expect(entity.properties.custom_cartesian2_interval.getValue(time2)).toEqual(Cartesian2.unpack(packet.properties.custom_cartesian2_interval[1].cartesian2)); - - expect(entity.properties.custom_cartesian2_sampled).toBeDefined(); - expect(entity.properties.custom_cartesian2_sampled.getValue(time1)).toBeInstanceOf(Cartesian2); - expect(entity.properties.custom_cartesian2_sampled.getValue(time1)).toEqual(Cartesian2.unpack(packet.properties.custom_cartesian2_sampled.cartesian2, 0 + 1)); - expect(entity.properties.custom_cartesian2_sampled.getValue(JulianDate.addSeconds(time1, 60, new JulianDate()))).toEqual(Cartesian2.unpack(packet.properties.custom_cartesian2_sampled.cartesian2, 2 + 2)); - - expect(entity.properties.custom_cartesian_constant).toBeDefined(); - expect(entity.properties.custom_cartesian_constant.getValue(time1)).toBeInstanceOf(Cartesian3); - expect(entity.properties.custom_cartesian_constant.getValue(time1)).toEqual(Cartesian3.unpack(packet.properties.custom_cartesian_constant.cartesian)); - - expect(entity.properties.custom_cartesian_interval).toBeDefined(); - expect(entity.properties.custom_cartesian_interval.getValue(time1)).toBeInstanceOf(Cartesian3); - expect(entity.properties.custom_cartesian_interval.getValue(time1)).toEqual(Cartesian3.unpack(packet.properties.custom_cartesian_interval[0].cartesian)); - expect(entity.properties.custom_cartesian_interval.getValue(time2)).toEqual(Cartesian3.unpack(packet.properties.custom_cartesian_interval[1].cartesian)); - - expect(entity.properties.custom_cartesian_sampled).toBeDefined(); - expect(entity.properties.custom_cartesian_sampled.getValue(time1)).toBeInstanceOf(Cartesian3); - expect(entity.properties.custom_cartesian_sampled.getValue(time1)).toEqual(Cartesian3.unpack(packet.properties.custom_cartesian_sampled.cartesian, 0 + 1)); - expect(entity.properties.custom_cartesian_sampled.getValue(JulianDate.addSeconds(time1, 60, new JulianDate()))).toEqual(Cartesian3.unpack(packet.properties.custom_cartesian_sampled.cartesian, 3 + 2)); - - expect(entity.properties.custom_color_constant).toBeDefined(); - expect(entity.properties.custom_color_constant.getValue(time1)).toBeInstanceOf(Color); - expect(entity.properties.custom_color_constant.getValue(time1)).toEqual(Color.unpack(packet.properties.custom_color_constant.rgbaf)); - - expect(entity.properties.custom_color_interval).toBeDefined(); - expect(entity.properties.custom_color_interval.getValue(time1)).toBeInstanceOf(Color); - expect(entity.properties.custom_color_interval.getValue(time1)).toEqual(Color.unpack(packet.properties.custom_color_interval[0].rgbaf)); - expect(entity.properties.custom_color_interval.getValue(time2)).toEqual(Color.unpack(packet.properties.custom_color_interval[1].rgbaf)); - - expect(entity.properties.custom_color_sampled).toBeDefined(); - expect(entity.properties.custom_color_sampled.getValue(time1)).toBeInstanceOf(Color); - expect(entity.properties.custom_color_sampled.getValue(time1)).toEqual(Color.unpack(packet.properties.custom_color_sampled.rgbaf, 0 + 1)); - expect(entity.properties.custom_color_sampled.getValue(JulianDate.addSeconds(time1, 60, new JulianDate()))).toEqual(Color.unpack(packet.properties.custom_color_sampled.rgbaf, 4 + 2)); - - expect(entity.properties.custom_date_constant).toBeDefined(); - expect(entity.properties.custom_date_constant.getValue(time1)).toBeInstanceOf(JulianDate); - expect(entity.properties.custom_date_constant.getValue(time1)).toEqual(JulianDate.fromIso8601(packet.properties.custom_date_constant.date)); - - expect(entity.properties.custom_date_interval).toBeDefined(); - expect(entity.properties.custom_date_interval.getValue(time1)).toBeInstanceOf(JulianDate); - expect(entity.properties.custom_date_interval.getValue(time1)).toEqual(JulianDate.fromIso8601(packet.properties.custom_date_interval[0].date)); - expect(entity.properties.custom_date_interval.getValue(time2)).toEqual(JulianDate.fromIso8601(packet.properties.custom_date_interval[1].date)); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.getById('MyID'); + expect(entity).toBeDefined(); + expect(entity.properties).toBeDefined(); + + var time1 = JulianDate.fromIso8601('2012-06-01'); + var time2 = JulianDate.fromIso8601('2013-06-01'); + + expect(entity.properties.custom_array_constant).toBeDefined(); + expect(entity.properties.custom_array_constant.getValue(time1)).toBeInstanceOf(Array); + expect(entity.properties.custom_array_constant.getValue(time1)).toEqual(packet.properties.custom_array_constant.array); + + expect(entity.properties.custom_array_interval).toBeDefined(); + expect(entity.properties.custom_array_interval.getValue(time1)).toBeInstanceOf(Array); + expect(entity.properties.custom_array_interval.getValue(time1)).toEqual(packet.properties.custom_array_interval[0].array); + expect(entity.properties.custom_array_interval.getValue(time2)).toEqual(packet.properties.custom_array_interval[1].array); + + expect(entity.properties.custom_boolean_constant).toBeDefined(); + expect(entity.properties.custom_boolean_constant.getValue(time1)).toEqual(packet.properties.custom_boolean_constant.boolean); + + expect(entity.properties.custom_boolean_interval).toBeDefined(); + expect(entity.properties.custom_boolean_interval.getValue(time1)).toEqual(packet.properties.custom_boolean_interval[0].boolean); + expect(entity.properties.custom_boolean_interval.getValue(time2)).toEqual(packet.properties.custom_boolean_interval[1].boolean); + + expect(entity.properties.custom_boundingRectangle_constant).toBeDefined(); + expect(entity.properties.custom_boundingRectangle_constant.getValue(time1)).toBeInstanceOf(BoundingRectangle); + expect(entity.properties.custom_boundingRectangle_constant.getValue(time1)).toEqual(BoundingRectangle.unpack(packet.properties.custom_boundingRectangle_constant.boundingRectangle)); + + expect(entity.properties.custom_boundingRectangle_interval).toBeDefined(); + expect(entity.properties.custom_boundingRectangle_interval.getValue(time1)).toBeInstanceOf(BoundingRectangle); + expect(entity.properties.custom_boundingRectangle_interval.getValue(time1)).toEqual(BoundingRectangle.unpack(packet.properties.custom_boundingRectangle_interval[0].boundingRectangle)); + expect(entity.properties.custom_boundingRectangle_interval.getValue(time2)).toEqual(BoundingRectangle.unpack(packet.properties.custom_boundingRectangle_interval[1].boundingRectangle)); + + expect(entity.properties.custom_boundingRectangle_sampled).toBeDefined(); + expect(entity.properties.custom_boundingRectangle_sampled.getValue(time1)).toBeInstanceOf(BoundingRectangle); + expect(entity.properties.custom_boundingRectangle_sampled.getValue(time1)).toEqual(BoundingRectangle.unpack(packet.properties.custom_boundingRectangle_sampled.boundingRectangle, 0 + 1)); + expect(entity.properties.custom_boundingRectangle_sampled.getValue(JulianDate.addSeconds(time1, 60, new JulianDate()))).toEqual(BoundingRectangle.unpack(packet.properties.custom_boundingRectangle_sampled.boundingRectangle, 4 + 2)); + + expect(entity.properties.custom_cartesian2_constant).toBeDefined(); + expect(entity.properties.custom_cartesian2_constant.getValue(time1)).toBeInstanceOf(Cartesian2); + expect(entity.properties.custom_cartesian2_constant.getValue(time1)).toEqual(Cartesian2.unpack(packet.properties.custom_cartesian2_constant.cartesian2)); + + expect(entity.properties.custom_cartesian2_interval).toBeDefined(); + expect(entity.properties.custom_cartesian2_interval.getValue(time1)).toBeInstanceOf(Cartesian2); + expect(entity.properties.custom_cartesian2_interval.getValue(time1)).toEqual(Cartesian2.unpack(packet.properties.custom_cartesian2_interval[0].cartesian2)); + expect(entity.properties.custom_cartesian2_interval.getValue(time2)).toEqual(Cartesian2.unpack(packet.properties.custom_cartesian2_interval[1].cartesian2)); + + expect(entity.properties.custom_cartesian2_sampled).toBeDefined(); + expect(entity.properties.custom_cartesian2_sampled.getValue(time1)).toBeInstanceOf(Cartesian2); + expect(entity.properties.custom_cartesian2_sampled.getValue(time1)).toEqual(Cartesian2.unpack(packet.properties.custom_cartesian2_sampled.cartesian2, 0 + 1)); + expect(entity.properties.custom_cartesian2_sampled.getValue(JulianDate.addSeconds(time1, 60, new JulianDate()))).toEqual(Cartesian2.unpack(packet.properties.custom_cartesian2_sampled.cartesian2, 2 + 2)); + + expect(entity.properties.custom_cartesian_constant).toBeDefined(); + expect(entity.properties.custom_cartesian_constant.getValue(time1)).toBeInstanceOf(Cartesian3); + expect(entity.properties.custom_cartesian_constant.getValue(time1)).toEqual(Cartesian3.unpack(packet.properties.custom_cartesian_constant.cartesian)); + + expect(entity.properties.custom_cartesian_interval).toBeDefined(); + expect(entity.properties.custom_cartesian_interval.getValue(time1)).toBeInstanceOf(Cartesian3); + expect(entity.properties.custom_cartesian_interval.getValue(time1)).toEqual(Cartesian3.unpack(packet.properties.custom_cartesian_interval[0].cartesian)); + expect(entity.properties.custom_cartesian_interval.getValue(time2)).toEqual(Cartesian3.unpack(packet.properties.custom_cartesian_interval[1].cartesian)); + + expect(entity.properties.custom_cartesian_sampled).toBeDefined(); + expect(entity.properties.custom_cartesian_sampled.getValue(time1)).toBeInstanceOf(Cartesian3); + expect(entity.properties.custom_cartesian_sampled.getValue(time1)).toEqual(Cartesian3.unpack(packet.properties.custom_cartesian_sampled.cartesian, 0 + 1)); + expect(entity.properties.custom_cartesian_sampled.getValue(JulianDate.addSeconds(time1, 60, new JulianDate()))).toEqual(Cartesian3.unpack(packet.properties.custom_cartesian_sampled.cartesian, 3 + 2)); + + expect(entity.properties.custom_color_constant).toBeDefined(); + expect(entity.properties.custom_color_constant.getValue(time1)).toBeInstanceOf(Color); + expect(entity.properties.custom_color_constant.getValue(time1)).toEqual(Color.unpack(packet.properties.custom_color_constant.rgbaf)); + + expect(entity.properties.custom_color_interval).toBeDefined(); + expect(entity.properties.custom_color_interval.getValue(time1)).toBeInstanceOf(Color); + expect(entity.properties.custom_color_interval.getValue(time1)).toEqual(Color.unpack(packet.properties.custom_color_interval[0].rgbaf)); + expect(entity.properties.custom_color_interval.getValue(time2)).toEqual(Color.unpack(packet.properties.custom_color_interval[1].rgbaf)); + + expect(entity.properties.custom_color_sampled).toBeDefined(); + expect(entity.properties.custom_color_sampled.getValue(time1)).toBeInstanceOf(Color); + expect(entity.properties.custom_color_sampled.getValue(time1)).toEqual(Color.unpack(packet.properties.custom_color_sampled.rgbaf, 0 + 1)); + expect(entity.properties.custom_color_sampled.getValue(JulianDate.addSeconds(time1, 60, new JulianDate()))).toEqual(Color.unpack(packet.properties.custom_color_sampled.rgbaf, 4 + 2)); + + expect(entity.properties.custom_date_constant).toBeDefined(); + expect(entity.properties.custom_date_constant.getValue(time1)).toBeInstanceOf(JulianDate); + expect(entity.properties.custom_date_constant.getValue(time1)).toEqual(JulianDate.fromIso8601(packet.properties.custom_date_constant.date)); + + expect(entity.properties.custom_date_interval).toBeDefined(); + expect(entity.properties.custom_date_interval.getValue(time1)).toBeInstanceOf(JulianDate); + expect(entity.properties.custom_date_interval.getValue(time1)).toEqual(JulianDate.fromIso8601(packet.properties.custom_date_interval[0].date)); + expect(entity.properties.custom_date_interval.getValue(time2)).toEqual(JulianDate.fromIso8601(packet.properties.custom_date_interval[1].date)); + }); }); it('handles properties in a way that allows CompositeEntityCollection to work', function() { @@ -2022,27 +2158,29 @@ defineSuite([ availability : '2000-01-01/2001-01-01' }; - var dataSource = new CzmlDataSource(); - dataSource.process(makePacket(packet1)); - var entity = dataSource.entities.values[0]; - - var interval = TimeInterval.fromIso8601({ - iso8601 : packet1.availability - }); - expect(entity.availability.length).toEqual(1); - expect(entity.availability.get(0)).toEqual(interval); - var packet2 = { - id : 'testObject', - availability : '2000-02-02/2001-02-02' + id: 'testObject', + availability: '2000-02-02/2001-02-02' }; - dataSource.process(packet2); - interval = TimeInterval.fromIso8601({ - iso8601 : packet2.availability + var dataSource = new CzmlDataSource(); + return dataSource.process(makePacket(packet1)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + var interval = TimeInterval.fromIso8601({ + iso8601: packet1.availability + }); + expect(entity.availability.length).toEqual(1); + expect(entity.availability.get(0)).toEqual(interval); + + return dataSource.process(packet2); + }).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + var interval = TimeInterval.fromIso8601({ + iso8601: packet2.availability + }); + expect(entity.availability.length).toEqual(1); + expect(entity.availability.get(0)).toEqual(interval); }); - expect(entity.availability.length).toEqual(1); - expect(entity.availability.get(0)).toEqual(interval); }); it('CZML Availability works with multiple intervals.', function() { @@ -2050,36 +2188,38 @@ defineSuite([ id : 'testObject', availability : ['2000-01-01/2001-01-01', '2002-01-01/2003-01-01'] }; - - var dataSource = new CzmlDataSource(); - dataSource.process(makePacket(packet1)); - var entity = dataSource.entities.values[0]; - - var interval1 = TimeInterval.fromIso8601({ - iso8601 : packet1.availability[0] - }); - var interval2 = TimeInterval.fromIso8601({ - iso8601 : packet1.availability[1] - }); - expect(entity.availability.length).toEqual(2); - expect(entity.availability.get(0)).toEqual(interval1); - expect(entity.availability.get(1)).toEqual(interval2); - var packet2 = { id : 'testObject', availability : ['2003-01-01/2004-01-01', '2005-01-01/2006-01-01'] }; - dataSource.process(packet2); - interval1 = TimeInterval.fromIso8601({ - iso8601 : packet2.availability[0] - }); - interval2 = TimeInterval.fromIso8601({ - iso8601 : packet2.availability[1] + var dataSource = new CzmlDataSource(); + return dataSource.process(makePacket(packet1)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + var interval1 = TimeInterval.fromIso8601({ + iso8601: packet1.availability[0] + }); + var interval2 = TimeInterval.fromIso8601({ + iso8601: packet1.availability[1] + }); + expect(entity.availability.length).toEqual(2); + expect(entity.availability.get(0)).toEqual(interval1); + expect(entity.availability.get(1)).toEqual(interval2); + + return dataSource.process(packet2); + }).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + var interval1 = TimeInterval.fromIso8601({ + iso8601: packet2.availability[0] + }); + var interval2 = TimeInterval.fromIso8601({ + iso8601: packet2.availability[1] + }); + expect(entity.availability.length).toEqual(2); + expect(entity.availability.get(0)).toEqual(interval1); + expect(entity.availability.get(1)).toEqual(interval2); }); - expect(entity.availability.length).toEqual(2); - expect(entity.availability.get(0)).toEqual(interval1); - expect(entity.availability.get(1)).toEqual(interval2); }); it('CZML adds data for infinite path.', function() { @@ -2105,18 +2245,19 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(pathPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.path).toBeDefined(); - expect(entity.path.material.color.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); - expect(entity.path.width.getValue(Iso8601.MINIMUM_VALUE)).toEqual(pathPacket.path.width); - expect(entity.path.resolution.getValue(Iso8601.MINIMUM_VALUE)).toEqual(pathPacket.path.resolution); - expect(entity.path.material.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); - expect(entity.path.material.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(1.0); - expect(entity.path.leadTime.getValue(Iso8601.MINIMUM_VALUE)).toEqual(pathPacket.path.leadTime); - expect(entity.path.trailTime.getValue(Iso8601.MINIMUM_VALUE)).toEqual(pathPacket.path.trailTime); - expect(entity.path.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + return dataSource.load(makePacket(pathPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.path).toBeDefined(); + expect(entity.path.material.color.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); + expect(entity.path.width.getValue(Iso8601.MINIMUM_VALUE)).toEqual(pathPacket.path.width); + expect(entity.path.resolution.getValue(Iso8601.MINIMUM_VALUE)).toEqual(pathPacket.path.resolution); + expect(entity.path.material.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); + expect(entity.path.material.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(1.0); + expect(entity.path.leadTime.getValue(Iso8601.MINIMUM_VALUE)).toEqual(pathPacket.path.leadTime); + expect(entity.path.trailTime.getValue(Iso8601.MINIMUM_VALUE)).toEqual(pathPacket.path.trailTime); + expect(entity.path.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + }); }); it('CZML adds data for constrained path.', function() { @@ -2148,24 +2289,25 @@ defineSuite([ var invalidTime = JulianDate.addSeconds(validTime, -1, new JulianDate()); var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(pathPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.path).toBeDefined(); - expect(entity.path.width.getValue(validTime)).toEqual(pathPacket.path.width); - expect(entity.path.resolution.getValue(validTime)).toEqual(pathPacket.path.resolution); - expect(entity.path.leadTime.getValue(validTime)).toEqual(pathPacket.path.leadTime); - expect(entity.path.trailTime.getValue(validTime)).toEqual(pathPacket.path.trailTime); - expect(entity.path.show.getValue(validTime)).toEqual(true); - expect(entity.path.material.getValue(validTime).color).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); - expect(entity.path.material.getValue(validTime).outlineColor).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); - expect(entity.path.material.getValue(validTime).outlineWidth).toEqual(1.0); - - expect(entity.path.material.getValue(invalidTime)).toBeUndefined(); - expect(entity.path.width.getValue(invalidTime)).toBeUndefined(); - expect(entity.path.leadTime.getValue(invalidTime)).toBeUndefined(); - expect(entity.path.trailTime.getValue(invalidTime)).toBeUndefined(); - expect(entity.path.show.getValue(invalidTime)).toBeUndefined(); + return dataSource.load(makePacket(pathPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.path).toBeDefined(); + expect(entity.path.width.getValue(validTime)).toEqual(pathPacket.path.width); + expect(entity.path.resolution.getValue(validTime)).toEqual(pathPacket.path.resolution); + expect(entity.path.leadTime.getValue(validTime)).toEqual(pathPacket.path.leadTime); + expect(entity.path.trailTime.getValue(validTime)).toEqual(pathPacket.path.trailTime); + expect(entity.path.show.getValue(validTime)).toEqual(true); + expect(entity.path.material.getValue(validTime).color).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); + expect(entity.path.material.getValue(validTime).outlineColor).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); + expect(entity.path.material.getValue(validTime).outlineWidth).toEqual(1.0); + + expect(entity.path.material.getValue(invalidTime)).toBeUndefined(); + expect(entity.path.width.getValue(invalidTime)).toBeUndefined(); + expect(entity.path.leadTime.getValue(invalidTime)).toBeUndefined(); + expect(entity.path.trailTime.getValue(invalidTime)).toBeUndefined(); + expect(entity.path.show.getValue(invalidTime)).toBeUndefined(); + }); }); it('CZML adds data for infinite point.', function() { @@ -2191,18 +2333,19 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(pointPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.point).toBeDefined(); - expect(entity.point.color.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); - expect(entity.point.pixelSize.getValue(Iso8601.MINIMUM_VALUE)).toEqual(pointPacket.point.pixelSize); - expect(entity.point.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); - expect(entity.point.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(pointPacket.point.outlineWidth); - expect(entity.point.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); - expect(entity.point.scaleByDistance.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new NearFarScalar(1.0, 2.0, 10000.0, 3.0)); - expect(entity.point.translucencyByDistance.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new NearFarScalar(1.0, 1.0, 10000.0, 0.0)); - expect(entity.point.heightReference.getValue(Iso8601.MINIMUM_VALUE)).toEqual(HeightReference.CLAMP_TO_GROUND); + return dataSource.load(makePacket(pointPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.point).toBeDefined(); + expect(entity.point.color.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); + expect(entity.point.pixelSize.getValue(Iso8601.MINIMUM_VALUE)).toEqual(pointPacket.point.pixelSize); + expect(entity.point.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); + expect(entity.point.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(pointPacket.point.outlineWidth); + expect(entity.point.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + expect(entity.point.scaleByDistance.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new NearFarScalar(1.0, 2.0, 10000.0, 3.0)); + expect(entity.point.translucencyByDistance.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new NearFarScalar(1.0, 1.0, 10000.0, 0.0)); + expect(entity.point.heightReference.getValue(Iso8601.MINIMUM_VALUE)).toEqual(HeightReference.CLAMP_TO_GROUND); + }); }); it('CZML adds data for constrained point.', function() { @@ -2227,21 +2370,22 @@ defineSuite([ var invalidTime = JulianDate.addSeconds(validTime, -1, new JulianDate()); var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(pointPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.point).toBeDefined(); - expect(entity.point.color.getValue(validTime)).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); - expect(entity.point.pixelSize.getValue(validTime)).toEqual(pointPacket.point.pixelSize); - expect(entity.point.outlineColor.getValue(validTime)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); - expect(entity.point.outlineWidth.getValue(validTime)).toEqual(pointPacket.point.outlineWidth); - expect(entity.point.show.getValue(validTime)).toEqual(true); - - expect(entity.point.color.getValue(invalidTime)).toBeUndefined(); - expect(entity.point.pixelSize.getValue(invalidTime)).toBeUndefined(); - expect(entity.point.outlineColor.getValue(invalidTime)).toBeUndefined(); - expect(entity.point.outlineWidth.getValue(invalidTime)).toBeUndefined(); - expect(entity.point.show.getValue(invalidTime)).toBeUndefined(); + return dataSource.load(makePacket(pointPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.point).toBeDefined(); + expect(entity.point.color.getValue(validTime)).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); + expect(entity.point.pixelSize.getValue(validTime)).toEqual(pointPacket.point.pixelSize); + expect(entity.point.outlineColor.getValue(validTime)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); + expect(entity.point.outlineWidth.getValue(validTime)).toEqual(pointPacket.point.outlineWidth); + expect(entity.point.show.getValue(validTime)).toEqual(true); + + expect(entity.point.color.getValue(invalidTime)).toBeUndefined(); + expect(entity.point.pixelSize.getValue(invalidTime)).toBeUndefined(); + expect(entity.point.outlineColor.getValue(invalidTime)).toBeUndefined(); + expect(entity.point.outlineWidth.getValue(invalidTime)).toBeUndefined(); + expect(entity.point.show.getValue(invalidTime)).toBeUndefined(); + }); }); it('CZML adds data for infinite polygon.', function() { @@ -2271,22 +2415,23 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(polygonPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.polygon).toBeDefined(); - expect(entity.polygon.material.getValue(Iso8601.MINIMUM_VALUE).color).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); - expect(entity.polygon.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); - expect(entity.polygon.height.getValue(Iso8601.MINIMUM_VALUE)).toEqual(1); - expect(entity.polygon.extrudedHeight.getValue(Iso8601.MINIMUM_VALUE)).toEqual(2); - expect(entity.polygon.granularity.getValue(Iso8601.MINIMUM_VALUE)).toEqual(3); - expect(entity.polygon.stRotation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(4); - expect(entity.polygon.outline.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); - expect(entity.polygon.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); - expect(entity.polygon.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); - expect(entity.polygon.closeTop.getValue(Iso8601.MINIMUM_VALUE)).toEqual(false); - expect(entity.polygon.closeBottom.getValue(Iso8601.MINIMUM_VALUE)).toEqual(false); - expect(entity.polygon.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + return dataSource.load(makePacket(polygonPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.polygon).toBeDefined(); + expect(entity.polygon.material.getValue(Iso8601.MINIMUM_VALUE).color).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); + expect(entity.polygon.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + expect(entity.polygon.height.getValue(Iso8601.MINIMUM_VALUE)).toEqual(1); + expect(entity.polygon.extrudedHeight.getValue(Iso8601.MINIMUM_VALUE)).toEqual(2); + expect(entity.polygon.granularity.getValue(Iso8601.MINIMUM_VALUE)).toEqual(3); + expect(entity.polygon.stRotation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(4); + expect(entity.polygon.outline.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + expect(entity.polygon.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); + expect(entity.polygon.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); + expect(entity.polygon.closeTop.getValue(Iso8601.MINIMUM_VALUE)).toEqual(false); + expect(entity.polygon.closeBottom.getValue(Iso8601.MINIMUM_VALUE)).toEqual(false); + expect(entity.polygon.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + }); }); it('CZML adds data for constrained polygon.', function() { @@ -2311,18 +2456,18 @@ defineSuite([ var invalidTime = JulianDate.addSeconds(validTime, -1, new JulianDate()); var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(polygonPacket)); - var entity = dataSource.entities.values[0]; + return dataSource.load(makePacket(polygonPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; - expect(entity.polygon).toBeDefined(); - expect(entity.polygon.material.getValue(validTime).color).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); - expect(entity.polygon.show.getValue(validTime)).toEqual(true); - expect(entity.polygon.shadows.getValue(validTime)).toEqual(ShadowMode.ENABLED); - - expect(entity.polygon.material.getValue(invalidTime)).toBeUndefined(); - expect(entity.polygon.show.getValue(invalidTime)).toBeUndefined(); - expect(entity.polygon.shadows.getValue(invalidTime)).toBeUndefined(); + expect(entity.polygon).toBeDefined(); + expect(entity.polygon.material.getValue(validTime).color).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); + expect(entity.polygon.show.getValue(validTime)).toEqual(true); + expect(entity.polygon.shadows.getValue(validTime)).toEqual(ShadowMode.ENABLED); + expect(entity.polygon.material.getValue(invalidTime)).toBeUndefined(); + expect(entity.polygon.show.getValue(invalidTime)).toBeUndefined(); + expect(entity.polygon.shadows.getValue(invalidTime)).toBeUndefined(); + }); }); it('CZML adds data for infinite polyline.', function() { @@ -2346,16 +2491,17 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(polylinePacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.polyline).toBeDefined(); - expect(entity.polyline.material.color.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); - expect(entity.polyline.width.getValue(Iso8601.MINIMUM_VALUE)).toEqual(polylinePacket.polyline.width); - expect(entity.polyline.material.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); - expect(entity.polyline.material.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(1.0); - expect(entity.polyline.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); - expect(entity.polyline.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + return dataSource.load(makePacket(polylinePacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.polyline).toBeDefined(); + expect(entity.polyline.material.color.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); + expect(entity.polyline.width.getValue(Iso8601.MINIMUM_VALUE)).toEqual(polylinePacket.polyline.width); + expect(entity.polyline.material.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); + expect(entity.polyline.material.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(1.0); + expect(entity.polyline.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + expect(entity.polyline.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + }); }); it('CZML adds data for constrained polyline.', function() { @@ -2385,21 +2531,22 @@ defineSuite([ var invalidTime = JulianDate.addSeconds(validTime, -1, new JulianDate()); var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(polylinePacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.polyline).toBeDefined(); - expect(entity.polyline.material.getValue(validTime).color).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); - expect(entity.polyline.width.getValue(validTime)).toEqual(polylinePacket.polyline.width); - expect(entity.polyline.material.getValue(validTime).outlineColor).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); - expect(entity.polyline.material.getValue(validTime).outlineWidth).toEqual(1.0); - expect(entity.polyline.show.getValue(validTime)).toEqual(true); - expect(entity.polyline.shadows.getValue(validTime)).toEqual(ShadowMode.ENABLED); - - expect(entity.polyline.material.getValue(invalidTime)).toBeUndefined(); - expect(entity.polyline.width.getValue(invalidTime)).toBeUndefined(); - expect(entity.polyline.show.getValue(invalidTime)).toBeUndefined(); - expect(entity.polyline.shadows.getValue(invalidTime)).toBeUndefined(); + return dataSource.load(makePacket(polylinePacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.polyline).toBeDefined(); + expect(entity.polyline.material.getValue(validTime).color).toEqual(new Color(0.1, 0.1, 0.1, 0.1)); + expect(entity.polyline.width.getValue(validTime)).toEqual(polylinePacket.polyline.width); + expect(entity.polyline.material.getValue(validTime).outlineColor).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); + expect(entity.polyline.material.getValue(validTime).outlineWidth).toEqual(1.0); + expect(entity.polyline.show.getValue(validTime)).toEqual(true); + expect(entity.polyline.shadows.getValue(validTime)).toEqual(ShadowMode.ENABLED); + + expect(entity.polyline.material.getValue(invalidTime)).toBeUndefined(); + expect(entity.polyline.width.getValue(invalidTime)).toBeUndefined(); + expect(entity.polyline.show.getValue(invalidTime)).toBeUndefined(); + expect(entity.polyline.shadows.getValue(invalidTime)).toBeUndefined(); + }); }); it('CZML adds data for infinite model.', function() { @@ -2439,36 +2586,37 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(modelPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.model).toBeDefined(); - expect(entity.model.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); - expect(entity.model.scale.getValue(Iso8601.MINIMUM_VALUE)).toEqual(3.0); - expect(entity.model.minimumPixelSize.getValue(Iso8601.MINIMUM_VALUE)).toEqual(5.0); - expect(entity.model.maximumScale.getValue(Iso8601.MINIMUM_VALUE)).toEqual(4.0); - expect(entity.model.uri.getValue(Iso8601.MINIMUM_VALUE)).toEqual('./Data/Models/Box/CesiumBoxTest.gltf'); - expect(entity.model.incrementallyLoadTextures.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); - expect(entity.model.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); - expect(entity.model.heightReference.getValue(Iso8601.MINIMUM_VALUE)).toEqual(HeightReference.CLAMP_TO_GROUND); - expect(entity.model.silhouetteColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(1.0, 0.0, 0.0, 1.0)); - expect(entity.model.silhouetteSize.getValue(Iso8601.MINIMUM_VALUE)).toEqual(2.0); - expect(entity.model.color.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.0, 1.0, 0.0, 0.2)); - expect(entity.model.colorBlendMode.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ColorBlendMode.HIGHLIGHT); - expect(entity.model.colorBlendAmount.getValue(Iso8601.MINIMUM_VALUE)).toEqual(0.5); - - var nodeTransform = entity.model.nodeTransformations.getValue(Iso8601.MINIMUM_VALUE).Mesh; - expect(nodeTransform).toBeDefined(); - expect(nodeTransform.scale).toEqual(new Cartesian3(1.0, 2.0, 3.0)); - expect(nodeTransform.translation).toEqual(new Cartesian3(4.0, 5.0, 6.0)); - - var expectedRotation = new Quaternion(0.0, 0.707, 0.0, 0.707); - Quaternion.normalize(expectedRotation, expectedRotation); - expect(nodeTransform.rotation).toEqual(expectedRotation); - - expect(entity.model.nodeTransformations.Mesh.scale.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(1.0, 2.0, 3.0)); - expect(entity.model.nodeTransformations.Mesh.translation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(4.0, 5.0, 6.0)); - expect(entity.model.nodeTransformations.Mesh.rotation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(expectedRotation); + return dataSource.load(makePacket(modelPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.model).toBeDefined(); + expect(entity.model.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + expect(entity.model.scale.getValue(Iso8601.MINIMUM_VALUE)).toEqual(3.0); + expect(entity.model.minimumPixelSize.getValue(Iso8601.MINIMUM_VALUE)).toEqual(5.0); + expect(entity.model.maximumScale.getValue(Iso8601.MINIMUM_VALUE)).toEqual(4.0); + expect(entity.model.uri.getValue(Iso8601.MINIMUM_VALUE)).toEqual('./Data/Models/Box/CesiumBoxTest.gltf'); + expect(entity.model.incrementallyLoadTextures.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + expect(entity.model.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + expect(entity.model.heightReference.getValue(Iso8601.MINIMUM_VALUE)).toEqual(HeightReference.CLAMP_TO_GROUND); + expect(entity.model.silhouetteColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(1.0, 0.0, 0.0, 1.0)); + expect(entity.model.silhouetteSize.getValue(Iso8601.MINIMUM_VALUE)).toEqual(2.0); + expect(entity.model.color.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.0, 1.0, 0.0, 0.2)); + expect(entity.model.colorBlendMode.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ColorBlendMode.HIGHLIGHT); + expect(entity.model.colorBlendAmount.getValue(Iso8601.MINIMUM_VALUE)).toEqual(0.5); + + var nodeTransform = entity.model.nodeTransformations.getValue(Iso8601.MINIMUM_VALUE).Mesh; + expect(nodeTransform).toBeDefined(); + expect(nodeTransform.scale).toEqual(new Cartesian3(1.0, 2.0, 3.0)); + expect(nodeTransform.translation).toEqual(new Cartesian3(4.0, 5.0, 6.0)); + + var expectedRotation = new Quaternion(0.0, 0.707, 0.0, 0.707); + Quaternion.normalize(expectedRotation, expectedRotation); + expect(nodeTransform.rotation).toEqual(expectedRotation); + + expect(entity.model.nodeTransformations.Mesh.scale.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(1.0, 2.0, 3.0)); + expect(entity.model.nodeTransformations.Mesh.translation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(4.0, 5.0, 6.0)); + expect(entity.model.nodeTransformations.Mesh.rotation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(expectedRotation); + }); }); it('CZML adds data for constrained model.', function() { @@ -2513,62 +2661,66 @@ defineSuite([ var invalidTime = JulianDate.addSeconds(validTime, -1, new JulianDate()); var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(modelPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.model).toBeDefined(); - expect(entity.model.show.getValue(validTime)).toEqual(true); - expect(entity.model.scale.getValue(validTime)).toEqual(3.0); - expect(entity.model.minimumPixelSize.getValue(validTime)).toEqual(5.0); - expect(entity.model.uri.getValue(validTime)).toEqual('./Data/Models/Box/CesiumBoxTest.gltf'); - expect(entity.model.incrementallyLoadTextures.getValue(validTime)).toEqual(true); - expect(entity.model.shadows.getValue(validTime)).toEqual(ShadowMode.ENABLED); - expect(entity.model.heightReference.getValue(validTime)).toEqual(HeightReference.CLAMP_TO_GROUND); - expect(entity.model.silhouetteColor.getValue(validTime)).toEqual(new Color(1.0, 0.0, 0.0, 1.0)); - expect(entity.model.silhouetteSize.getValue(validTime)).toEqual(2.0); - expect(entity.model.color.getValue(validTime)).toEqual(new Color(0.0, 1.0, 0.0, 0.2)); - expect(entity.model.colorBlendMode.getValue(validTime)).toEqual(ColorBlendMode.HIGHLIGHT); - expect(entity.model.colorBlendAmount.getValue(validTime)).toEqual(0.5); - - var nodeTransform = entity.model.nodeTransformations.getValue(validTime).Mesh; - expect(nodeTransform).toBeDefined(); - expect(nodeTransform.scale).toEqual(new Cartesian3(1.0, 2.0, 3.0)); - expect(nodeTransform.translation).toEqual(new Cartesian3(4.0, 5.0, 6.0)); - - var expectedRotation = new Quaternion(0.0, 0.707, 0.0, 0.707); - Quaternion.normalize(expectedRotation, expectedRotation); - expect(nodeTransform.rotation).toEqual(expectedRotation); - - expect(entity.model.nodeTransformations.Mesh.scale.getValue(validTime)).toEqual(new Cartesian3(1.0, 2.0, 3.0)); - expect(entity.model.nodeTransformations.Mesh.translation.getValue(validTime)).toEqual(new Cartesian3(4.0, 5.0, 6.0)); - expect(entity.model.nodeTransformations.Mesh.rotation.getValue(validTime)).toEqual(expectedRotation); - - expect(entity.model.show.getValue(invalidTime)).toBeUndefined(); - expect(entity.model.scale.getValue(invalidTime)).toBeUndefined(); - expect(entity.model.minimumPixelSize.getValue(invalidTime)).toBeUndefined(); - expect(entity.model.uri.getValue(invalidTime)).toBeUndefined(); - expect(entity.model.incrementallyLoadTextures.getValue(invalidTime)).toBeUndefined(); - expect(entity.model.shadows.getValue(invalidTime)).toBeUndefined(); - expect(entity.model.heightReference.getValue(invalidTime)).toBeUndefined(); - expect(entity.model.color.getValue(invalidTime)).toBeUndefined(); - expect(entity.model.silhouetteColor.getValue(invalidTime)).toBeUndefined(); - expect(entity.model.silhouetteSize.getValue(invalidTime)).toBeUndefined(); - expect(entity.model.colorBlendMode.getValue(invalidTime)).toBeUndefined(); - expect(entity.model.colorBlendAmount.getValue(invalidTime)).toBeUndefined(); - - expect(entity.model.nodeTransformations.Mesh.getValue(invalidTime)).toEqual(new TranslationRotationScale()); - expect(entity.model.nodeTransformations.Mesh.scale.getValue(invalidTime)).toBeUndefined(); - expect(entity.model.nodeTransformations.Mesh.translation.getValue(invalidTime)).toBeUndefined(); - expect(entity.model.nodeTransformations.Mesh.rotation.getValue(invalidTime)).toBeUndefined(); + return dataSource.load(makePacket(modelPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.model).toBeDefined(); + expect(entity.model.show.getValue(validTime)).toEqual(true); + expect(entity.model.scale.getValue(validTime)).toEqual(3.0); + expect(entity.model.minimumPixelSize.getValue(validTime)).toEqual(5.0); + expect(entity.model.uri.getValue(validTime)).toEqual('./Data/Models/Box/CesiumBoxTest.gltf'); + expect(entity.model.incrementallyLoadTextures.getValue(validTime)).toEqual(true); + expect(entity.model.shadows.getValue(validTime)).toEqual(ShadowMode.ENABLED); + expect(entity.model.heightReference.getValue(validTime)).toEqual(HeightReference.CLAMP_TO_GROUND); + expect(entity.model.silhouetteColor.getValue(validTime)).toEqual(new Color(1.0, 0.0, 0.0, 1.0)); + expect(entity.model.silhouetteSize.getValue(validTime)).toEqual(2.0); + expect(entity.model.color.getValue(validTime)).toEqual(new Color(0.0, 1.0, 0.0, 0.2)); + expect(entity.model.colorBlendMode.getValue(validTime)).toEqual(ColorBlendMode.HIGHLIGHT); + expect(entity.model.colorBlendAmount.getValue(validTime)).toEqual(0.5); + + var nodeTransform = entity.model.nodeTransformations.getValue(validTime).Mesh; + expect(nodeTransform).toBeDefined(); + expect(nodeTransform.scale).toEqual(new Cartesian3(1.0, 2.0, 3.0)); + expect(nodeTransform.translation).toEqual(new Cartesian3(4.0, 5.0, 6.0)); + + var expectedRotation = new Quaternion(0.0, 0.707, 0.0, 0.707); + Quaternion.normalize(expectedRotation, expectedRotation); + expect(nodeTransform.rotation).toEqual(expectedRotation); + + expect(entity.model.nodeTransformations.Mesh.scale.getValue(validTime)).toEqual(new Cartesian3(1.0, 2.0, 3.0)); + expect(entity.model.nodeTransformations.Mesh.translation.getValue(validTime)).toEqual(new Cartesian3(4.0, 5.0, 6.0)); + expect(entity.model.nodeTransformations.Mesh.rotation.getValue(validTime)).toEqual(expectedRotation); + + expect(entity.model.show.getValue(invalidTime)).toBeUndefined(); + expect(entity.model.scale.getValue(invalidTime)).toBeUndefined(); + expect(entity.model.minimumPixelSize.getValue(invalidTime)).toBeUndefined(); + expect(entity.model.uri.getValue(invalidTime)).toBeUndefined(); + expect(entity.model.incrementallyLoadTextures.getValue(invalidTime)).toBeUndefined(); + expect(entity.model.shadows.getValue(invalidTime)).toBeUndefined(); + expect(entity.model.heightReference.getValue(invalidTime)).toBeUndefined(); + expect(entity.model.color.getValue(invalidTime)).toBeUndefined(); + expect(entity.model.silhouetteColor.getValue(invalidTime)).toBeUndefined(); + expect(entity.model.silhouetteSize.getValue(invalidTime)).toBeUndefined(); + expect(entity.model.colorBlendMode.getValue(invalidTime)).toBeUndefined(); + expect(entity.model.colorBlendAmount.getValue(invalidTime)).toBeUndefined(); + + expect(entity.model.nodeTransformations.Mesh.getValue(invalidTime)).toEqual(new TranslationRotationScale()); + expect(entity.model.nodeTransformations.Mesh.scale.getValue(invalidTime)).toBeUndefined(); + expect(entity.model.nodeTransformations.Mesh.translation.getValue(invalidTime)).toBeUndefined(); + expect(entity.model.nodeTransformations.Mesh.rotation.getValue(invalidTime)).toBeUndefined(); + }); }); it('processCzml deletes an existing object.', function() { var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(staticCzml)); - var objects = dataSource.entities.values; - expect(objects.length).toEqual(1); - dataSource.load(makePacket(czmlDelete)); - expect(objects.length).toEqual(0); + return dataSource.load(makePacket(staticCzml)).then(function(dataSource) { + var objects = dataSource.entities.values; + expect(objects.length).toEqual(1); + return dataSource.load(makePacket(czmlDelete)); + }).then(function(dataSource) { + var objects = dataSource.entities.values; + expect(objects.length).toEqual(0); + }); }); it('Processes parent property.', function() { @@ -2583,14 +2735,15 @@ defineSuite([ }]; var dataSource = new CzmlDataSource(); - dataSource.load(parentChildCzml); - var objects = dataSource.entities; + return dataSource.load(parentChildCzml).then(function(dataSource) { + var objects = dataSource.entities; - var parent = objects.getById('parent'); - expect(parent.parent).toBeUndefined(); + var parent = objects.getById('parent'); + expect(parent.parent).toBeUndefined(); - var child = objects.getById('child'); - expect(child.parent).toBe(parent); + var child = objects.getById('child'); + expect(child.parent).toBe(parent); + }); }); it('Processes parent property out of order.', function() { @@ -2616,26 +2769,27 @@ defineSuite([ }]; var dataSource = new CzmlDataSource(); - dataSource.load(parentChildCzml); - var objects = dataSource.entities; + return dataSource.load(parentChildCzml).then(function(dataSource) { + var objects = dataSource.entities; - var grandparent = objects.getById('grandparent'); - expect(grandparent.parent).toBeUndefined(); + var grandparent = objects.getById('grandparent'); + expect(grandparent.parent).toBeUndefined(); - var grandparent2 = objects.getById('grandparent'); - expect(grandparent2.parent).toBeUndefined(); + var grandparent2 = objects.getById('grandparent'); + expect(grandparent2.parent).toBeUndefined(); - var parent = objects.getById('parent'); - expect(parent.parent).toBe(grandparent); + var parent = objects.getById('parent'); + expect(parent.parent).toBe(grandparent); - var parent2 = objects.getById('parent2'); - expect(parent2.parent).toBe(grandparent); + var parent2 = objects.getById('parent2'); + expect(parent2.parent).toBe(grandparent); - var child = objects.getById('child'); - expect(child.parent).toBe(parent); + var child = objects.getById('child'); + expect(child.parent).toBe(parent); - var child2 = objects.getById('child2'); - expect(child2.parent).toBe(parent); + var child2 = objects.getById('child2'); + expect(child2.parent).toBe(parent); + }); }); it('Processes JulianDate packets.', function() { @@ -2691,9 +2845,9 @@ defineSuite([ var dataSource = new CzmlDataSource(); dataSource.entities.collectionChanged.addEventListener(spy); - dataSource.load(packets); - - expect(spy.calls.count()).toEqual(1); + return dataSource.load(packets).then(function(dataSource) { + expect(spy.calls.count()).toEqual(1); + }); }); it('CZML materials work with composite interval', function() { @@ -2740,13 +2894,14 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - var entity = dataSource.entities.values[0]; - expect(entity.polygon.material.getType(solid)).toBe('Color'); - expect(entity.polygon.material.getType(grid1)).toBe('Grid'); - expect(entity.polygon.material.getType(grid2)).toBe('Grid'); - expect(entity.polygon.material.getType(before)).toBeUndefined(); - expect(entity.polygon.material.getType(after)).toBeUndefined(); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.polygon.material.getType(solid)).toBe('Color'); + expect(entity.polygon.material.getType(grid1)).toBe('Grid'); + expect(entity.polygon.material.getType(grid2)).toBe('Grid'); + expect(entity.polygon.material.getType(before)).toBeUndefined(); + expect(entity.polygon.material.getType(after)).toBeUndefined(); + }); }); it('CZML adds data for rectangle.', function() { @@ -2782,24 +2937,25 @@ defineSuite([ var czmlRectangle = rectanglePacket.rectangle; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(rectanglePacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.rectangle).toBeDefined(); - expect(entity.rectangle.coordinates.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Rectangle(0, 1, 2, 3)); - expect(entity.rectangle.material.getValue(Iso8601.MINIMUM_VALUE).color).toEqual(new Color(0.1, 0.2, 0.3, 0.4)); - expect(entity.rectangle.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.show); - expect(entity.rectangle.height.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.height); - expect(entity.rectangle.extrudedHeight.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.extrudedHeight); - expect(entity.rectangle.granularity.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.granularity); - expect(entity.rectangle.rotation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.rotation); - expect(entity.rectangle.stRotation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.stRotation); - expect(entity.rectangle.closeBottom.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.closeBottom); - expect(entity.rectangle.closeTop.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.closeTop); - expect(entity.rectangle.outline.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); - expect(entity.rectangle.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); - expect(entity.rectangle.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); - expect(entity.rectangle.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + return dataSource.load(makePacket(rectanglePacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.rectangle).toBeDefined(); + expect(entity.rectangle.coordinates.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Rectangle(0, 1, 2, 3)); + expect(entity.rectangle.material.getValue(Iso8601.MINIMUM_VALUE).color).toEqual(new Color(0.1, 0.2, 0.3, 0.4)); + expect(entity.rectangle.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.show); + expect(entity.rectangle.height.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.height); + expect(entity.rectangle.extrudedHeight.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.extrudedHeight); + expect(entity.rectangle.granularity.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.granularity); + expect(entity.rectangle.rotation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.rotation); + expect(entity.rectangle.stRotation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.stRotation); + expect(entity.rectangle.closeBottom.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.closeBottom); + expect(entity.rectangle.closeTop.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.closeTop); + expect(entity.rectangle.outline.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + expect(entity.rectangle.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); + expect(entity.rectangle.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); + expect(entity.rectangle.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + }); }); it('can handle constant rectangle coordinates in degrees.', function() { @@ -2812,9 +2968,10 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(rectanglePacket)); - var entity = dataSource.entities.values[0]; - expect(entity.rectangle.coordinates.getValue(Iso8601.MINIMUM_VALUE)).toEqual(Rectangle.fromDegrees(0, 1, 2, 3)); + return dataSource.load(makePacket(rectanglePacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.rectangle.coordinates.getValue(Iso8601.MINIMUM_VALUE)).toEqual(Rectangle.fromDegrees(0, 1, 2, 3)); + }); }); it('can handle sampled rectangle coordinates.', function() { @@ -2831,16 +2988,17 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(rectanglePacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.rectangle).toBeDefined(); - var date1 = epoch; - var date2 = JulianDate.addSeconds(epoch, 0.5, new JulianDate()); - var date3 = JulianDate.addSeconds(epoch, 1.0, new JulianDate()); - expect(entity.rectangle.coordinates.getValue(date1)).toEqual(new Rectangle(1.0, 2.0, 3.0, 4.0)); - expect(entity.rectangle.coordinates.getValue(date2)).toEqual(new Rectangle(2.0, 3.0, 4.0, 5.0)); - expect(entity.rectangle.coordinates.getValue(date3)).toEqual(new Rectangle(3.0, 4.0, 5.0, 6.0)); + return dataSource.load(makePacket(rectanglePacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.rectangle).toBeDefined(); + var date1 = epoch; + var date2 = JulianDate.addSeconds(epoch, 0.5, new JulianDate()); + var date3 = JulianDate.addSeconds(epoch, 1.0, new JulianDate()); + expect(entity.rectangle.coordinates.getValue(date1)).toEqual(new Rectangle(1.0, 2.0, 3.0, 4.0)); + expect(entity.rectangle.coordinates.getValue(date2)).toEqual(new Rectangle(2.0, 3.0, 4.0, 5.0)); + expect(entity.rectangle.coordinates.getValue(date3)).toEqual(new Rectangle(3.0, 4.0, 5.0, 6.0)); + }); }); it('can handle sampled rectangle coordinates in degrees.', function() { @@ -2857,16 +3015,17 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(rectanglePacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.rectangle).toBeDefined(); - var date1 = epoch; - var date2 = JulianDate.addSeconds(epoch, 0.5, new JulianDate()); - var date3 = JulianDate.addSeconds(epoch, 1.0, new JulianDate()); - expect(entity.rectangle.coordinates.getValue(date1)).toEqual(Rectangle.fromDegrees(1.0, 2.0, 3.0, 4.0)); - expect(entity.rectangle.coordinates.getValue(date2)).toEqualEpsilon(Rectangle.fromDegrees(2.0, 3.0, 4.0, 5.0), CesiumMath.EPSILON15); - expect(entity.rectangle.coordinates.getValue(date3)).toEqual(Rectangle.fromDegrees(3.0, 4.0, 5.0, 6.0)); + return dataSource.load(makePacket(rectanglePacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.rectangle).toBeDefined(); + var date1 = epoch; + var date2 = JulianDate.addSeconds(epoch, 0.5, new JulianDate()); + var date3 = JulianDate.addSeconds(epoch, 1.0, new JulianDate()); + expect(entity.rectangle.coordinates.getValue(date1)).toEqual(Rectangle.fromDegrees(1.0, 2.0, 3.0, 4.0)); + expect(entity.rectangle.coordinates.getValue(date2)).toEqualEpsilon(Rectangle.fromDegrees(2.0, 3.0, 4.0, 5.0), CesiumMath.EPSILON15); + expect(entity.rectangle.coordinates.getValue(date3)).toEqual(Rectangle.fromDegrees(3.0, 4.0, 5.0, 6.0)); + }); }); it('CZML adds data for wall.', function() { @@ -2899,19 +3058,20 @@ defineSuite([ var czmlRectangle = wallPacket.wall; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(wallPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.wall).toBeDefined(); - expect(entity.wall.material.getValue(Iso8601.MINIMUM_VALUE).color).toEqual(new Color(0.1, 0.2, 0.3, 0.4)); - expect(entity.wall.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.show); - expect(entity.wall.granularity.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.granularity); - expect(entity.wall.minimumHeights.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.minimumHeights.array); - expect(entity.wall.maximumHeights.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.maximumHeights.array); - expect(entity.wall.outline.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); - expect(entity.wall.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); - expect(entity.wall.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); - expect(entity.wall.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + return dataSource.load(makePacket(wallPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.wall).toBeDefined(); + expect(entity.wall.material.getValue(Iso8601.MINIMUM_VALUE).color).toEqual(new Color(0.1, 0.2, 0.3, 0.4)); + expect(entity.wall.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.show); + expect(entity.wall.granularity.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.granularity); + expect(entity.wall.minimumHeights.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.minimumHeights.array); + expect(entity.wall.maximumHeights.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlRectangle.maximumHeights.array); + expect(entity.wall.outline.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + expect(entity.wall.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); + expect(entity.wall.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); + expect(entity.wall.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + }); }); it('CZML adds data for wall with minimumHeights as references.', function() { @@ -2941,12 +3101,13 @@ defineSuite([ }]; var dataSource = new CzmlDataSource(); - dataSource.load(packets); - var entity = dataSource.entities.getById('wall'); + return dataSource.load(packets).then(function(dataSource) { + var entity = dataSource.entities.getById('wall'); - expect(entity.wall).toBeDefined(); - expect(entity.wall.minimumHeights.getValue(Iso8601.MINIMUM_VALUE)).toEqual([packets[1].billboard.scale, packets[2].billboard.scale]); - expect(entity.wall.maximumHeights.getValue(Iso8601.MINIMUM_VALUE)).toEqual([packets[2].billboard.scale, packets[1].billboard.scale]); + expect(entity.wall).toBeDefined(); + expect(entity.wall.minimumHeights.getValue(Iso8601.MINIMUM_VALUE)).toEqual([packets[1].billboard.scale, packets[2].billboard.scale]); + expect(entity.wall.maximumHeights.getValue(Iso8601.MINIMUM_VALUE)).toEqual([packets[2].billboard.scale, packets[1].billboard.scale]); + }); }); it('CZML adds data for box.', function() { @@ -2973,17 +3134,18 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(boxPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.box).toBeDefined(); - expect(entity.box.dimensions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(1, 2, 3)); - expect(entity.box.material.getValue(Iso8601.MINIMUM_VALUE).color).toEqual(new Color(0.1, 0.2, 0.3, 0.4)); - expect(entity.box.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); - expect(entity.box.outline.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); - expect(entity.box.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); - expect(entity.box.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); - expect(entity.box.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + return dataSource.load(makePacket(boxPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.box).toBeDefined(); + expect(entity.box.dimensions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Cartesian3(1, 2, 3)); + expect(entity.box.material.getValue(Iso8601.MINIMUM_VALUE).color).toEqual(new Color(0.1, 0.2, 0.3, 0.4)); + expect(entity.box.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + expect(entity.box.outline.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + expect(entity.box.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); + expect(entity.box.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); + expect(entity.box.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + }); }); it('CZML adds data for cylinder.', function() { @@ -3012,21 +3174,22 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(cylinderPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.cylinder).toBeDefined(); - expect(entity.cylinder.length.getValue(Iso8601.MINIMUM_VALUE)).toEqual(5); - expect(entity.cylinder.topRadius.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); - expect(entity.cylinder.bottomRadius.getValue(Iso8601.MINIMUM_VALUE)).toEqual(7); - expect(entity.cylinder.material.getValue(Iso8601.MINIMUM_VALUE).color).toEqual(new Color(0.1, 0.2, 0.3, 0.4)); - expect(entity.cylinder.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); - expect(entity.cylinder.outline.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); - expect(entity.cylinder.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); - expect(entity.cylinder.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); - expect(entity.cylinder.numberOfVerticalLines.getValue(Iso8601.MINIMUM_VALUE)).toEqual(15); - expect(entity.cylinder.slices.getValue(Iso8601.MINIMUM_VALUE)).toEqual(100); - expect(entity.cylinder.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + return dataSource.load(makePacket(cylinderPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.cylinder).toBeDefined(); + expect(entity.cylinder.length.getValue(Iso8601.MINIMUM_VALUE)).toEqual(5); + expect(entity.cylinder.topRadius.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); + expect(entity.cylinder.bottomRadius.getValue(Iso8601.MINIMUM_VALUE)).toEqual(7); + expect(entity.cylinder.material.getValue(Iso8601.MINIMUM_VALUE).color).toEqual(new Color(0.1, 0.2, 0.3, 0.4)); + expect(entity.cylinder.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + expect(entity.cylinder.outline.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + expect(entity.cylinder.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); + expect(entity.cylinder.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); + expect(entity.cylinder.numberOfVerticalLines.getValue(Iso8601.MINIMUM_VALUE)).toEqual(15); + expect(entity.cylinder.slices.getValue(Iso8601.MINIMUM_VALUE)).toEqual(100); + expect(entity.cylinder.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + }); }); it('CZML adds data for corridor.', function() { @@ -3062,37 +3225,40 @@ defineSuite([ var czmlCorridor = corridorPacket.corridor; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(corridorPacket)); - var entity = dataSource.entities.values[0]; - - expect(entity.corridor).toBeDefined(); - expect(entity.corridor.positions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(expectedResult); - expect(entity.corridor.material.getValue(Iso8601.MINIMUM_VALUE).color).toEqual(new Color(0.1, 0.2, 0.3, 0.4)); - expect(entity.corridor.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlCorridor.show); - expect(entity.corridor.height.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlCorridor.height); - expect(entity.corridor.width.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlCorridor.width); - expect(entity.corridor.cornerType.getValue(Iso8601.MINIMUM_VALUE)).toEqual(CornerType.MITERED); - expect(entity.corridor.extrudedHeight.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlCorridor.extrudedHeight); - expect(entity.corridor.granularity.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlCorridor.granularity); - expect(entity.corridor.outline.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); - expect(entity.corridor.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); - expect(entity.corridor.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); - expect(entity.corridor.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + return dataSource.load(makePacket(corridorPacket)).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + + expect(entity.corridor).toBeDefined(); + expect(entity.corridor.positions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(expectedResult); + expect(entity.corridor.material.getValue(Iso8601.MINIMUM_VALUE).color).toEqual(new Color(0.1, 0.2, 0.3, 0.4)); + expect(entity.corridor.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlCorridor.show); + expect(entity.corridor.height.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlCorridor.height); + expect(entity.corridor.width.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlCorridor.width); + expect(entity.corridor.cornerType.getValue(Iso8601.MINIMUM_VALUE)).toEqual(CornerType.MITERED); + expect(entity.corridor.extrudedHeight.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlCorridor.extrudedHeight); + expect(entity.corridor.granularity.getValue(Iso8601.MINIMUM_VALUE)).toEqual(czmlCorridor.granularity); + expect(entity.corridor.outline.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true); + expect(entity.corridor.outlineColor.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Color(0.2, 0.2, 0.2, 0.2)); + expect(entity.corridor.outlineWidth.getValue(Iso8601.MINIMUM_VALUE)).toEqual(6); + expect(entity.corridor.shadows.getValue(Iso8601.MINIMUM_VALUE)).toEqual(ShadowMode.ENABLED); + }); }); it('Has entity collection with link to data source', function() { var dataSource = new CzmlDataSource(); - dataSource.load(nameCzml); - var entityCollection = dataSource.entities; - expect(entityCollection.owner).toEqual(dataSource); + return dataSource.load(nameCzml).then(function(dataSource) { + var entityCollection = dataSource.entities; + expect(entityCollection.owner).toEqual(dataSource); + }); }); it('Has entity with link to entity collection', function() { var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(staticCzml)); - var entityCollection = dataSource.entities; - var entity = entityCollection.values[0]; - expect(entity.entityCollection).toEqual(entityCollection); + return dataSource.load(makePacket(staticCzml)).then(function(dataSource) { + var entityCollection = dataSource.entities; + var entity = entityCollection.values[0]; + expect(entity.entityCollection).toEqual(entityCollection); + }); }); it('Can use constant reference properties', function() { @@ -3115,13 +3281,13 @@ defineSuite([ }]; var dataSource = new CzmlDataSource(); - dataSource.load(packets); + return dataSource.load(packets).then(function(dataSource) { + var targetEntity = dataSource.entities.getById('targetId'); + var referenceObject = dataSource.entities.getById('referenceId'); - var targetEntity = dataSource.entities.getById('targetId'); - var referenceObject = dataSource.entities.getById('referenceId'); - - expect(referenceObject.point.pixelSize instanceof ReferenceProperty).toBe(true); - expect(targetEntity.point.pixelSize.getValue(time)).toEqual(referenceObject.point.pixelSize.getValue(time)); + expect(referenceObject.point.pixelSize instanceof ReferenceProperty).toBe(true); + expect(targetEntity.point.pixelSize.getValue(time)).toEqual(referenceObject.point.pixelSize.getValue(time)); + }); }); it('Can use interval reference properties', function() { @@ -3155,14 +3321,14 @@ defineSuite([ var time2 = JulianDate.fromIso8601('2014'); var dataSource = new CzmlDataSource(); - dataSource.load(packets); - - var targetEntity = dataSource.entities.getById('targetId'); - var targetEntity2 = dataSource.entities.getById('targetId2'); - var referenceObject = dataSource.entities.getById('referenceId'); + return dataSource.load(packets).then(function(dataSource) { + var targetEntity = dataSource.entities.getById('targetId'); + var targetEntity2 = dataSource.entities.getById('targetId2'); + var referenceObject = dataSource.entities.getById('referenceId'); - expect(targetEntity.point.pixelSize.getValue(time1)).toEqual(referenceObject.point.pixelSize.getValue(time1)); - expect(targetEntity2.point.pixelSize.getValue(time2)).toEqual(referenceObject.point.pixelSize.getValue(time2)); + expect(targetEntity.point.pixelSize.getValue(time1)).toEqual(referenceObject.point.pixelSize.getValue(time1)); + expect(targetEntity2.point.pixelSize.getValue(time2)).toEqual(referenceObject.point.pixelSize.getValue(time2)); + }); }); it('Can use constant reference properties for position', function() { @@ -3184,13 +3350,13 @@ defineSuite([ }]; var dataSource = new CzmlDataSource(); - dataSource.load(packets); - - var targetEntity = dataSource.entities.getById('targetId'); - var referenceObject = dataSource.entities.getById('referenceId'); + return dataSource.load(packets).then(function(dataSource) { + var targetEntity = dataSource.entities.getById('targetId'); + var referenceObject = dataSource.entities.getById('referenceId'); - expect(referenceObject.position instanceof ReferenceProperty).toBe(true); - expect(targetEntity.position.getValue(time)).toEqual(referenceObject.position.getValue(time)); + expect(referenceObject.position instanceof ReferenceProperty).toBe(true); + expect(targetEntity.position.getValue(time)).toEqual(referenceObject.position.getValue(time)); + }); }); it('Can use interval reference properties for positions', function() { @@ -3222,14 +3388,14 @@ defineSuite([ var time2 = JulianDate.fromIso8601('2014'); var dataSource = new CzmlDataSource(); - dataSource.load(packets); + return dataSource.load(packets).then(function(dataSource) { + var targetEntity = dataSource.entities.getById('targetId'); + var targetEntity2 = dataSource.entities.getById('targetId2'); + var referenceObject = dataSource.entities.getById('referenceId'); - var targetEntity = dataSource.entities.getById('targetId'); - var targetEntity2 = dataSource.entities.getById('targetId2'); - var referenceObject = dataSource.entities.getById('referenceId'); - - expect(targetEntity.position.getValue(time1)).toEqual(referenceObject.position.getValue(time1)); - expect(targetEntity2.position.getValue(time2)).toEqual(referenceObject.position.getValue(time2)); + expect(targetEntity.position.getValue(time1)).toEqual(referenceObject.position.getValue(time1)); + expect(targetEntity2.position.getValue(time2)).toEqual(referenceObject.position.getValue(time2)); + }); }); it('Can reference properties before they exist.', function() { @@ -3252,13 +3418,13 @@ defineSuite([ }]; var dataSource = new CzmlDataSource(); - dataSource.load(packets); + return dataSource.load(packets).then(function(dataSource) { + var targetEntity = dataSource.entities.getById('targetId'); + var referenceObject = dataSource.entities.getById('referenceId'); - var targetEntity = dataSource.entities.getById('targetId'); - var referenceObject = dataSource.entities.getById('referenceId'); - - expect(referenceObject.point.pixelSize instanceof ReferenceProperty).toBe(true); - expect(targetEntity.point.pixelSize.getValue(time)).toEqual(referenceObject.point.pixelSize.getValue(time)); + expect(referenceObject.point.pixelSize instanceof ReferenceProperty).toBe(true); + expect(targetEntity.point.pixelSize.getValue(time)).toEqual(referenceObject.point.pixelSize.getValue(time)); + }); }); it('Can reference local properties.', function() { @@ -3274,11 +3440,11 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - - var targetEntity = dataSource.entities.getById('testObject'); - expect(targetEntity.point.outlineWidth instanceof ReferenceProperty).toBe(true); - expect(targetEntity.point.outlineWidth.getValue(time)).toEqual(targetEntity.point.pixelSize.getValue(time)); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var targetEntity = dataSource.entities.getById('testObject'); + expect(targetEntity.point.outlineWidth instanceof ReferenceProperty).toBe(true); + expect(targetEntity.point.outlineWidth.getValue(time)).toEqual(targetEntity.point.pixelSize.getValue(time)); + }); }); it('Polyline glow.', function() { @@ -3297,11 +3463,11 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - - var entity = dataSource.entities.getById('polylineGlow'); - expect(entity.polyline.material.color.getValue()).toEqual(new Color(0.1, 0.2, 0.3, 0.4)); - expect(entity.polyline.material.glowPower.getValue()).toEqual(0.75); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.getById('polylineGlow'); + expect(entity.polyline.material.color.getValue()).toEqual(new Color(0.1, 0.2, 0.3, 0.4)); + expect(entity.polyline.material.glowPower.getValue()).toEqual(0.75); + }); }); it('Polyline arrow.', function() { @@ -3319,10 +3485,10 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - - var entity = dataSource.entities.getById('polylineArrow'); - expect(entity.polyline.material.color.getValue()).toEqual(new Color(0.1, 0.2, 0.3, 0.4)); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.getById('polylineArrow'); + expect(entity.polyline.material.color.getValue()).toEqual(new Color(0.1, 0.2, 0.3, 0.4)); + }); }); it('Polyline dash.', function() { @@ -3342,12 +3508,12 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - - var entity = dataSource.entities.getById('polylineDash'); - expect(entity.polyline.material.color.getValue()).toEqual(new Color(0.1, 0.2, 0.3, 0.4)); - expect(entity.polyline.material.dashLength.getValue()).toEqual(16.0); - expect(entity.polyline.material.dashPattern.getValue()).toEqual(7.0); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.getById('polylineDash'); + expect(entity.polyline.material.color.getValue()).toEqual(new Color(0.1, 0.2, 0.3, 0.4)); + expect(entity.polyline.material.dashLength.getValue()).toEqual(16.0); + expect(entity.polyline.material.dashPattern.getValue()).toEqual(7.0); + }); }); it('Processes extrapolation options', function() { @@ -3372,20 +3538,20 @@ defineSuite([ }; var dataSource = new CzmlDataSource(); - dataSource.load(makePacket(packet)); - - var entity = dataSource.entities.getById('point'); - var color = entity.point.color; - expect(color.forwardExtrapolationType).toEqual(ExtrapolationType.NONE); - expect(color.forwardExtrapolationDuration).toEqual(1.0); - expect(color.backwardExtrapolationType).toEqual(ExtrapolationType.HOLD); - expect(color.backwardExtrapolationDuration).toEqual(2.0); - - var position = entity.position; - expect(position.forwardExtrapolationType).toEqual(ExtrapolationType.HOLD); - expect(position.forwardExtrapolationDuration).toEqual(2.0); - expect(position.backwardExtrapolationType).toEqual(ExtrapolationType.NONE); - expect(position.backwardExtrapolationDuration).toEqual(1.0); + return dataSource.load(makePacket(packet)).then(function(dataSource) { + var entity = dataSource.entities.getById('point'); + var color = entity.point.color; + expect(color.forwardExtrapolationType).toEqual(ExtrapolationType.NONE); + expect(color.forwardExtrapolationDuration).toEqual(1.0); + expect(color.backwardExtrapolationType).toEqual(ExtrapolationType.HOLD); + expect(color.backwardExtrapolationDuration).toEqual(2.0); + + var position = entity.position; + expect(position.forwardExtrapolationType).toEqual(ExtrapolationType.HOLD); + expect(position.forwardExtrapolationDuration).toEqual(2.0); + expect(position.backwardExtrapolationType).toEqual(ExtrapolationType.NONE); + expect(position.backwardExtrapolationDuration).toEqual(1.0); + }); }); it('rejects if first document packet lacks version information', function() {