How to load stereo lines in batch by Cesium
Editor to share with you how Cesium loads stereo lines in batches. I hope you will get something after reading this article. Let's discuss it together.
In the sample program of Cesium's official website, how to draw a line into a three-dimensional shape, the detailed address is: https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/index.html?src=Corridor.html&label=Geometries
In the sample program of Cesium's official website, how to load the data of geojson. The detailed address is: https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/index.html?src=GeoJSON%20and%20TopoJSON.html&label=DataSources.
So, how to bulk load the geojson data into a three-dimensional linear mode, the following is a detailed implementation code:
Load the geojson and wait synchronously.
Let promise = Cesium.GeoJsonDataSource.load ('data/guizhouroad1.geojson')
In the wait event, perform the conversion of the line to a solid column
Promise.then (function (dataSource) {
/ / entities loaded by geojson
Let entities = dataSource.entities.values
/ / convert solid columnar lines
Entity.polylineVolume = new Cesium.PolylineVolumeGraphics ({
/ / set the location
Positions: entity.polyline.positions
/ / calculate solid cylindrical coordinates
Shape: computeCircle (300.0)
/ / set color or map
Material: Cesium.Color.RED
});
/ / set the plane to be empty first
Entity.polyline = null
}
/ / add a data source and zoom over
Viewer.dataSources.add (dataSource)
Viewer.zoomTo (viewer.entities)
Console.log (idx)
) .otherwise (function (error) {
Window.alert (error)
});
/ / calculate the solid cylindrical function
Function computeCircle (radius) {
Var positions = []
For (var I = 0; I < 360; I + = 2) {
Var radians = Cesium.Math.toRadians (I)
Positions.push (new Cesium.Cartesian2 (radius * Math.cos (radians), radius * Math.sin (radians)
}
Return positions
}
After reading this article, I believe you have a certain understanding of "how to bulk load stereo lines in Cesium". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!