diff --git a/CHANGES.md b/CHANGES.md index 99397a1266c3..bbe0639f423f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ Change Log ========== ### 1.39 - 2017-11-01 +* Added function that inserts missing namespace declarations into KML files. [#5860](https://github.com/AnalyticalGraphicsInc/cesium/pull/5860) * Added support for the layer.json `parentUrl` property in `CesiumTerrainProvider` to allow for compositing of tilesets. * Fixed a bug that caused KML ground overlays to appear distorted when rotation was applied. [#5914](https://github.com/AnalyticalGraphicsInc/cesium/issues/5914) * Adds `invertClassification` and `invertClassificationColor` to `Scene`. When `invertClassification` is `true`, any 3D Tiles geometry that is not classified by a `ClassificationPrimitive` or `GroundPrimitive` will have its color multiplied by `invertClassificationColor`. [#5836](https://github.com/AnalyticalGraphicsInc/cesium/pull/5836) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d1476a7c992d..a9e5f51b5e3e 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -93,6 +93,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Logilab](https://www.logilab.fr/) * [Florent Cayré](https://github.com/fcayre/) * [Novetta](http://www.novetta.com/) + * [Natanael Rivera](https://github.com/nrivera-Novetta/) * [Justin Burr](https://github.com/jburr-nc/) ## [Individual CLA](Documentation/Contributors/CLAs/individual-cla-agi-v1.0.txt) diff --git a/Source/DataSources/KmlDataSource.js b/Source/DataSources/KmlDataSource.js index 0da6c9ea118a..4a574002a6c2 100644 --- a/Source/DataSources/KmlDataSource.js +++ b/Source/DataSources/KmlDataSource.js @@ -255,6 +255,33 @@ define([ return deferred.promise; } + function insertNamespaces(text) { + var namespaceMap = { + xsi : 'http://www.w3.org/2001/XMLSchema-instance' + }; + var firstPart, lastPart, reg, declaration; + + for (var key in namespaceMap) { + if (namespaceMap.hasOwnProperty(key)) { + reg = RegExp('[< ]' + key + ':'); + declaration = 'xmlns:' + key + '='; + if (reg.test(text) && text.indexOf(declaration) === -1) { + if (!defined(firstPart)) { + firstPart = text.substr(0, text.indexOf(' + + + + + image.png]]> + + 1,2,3 + + + + diff --git a/Specs/DataSources/KmlDataSourceSpec.js b/Specs/DataSources/KmlDataSourceSpec.js index 93d70d10f28e..acaacb86430c 100644 --- a/Specs/DataSources/KmlDataSourceSpec.js +++ b/Specs/DataSources/KmlDataSourceSpec.js @@ -244,6 +244,14 @@ defineSuite([ }); }); + it('load inserts missing namespace declaration', function() { + var dataSource = new KmlDataSource(options); + return dataSource.load('Data/KML/undeclaredNamespaces.kml').then(function(source) { + expect(source).toBe(dataSource); + expect(source.entities.values.length).toEqual(1); + }); + }); + it('load rejects nonexistent URL', function() { return KmlDataSource.load('test.invalid', options).otherwise(function(e) { expect(e).toBeInstanceOf(RequestErrorEvent);