自定义飞行路线管理
超图飞行管理是提前在桌面端定义好飞行路线,然后进行飞行,但是在业务中,有时候需要根据业务需要进行飞行,比如根据GPS取到的点进行实际路径飞行。实现思路:先定义一个空的飞行路径,也可以定义一个只包含一个点的飞行路径来进行定位。然后增加自定义站点,代码如下:
var points = [{x: 116.71275583943516,y: 39.895403435720063,z: -5,altitude: -5.1428938554599881,duration: 11.623106459071682,heading: 0.260995919619558,index:0},{x: 116.71261436907912,y: 39.895686008451534,z: -5,altitude: -5.9814573479816318,duration: 12.33481700746625,heading: 0.0340212,index: 1},{x: 116.71246024545442,y: 39.895982950739153,z: -5,duration:10.964990729795865,altitude: -5.5469268001616001,heading: 0.23512687249191,index: 2},{x: 116.71240014157664,y: 39.896118795529922,z: -5,duration:11.157674687612483,altitude: -4.2948793824762106,heading: 0.205987951731911,index: 3},{altitude: -5.673985555768013,duration: 10,heading: 0.038466827467274554,index: 4,x: 116.71217389893071,y: 39.896766717130667,z: -5},{x: 116.712101305757,y: 39.897437426384997,z: -5,duration:11.157674687612483,altitude: -4.2948793824762106,heading: 0.205987951731911,index: 3}];let routes = new Cesium.RouteCollection();var host = document.location.toString().match(/file:\/\//)?"http://localhost:8080":'http://' + document.location.host;var fpfUrl =host+test.fpf';routes.fromFile(fpfUrl);//添加飞行文件Cesium.when(routes.readyPromise, () => {var route = routes.get(0);this.flyManager = new Cesium.FlyManager({scene: this.viewer.scene, routes: routes});this.flyManager.stopArrived.addEventListener((routeStop) => {
// routeStop.waitTime = 3;//修改站点的停留时间routeStop.tilt = 0;//站点俯仰角
// routeStop.heading = scene.camera.heading;//站点方位角routeStop.altitude=-6;//站点高度console.log("到达站点:"+routeStop.stopName+"方位角:"+scene.camera.heading);console.log("到达站点:"+routeStop.stopName+"方位角:"+scene.camera.altitude);});// points.map(el => {
// route.addStop(el)
// });
// var points=data;
// points.sort(up);
// console.log(points);Cesium.when(this.flyManager.readyPromise, () => {var allStops = this.flyManager.getAllRouteStops();var route = this.flyManager.currentRoute;var stop = route.get(0);this.flyManager.viewToStop(stop);this.flyManager.currentIndex=1;//飞行路线可以添加多个route,设置索引来加载不同的路线for(var k = 0; k < points.length ;k++){var position = Cesium.Cartesian3.fromDegrees(parseFloat(points[k].x),parseFloat( points[k].y), parseFloat(points[k].z));var name = "站" + k;var routeStop = new Cesium.RouteStop({point:position,heading:scene.camera.heading,tilt:0,stopName:name,
// speed:23,
// waitTime: 5,index:k,//points[k].index,duration:3, //points[k].duration,altitude:-20//points[k].altitude})console.log("相机方位角:"+scene.camera.heading);route.addStop(routeStop);}setTimeout(function(){if(globe.globeAlpha<0.1){this.flyManager.play();}},7000);});});
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
