/** * 陆军实战战术模拟 */ var tankStartArr = []; var tankPathArr = []; var intervalPopArr = []; var intervaltankId; var tankdata; function loadtankdemo(){ var args = JSON.stringify({ "lType" : "坦克轨迹" }); $.ajax({ type : "post", url : "../../easyAPI/policeLine/queryPoliceLine.action", contentType : "application/json;charset=utf-8", data : args, success : function(data) { if (data.length != 0) { tankdata = data; var pathArr = []; var url = "../../easy3dfile/data/model/military/99tank.gltf"; var pinBuilder = new Cesium.PinBuilder(); for (var i = 0; i < data.length; i++) { var poiArr = stringToNumber(data[i].lPoyline); var poistart = Cesium.Cartesian3.fromDegrees(poiArr[0],poiArr[1],poiArr[2]); var poistartArr = [poistart]; tankStartArr.push(viewer.entities.add({ position : poistart, billboard : { image : pinBuilder.fromText(i,Cesium.Color.RED,36).toDataURL(), verticalOrigin : Cesium.VerticalOrigin.BOTTOM, } })); tankPathArr.push(viewer.entities.add({ id : 'tank'+data[i].lId, polyline : { clampToGround : true, width : 3, show : true, material : new Cesium.PolylineDashMaterialProperty({ color: Cesium.Color.YELLOW }) } })); pathArr.push(poistartArr); } CesiumPop.bindPopGlobeEventHandler(viewer); var j = 1; intervaltankId = setInterval(function(){ for (var x = 0; x < intervalPopArr.length; x++) { CesiumPop.stopInterval(intervalPopArr[x]); } intervalPopArr.length = 0; var startTime = Cesium.JulianDate.now(startTime); var stopTime = Cesium.JulianDate.now(startTime); for (var i = 0; i < tankdata.length; i++) { var poiArr = stringToNumber(data[i].lPoyline); var poiArrM = []; for (var k = 0; k < poiArr.length; k=k+3) { poiArrM.push([poiArr[k],poiArr[k+1],poiArr[k+2]]); } if(poiArrM[j]){ var curpos = Cesium.Cartesian3.fromDegrees(poiArrM[j][0],poiArrM[j][1],poiArrM[j][2]); var prepos = Cesium.Cartesian3.fromDegrees(poiArrM[j-1][0],poiArrM[j-1][1],poiArrM[j-1][2]); var heading = Cesium.Math.toRadians(azimuthtwopoi(poiArrM[j-1][0],poiArrM[j-1][1],poiArrM[j][0],poiArrM[j][1])-180); var hpr = new Cesium.HeadingPitchRoll(heading, 0, 0); var orientation = Cesium.Transforms.headingPitchRollQuaternion(curpos, hpr); pathArr[i].push(curpos); tankPathArr[i].polyline.positions = pathArr[i]; var result = createTankLines([prepos,curpos],orientation,url); if(Cesium.JulianDate.compare(startTime, result.startTime)>0){startTime = result.startTime;} if(Cesium.JulianDate.compare(stopTime, result.stopTime)<0){stopTime = result.stopTime;} if(i==0||i==7){ var popE = viewer.entities.getById("popentitytank"+i); if(popE){ intervalPopArr.push(CesiumPop.updateSampledPopPos(viewer,"tank"+i,[prepos,curpos],50,244,324,Cesium.Color.WHITE)); }else{ var curheight = poiArrM[j][2]+2; var content = '
' +'' +'' +'' +'' +'' +'' +'
型号99B型主战坦克
编号05'+i+'
' +'' +'
77旅
' +'
炮击模拟
' +'
实时载弹量42
XPS198pa
E/P°33
'; var options = { "viewer":viewer, "id":"tank"+i, "popupWidth":244, "popupHeight":324, "pos":{"lon":poiArrM[j][0],"lat":poiArrM[j][1],"alt":poiArrM[j][2]}, "extentHeight":50, "extentColor":Cesium.Color.WHITE, "content":content }; CesiumPop.addDivPop(options); intervalPopArr.push(CesiumPop.updateSampledPopPos(viewer,"tank"+i,[prepos,curpos],50,244,324,Cesium.Color.WHITE)); } } } } j++; viewer.clock.startTime = startTime.clone(); viewer.clock.stopTime = stopTime.clone(); viewer.clock.currentTime = startTime.clone(); viewer.clock.clockRange = Cesium.ClockRange.UNBOUNDED; viewer.clock.multiplier = 1; viewer.timeline.zoomTo(startTime, stopTime); }, 10000); }else{ console.log("坦克轨迹信息为空!"); } }, error : function(XMLHttpRequest, textStatus, errorThrown) { console.log("获取坦克轨迹信息失败!"); } }); } function createTankLines(nodes,orientation,url){ //添加移动实体 var times = []; var startTime = Cesium.JulianDate.now(startTime); for (var i = 0; i < nodes.length; i++) { var time = new Cesium.JulianDate(); Cesium.JulianDate.addSeconds(startTime, i*10, time); times.push(time); } var stopTime = times[times.length - 1]; //插值 var property = new Cesium.SampledPositionProperty(); property.addSamples(times, nodes); viewer.entities.add({ position : property, orientation : orientation, model : { uri : url, scale : 0.0017, lightColor : Cesium.Color.WHITE, shadows : Cesium.ShadowMode.DISABLED } }); return { startTime:startTime, stopTime:stopTime }; } /** * 海军实战战术模拟 */ var navyTargetEntity; var shipStart1; var shipStart2; var pathentity1; var pathentity2; var intervalId; function loadshipdemo(){ //靶区 var targetline = [ Cesium.Cartesian3.fromDegrees(116.367474,19.259384,100), Cesium.Cartesian3.fromDegrees(116.385871,17.255558,100), Cesium.Cartesian3.fromDegrees(112.982371,17.202515,100), Cesium.Cartesian3.fromDegrees(112.969148,19.254026,100), Cesium.Cartesian3.fromDegrees(116.367474,19.259384,100) ]; navyTargetEntity = viewer.entities.add({ id : 'targetregion', polyline : { positions : targetline, clampToGround : true, width : 2, show : true, material : new Cesium.PolylineDashMaterialProperty({ color: Cesium.Color.RED }) }, wall : { positions : Cesium.Cartesian3.fromDegreesArrayHeights([116.367474,19.259384, 3000.0, 116.385871,17.255558, 3000.0, 112.982371,17.202515, 3000.0, 112.969148,19.254026, 3000.0, 116.367474,19.259384, 3000.0]), material : Cesium.Color.RED.withAlpha(0.8), outline : false } }); //军舰移动 var url = "../../easy3dfile/data/model/military/ship2.gltf"; var url2 = "../../easy3dfile/data/model/military/ship2.gltf"; var pinBuilder = new Cesium.PinBuilder(); //指挥舰 var poistart1 = Cesium.Cartesian3.fromDegrees(path1[0][0],path1[0][1],path1[0][2]); shipStart1 = viewer.entities.add({ position : poistart1, billboard : { image : pinBuilder.fromText('指',Cesium.Color.RED,36).toDataURL(), verticalOrigin : Cesium.VerticalOrigin.BOTTOM, } }); pathentity1 = viewer.entities.add({ name : 'path1', polyline : { clampToGround : true, width : 3, show : true, material : new Cesium.PolylineDashMaterialProperty({ color: Cesium.Color.RED }) } }); //靶舰 var poistart2 = Cesium.Cartesian3.fromDegrees(path2[0][0],path2[0][1],path2[0][2]); shipStart2 = viewer.entities.add({ position : poistart2, billboard : { image : pinBuilder.fromText('靶',Cesium.Color.YELLOW,36).toDataURL(), verticalOrigin : Cesium.VerticalOrigin.BOTTOM, } }); pathentity2 = viewer.entities.add({ name : 'path2', polyline : { clampToGround : true, width : 3, show : true, material : new Cesium.PolylineDashMaterialProperty({ color: Cesium.Color.YELLOW }) } }); CesiumPop.bindPopGlobeEventHandler(viewer); var i = 1; var trend = true; var path1Arr = [poistart1]; var path2Arr = [poistart2]; intervalId = setInterval(function(){ var startTime = Cesium.JulianDate.now(startTime); var stopTime = Cesium.JulianDate.now(startTime); CesiumRadar.clear(viewer); if(path1[i]){ CesiumPop.removeDivPopById(viewer,'ship1'); var curpos1 = Cesium.Cartesian3.fromDegrees(path1[i][0],path1[i][1],path1[i][2]); var heading1 = Cesium.Math.toRadians(path1[i][3]-180); var pitch1 = 0; var roll1 = 0; var hpr1 = new Cesium.HeadingPitchRoll(heading1, pitch1, roll1); var orientation1 = Cesium.Transforms.headingPitchRollQuaternion(curpos1, hpr1); path1Arr.push(Cesium.Cartesian3.fromDegrees(path1[i][0],path1[i][1],path1[i][2])); pathentity1.polyline.positions = path1Arr; var content = '
' +'' +'' +'' +'' +'' +'' +'' +'' +'' +'
舰名辽宁舰
舷号16
' +'' +'
南 海
' +'
指 挥
' +'
经度'+path1[i][0]+'
纬度'+path1[i][1]+'
方位角'+path1[i][3]+'
Eb/n0'+path1[i][4]+'
AGC'+path1[i][5]+'
网速'+path1[i][6]+'
'; var options = { "viewer":viewer, "id":"ship1", "popupWidth":244, "popupHeight":324, "pos":{"lon":path1[i][0],"lat":path1[i][1],"alt":path1[i][2]}, "extentHeight":3000, "extentColor":Cesium.Color.WHITE, "content":content }; CesiumPop.addDivPop(options); var result = createShipLines([poistart1,curpos1],orientation1,url); poistart1 = curpos1; if(Cesium.JulianDate.compare(startTime, result.startTime)>0){startTime = result.startTime;} if(Cesium.JulianDate.compare(stopTime, result.stopTime)<0){stopTime = result.stopTime;} var smoption = {}; smoption.viewer = viewer; smoption.position = new Cesium.Cartesian3.fromDegrees(path1[i][0],path1[i][1],path1[i][2]); smoption.id = "radar1"; smoption.heading = 15*i; smoption.pitch = 0.0; smoption.roll = 0.0; smoption.angle = 120; smoption.cone = 40; smoption.far = 5000; smoption.near = 5; smoption.color = Cesium.Color.RED.withAlpha(0.2); smoption.outColor = Cesium.Color.RED.withAlpha(0.7); CesiumRadar.create(smoption); } if(path2[i]){ CesiumPop.removeDivPopById(viewer,'ship2'); var curpos2 = Cesium.Cartesian3.fromDegrees(path2[i][0],path2[i][1],path2[i][2]) var heading2 = Cesium.Math.toRadians(path2[i][3]-180); var pitch2 = 0; var roll2 = 0; var hpr2 = new Cesium.HeadingPitchRoll(heading2, pitch2, roll2); var orientation2 = Cesium.Transforms.headingPitchRollQuaternion(curpos2, hpr2); path2Arr.push(Cesium.Cartesian3.fromDegrees(path2[i][0],path2[i][1],path2[i][2])); pathentity2.polyline.positions = path2Arr; var content = '
' +'' +'' +'' +'' +'' +'' +'' +'' +'' +'
舰名鹰潭舰
舷号052
' +'' +'
南 海
' +'
靶 舰
' +'
经度'+path2[i][0]+'
纬度'+path2[i][1]+'
方位角'+path2[i][3]+'
Eb/n0'+path2[i][4]+'
AGC'+path2[i][5]+'
网速'+path2[i][6]+'
'; var options = { "viewer":viewer, "id":"ship2", "popupWidth":244, "popupHeight":324, "pos":{"lon":path2[i][0],"lat":path2[i][1],"alt":path2[i][2]}, "extentHeight":3000, "extentColor":Cesium.Color.WHITE, "content":content }; CesiumPop.addDivPop(options); var result = createShipLines([poistart2,curpos2],orientation2,url2); poistart2 = curpos2; if(Cesium.JulianDate.compare(startTime, result.startTime)>0){startTime = result.startTime;} if(Cesium.JulianDate.compare(stopTime, result.stopTime)<0){stopTime = result.stopTime;} var smoption = {}; smoption.viewer = viewer; smoption.position = new Cesium.Cartesian3.fromDegrees(path2[i][0],path2[i][1],path2[i][2]); smoption.id = "radar2"; smoption.heading = 20*i+30; smoption.pitch = 0.0; smoption.roll = 0.0; smoption.angle = 120; smoption.cone = 40; smoption.far = 5000; smoption.near = 5; smoption.color = Cesium.Color.GREEN.withAlpha(0.2); smoption.outColor = Cesium.Color.GREEN.withAlpha(0.7); CesiumRadar.create(smoption); } if(trend){ i++; if(i>300){ trend = false; } }else{ i--; if(i<1){ trend = true; } } viewer.clock.startTime = startTime.clone(); viewer.clock.stopTime = stopTime.clone(); viewer.clock.currentTime = startTime.clone(); viewer.clock.clockRange = Cesium.ClockRange.UNBOUNDED; viewer.clock.multiplier = 1; viewer.timeline.zoomTo(startTime, stopTime); }, 5000); } function createShipLines(nodes,orientation,url){ //添加移动实体 var times = []; var startTime = Cesium.JulianDate.now(startTime); for (var i = 0; i < nodes.length; i++) { var time = new Cesium.JulianDate(); Cesium.JulianDate.addSeconds(startTime, i*5, time); times.push(time); } var stopTime = times[times.length - 1]; //插值 var property = new Cesium.SampledPositionProperty(); property.addSamples(times, nodes); viewer.entities.add({ position : property, orientation : orientation, model : { uri : url, minimumPixelSize : 128, maximumScale : 25000 } }); return { startTime:startTime, stopTime:stopTime }; } function removetankdemo(){ clearInterval(intervaltankId); CesiumPop.clearDivPop(viewer); for (var x = 0; x < tankStartArr.length; x++) { viewer.entities.remove(tankStartArr[x]); } for (var y = 0; y < tankPathArr.length; y++) { viewer.entities.remove(tankPathArr[y]); } for (var i = 0; i < intervalPopArr.length; i++) { CesiumPop.stopInterval(intervalPopArr[i]); } intervalPopArr.length = 0; tankStartArr.length = 0; tankPathArr.length = 0; clearmissilelaunch(); } function removeshipdemo(){ clearInterval(intervalId); CesiumPop.clearDivPop(viewer); viewer.entities.remove(navyTargetEntity); viewer.entities.remove(shipStart1); viewer.entities.remove(shipStart2); viewer.entities.remove(pathentity1); viewer.entities.remove(pathentity2); for (var x = 0; x < disturbArr.length; x++) { viewer.entities.remove(disturbArr[x]); } CesiumRadar.clear(viewer); clearmissilelaunch(); } function removeMilitary(){ removeshipdemo(); removetankdemo(); } var disturbArr = []; function dropdisturb(x,y,z){ var pos1 = Cesium.Cartesian3.fromDegrees(x-0.01,y,z); var pos2 = Cesium.Cartesian3.fromDegrees(x,y-0.01,z); var pos3 = Cesium.Cartesian3.fromDegrees(x-0.01,y-0.01,z); var pos4 = Cesium.Cartesian3.fromDegrees(x+0.01,y,z); var pos5 = Cesium.Cartesian3.fromDegrees(x,y+0.01,z); var pos6 = Cesium.Cartesian3.fromDegrees(x+0.01,y+0.01,z); disturbArr.push(viewer.entities.add({ position: pos1, point: { pixelSize: 10, color: Cesium.Color.GREEN.withAlpha(0.8), disableDepthTestDistance: 8000, outlineWidth: 2, outlineColor: Cesium.Color.YELLOW.withAlpha(1), }, }), viewer.entities.add({ position: pos2, point: { pixelSize: 10, color: Cesium.Color.GREEN.withAlpha(0.8), disableDepthTestDistance: 8000, outlineWidth: 2, outlineColor: Cesium.Color.YELLOW.withAlpha(1) }, }), viewer.entities.add({ position: pos3, point: { pixelSize: 10, color: Cesium.Color.GREEN.withAlpha(0.8), disableDepthTestDistance: 8000, outlineWidth: 2, outlineColor: Cesium.Color.YELLOW.withAlpha(1) }, }), viewer.entities.add({ position: pos4, point: { pixelSize: 10, color: Cesium.Color.GREEN.withAlpha(0.8), disableDepthTestDistance: 8000, outlineWidth: 2, outlineColor: Cesium.Color.YELLOW.withAlpha(1) }, }), viewer.entities.add({ position: pos5, point: { pixelSize: 10, color: Cesium.Color.GREEN.withAlpha(0.8), disableDepthTestDistance: 8000, outlineWidth: 2, outlineColor: Cesium.Color.YELLOW.withAlpha(1) }, }), viewer.entities.add({ position: pos6, point: { pixelSize: 10, color: Cesium.Color.GREEN.withAlpha(0.8), disableDepthTestDistance: 8000, outlineWidth: 2, outlineColor: Cesium.Color.YELLOW.withAlpha(1) }, })); } function missileLaunch(x,y,z,tx,ty,ch){ clearmissilelaunch(); var options = { 'lon':x, 'lat':y, 'alt':z, 'targetlon':tx, 'targetlat':ty, 'curheight':ch, 'viewer':viewer }; CesiumCurvedTrail.create(options); } function clearmissilelaunch(){ CesiumCurvedTrail.clear(viewer); } function drawstraightArrow(){ var cssColorStr = '#'+$('.colpick_hex_field').children('input').val(); CesiumArrow.draw("straightArrow",cssColorStr); } function drawattackArrow(){ var cssColorStr = '#'+$('.colpick_hex_field').children('input').val(); CesiumArrow.draw("attackArrow",cssColorStr); } function drawpincerArrow(){ var cssColorStr = '#'+$('.colpick_hex_field').children('input').val(); CesiumArrow.draw("pincerArrow",cssColorStr); } function saveArrow(){ var planName = $('#planName').val(); if(planName!=''){ var result = CesiumArrow.saveData(); var obj = { 'planName':planName, 'planPos':result }; var args = JSON.stringify(obj); $.ajax({ type : "post", url : "../../easyAPI/plan/insert.action", data : args, contentType : "application/json;charset=utf-8", success : function(data) { if(data == 1){ getPlanAll(); }else{ console.log("保存失败!"); } }, error : function(XMLHttpRequest, textStatus, errorThrown) { console.log("ajax请求失败!"); } }); }else{ swal("请输入作战方案名称!","请重试!","error"); } } function clearOneArrow(){ CesiumArrow.clearOne(); } function clearAllArrow(){ CesiumArrow.clearAll(); } var planData; function getPlanAll(){ $.ajax({ type : "post", url : "../../easyAPI/plan/getPlan.action", contentType : "application/json;charset=utf-8", success : function(data) { showPlans(data); planData = data; }, error : function(XMLHttpRequest, textStatus, errorThrown) { console.log("获取标签信息失败!"); } }); } function deletePlanById(planId){ $.ajax({ type : "post", url : "../../easyAPI/plan/delete.action", data : "planId="+planId, success : function(data) { if (data == 1) { clearAllArrow(); getPlanAll(); }else{ console.log("删除作战方案失败!"); }; }, error : function(XMLHttpRequest, textStatus, errorThrown) { console.log("删除作战方案失败!"); } }); } function showPlans(data){ var content = ''; for (var i = 0; i < data.length; i++) { content += '
' + '
'; } $('#millayer').html(content); } function getPlanById(planId){ for (var i = 0; i < planData.length; i++) { if(planId==planData[i].planId){ var args = $.parseJSON(planData[i].planPos); CesiumArrow.showData(args); break; } } }