CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.93k stars 3.48k forks source link

Why Load geojson with Cesium3DTileset in 2d is not same as GeoJsonDataSource? #10777

Closed libofei2004 closed 2 years ago

libofei2004 commented 2 years ago

I load a geojson with dataSources in 2d like this way: viewer.dataSources.add( Cesium.GeoJsonDataSource.load( "../../Cesium-1.97/p1.json",
{ stroke: Cesium.Color.HOTPINK, fill: Cesium.Color.PINK.withAlpha(0.5), strokeWidth: 3 } ) ); It seems like this: image

Then I load the same geojson with Cesium3DTileset in 2d like this way: const tileset = new Cesium.Cesium3DTileset({ url: "../../Cesium-1.97/tileset.json" }); viewer.scene.primitives.add(tileset); tileset.style = new Cesium.Cesium3DTileStyle({ color: "rgba(255, 0, 0, 0.8)" }); the tileset.json content is: { "asset":{"version":"0.0","tilesetVersion":"1.0"}, "root":{ "boundingVolume":{ "region": [-3.14159,-1.57,3.14159,1.57,0,10000] }, "geometricError":100000, "content":{"uri":"p1.json"} } } The geojson seems like this, it's bend. image

In 3d mode, they looks the same,but in 2d mode,they are different, why? How to make geojson with Cesium3DTileset looks the same as GeoJsonDataSource?

ggetz commented 2 years ago

So the root of the difference in curvature is likely due to a difference in the arc type used in either case, which will determine how a 3D line is projected into 2D space. Though its odd that Cesium3dTileset and DataSource are not consistant. My guess is they both should be using Rhumb lines and result in a "straight line" in 2D.

@lilleyse Can you confirm?

lilleyse commented 2 years ago

GeoJsonLoader (used by 3D Tiles) uses geodesic lines for performance reasons to avoid subsampling the geometry. Generally unless you have a tileset with the MAXAR_content_geojson extension you should be using GeoJsonDataSource which is a much more complete GeoJson implementation.

libofei2004 commented 2 years ago

@lilleyse I use a tileset for drawing geojson is indeed for good performance,drawing by tileset is much more efficient than GeoJsonDataSource.

ggetz commented 2 years ago

Thanks @lilleyse! @libofei2004 I'm going to close the issue based on that answer. Let us know if there is still an issue.

libofei2004 commented 2 years ago

Generally unless you have a tileset with the MAXAR_content_geojson extension you should be using GeoJsonDataSource which is a much more complete GeoJson implementation.

@ggetz @lilleyse I want to know how to have a tileset with the MAXAR_content_geojson extension?Does it make the geojson drawing a straight line?