forked from drone/command-center-dashboard

chenyao
2025-04-10 4ca9d0b91c821c18eeeea381b6e16132fe6577b8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import * as Cesium from 'cesium';
import cesiumOperation from '@/utils/cesium-tsa';
import { analyzeKmzFile, XMLToJSON } from '@/utils/cesium/kmz.js'
import { cartesian3Convert, getCenterPoint, getLnglatDist } from '@/utils/cesium/mapUtil.js'
import { getLnglatAltitude, getPositionsHeight } from '@/utils/cesium/mapUtil'
 
const {
  addPoint,
  getEntityById,
  removeById,
  removeAllPoint,
  addLeftClickEvent,
  removeLeftClickEvent,
  addRightClickEvent,
  removeRightClickEvent,
  flyTo,
  pointInitEvent,
  pointUnInitEvent
} = cesiumOperation()
/**
 * 
 * @param { 单点航线 相关功能} url 
 */
export const initPointWayline = (url) => {
  
  let viewer = window.$viewer;
 
  // 解析kmz文件
  const parsingFiles = async (url) => {
    const { fileInfoObj } = analyzeKmzFile(`${url}?_t=${new Date().getTime()}`);
    const xmlStr = fileInfoObj['wpmz/template.kml']
    const xmlJson = XMLToJSON(xmlStr)?.['Document']
    if (xmlJson.Folder.Placemark.length) return;
    drawWayline(xmlJson)
  };
  // 在地图上画线
  const drawWayline = (xmlJson) => {
    const points = xmlJson?.['Folder']?.['Placemark'];
    getPositionsHeight(points, viewer, 100).then((result) => {
      positions = result.map((item) => {
        return Cesium.Cartesian3.fromDegrees(
          Number(item.longitude),
          Number(item.latitude),
          item.FinalHeight,
        )
      });
      result.forEach((item, index) => {
        let setting = {};
      });
    });
  };
};