diff --git a/CHANGES.md b/CHANGES.md index 2ac781d9c5e..6abe67e12f0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,8 @@ Change Log * Fixed a bug with rotated, textured rectangles. [#4430](https://github.com/AnalyticalGraphicsInc/cesium/pull/4430) * Fixed a bug when morphing from 2D to 3D. [#4388](https://github.com/AnalyticalGraphicsInc/cesium/pull/4388) * Fixed a bug where when KML features had duplicate IDs, only one was drawn. [#3941](https://github.com/AnalyticalGraphicsInc/cesium/issues/3941) +* `GeoJsonDataSource` now treats null crs values as a no-op instead of failing to load. +* `GeoJsonDataSource` now gracefully handles missing style icons instead of failing to load. * Added `Rectangle.simpleIntersection`. * Added the ability to specify retina options, such as `@2x.png`, via the `MapboxImageryProvider` `format` option. * Removed an unnecessary reprojection of Web Mercator imagery tiles to the Geographic projection on load. This should improve both visual quality and load performance slightly. diff --git a/Source/DataSources/GeoJsonDataSource.js b/Source/DataSources/GeoJsonDataSource.js index b8511574386..bdae9dfa831 100644 --- a/Source/DataSources/GeoJsonDataSource.js +++ b/Source/DataSources/GeoJsonDataSource.js @@ -871,12 +871,8 @@ define([ } //Check for a Coordinate Reference System. - var crsFunction = defaultCrsFunction; var crs = geoJson.crs; - - if (crs === null) { - throw new RuntimeError('crs is null.'); - } + var crsFunction = crs !== null ? defaultCrsFunction : null; if (defined(crs)) { if (!defined(crs.properties)) { @@ -912,7 +908,12 @@ define([ return when(crsFunction, function(crsFunction) { that._entityCollection.removeAll(); - typeHandler(that, geoJson, geoJson, crsFunction, options); + + // null is a valid value for the crs, but means the entire load process becomes a no-op + // because we can't assume anything about the coordinates. + if (crsFunction !== null) { + typeHandler(that, geoJson, geoJson, crsFunction, options); + } return when.all(that._promises, function() { that._promises.length = 0; diff --git a/Specs/DataSources/GeoJsonDataSourceSpec.js b/Specs/DataSources/GeoJsonDataSourceSpec.js index 0fba3375607..ac6b8540c02 100644 --- a/Specs/DataSources/GeoJsonDataSourceSpec.js +++ b/Specs/DataSources/GeoJsonDataSourceSpec.js @@ -1133,11 +1133,8 @@ defineSuite([ crs : null }; - return GeoJsonDataSource.load(featureWithNullCrs).then(function() { - fail('should not be called'); - }).otherwise(function(error) { - expect(error).toBeInstanceOf(RuntimeError); - expect(error.message).toContain('crs is null.'); + return GeoJsonDataSource.load(featureWithNullCrs).then(function(dataSource) { + expect(dataSource.entities.values.length).toBe(0); }); });