feature: 实现两个曲线图同时动态绘制

devzpx
zhaipx 2 months ago
parent 5548c7e57e
commit e81f71b1d3

@ -119,6 +119,23 @@ export default class MeasureDistance {
this.viewer.scene.requestRender() this.viewer.scene.requestRender()
} }
addPointEntity(position){
let pEntity = this.viewer.entities.add({
position: position,
type: "routeDetectPoint",
point: {
show: true,
pixelSize: 10,
color: Cesium.Color.ORANGERED,
outlineColor: Cesium.Color.WHITE,
outlineWidth: 2,
clampToGround: true,
heightReference:Cesium.HeightReference.CLAMP_TO_GROUND,
disableDepthTestDistance:99000000,
},
});
this.vertexEntities.push(pEntity)
}
addKml(kml_file){ addKml(kml_file){
let kmlDataPromise = Cesium.KmlDataSource.load(kml_file, { let kmlDataPromise = Cesium.KmlDataSource.load(kml_file, {
camera: this.viewer.scene.camera, camera: this.viewer.scene.camera,
@ -377,6 +394,7 @@ export default class MeasureDistance {
window.viewer.trackedEntity = null; window.viewer.trackedEntity = null;
window.viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY); window.viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
} }
stopAreaMeasure(){ stopAreaMeasure(){
if (!this.measAreaStatus) return; if (!this.measAreaStatus) return;
this.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); this.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);

@ -8,7 +8,7 @@ import {useLayerStore} from "@/store/layerManagerStore.ts";
*/ */
function dataProcess(websocketDataCC:any): UavDynamicInfo|null { function dataProcess(websocketDataCC:any): UavDynamicInfo|null {
let data:UavDynamicInfo = { let data:UavDynamicInfo = {
alt: 0, groundSpeed: 0, heading: 0, lat: 0, lon: 0, uavId: "", uavType: "" alt: 0, groundSpeed: 0, heading: 0, pitch: 0,lat: 0, lon: 0, uavId: "", uavType: ""
} }
if(websocketDataCC.infoType===1) { if(websocketDataCC.infoType===1) {
let aUavInfo:any = websocketDataCC.info[0] //目前只取第一个uav let aUavInfo:any = websocketDataCC.info[0] //目前只取第一个uav
@ -38,11 +38,12 @@ function dataProcess(websocketDataCC:any): UavDynamicInfo|null {
*/ */
function dataProcess_fromQT(websocketDataQT:any): UavDynamicInfo|null { function dataProcess_fromQT(websocketDataQT:any): UavDynamicInfo|null {
let data:UavDynamicInfo = { let data:UavDynamicInfo = {
alt: 0, groundSpeed: 0, heading: 0, lat: 0, lon: 0, uavId: "", uavType: "" alt: 0, groundSpeed: 0, heading: 0, pitch: 0, lat: 0, lon: 0, uavId: "", uavType: ""
} }
data.uavId = websocketDataQT.pos.uavId data.uavId = websocketDataQT.pos.uavId
data.uavType = websocketDataQT.pos.uavType data.uavType = websocketDataQT.pos.uavType
data.heading = websocketDataQT.pos.HeadAngle data.heading = websocketDataQT.pos.HeadAngle
data.pitch = websocketDataQT.pos.FyAngle
data.lon = websocketDataQT.pos.lon data.lon = websocketDataQT.pos.lon
data.lat = websocketDataQT.pos.lat data.lat = websocketDataQT.pos.lat
data.alt = Number(websocketDataQT.pos.height) + useLayerStore().navi.hFactor data.alt = Number(websocketDataQT.pos.height) + useLayerStore().navi.hFactor

@ -11,26 +11,28 @@ import {EChartsType} from "echarts";
import {useLayerStore} from "@/store/layerManagerStore.ts"; import {useLayerStore} from "@/store/layerManagerStore.ts";
let l_store = useLayerStore() let l_store = useLayerStore()
let myChart: EChartsType = undefined let myChart: EChartsType = undefined
let myChart1: EChartsType = undefined
let uavDisArr: number[] = [] let uavDisArr: number[] = []
let uavHeightArr: number[] = [] let uavHeightArr: number[] = []
let terrainArr: number[] = [] let terrainArr: number[] = []
onMounted(()=>{ onMounted(()=>{
myChart = echarts.init(document.getElementById('detection-chart')) myChart = echarts.init(document.getElementById('detection-chart'))
myChart1 = echarts.init(document.getElementById('terrain-chart'))
}) })
const props = defineProps(['groundHeight']) const props = defineProps(['groundHeight'])
/** /**
* 绘制地形碰撞检测折线图 * 绘制地形碰撞检测折线图差值间隔为1km
* @param height 飞机高度作为检测线 * @param height 飞机高度作为检测线
* @param currentPos 当前飞机经纬度作为原点 * @param currentPos 当前飞机经纬度作为原点
* @param nextPos 下一航点经纬度作为目标点 * @param nextPos 下一航点经纬度作为目标点
* @param max_dis 预先探测距离 m
*/ */
const drawDetection = (height: number, currentPos:Cartesian3, nextPos: Cartesian3) => { const drawTerrain = (height: number, currentPos:Cartesian3, nextPos: Cartesian3, max_dis: number) => {
// //
let res = profileAnalyse(window.viewer, [currentPos, nextPos], 10) let res = profileAnalyse(window.viewer, [currentPos, nextPos], max_dis/1000)
// //
drawEcharts_CollisionDetection(myChart, res.distanceArray, res.elevationArray, height) drawEcharts_CollisionDetection(myChart1, res.distanceArray, res.elevationArray, height, max_dis)
} }
/** /**
@ -39,7 +41,7 @@ const drawDetection = (height: number, currentPos:Cartesian3, nextPos: Cartesian
* @param uavDis 飞机当前位置与上一位置的距离 * @param uavDis 飞机当前位置与上一位置的距离
* @param terrainH 飞机当前地面投影点的地形高度 * @param terrainH 飞机当前地面投影点的地形高度
*/ */
const drawDetection2 = (uavH: number, uavDis:number, terrainH: number) => { const drawDetection = (uavH: number, uavDis:number, terrainH: number) => {
if(uavDisArr.length == 0){ if(uavDisArr.length == 0){
uavDisArr.push(Math.round(uavDis)) uavDisArr.push(Math.round(uavDis))
} }
@ -57,24 +59,28 @@ const drawDetection2 = (uavH: number, uavDis:number, terrainH: number) => {
defineExpose({ defineExpose({
drawDetection, drawDetection,
drawDetection2, drawTerrain,
}) })
</script> </script>
<template> <template>
<n-space> <div class="chart" id="detection-chart"></div>
<span style="font-weight: bolder"> <div class="chart" id="terrain-chart"></div>
飞机对地高度{{props.groundHeight}} <!-- <n-grid x-gap="12" :cols="2">-->
</span> <!-- <n-gi class="chart">-->
<div id="detection-chart"></div> <!-- <div id="detection-chart"></div>-->
</n-space> <!-- </n-gi>-->
<!-- <n-gi class="chart">-->
<!-- <div id="terrain-chart"></div>-->
<!-- </n-gi>-->
<!-- </n-grid>-->
</template> </template>
<style scoped> <style scoped>
#detection-chart{ .chart{
width: 50rem;
height: 15rem; height: 15rem;
position: relative; width: 33rem;
margin: 1rem 0 -4rem 0;
} }
</style> </style>

@ -21,7 +21,7 @@ import {
} from '@/utils/map/TDTProvider' } from '@/utils/map/TDTProvider'
import { initViewer, perfViewer, showNavigator } from '@/utils/map/sceneViewer' import { initViewer, perfViewer, showNavigator } from '@/utils/map/sceneViewer'
import { flyToChina } from '@/utils/map/camera' import { flyToChina } from '@/utils/map/camera'
import MeasureDistance from "@/assets/js/cesium-map/measureDistance"; import MeasureDistance from "@/assets/js/measureDistance.js";
const viewerDivRef = ref<HTMLDivElement>() const viewerDivRef = ref<HTMLDivElement>()
let viewer: Viewer let viewer: Viewer

@ -17,7 +17,7 @@ import LayerManager from "@/components/map/LayerManager.vue";
import CollisionDetection from "@/components/CollisionDetection.vue"; import CollisionDetection from "@/components/CollisionDetection.vue";
import {useLayerStore} from "@/store/layerManagerStore.ts"; import {useLayerStore} from "@/store/layerManagerStore.ts";
import {Cartesian3} from "cesium"; import {Cartesian3} from "cesium";
import {getDistance, getElevation} from "@/utils/map/geocomputation.ts"; import {ByDirectionAndLen, getDistance, getElevation} from "@/utils/map/geocomputation.ts";
const message = useMessage(); const message = useMessage();
let SceneValue; let SceneValue;
@ -172,12 +172,12 @@ async function connectWebSocket() {
SceneValue.value = 'fallow' SceneValue.value = 'fallow'
hasPlane.value = true; hasPlane.value = true;
} }
console.log(frameCount)
// (50) // (50)
if(frameCount>50){ if(frameCount>50){
showDetection.value = true showDetection.value = true
frameCount = 0 frameCount = 0
let currentPos = Cartesian3.fromDegrees(ycData.lon, ycData.lat,ycData.alt) let currentPos = Cartesian3.fromDegrees(ycData.lon, ycData.lat,ycData.alt)
// 线
new Promise(resolve => { new Promise(resolve => {
// m // m
groundHeight.value = ycData.alt - getElevation(window.viewer, currentPos) groundHeight.value = ycData.alt - getElevation(window.viewer, currentPos)
@ -189,7 +189,18 @@ async function connectWebSocket() {
lastPos = currentPos lastPos = currentPos
resolve(dis) resolve(dis)
}).then(res=>{ }).then(res=>{
collisionDetection.value.drawDetection2(ycData.alt, res, ycData.alt-groundHeight.value) collisionDetection.value.drawDetection(ycData.alt, res, ycData.alt-groundHeight.value)
})
// 线 10
let max_dis = 5000
new Promise(resolve => {
// 10
let detectPos = ByDirectionAndLen(currentPos, ycData.heading, max_dis)
//
collisionDetection.value.drawTerrain(ycData.alt, currentPos, detectPos, max_dis)
resolve(detectPos)
}).then(res=>{
window.measureViewer.addPointEntity(res)
}) })
} }
} }
@ -200,20 +211,7 @@ async function connectWebSocket() {
lStore.navi.airlines.push(routeData) lStore.navi.airlines.push(routeData)
lStore.navi.currentRouteID = routeData.code lStore.navi.currentRouteID = routeData.code
console.log(routeData) console.log(routeData)
window.measureViewer.showAirLine(routeData) window.measureViewer.showAirLine(routeData)
//线store
// FIXME:
/*
profileAnalyse_promise(window.viewer, routeData,100).then((result) => {
let routeTerr = {}
routeTerr.routeID = routeData.code
routeTerr.distanceArray = result.distanceArray
routeTerr.elevationArray = result.elevationArray
lStore.routesTerrain.push(routeTerr)
})
*/
} }
} }
@ -314,9 +312,9 @@ function manageLayer(){
</n-button> </n-button>
</n-row> </n-row>
</n-space> </n-space>
<n-space id="detectionGraph" v-show="showDetection"> <n-flex id="detectionGraph" justify="center" v-show="showDetection">
<CollisionDetection ref="collisionDetection" :groundHeight="groundHeight"></CollisionDetection> <CollisionDetection ref="collisionDetection" :groundHeight="groundHeight"></CollisionDetection>
</n-space> </n-flex>
<n-modal v-model:show="showModal" <n-modal v-model:show="showModal"
style="width: 30%" style="width: 30%"
@ -364,9 +362,9 @@ function manageLayer(){
#detectionGraph{ #detectionGraph{
position: absolute; position: absolute;
bottom: 2rem; bottom: 2rem;
width: 100rem; width: 100%;
height: 15rem; height: 15rem;
border-radius: 7px; border-radius: 7px;
background: rgba(255, 255, 255, 0.94); background: rgba(255, 255, 255, 0.8);
} }
</style> </style>

@ -30,6 +30,7 @@ export type UavDynamicInfo = {
uavType: string, uavType: string,
uavFlightControlSn?: string, uavFlightControlSn?: string,
heading:number, heading:number,
pitch:number,
lon:number, lon:number,
lat:number, lat:number,
alt:number, alt:number,

@ -283,8 +283,9 @@ export function drawEchartsProfileAnalyse(xData:number[], yData:number[]) {
* @param xData x * @param xData x
* @param yData y线 * @param yData y线
* @param height 线 * @param height 线
* @param max_distance
*/ */
export function drawEcharts_CollisionDetection(myChart: EChartsType, xData:number[], yData:number[], height:number) { export function drawEcharts_CollisionDetection(myChart: EChartsType, xData:number[], yData:number[], height:number,max_distance:number) {
// 绘制图表 // 绘制图表
myChart.setOption({ myChart.setOption({
legend: { legend: {
@ -319,13 +320,14 @@ export function drawEcharts_CollisionDetection(myChart: EChartsType, xData:numbe
formatter:'地表高度: {c0}' formatter:'地表高度: {c0}'
}, },
xAxis: { xAxis: {
max: max_distance,
data: xData, data: xData,
name: '距离/米',
nameTextStyle: { nameTextStyle: {
fontWeight:'bolder', fontWeight:'bolder',
fontSize: 14 fontSize: 14,
padding:[0,0,-520,0]
}, },
nameLocation: 'end', nameLocation: 'bottom',
axisLine:{ axisLine:{
onZero: false, onZero: false,
show: true, // 是否显示坐标轴轴线 show: true, // 是否显示坐标轴轴线
@ -333,7 +335,7 @@ export function drawEcharts_CollisionDetection(myChart: EChartsType, xData:numbe
symbolSize: [7, 10] symbolSize: [7, 10]
}, },
axisLabel: { axisLabel: {
formatter: '{value}', formatter: '{value} m',
margin: 5, margin: 5,
}, },
axisTick: { axisTick: {
@ -349,6 +351,12 @@ export function drawEcharts_CollisionDetection(myChart: EChartsType, xData:numbe
yAxis: { yAxis: {
type: 'value', type: 'value',
name: '高度/米', name: '高度/米',
max: (value:any)=>{
return Math.floor(Math.max(value.max,height) * 1.01)
},
min: (value:any)=>{
return Math.floor(value.min * 0.99)
},
nameTextStyle: { nameTextStyle: {
fontWeight:'bolder', fontWeight:'bolder',
fontSize: 14 fontSize: 14
@ -364,23 +372,6 @@ export function drawEcharts_CollisionDetection(myChart: EChartsType, xData:numbe
symbolSize: [7, 10] symbolSize: [7, 10]
} }
}, },
visualMap: {
type: 'piecewise',
show: false,
dimension: 1,
// seriesIndex: [0, 1], // 虽然可以指定多个series但是线的颜色只能设置一条
seriesIndex: [0, 1],
pieces: [{
gt: height,
color: 'red'
}, {
lt: 0,
color: 'blue'
}],
outOfRange: { // 在选中范围外 的视觉元素,这里设置在正常范围内的图形颜色
color: 'blue',
},
},
series: [ series: [
{ {
name:'地形', name:'地形',
@ -394,7 +385,7 @@ export function drawEcharts_CollisionDetection(myChart: EChartsType, xData:numbe
name: "飞机高度", name: "飞机高度",
data: [ data: [
{ {
yAxis: height, yAxis: height.toString(),
itemStyle: { itemStyle: {
normal: { color: '#c60c30' } normal: { color: '#c60c30' }
} }
@ -448,14 +439,7 @@ export function drawEcharts_CollisionDetection2(myChart: EChartsType, xData:numb
}, },
{ {
name: '飞机高度', name: '飞机高度',
lineStyle: { lineStyle: 'inherit',
type: 'dotted',
width: 3,
color: '#f8364d'
},
itemStyle: {
fontSize: 18
}
} }
] ]
}, },
@ -469,7 +453,7 @@ export function drawEcharts_CollisionDetection2(myChart: EChartsType, xData:numb
}, },
xAxis: { xAxis: {
data: xData, data: xData,
name: '距离/米', // name: '距离/米',
nameTextStyle: { nameTextStyle: {
fontWeight:'bolder', fontWeight:'bolder',
fontSize: 14 fontSize: 14

@ -5,7 +5,15 @@
* @LastEditTime: 2024-04-01 14:05:43 * @LastEditTime: 2024-04-01 14:05:43
* @Description: * @Description:
*/ */
import {Cartesian3, Cartographic, EllipsoidGeodesic, Math as Cesium_Math, Matrix4, Transforms, Viewer} from 'cesium' import {
Cartesian3,
Cartographic,
EllipsoidGeodesic,
Math as Cesium_Math, Matrix3,
Matrix4,
Transforms,
Viewer
} from 'cesium'
import {Angle} from "@/utils/map/angle.ts"; import {Angle} from "@/utils/map/angle.ts";
/** /**
@ -161,5 +169,19 @@ export function getElevation(viewer: Viewer, pos: Cartographic|Cartesian3|number
} }
} }
/**
*
* @param position
* @param angle 090
* @param distance
* @constructor
*/
export function ByDirectionAndLen(position: Cartesian3, angle:number, distance:number){
let matrix = Transforms.eastNorthUpToFixedFrame(position);
let mz = Matrix3.fromRotationZ(2*Cesium_Math.PI - Cesium_Math.toRadians(angle || 0))
let rotationZ = Matrix4.fromRotationTranslation(mz);
Matrix4.multiply(matrix, rotationZ, matrix);
return Matrix4.multiplyByPoint(matrix, new Cartesian3(0, distance, 0),
new Cartesian3());
}
export { getClosestPoint, isOnLineSegment, getDistance, getAzimuth, getPolygonArea } export { getClosestPoint, isOnLineSegment, getDistance, getAzimuth, getPolygonArea }

Loading…
Cancel
Save