溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Cesium如何批量加載立體線

發(fā)布時(shí)間:2021-12-03 17:44:45 來源:億速云 閱讀:246 作者:小新 欄目:大數(shù)據(jù)

小編給大家分享一下Cesium如何批量加載立體線,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

Cesium的官網(wǎng)程序樣例中,如何把一條線,畫成一個(gè)立體的形狀,詳細(xì)地址為:https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/index.html?src=Corridor.html&label=Geometries

Cesium如何批量加載立體線

Cesium的官網(wǎng)程序樣例中,如何加載geojson的數(shù)據(jù),詳細(xì)地址為:https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/index.html?src=GeoJSON%20and%20TopoJSON.html&label=DataSources

Cesium如何批量加載立體線

那么,如何將geojson的數(shù)據(jù),批量的加載成立體的線狀模式呢,下邊列舉詳細(xì)的實(shí)現(xiàn)代碼:

把geojson給加載進(jìn)來,采用同步等待的方式;

let promise = Cesium.GeoJsonDataSource.load('data/guizhouroad1.geojson');

 在等待事件中,執(zhí)行將線轉(zhuǎn)換成立體柱狀;

promise.then(function(dataSource) {

//geojson加載進(jìn)來的實(shí)體

let entities = dataSource.entities.values; 

//轉(zhuǎn)換立體柱狀線

entity.polylineVolume = new Cesium.PolylineVolumeGraphics({

               //設(shè)置位置

positions: entity.polyline.positions,

               //計(jì)算立體柱狀坐標(biāo)

shape: computeCircle(300.0),

              //設(shè)置顏色或貼圖

material: Cesium.Color.RED

}); 

              //設(shè)置平面先為空

entity.polyline = null;

}

                //添加數(shù)據(jù)源并縮放過去

 viewer.dataSources.add(dataSource);

 viewer.zoomTo(viewer.entities);

 console.log(idx); 

}).otherwise(function(error) { 

window.alert(error);

                     });

 //計(jì)算立體柱狀函數(shù)

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;

}

看完了這篇文章,相信你對(duì)“Cesium如何批量加載立體線”有了一定的了解,如果想了解更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI