Geojson crashes the map

I’m trying to load a json file (.GeoJson), please see attached (change file from .txt to .json). I’m using Cesium 1.53, but the map crashes giving me a DeveloperError: EllipsoidRhumbLine must have distinct start and end set.

This file can be visualized correctly in QGIS for example, no errors.

Basically, I’m doing:

viewer.dataSources.add(Cesium.GeoJsonDataSource.load(‘path_to_file’, {

stroke: Cesium.Color.HOTPINK,

fill: Cesium.Color.PINK.withAlpha(0.5),

strokeWidth: 3

}));

features.txt (384 KB)

This is a known issue, see: https://github.com/AnalyticalGraphicsInc/cesium/issues/7864

As a workaround for now, you’ll need to add this snippet to take the loaded GeoJSON and change its arc type:

var geoJSON = Cesium.GeoJsonDataSource.load( ‘path_to_file’, {
stroke: Cesium.Color.HOTPINK,

fill: Cesium.Color.PINK.withAlpha(0.5),

strokeWidth: 3

});

geoJSON.then(function(data){

// Change the arcType to GEODESIC, which is what it was in CesiumJS 1.53.

for (var i = 0; i < data.entities.values.length; i++) {

    var entity = data.entities.values[i];

    if (Cesium.defined(entity.polygon)) {

        // entity.polygon.arcType = Cesium.ArcType.GEODESIC;

    }

}

viewer.dataSources.add(data);

});

``

Let me know if this works.

Thanks for the answer,

Unfortunately I’m using the React version of Cesium, and still I haven’t found the way of fixing this.

I’ll keep you updated.

That same code should work regardless of how you’re loading in CesiumJS, as long as you can get a reference to the loaded data source and to the viewer instance.

Update: Apparently the dataset (.json) had self-intersecting polygons. I have fixed this, so now Cesium doesn’t crash (it doesn’t show that error message), but it is not solved as Cesium doesn’t render the polygons correctly. Have a look at the attached picture. It draws artifacts. It could be related to that ArcType parameter as well. I don’t know.