zoukankan      html  css  js  c++  java
  • Cesium 模拟卫星扫描

    此功能已有一段时间没有维护了,后面重新写了一个。

    有疑问可以给我留言或者联系我的q 951973194;感谢大家的关注。

    最近一直在弄关于卫星轨道及卫星扫描的功能,但是又没提供轨道的具体坐标,后端也不提供轨道根数计算轨道坐标的接口。没办法,自己翻阅了好多资料,找出了一个比较冷门的方法,通过卫星的两行参数,结合sgp4来模拟出一段时间的轨道坐标;这次就不晒出结合的方法了,只演示下如何模拟卫星扫描;

    先晒出成果图:

    思路:这里我将卫星和下面的椎体分成了两个entity,通过Cesium.SampledPositionProperty将坐标和时间进行关联,通过插值算法,让轨道平滑,最终达到了这个效果;

    以下为代码:

    var viewer = new Cesium.Viewer('map');
    		var data = [];
    
    		data = [{
    			longitude: 116.405419,
    			dimension: 39.918034,
    			height: 700000,
    			time: 0
    		}, {
    			longitude: 115.2821,
    			dimension: 39.918145,
    			height: 700000,
    			time: 40
    		}, {
    			longitude: 114.497402,
    			dimension: 39.344641,
    			height: 700000,
    			time: 100
    		}, {
    			longitude: 107.942392,
    			dimension: 35.559967,
    			height: 700000,
    			time: 280
    		}, {
    			longitude: 106.549265,
    			dimension: 34.559967,
    			height: 700000,
    			time: 360
    		}, {
    			longitude: 95.2821,
    			dimension: 32.918145,
    			height: 700000,
    			time: 400
    		}, {
    			longitude: 94.497402,
    			dimension: 30.344641,
    			height: 700000,
    			time: 450
    		}, {
    			longitude: 87.942392,
    			dimension: 25.559967,
    			height: 700000,
    			time: 550
    		}, {
    			longitude: 66.549265,
    			dimension: 24.559967,
    			height: 700000,
    			time: 600
    		}];
    
    		// 起始时间
    		var start = Cesium.JulianDate.fromDate(new Date(2017, 7, 11));
    		// 结束时间
    		var stop = Cesium.JulianDate.addSeconds(start, 600, new Cesium.JulianDate());
    
    		// 设置始时钟始时间
    		viewer.clock.startTime = start.clone();
    		// 设置时钟当前时间
    		viewer.clock.currentTime = start.clone();
    		// 设置始终停止时间
    		viewer.clock.stopTime = stop.clone();
    		// 时间速率,数字越大时间过的越快
    		viewer.clock.multiplier = 10;
    		// 时间轴
    		viewer.timeline.zoomTo(start, stop);
    		// 循环执行
    		viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP;
    
    
    		var property = computeFlight(data);
    		// 添加模型
    		var planeModel = viewer.entities.add({
    			// 和时间轴关联
    			availability: new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({
    				start: start,
    				stop: stop
    			})]),
    			position: property,
    			// 根据所提供的速度计算点
    			orientation: new Cesium.VelocityOrientationProperty(property),
    			// 模型数据
    			model: {
    				uri: '../gltfModel/weixin.gltf',
    				minimumPixelSize: 128
    			},
    			path: {
    				resolution: 1,
    				material: new Cesium.PolylineGlowMaterialProperty({
    					glowPower: .1,
    					color: Cesium.Color.YELLOW
    				}),
    				 10
    			}
    		});
    		planeModel.position.setInterpolationOptions({ //设定位置的插值算法
    			interpolationDegree: 5,
    			interpolationAlgorithm: Cesium.LagrangePolynomialApproximation
    		});
    
    		var property2 = computeFlight2(data);
    		var entity_ty = viewer.entities.add({
    			availability: new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({
    				start: start,
    				stop: stop
    			})]),
    			position: property2,
    			orientation: new Cesium.VelocityOrientationProperty(property2),
    			cylinder: {
    				HeightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
    				length: 700000,
    				topRadius: 0,
    				bottomRadius: 700000 / 2,
    				material: Cesium.Color.RED.withAlpha(.4),
    				outline: !0,
    				numberOfVerticalLines: 0,
    				outlineColor: Cesium.Color.RED.withAlpha(.8)
    			},
    		});
    		entity_ty.position.setInterpolationOptions({
    			interpolationDegree: 5,
    			interpolationAlgorithm: Cesium.LagrangePolynomialApproximation
    		});
    
    
    		
    		function computeFlight(source) {
    			var property = new Cesium.SampledPositionProperty();
    			for (var i = 0; i < source.length; i++) {
    				var time = Cesium.JulianDate.addSeconds(start, source[i].time, new Cesium.JulianDate);
    				var position = Cesium.Cartesian3.fromDegrees(source[i].longitude, source[i].dimension, source[i].height);
    				// 添加位置,和时间对应
    				property.addSample(time, position);
    			}
    			return property;
    		}
    
    		function computeFlight2(source) {
    			var property = new Cesium.SampledPositionProperty();
    			for (var i = 0; i < source.length; i++) {
    				var time = Cesium.JulianDate.addSeconds(start, source[i].time, new Cesium.JulianDate);
    				var position = Cesium.Cartesian3.fromDegrees(source[i].longitude, source[i].dimension, source[i].height / 2);
    				// 添加位置,和时间对应
    				property.addSample(time, position);
    			}
    			return property;
    		}
    

    其中computeFlight 和 computeFlight2最大的区别就在于椎体的height的高度为卫星的一半;

    本文转自 https://blog.csdn.net/caozl1132/article/details/86287900,如有侵权,请联系删除。

  • 相关阅读:
    斐波那契数列 的两种实现方式(Java)
    单链表反转
    单链表合并
    两个有序list合并
    list去重 转载
    RemoveAll 要重写equals方法
    Java for LeetCode 138 Copy List with Random Pointer
    Java for LeetCode 137 Single Number II
    Java for LeetCode 136 Single Number
    Java for LeetCode 135 Candy
  • 原文地址:https://www.cnblogs.com/hustshu/p/15614310.html
Copyright © 2011-2022 走看看