Skip to content

Commit

Permalink
Merge pull request #4456 from AnalyticalGraphicsInc/null-crs
Browse files Browse the repository at this point in the history
Treats null crs values as a no-op instead of failing to load
  • Loading branch information
Hannah committed Oct 19, 2016
2 parents c384bf8 + 5ccc13e commit c2002cc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 7 additions & 6 deletions Source/DataSources/GeoJsonDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions Specs/DataSources/GeoJsonDataSourceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand Down

0 comments on commit c2002cc

Please sign in to comment.