Hi,
With the newest version of cesium I am getting abnormal rendering on ploygon heirarchy objects that was not present before. Currently using an intel dell computer and the bug shows up on chrome and edge browsers. The bug also shows in the sand box on my college’s mac.
Here is a link to the sandbox:
bug example
When the geojson is displayed outside of cesium there are only rectangular objects, so the issue causes angles lines cutting through the holes.
The behavior is present regardless of clamp to ground conditions. When clamp to ground is true the anomaly moves with zooms, but it is stationary when false. For reference these polygons are created from geojson multipolygons.
Any ideas on a fix besides downgrading cesium?
Thanks!
Hi there,
I’m looking for a bit more context. I see you have an array of polygon positions. It sounds like these are concatenated polygons from a GeoJSON multipolygon.
Are the additional polygons intended to be holes within the first polygon?
Hi Gabby,
Yes, the additional polygons are intended to be holes within the first. For reference, this is what the geojson looks like when correctly displayed:
test.geojson (3.7 KB)
Also here is the raw geojson file
Thanks!
Unfortunately, this is a different issue than the one identified in Cesium v1.110 Introduced Problems with Polygons Containing Holes - #4 by Sequoiaandrade. That example specified holes with the PolygonHierarchy
option holes
, which I don’t see being used here.
Instead, this approach relies on a sort of artifacts of polygon rendering where overlapping to show the holes. Technically though, these polygons are not simple, and therefore not officially supported by CesiumJS since the triagulation library we use under the hood, earcut, does not support these kinds of polygons.
I think it was a happy accident that these were rendering correctly in previous versions. Going forward, I would reccomend simplifying your geojsons before visualizing them in CesiumJS. Turf.js’s unkinkPolygon is one such tool you could use.
Good to know. A bit odd though that everything worked fine for months until the recent update. My geojsons are typically constructed from gdal so I’m not sure that another tool could simplify them, though I’ll look into it. I typically create the imagery using Cesium.GeoJsonDataSource.load() - so just to confirm that method also does not use the holes?
You can usually use these tools on any existing geosjon, so it should still work for geojsons generated from gdal.
Cesium.GeoJsonDataSource.load
will handle holes, as long as they are simple polygons and entirely inside of the outer polygon. See some discussion on thsi topic here. Otherwise the behavior is undefined.