suerprisePlus
2024-06-27 6ae4841b48665145aa469d574fbadb988a9c498c
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import * as turf from "@turf/turf";
 
const json2md = require("json2md");
const mapConfig = {
  flyToImageryLayer(res) {
    earthCtrl.userScene.flyTo(res);
  },
  setPointToCrical(lon, lat, distance) {
    var buffered = turf.circle([lon, lat], distance, {
      units: "kilometers",
      steps: 10,
      properties: { foo: "bar" }
    });
    const coord = buffered.geometry.coordinates[0];
    const std = coord.map((item) => {
      const rs = turf.toMercator(turf.point(item));
      return rs.geometry.coordinates;
    });
    buffered.geometry.coordinates[0] = std;
    return buffered;
  },
  setScanList(response, filed) {
    const obj = [];
    for (var i in response) {
      const item = response[i];
      if (item[filed]) {
        const count = "count_" + filed;
        obj.push(item[filed] + " : " + item[count]);
      }
    }
    if (filed == "weaponname") {
      return "发现疑似 " + obj.toString().replaceAll(",", "个; ");
    }else if(filed==='targettype'){
      return "发现 " + obj.toString().replaceAll(",", "个; ");
    }
 
    return "暂无信息";
  },
  setArrList(list, flag) {
    var result = [];
    const item = list.split("{");
    for (var i in item) {
      if (item[i]) {
        if (item[i].indexOf(",") > -1) {
        
          result.push({
            p: item[i].replaceAll('"','').replaceAll('}','')
          });
        } else {
          result.push({
            h6: item[i].replaceAll('"','')
          });
        }
      }
    }
    return result;
  },
  setJsonToMd(res) {
    // const data = {
    //     "name": "John Doe",
    //     "age": 30,
    //     "hobbies": ["reading", "programming"]
    // }
    return json2md(res);
 
    // return json2md([
    //   { h1: "JSON To Markdown" },
    //   { blockquote: "A JSON to Markdown converter." },
    //   {
    //     img: [
    //       {
    //         title: "Some image",
    //         source: "https://www.bizhigq.com/pc-img/2023-05/g2246.jpg"
    //       },
    //       {
    //         title: "Another image",
    //         source:
    //           "https://desk-fd.zol-img.com.cn/t_s960x600c5/g2/M00/0B/08/Cg-4WlUwdDWIZ7zKAAqGM6NxoXkAABuAQPwTs0ACoZL265.jpg"
    //       },
    //       {
    //         title: "Yet another image",
    //         source:
    //           "https://pic4.zhimg.com/v2-f72106aeb21976228c3f0dff703cbc35_r.jpg"
    //       }
    //     ]
    //   },
    //   { h2: "特性" },
    //   { ul: ["易于使用", "您可以程序化地生成 Markdown 内容", "..."] },
    //   { h2: "如何贡献" },
    //   { ol: ["创建项目分支", "开始你的工作", "提出 pull request"] },
    //   { h2: "代码块" },
    //   { p: "下面你可以看到一个代码块示例。" },
    //   {
    //     code: {
    //       language: "js",
    //       content: [
    //         "function sum (a, b) {",
    //         "   return a + b",
    //         "}",
    //         "sum(1, 2)"
    //       ]
    //     }
    //   }
    // ]);
  }
};
export default mapConfig;