2025-02-19 08:06:46 +00:00
|
|
|
import { reactive } from 'vue'
|
2025-01-13 08:45:08 +00:00
|
|
|
import { getMubiaoHisTraj } from '@/api/Mubiao'
|
2025-01-06 01:18:58 +00:00
|
|
|
|
|
|
|
const baseMap = new Map()
|
|
|
|
const mubiaoMap = new Map()
|
2025-02-19 08:06:46 +00:00
|
|
|
const mubiaoConicMap = new Map()
|
2025-01-06 01:18:58 +00:00
|
|
|
const satelliteMap = new Map()
|
2025-02-19 08:06:46 +00:00
|
|
|
|
|
|
|
const mbPayloadShowMap = reactive(new Map())
|
|
|
|
// const satDetectingPayloadMap = reactive(new Map())
|
|
|
|
// const satCommunicationPayloadMap = reactive(new Map())
|
|
|
|
const satellitePayloadShowMap = reactive(new Map())
|
|
|
|
|
2025-01-06 01:18:58 +00:00
|
|
|
export const useEntity = () => {
|
|
|
|
return {
|
|
|
|
baseMap,
|
|
|
|
mubiaoMap,
|
2025-02-19 08:06:46 +00:00
|
|
|
mubiaoConicMap,
|
2025-01-06 01:18:58 +00:00
|
|
|
satelliteMap,
|
2025-02-19 08:06:46 +00:00
|
|
|
mbPayloadShowMap,
|
|
|
|
// satDetectingPayloadMap,
|
|
|
|
// satCommunicationPayloadMap,
|
|
|
|
satellitePayloadShowMap,
|
2025-01-13 08:45:08 +00:00
|
|
|
showEntity,
|
|
|
|
getHisTraj,
|
|
|
|
getMBEntityOpt,
|
2025-02-19 08:06:46 +00:00
|
|
|
createMBConicSensor,
|
2025-01-23 01:05:13 +00:00
|
|
|
iconOrModel,
|
2025-01-13 08:45:08 +00:00
|
|
|
changeIconOrModel,
|
2025-02-14 08:33:28 +00:00
|
|
|
showOrHideLoad,
|
|
|
|
changeShowOrHideLoad,
|
2025-01-06 01:18:58 +00:00
|
|
|
}
|
|
|
|
}
|
2025-01-13 08:45:08 +00:00
|
|
|
|
|
|
|
function showEntity(show: boolean) {
|
|
|
|
;[...mubiaoMap.values()].forEach(entity => {
|
|
|
|
entity.show = show
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
async function getHisTraj({
|
|
|
|
id,
|
|
|
|
timeRange,
|
|
|
|
}: {
|
|
|
|
id: string
|
|
|
|
timeRange: string[]
|
|
|
|
}) {
|
|
|
|
const [timeBegin, timeEnd] = timeRange
|
|
|
|
const { code, data: result } = await getMubiaoHisTraj({
|
|
|
|
target_id: id,
|
|
|
|
timeBegin,
|
|
|
|
timeEnd,
|
|
|
|
})
|
|
|
|
if (code !== '200') {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
const timeArray = result.map(item => {
|
|
|
|
return new Date(item.time).getTime()
|
|
|
|
})
|
|
|
|
const posArray = result.map(item => item.position).flat(Infinity)
|
|
|
|
const points = result.reduce<TPoints>((acc, point, index, array) => {
|
|
|
|
const { time, position } = point
|
|
|
|
const cartesian3 = Cesium.Cartesian3.fromDegrees(...position)
|
|
|
|
if (index === 0) {
|
|
|
|
acc.push({ time: 0, position: cartesian3 })
|
|
|
|
} else {
|
|
|
|
acc.push({
|
|
|
|
time:
|
|
|
|
(new Date(time).getTime() - new Date(array[0].time).getTime()) / 1000,
|
|
|
|
position: cartesian3,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return acc
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
return { points, posArray, timeArray }
|
|
|
|
}
|
|
|
|
|
|
|
|
function getMBEntityOpt({
|
|
|
|
id,
|
|
|
|
targetType,
|
2025-02-19 08:06:46 +00:00
|
|
|
extendInfo,
|
2025-01-13 08:45:08 +00:00
|
|
|
}: {
|
|
|
|
id: string
|
|
|
|
targetType: string
|
2025-02-19 08:06:46 +00:00
|
|
|
extendInfo?: { detectingPayload: Record<string, number> }
|
2025-01-13 08:45:08 +00:00
|
|
|
}) {
|
|
|
|
const mubiaoDict = window.settings.mbDict[targetType]
|
|
|
|
|
2025-02-19 08:06:46 +00:00
|
|
|
let ellipsoid
|
|
|
|
if (extendInfo) {
|
|
|
|
const {
|
|
|
|
angle,
|
|
|
|
maximumCone,
|
|
|
|
minimumCone,
|
|
|
|
minimumClock,
|
|
|
|
maximumClock,
|
|
|
|
radius,
|
|
|
|
} = extendInfo.detectingPayload
|
|
|
|
if (radius) {
|
|
|
|
ellipsoid = {
|
|
|
|
ellipsoid: {
|
|
|
|
show: mbPayloadShowMap.get(id)?.detectingPayload?.show || false,
|
|
|
|
radii: new Cesium.Cartesian3(radius, radius, radius),
|
|
|
|
innerRadii: new Cesium.Cartesian3(1.0, 1.0, 1.0),
|
|
|
|
maximumCone: Cesium.Math.toRadians(90),
|
|
|
|
minimumCone: Cesium.Math.toRadians(minimumCone),
|
|
|
|
minimumClock: Cesium.Math.toRadians(minimumClock),
|
|
|
|
maximumClock: Cesium.Math.toRadians(maximumClock),
|
|
|
|
material: Cesium.Color.fromCssColorString('#00dcff44'),
|
|
|
|
outline: true,
|
|
|
|
outlineColor: Cesium.Color.fromCssColorString('#00dcff'),
|
|
|
|
outlineWidth: 1,
|
|
|
|
distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
|
|
|
|
0.0,
|
|
|
|
10.5e8
|
|
|
|
),
|
|
|
|
slicePartitions: 24,
|
|
|
|
stackPartitions: 36,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2025-01-13 08:45:08 +00:00
|
|
|
return {
|
|
|
|
label: {
|
|
|
|
text: `${id}`,
|
|
|
|
font: '12pt sans-serif',
|
|
|
|
fillColor: Cesium.Color.YELLOW,
|
|
|
|
outlineColor: Cesium.Color.BLACK,
|
|
|
|
outlineWidth: 2,
|
|
|
|
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
|
|
|
|
pixelOffset: new Cesium.Cartesian2(20, -20),
|
|
|
|
pixelOffsetScaleByDistance: new Cesium.NearFarScalar(
|
|
|
|
7000000,
|
|
|
|
1.0,
|
|
|
|
18000000,
|
|
|
|
0.4
|
|
|
|
),
|
|
|
|
scaleByDistance: new Cesium.NearFarScalar(7000000, 1.0, 18000000, 0.4),
|
|
|
|
},
|
|
|
|
billboard: {
|
2025-01-23 01:05:13 +00:00
|
|
|
show: !iconOrModel.value,
|
2025-01-13 08:45:08 +00:00
|
|
|
image: mubiaoDict.icon,
|
|
|
|
width: 30,
|
|
|
|
height: 30,
|
|
|
|
color: Cesium.Color.fromCssColorString(mubiaoDict.color),
|
|
|
|
scaleByDistance: new Cesium.NearFarScalar(7000000, 1.0, 18000000, 0.4),
|
|
|
|
},
|
|
|
|
model: {
|
2025-01-23 01:05:13 +00:00
|
|
|
show: iconOrModel.value,
|
2025-01-13 08:45:08 +00:00
|
|
|
uri: mubiaoDict.model,
|
|
|
|
scale: 1000,
|
|
|
|
minimumPixelSize: 50,
|
|
|
|
},
|
2025-02-19 08:06:46 +00:00
|
|
|
...ellipsoid,
|
2025-01-13 08:45:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-02-19 08:06:46 +00:00
|
|
|
function createMBConicSensor({
|
|
|
|
entity,
|
|
|
|
angle,
|
|
|
|
show,
|
|
|
|
}: {
|
|
|
|
entity: Cesium.Entity
|
|
|
|
angle: number
|
|
|
|
show: boolean
|
|
|
|
}) {
|
|
|
|
console.log('entity', angle)
|
|
|
|
const conicSensor = new CesiumSensorVolumes.ConicSensorGraphics({
|
|
|
|
show,
|
|
|
|
radius: 2e7,
|
|
|
|
innerHalfAngle: 0,
|
|
|
|
outerHalfAngle: Cesium.Math.toRadians(angle / 2),
|
|
|
|
minimumClockAngle: 0,
|
|
|
|
maximumClockAngle: 2 * Math.PI,
|
|
|
|
showIntersection: true,
|
|
|
|
intersectionColor: new Cesium.Color(1, 1, 1, 1),
|
|
|
|
intersectionWidth: 3,
|
|
|
|
lateralSurfaceMaterial: new Cesium.Color(0.0, 1.0, 1.0, 0.3),
|
|
|
|
})
|
|
|
|
const mbConic = viewer.entities.add({
|
|
|
|
position: entity.position,
|
|
|
|
orientation:
|
|
|
|
entity.position &&
|
|
|
|
Cesium.Transforms.headingPitchRollQuaternion(
|
|
|
|
entity.position._value,
|
|
|
|
new Cesium.HeadingPitchRoll(
|
|
|
|
Cesium.Math.toRadians(90),
|
|
|
|
0,
|
|
|
|
Cesium.Math.toRadians(180)
|
|
|
|
) // 初始朝向
|
|
|
|
),
|
|
|
|
conicSensor: conicSensor,
|
|
|
|
})
|
|
|
|
return mbConic
|
|
|
|
}
|
|
|
|
|
2025-01-23 01:05:13 +00:00
|
|
|
const iconOrModel = ref(false)
|
2025-01-13 08:45:08 +00:00
|
|
|
function changeIconOrModel() {
|
2025-01-23 01:05:13 +00:00
|
|
|
iconOrModel.value = !iconOrModel.value
|
|
|
|
;[...mubiaoMap.values(), ...baseMap.values()].forEach(entity => {
|
2025-01-13 08:45:08 +00:00
|
|
|
entity.model.show = !entity.model.show._value
|
|
|
|
entity.billboard.show = !entity.billboard.show._value
|
|
|
|
})
|
|
|
|
}
|
2025-02-14 08:33:28 +00:00
|
|
|
|
2025-02-19 08:06:46 +00:00
|
|
|
const showOrHideLoad = ref(false)
|
2025-02-14 08:33:28 +00:00
|
|
|
|
2025-02-19 08:06:46 +00:00
|
|
|
watch([mbPayloadShowMap, satellitePayloadShowMap], ([newMb, newSatellite]) => {
|
|
|
|
;[...newMb.keys()].forEach(key => {
|
|
|
|
let show = false
|
|
|
|
if (newMb.get(key).detectingPayload) {
|
|
|
|
show = newMb.get(key).detectingPayload.show
|
|
|
|
}
|
|
|
|
if (mubiaoMap.has(key)) {
|
|
|
|
// if(console.log(mubiaoMap.get(key).ellipsoid)
|
|
|
|
mubiaoMap.get(key).ellipsoid && (mubiaoMap.get(key).ellipsoid.show = show)
|
|
|
|
|
|
|
|
mubiaoConicMap.get(key)?.conicSensor &&
|
|
|
|
(mubiaoConicMap.get(key).conicSensor.show = show)
|
|
|
|
}
|
2025-02-14 08:33:28 +00:00
|
|
|
})
|
2025-02-19 08:06:46 +00:00
|
|
|
;[...newSatellite.keys()].forEach(key => {
|
|
|
|
let show = false
|
|
|
|
if (newSatellite.get(key).detectingPayload) {
|
|
|
|
show = newSatellite.get(key).detectingPayload.show
|
|
|
|
// console.log(newSatellite.get(key).detectingPayload.show)
|
|
|
|
}
|
|
|
|
if (satelliteMap.has(key)) {
|
|
|
|
satelliteMap.get(key).sensor = show
|
|
|
|
}
|
2025-02-14 08:33:28 +00:00
|
|
|
})
|
2025-02-19 08:06:46 +00:00
|
|
|
})
|
|
|
|
function changeShowOrHideLoad() {
|
|
|
|
showOrHideLoad.value = !showOrHideLoad.value
|
|
|
|
// ;[...mubiaoMap.values()].forEach(entity => {
|
|
|
|
// entity.ellipsoid.show = !entity.ellipsoid.show._value
|
|
|
|
// })
|
|
|
|
for (const [key] of mbPayloadShowMap.entries()) {
|
|
|
|
mbPayloadShowMap.get(key).detectingPayload.show = showOrHideLoad.value
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const [key] of satellitePayloadShowMap.entries()) {
|
|
|
|
satellitePayloadShowMap.get(key).detectingPayload &&
|
|
|
|
(satellitePayloadShowMap.get(key).detectingPayload.show =
|
|
|
|
showOrHideLoad.value)
|
|
|
|
satellitePayloadShowMap.get(key).communicationPayload &&
|
|
|
|
(satellitePayloadShowMap.get(key).communicationPayload.show =
|
|
|
|
showOrHideLoad.value)
|
|
|
|
}
|
|
|
|
// ;[...satelliteMap.values()].forEach(satellite => {
|
|
|
|
// satellite.sensor = showOrHideLoad.value
|
|
|
|
// })
|
2025-02-14 08:33:28 +00:00
|
|
|
}
|