huweili-cesium 1.2.85 → 1.2.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/js/labelDiv.js +40 -5
  2. package/package.json +1 -1
package/js/labelDiv.js CHANGED
@@ -12,6 +12,35 @@ const DRONE_INFO_UPDATE_MIN_MS = 1000;
12
12
 
13
13
  /** @typedef {{ lng: string, lat: string, alt: string, speed: string, flyingHandName: string, flyingHandPhone: string, flyingHandPosition: string, frequencyBand: string, distance: string, receiveTime: string }} DroneInfoDisplay */
14
14
 
15
+ /**
16
+ * 飞手经纬度无效时(含 0,0)展示为 --
17
+ * @param {unknown} groundLinkLng
18
+ * @param {unknown} groundLinkLat
19
+ * @param {unknown} fallback
20
+ * @returns {string}
21
+ */
22
+ function normalizeFlyingHandPosition(groundLinkLng, groundLinkLat, fallback) {
23
+ if (groundLinkLng !== '--' && groundLinkLat !== '--') {
24
+ const lng = parseFloat(String(groundLinkLng));
25
+ const lat = parseFloat(String(groundLinkLat));
26
+ if (Number.isFinite(lng) && Number.isFinite(lat) && lng === 0 && lat === 0) {
27
+ return '--';
28
+ }
29
+ return `${groundLinkLng},${groundLinkLat}`;
30
+ }
31
+ const fb = fallback ?? '--';
32
+ if (fb === '--') return '--';
33
+ const match = String(fb).match(/^([-\d.]+)[,,]\s*([-\d.]+)$/);
34
+ if (match) {
35
+ const lng = parseFloat(match[1]);
36
+ const lat = parseFloat(match[2]);
37
+ if (Number.isFinite(lng) && Number.isFinite(lat) && lng === 0 && lat === 0) {
38
+ return '--';
39
+ }
40
+ }
41
+ return String(fb);
42
+ }
43
+
15
44
  /**
16
45
  * 将 getInfo 原始数据格式化为详情面板展示字段
17
46
  * @param {Record<string, unknown>|null|undefined} info
@@ -31,10 +60,11 @@ function formatDroneInfoDisplay(info) {
31
60
  const receiveTime = info?.receiveTime ?? '--';
32
61
  const groundLinkLng = info?.groundLinkLng ?? '--';
33
62
  const groundLinkLat = info?.groundLinkLat ?? '--';
34
- const flyingHandPosition =
35
- groundLinkLng !== '--' && groundLinkLat !== '--'
36
- ? `${groundLinkLng},${groundLinkLat}`
37
- : (info?.flyingHandPosition ?? '--');
63
+ const flyingHandPosition = normalizeFlyingHandPosition(
64
+ groundLinkLng,
65
+ groundLinkLat,
66
+ info?.flyingHandPosition
67
+ );
38
68
  const parseDistance = parseFloat(String(info?.distance ?? '').replace(/[^\d.-]/g, ''));
39
69
  const distance = Number.isFinite(parseDistance) ? parseDistance.toFixed(1) : '--';
40
70
  return {
@@ -67,6 +97,11 @@ function resolveInfoDisplay(info, cached) {
67
97
  merged[key] = cached[key];
68
98
  }
69
99
  }
100
+ merged.flyingHandPosition = normalizeFlyingHandPosition(
101
+ info?.groundLinkLng ?? '--',
102
+ info?.groundLinkLat ?? '--',
103
+ merged.flyingHandPosition
104
+ );
70
105
  return merged;
71
106
  }
72
107
 
@@ -260,7 +295,7 @@ export function labelDiv() {
260
295
  <div><span class="pilot-title">高度:</span><span class="alt">${initialDisplay.alt}</span>m</div>
261
296
  <div><span class="pilot-title">速度:</span><span class="speed">${initialDisplay.speed}</span>m/s</div>
262
297
  <div><span class="pilot-title">距离:</span><span class="distance">${initialDisplay.distance}</span>m</div>
263
- ${!isUnknown ? `<div><span class="pilot-title">频段:</span><span class="band">${bandText}</span></div>` : ''}
298
+ ${!isUnknown ? `<div><span class="pilot-title">频段:</span><span class="band">2.4GHz、5.8GHz</span></div>` : ''}
264
299
  </div>
265
300
  ${!isUnknown ? `
266
301
  <div class="drone-detail-divider"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huweili-cesium",
3
- "version": "1.2.85",
3
+ "version": "1.2.87",
4
4
  "description": "基于 Cesium 的地图工具库(无人机态势、轨迹、围栏、工具栏等)",
5
5
  "type": "module",
6
6
  "main": "./index.js",