diff --git a/Source/DynamicScene/KmlDataSource.js b/Source/DynamicScene/KmlDataSource.js index 7b3a1a857b0d..63a2c074167d 100644 --- a/Source/DynamicScene/KmlDataSource.js +++ b/Source/DynamicScene/KmlDataSource.js @@ -165,8 +165,6 @@ define(['../Core/createGuid', if(styleUrl.length > 0){ var styleObj = styleCollection.getObject(styleUrl[0].textContent); dynamicObject.merge(styleObj); - } else { - throw new RuntimeError('Undefined style'); } } dynamicObject.position = new ConstantPositionProperty(cartesian3); diff --git a/Specs/DynamicScene/KmlDataSourceSpec.js b/Specs/DynamicScene/KmlDataSourceSpec.js index 8c61f5634265..87373f291b36 100644 --- a/Specs/DynamicScene/KmlDataSourceSpec.js +++ b/Specs/DynamicScene/KmlDataSourceSpec.js @@ -4,14 +4,20 @@ defineSuite(['DynamicScene/KmlDataSource', 'DynamicScene/DynamicBillboard', 'DynamicScene/DynamicPolyline', 'Core/loadXML', - 'Core/Event' + 'Core/Cartographic', + 'Core/Ellipsoid', + 'Core/Event', + 'Core/Math' ], function( KmlDataSource, DynamicObjectCollection, DynamicBillboard, DynamicPolyline, loadXML, - Event) { + Cartographic, + Ellipsoid, + Event, + CesiumMath) { "use strict"; /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/ @@ -25,22 +31,50 @@ defineSuite(['DynamicScene/KmlDataSource', expect(dataSource.getIsTimeVarying()).toEqual(true); }); - it('handlesPointGeometry', function() { - var txt = ''; - txt = txt + ''; - txt = txt + ' IconStyle.kml #randomColorIcon'; - txt = txt + ' -9.171441666666666,38.67883055555556,0 '; + it('handles Point Geometry', function() { + var position = new Cartographic(CesiumMath.toRadians(1), CesiumMath.toRadians(2), 3); + var cartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(position); + var pointKml = '\ + \ + \ + \ + \ + 1,2,3\ + \ + \ + \ + '; + + var parser = new DOMParser(); + var xmlDoc = parser.parseFromString(pointKml, "text/xml"); + var dataSource = new KmlDataSource(); + dataSource.load(xmlDoc); + expect(dataSource.getDynamicObjectCollection().getObjects().length).toEqual(1); + expect(dataSource.getDynamicObjectCollection().getObjects()[0].position.getValueCartesian()).toEqual(cartesianPosition); + }); - var parser=new DOMParser(); - var xmlDoc=parser.parseFromString(txt,"text/xml"); + it('handles Point Geometry without altitude', function() { + var position = new Cartographic(CesiumMath.toRadians(1), CesiumMath.toRadians(2), 0); + var cartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(position); + var pointKml = '\ + \ + \ + \ + \ + 1,2\ + \ + \ + \ + '; + var parser = new DOMParser(); + var xmlDoc = parser.parseFromString(pointKml, "text/xml"); + + var dataSource = new KmlDataSource(); dataSource.load(xmlDoc); - expect(dataSource.getDynamicObjectCollection()).toBeInstanceOf(DynamicObjectCollection); expect(dataSource.getDynamicObjectCollection().getObjects().length).toEqual(1); - expect(dataSource.getDynamicObjectCollection().getObjects()[0].billboard).toBeInstanceOf(DynamicBillboard); - expect(dataSource.getDynamicObjectCollection().getObjects()[0].position).toBeDefined(); + expect(dataSource.getDynamicObjectCollection().getObjects()[0].position.getValueCartesian()).toEqual(cartesianPosition); }); it('handlesLineGeometry', function() { @@ -53,8 +87,8 @@ defineSuite(['DynamicScene/KmlDataSource', txt = txt + '-122.364167,37.824787,50 -122.363917,37.824423,50'; var dataSource = new KmlDataSource(); - var parser=new DOMParser(); - var xmlDoc=parser.parseFromString(txt,"text/xml"); + var parser = new DOMParser(); + var xmlDoc = parser.parseFromString(txt, "text/xml"); dataSource.load(xmlDoc); expect(dataSource.getDynamicObjectCollection()).toBeInstanceOf(DynamicObjectCollection);