From d8018b023239a900979b795ab8720fcc5a236ec1 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Mon, 17 Aug 2015 18:11:46 -0400 Subject: [PATCH 1/2] Don't assume the first element of the KML node is the root feature NetworkLinkControl elements can be children of the kml root node but do not count as the root feature node. Instead, we need to iterate all kml child nodes to locate the root feature node. --- Source/DataSources/KmlDataSource.js | 9 ++++++++- Specs/DataSources/KmlDataSourceSpec.js | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Source/DataSources/KmlDataSource.js b/Source/DataSources/KmlDataSource.js index 8a4c30f88ca8..096299d6e8dd 100644 --- a/Source/DataSources/KmlDataSource.js +++ b/Source/DataSources/KmlDataSource.js @@ -1544,7 +1544,14 @@ define([ return when.all(processStyles(dataSource, kml, styleCollection, sourceUri, false, uriResolver), function() { var element = kml.documentElement; if (element.localName === 'kml') { - element = element.firstElementChild; + var childNodes = element.childNodes; + for (var i = 0; i < childNodes.length; i++) { + var tmp = childNodes[i]; + if (defined(featureTypes[tmp.localName])) { + element = tmp; + break; + } + } } processFeatureNode(dataSource, element, undefined, entityCollection, styleCollection, sourceUri, uriResolver); diff --git a/Specs/DataSources/KmlDataSourceSpec.js b/Specs/DataSources/KmlDataSourceSpec.js index 66f2096f0c0b..57097bf62da4 100644 --- a/Specs/DataSources/KmlDataSourceSpec.js +++ b/Specs/DataSources/KmlDataSourceSpec.js @@ -2833,4 +2833,22 @@ defineSuite([ expect(entity.polygon.perPositionHeight.getValue()).toEqual(true); }); }); + + it('Properly finds the root feature node when it is not the first child of the KML node', function() { + var kml = '\ + \ + \ + \ + \ + bob\ + \ + '; + + return KmlDataSource.load(parser.parseFromString(kml, "text/xml")).then(function(dataSource) { + var entity = dataSource.entities.values[0]; + expect(entity.name).toBe('bob'); + expect(entity.label).toBeDefined(); + expect(entity.label.text.getValue()).toBe('bob'); + }); + }); }); \ No newline at end of file From a494d60660c5a084a6becdfea439463a7d9cd89d Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Mon, 17 Aug 2015 18:14:11 -0400 Subject: [PATCH 2/2] Update changes. --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 57cee6cb5f9e..2a8d1bf01348 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,7 @@ Change Log * Deprecated * * Fix issue where extruded `PolygonGeometry` was always extruding to the ellipsoid surface instead of specified height. - +* Fix an issue where non-feature nodes prevented KML documents from loading. [#2945](https://github.com/AnalyticalGraphicsInc/cesium/pull/2945). ### 1.12 - 2015-08-03