@lumikmz/kmz 0.6.1 → 0.6.2

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.
package/dist/index.mjs CHANGED
@@ -1061,7 +1061,7 @@ function planWaypoint(template) {
1061
1061
  const placemarks = folder.Placemark.map((p, i) => {
1062
1062
  const heading = p.useGlobalHeadingParam || p.waypointHeadingParam === void 0 ? folder.globalWaypointHeadingParam : p.waypointHeadingParam;
1063
1063
  const turn = p.useGlobalTurnParam || p.waypointTurnParam === void 0 ? { waypointTurnMode: folder.globalWaypointTurnMode } : p.waypointTurnParam;
1064
- const executeHeight = p.useGlobalHeight || p.height === void 0 ? folder.globalHeight : p.height;
1064
+ const executeHeight = folder.waylineCoordinateSysParam.heightMode === "aboveGroundLevel" && p.ellipsoidHeight !== void 0 ? p.ellipsoidHeight : p.useGlobalHeight || p.height === void 0 ? folder.globalHeight : p.height;
1065
1065
  const waypointSpeed = p.useGlobalSpeed || p.waypointSpeed === void 0 ? folder.autoFlightSpeed : p.waypointSpeed;
1066
1066
  return {
1067
1067
  Point: p.Point,
@@ -1090,13 +1090,13 @@ function planWaypoint(template) {
1090
1090
  /**
1091
1091
  * Map a template heightMode to a waylines executeHeightMode.
1092
1092
  * - `EGM96` → `WGS84` (waylines spec doesn't expose EGM96; runtime resolves it).
1093
- * - `aboveGroundLevel` → `realTimeFollowSurface` (closest executable analog).
1093
+ * - `aboveGroundLevel` → `WGS84` (waypoint waylines use per-point ellipsoid heights).
1094
1094
  */
1095
1095
  function heightModeToExecuteMode(mode) {
1096
1096
  switch (mode) {
1097
- case "EGM96": return "WGS84";
1097
+ case "EGM96":
1098
+ case "aboveGroundLevel": return "WGS84";
1098
1099
  case "relativeToStartPoint": return "relativeToStartPoint";
1099
- case "aboveGroundLevel":
1100
1100
  case "realTimeFollowSurface": return "realTimeFollowSurface";
1101
1101
  }
1102
1102
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumikmz/kmz",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "DJI KMZ/WPML domain model + plan() algorithm + validate(), spec-aligned types mirroring docs/kmz/",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,7 +25,12 @@ export function planWaypoint(template: WaypointTemplate): Waylines {
25
25
  : p.waypointTurnParam;
26
26
 
27
27
  const executeHeight =
28
- p.useGlobalHeight || p.height === undefined ? folder.globalHeight : p.height;
28
+ folder.waylineCoordinateSysParam.heightMode === "aboveGroundLevel" &&
29
+ p.ellipsoidHeight !== undefined
30
+ ? p.ellipsoidHeight
31
+ : p.useGlobalHeight || p.height === undefined
32
+ ? folder.globalHeight
33
+ : p.height;
29
34
 
30
35
  const waypointSpeed =
31
36
  p.useGlobalSpeed || p.waypointSpeed === undefined ? folder.autoFlightSpeed : p.waypointSpeed;
@@ -58,17 +63,17 @@ export function planWaypoint(template: WaypointTemplate): Waylines {
58
63
  /**
59
64
  * Map a template heightMode to a waylines executeHeightMode.
60
65
  * - `EGM96` → `WGS84` (waylines spec doesn't expose EGM96; runtime resolves it).
61
- * - `aboveGroundLevel` → `realTimeFollowSurface` (closest executable analog).
66
+ * - `aboveGroundLevel` → `WGS84` (waypoint waylines use per-point ellipsoid heights).
62
67
  */
63
68
  function heightModeToExecuteMode(
64
69
  mode: WaypointFolder["waylineCoordinateSysParam"]["heightMode"],
65
70
  ): ExecuteHeightMode {
66
71
  switch (mode) {
67
72
  case "EGM96":
73
+ case "aboveGroundLevel":
68
74
  return "WGS84";
69
75
  case "relativeToStartPoint":
70
76
  return "relativeToStartPoint";
71
- case "aboveGroundLevel":
72
77
  case "realTimeFollowSurface":
73
78
  return "realTimeFollowSurface";
74
79
  }
@@ -61,6 +61,52 @@ describe("plan", () => {
61
61
  expect(waylines.missionConfig).toBe(template.missionConfig);
62
62
  });
63
63
 
64
+ it("waypoint aboveGroundLevel uses per-point ellipsoid heights as WGS84 executeHeight", () => {
65
+ const template: WaypointTemplate = {
66
+ missionConfig,
67
+ Folder: {
68
+ templateType: "waypoint",
69
+ templateId: 0,
70
+ waylineCoordinateSysParam: { coordinateMode: "WGS84", heightMode: "aboveGroundLevel" },
71
+ autoFlightSpeed: metersPerSecond(10),
72
+ globalWaypointTurnMode: "toPointAndStopWithDiscontinuityCurvature",
73
+ gimbalPitchMode: "manual",
74
+ globalHeight: meters(50),
75
+ globalWaypointHeadingParam: {
76
+ waypointHeadingMode: "followWayline",
77
+ waypointHeadingPathMode: "followBadArc",
78
+ },
79
+ Placemark: [
80
+ {
81
+ Point: { coordinates: { lng: 113.938, lat: 22.5397 } },
82
+ index: 0,
83
+ useGlobalHeight: false,
84
+ height: meters(80),
85
+ ellipsoidHeight: meters(180),
86
+ useGlobalSpeed: true,
87
+ useGlobalHeadingParam: true,
88
+ useGlobalTurnParam: true,
89
+ },
90
+ {
91
+ Point: { coordinates: { lng: 113.939, lat: 22.5407 } },
92
+ index: 1,
93
+ useGlobalHeight: false,
94
+ height: meters(90),
95
+ ellipsoidHeight: meters(190),
96
+ useGlobalSpeed: true,
97
+ useGlobalHeadingParam: true,
98
+ useGlobalTurnParam: true,
99
+ },
100
+ ],
101
+ },
102
+ };
103
+
104
+ const waylines = plan(template);
105
+
106
+ expect(waylines.Folder[0]!.executeHeightMode).toBe("WGS84");
107
+ expect(waylines.Folder[0]!.Placemark.map((p) => Number(p.executeHeight))).toEqual([180, 190]);
108
+ });
109
+
64
110
  it("compiles a mapping2d template into a serpentine scan", () => {
65
111
  const template: Mapping2dTemplate = {
66
112
  missionConfig,