cesium은 두 점 사이의 거리를 계산한다

1236 단어 js
//positions  
disTance=function(positions){
			var distance = 0;
			for (var i = 0; i < positions.length - 1; i++) { 
				
			var point1cartographic = Cesium.Cartographic.fromCartesian(positions[i]);
			var point2cartographic = Cesium.Cartographic.fromCartesian(positions[i+1]);
			/** **/
			var geodesic = new Cesium.EllipsoidGeodesic();
			geodesic.setEndPoints(point1cartographic, point2cartographic);
			var s = geodesic.surfaceDistance;
		    // 
//			s = Math.sqrt(Math.pow(s, 2) + Math.pow(point2cartographic.height - point1cartographic.height, 2));	
			s=Math.abs(point2cartographic.height - point1cartographic.height);	
			distance = distance + s;
			}	
			return distance.toFixed(3);
		}	

평면 좌표를 위도 좌표로 변환하는 두 점을 그립니다.
var cartesian = viewer.scene.pickPosition(e.position);
result.points.push(cartesian);        
 var points=[];
        		result.points.map((item)=>{
			    var cartographic = Cesium.Cartographic.fromCartesian(item);
			    var point={};
			    point.x = Cesium.Math.toDegrees(cartographic.longitude);
			    point.y= Cesium.Math.toDegrees(cartographic.latitude);
			    point.z = cartographic.height;
     	        points.push(point);
			});

좋은 웹페이지 즐겨찾기