Cesium 遥感卫星影像推送效果绘制

 

 

//添加卫星
        function addSatellite() {
            satellite.curRouteLine = viewer.entities.add({
                name: "satelliteline",
                polyline: {
                    positions: new Cesium.CallbackProperty(function (time, result) {
                        return satellite.curRoutePositions;
                    }, false),
                    material: new Cesium.ColorMaterialProperty(Cesium.Color.YELLOW),
                    width: 3,
                },
            });

            satellite.entity = viewer.entities.add({
                position: Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883),
                billboard: {
                    image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADJSURBVDhPnZHRDcMgEEMZjVEYpaNklIzSEfLfD4qNnXAJSFWfhO7w2Zc0Tf9QG2rXrEzSUeZLOGm47WoH95x3Hl3jEgilvDgsOQUTqsNl68ezEwn1vae6lceSEEYvvWNT/Rxc4CXQNGadho1NXoJ+9iaqc2xi2xbt23PJCDIB6TQjOC6Bho/sDy3fBQT8PrVhibU7yBFcEPaRxOoseTwbwByCOYf9VGp1BYI1BA+EeHhmfzKbBoJEQwn1yzUZtyspIQUha85MpkNIXB7GizqDEECsAAAAASUVORK5CYII=",
                },
                label: {
                    text: 'Landsat8'
                },
                polyline: {
                    positions: new Cesium.CallbackProperty(function (time, result) {
                        //return satellite.entity.position.concat(satellite.curNadir);
                        return (satellite.curNadir && satellite.entity) ? [satellite.entity.position._value, satellite.curNadir] : []
                    }, false),
                    material: new Cesium.ColorMaterialProperty(Cesium.Color.BLUE),
                    width: 1
                }
            });
            var redCone = viewer.entities.add({//红色圆锥体
                name: 'Red cone',
                position: new Cesium.CallbackProperty(function (time, result) {
                    if (satellite.entity) {
                        let p = cesiumCoordUtil.cartesian3ToDegree2(satellite.entity.position._value);
                        return Cesium.Cartesian3.fromDegrees(p.lon, p.lat, p.height / 6 * 5);
                    } else {
                        return Cesium.Cartesian3.fromDegrees(0, 0, 0);
                    }

                }, false),
                cylinder: {
                    length: new Cesium.CallbackProperty(function (time, result) {
                        return (satellite.entity ? cesiumCoordUtil.cartesian3ToDegree2(satellite.entity.position._value).height : 0) / 3;
                    }, false),
                    topRadius: 0.0,
                    bottomRadius: new Cesium.CallbackProperty(function (time, result) {
                        return (satellite.entity ? cesiumCoordUtil.cartesian3ToDegree2(satellite.entity.position._value).height : 0) / 6;
                    }, false),
                    material: Cesium.Color.RED
                }
            });
        }
//动态推送图像
        function addByTime() {
            clear1();
            Cesium.Resource.fetchJson({
                url: './datas/testfilenew.json'
            }).then(function (jsonData) {
                if (!jsonData) {
                    return;
                }
                let level0 = jsonData.level3;
                for (let index = 0; index < level0.length; index++) {
                    const tileData = level0[index];
                    let bbox = tileData.bbox;

                    let imagePath = tileData.imagePath;
                    let id = tileData.id;
                    console.log(id);
                    console.log(imagePath);
                    let xnum = id.split('_')[0];
                    let ynum = id.split('_')[1];
                    imagePath = './datas' + imagePath.replace('./', '/');
                    // start(bbox, imagePath);
                    (function (index) {
                        setTimeout(function () {
                            console.log(index, "interval");
                            //addImage(bbox, './datas/aaa.jpg');
                            addImage(bbox, imagePath);
                            let curSillitePos = Cesium.Cartesian3.fromArray(satellite.routeLine[index]);
                            satellite.curRoutePositions.push(curSillitePos);
                            satellite.entity.position = curSillitePos;
                            satellite.curNadir = Cesium.Cartesian3.fromDegrees(satellite.nadirs[index][0], satellite.nadirs[index][1], 0.0);

                        }, index * 300);
                    })(index);
                }
            }).otherwise(function (error) {

            });

            addSatellite();
        }

 

 

 

 

 

posted on 2020-11-26 19:04  苹果园dog  阅读(1769)  评论(1编辑  收藏  举报

导航