@vesium/plot 1.0.1-beta.52 → 1.0.1-beta.57

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
@@ -2,7 +2,7 @@ import { CallbackPositionProperty, CallbackProperty, Cartesian3, Cartographic, C
2
2
  import { arrayDiff, assertError, canvasCoordToCartesian, isFunction, pickHitGraphic, toCartesian3, toCartographic, toCoord, toProperty, toPropertyValue, useCesiumEventListener, useDataSource, useEntityScope, useGraphicEvent, usePrimitive, usePrimitiveScope, useScreenSpaceEventHandler, useViewer } from "vesium";
3
3
  import { assert, onKeyStroke, promiseTimeout, watchArray } from "@vueuse/core";
4
4
  import { computed, nextTick, ref, shallowReactive, shallowRef, toValue, watch, watchEffect } from "vue";
5
- import * as turf$1 from "@turf/turf";
5
+ import { arc, arrowAttackDirection, arrowAttackDirectionTailed, arrowClamped, arrowStraight, arrowStraightSharp, arrowUnitCombatOperation, arrowUnitCombatOperationTailed, assemblingPlace } from "@vesium/geometry";
6
6
  import * as turf from "@turf/turf";
7
7
 
8
8
  //#region usePlot/PlotScheme.ts
@@ -182,16 +182,13 @@ var SampledPlotProperty = class SampledPlotProperty {
182
182
  const end = this._times[this._times.length - 1];
183
183
  if (JulianDate.lessThan(time, start) || JulianDate.greaterThan(time, end)) switch (this.strategy) {
184
184
  case SampledPlotStrategy.STRICT: return;
185
- case SampledPlotStrategy.NEAR: {
185
+ case SampledPlotStrategy.NEAR:
186
186
  time = JulianDate.lessThan(time, this._times[0]) ? this._times[0].clone() : this._times[this._times.length - 1].clone();
187
187
  break;
188
- }
189
188
  case SampledPlotStrategy.CYCLE: {
190
189
  const startMS = JulianDate.toDate(this._times[0]).getTime();
191
- const endMS = JulianDate.toDate(this._times[this._times.length - 1]).getTime();
192
- const duration = endMS - startMS;
193
- const timeMS = JulianDate.toDate(time).getTime();
194
- const diff = (timeMS - startMS) % duration;
190
+ const duration = JulianDate.toDate(this._times[this._times.length - 1]).getTime() - startMS;
191
+ const diff = (JulianDate.toDate(time).getTime() - startMS) % duration;
195
192
  const dete = new Date(startMS + diff);
196
193
  time = JulianDate.fromDate(dete);
197
194
  break;
@@ -201,11 +198,10 @@ var SampledPlotProperty = class SampledPlotProperty {
201
198
  const nextIndex = Math.min(prevIndex, this._times.length - 1);
202
199
  const prevMs = JulianDate.toDate(this._times[prevIndex]).getTime();
203
200
  const nextMs = JulianDate.toDate(this._times[nextIndex]).getTime();
204
- const ms = JulianDate.toDate(time).getTime();
205
201
  return {
206
202
  prevIndex,
207
203
  nextIndex,
208
- proportion: (ms - prevMs) / (nextMs - prevMs) || 0
204
+ proportion: (JulianDate.toDate(time).getTime() - prevMs) / (nextMs - prevMs) || 0
209
205
  };
210
206
  }
211
207
  /**
@@ -297,8 +293,7 @@ var SampledPlotProperty = class SampledPlotProperty {
297
293
  if (index !== -1) {
298
294
  this._sampleds.splice(index, 1);
299
295
  this._derivatives.splice(index, 1);
300
- const removed = this._times.splice(index, 1);
301
- if (removed.length) {
296
+ if (this._times.splice(index, 1).length) {
302
297
  this._definitionChanged.raiseEvent(this);
303
298
  return true;
304
299
  }
@@ -528,19 +523,27 @@ function useRender(plots, current, getCurrentTime) {
528
523
  }
529
524
  });
530
525
  const update = async (plot) => {
531
- const reslut = await plot.scheme.render?.({
532
- packable: plot.sampled.getValue(getCurrentTime()),
533
- mouse: plot.defining ? mouseCartesian.value : void 0,
526
+ await nextTick();
527
+ const packable = plot.sampled.getValue(getCurrentTime());
528
+ const mouse = plot.defining ? mouseCartesian.value : void 0;
529
+ const result = await plot.scheme.render?.({
530
+ packable,
531
+ mouse,
534
532
  defining: plot.defining,
535
533
  previous: {
536
534
  entities: plot.entities,
537
535
  primitives: plot.primitives,
538
536
  groundPrimitives: plot.groundPrimitives
537
+ },
538
+ getPositions() {
539
+ const points = packable.positions;
540
+ mouse && points.push(mouse);
541
+ return points;
539
542
  }
540
543
  });
541
- plot.entities = reslut?.entities ?? [];
542
- plot.primitives = reslut?.primitives ?? [];
543
- plot.groundPrimitives = reslut?.groundPrimitives ?? [];
544
+ plot.entities = result?.entities ?? [];
545
+ plot.primitives = result?.primitives ?? [];
546
+ plot.groundPrimitives = result?.groundPrimitives ?? [];
544
547
  };
545
548
  watch(current, (plot, previous) => {
546
549
  previous && update(previous);
@@ -583,8 +586,7 @@ function useSampled(current, getCurrentTime) {
583
586
  packable.value.positions ??= [];
584
587
  packable.value.positions.push(position);
585
588
  sampled.setSample(packable.value);
586
- const completed = scheme.complete?.(packable.value);
587
- completed && PlotFeature.setDefining(current.value, false);
589
+ scheme.complete?.(packable.value) && PlotFeature.setDefining(current.value, false);
588
590
  });
589
591
  useScreenSpaceEventHandler(ScreenSpaceEventType.LEFT_DOUBLE_CLICK, async (ctx) => {
590
592
  if (!current.value || !packable.value) return;
@@ -593,10 +595,8 @@ function useSampled(current, getCurrentTime) {
593
595
  doubleClicking.value = false;
594
596
  const { scheme, defining } = current.value;
595
597
  if (!defining) return;
596
- const position = canvasCoordToCartesian(ctx.position, viewer.value.scene);
597
- if (!position) return;
598
- const completed = scheme.allowManualComplete?.(packable.value);
599
- completed && PlotFeature.setDefining(current.value, false);
598
+ if (!canvasCoordToCartesian(ctx.position, viewer.value.scene)) return;
599
+ scheme.allowManualComplete?.(packable.value) && PlotFeature.setDefining(current.value, false);
600
600
  });
601
601
  useScreenSpaceEventHandler(ScreenSpaceEventType.RIGHT_CLICK, async () => {
602
602
  if (!current.value || !packable.value) return;
@@ -646,13 +646,11 @@ function useSkeleton(plots, current, getCurrentTime) {
646
646
  const packable = plot.sampled.getValue(getCurrentTime());
647
647
  const defining = plot.defining;
648
648
  const active = current.value === plot;
649
- const skeletons = plot.scheme.skeletons;
650
- skeletons.forEach((skeleton) => {
651
- const disabled = isFunction(skeleton.disabled) ? skeleton.disabled({
649
+ plot.scheme.skeletons.forEach((skeleton) => {
650
+ if (isFunction(skeleton.disabled) ? skeleton.disabled({
652
651
  active,
653
652
  defining
654
- }) : skeleton.disabled;
655
- if (disabled) return;
653
+ }) : skeleton.disabled) return;
656
654
  const positions = skeleton.format?.(packable) ?? packable?.positions ?? [];
657
655
  positions.forEach((position, index) => {
658
656
  let entity = oldEntities.find((item) => item.index === index && item.skeleton === skeleton);
@@ -679,9 +677,9 @@ function useSkeleton(plots, current, getCurrentTime) {
679
677
  }
680
678
  plot.skeletons = entities;
681
679
  };
682
- const { addGraphicEvent } = useGraphicEvent();
680
+ const graphicEvent = useGraphicEvent();
683
681
  watchEffect((onCleanup) => {
684
- const remove = addGraphicEvent("global", "DRAG", ({ event, pick, dragging, lockCamera }) => {
682
+ onCleanup(graphicEvent.add("global", "DRAG", ({ event, pick, dragging, lockCamera }) => {
685
683
  if (pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
686
684
  const entity = pick.id;
687
685
  const plot = entity.plot;
@@ -714,8 +712,7 @@ function useSkeleton(plots, current, getCurrentTime) {
714
712
  return isFunction(skeleton?.dragCursor) ? skeleton.dragCursor(pick) : toValue(skeleton?.dragCursor);
715
713
  }
716
714
  }
717
- });
718
- onCleanup(remove);
715
+ }));
719
716
  });
720
717
  onKeyStroke((keyEvent) => {
721
718
  if (activeEntity.value) {
@@ -734,16 +731,13 @@ function useSkeleton(plots, current, getCurrentTime) {
734
731
  }
735
732
  });
736
733
  watchEffect((onCleanup) => {
737
- const remove = addGraphicEvent("global", "HOVER", ({ hovering, pick }) => {
738
- if (hovering && pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
739
- const entity = pick.id;
740
- hoverEntity.value = entity;
741
- } else hoverEntity.value = void 0;
742
- });
743
- onCleanup(remove);
734
+ onCleanup(graphicEvent.add("global", "HOVER", ({ hovering, pick }) => {
735
+ if (hovering && pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) hoverEntity.value = pick.id;
736
+ else hoverEntity.value = void 0;
737
+ }));
744
738
  });
745
739
  watchEffect((onCleanup) => {
746
- const remove = addGraphicEvent("global", "LEFT_CLICK", ({ event, pick }) => {
740
+ onCleanup(graphicEvent.add("global", "LEFT_CLICK", ({ event, pick }) => {
747
741
  if (pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
748
742
  const entity = pick.id;
749
743
  activeEntity.value = entity;
@@ -761,8 +755,7 @@ function useSkeleton(plots, current, getCurrentTime) {
761
755
  event
762
756
  });
763
757
  } else activeEntity.value = void 0;
764
- });
765
- onCleanup(remove);
758
+ }));
766
759
  });
767
760
  watchArray(plots, (value, oldValue, added, removed = []) => {
768
761
  added.forEach((plot) => update(plot));
@@ -827,8 +820,7 @@ function usePlot(options) {
827
820
  if (previous) {
828
821
  if (previous.defining) {
829
822
  const packable$1 = previous.sampled.getValue(getCurrentTime());
830
- const completed = previous.scheme.allowManualComplete?.(packable$1);
831
- if (completed) {
823
+ if (previous.scheme.allowManualComplete?.(packable$1)) {
832
824
  PlotFeature.setDefining(previous, false);
833
825
  operateResolve?.(previous);
834
826
  } else collection.delete(previous);
@@ -912,8 +904,7 @@ function control() {
912
904
  const newHeading = (viewer.camera.heading + headingAdjust) % (2 * Math.PI);
913
905
  const positions = [...packable.positions ?? []];
914
906
  const cartographic = toCartographic(positions[index]);
915
- const r = height / 1e5;
916
- const distance$1 = r * Math.PI / 180 / 1e3;
907
+ const distance$1 = height / 1e5 * Math.PI / 180 / 1e3;
917
908
  cartographic.latitude += distance$1 * Math.cos(newHeading);
918
909
  cartographic.longitude += distance$1 * Math.sin(newHeading);
919
910
  positions[index] = toCartesian3(cartographic);
@@ -924,16 +915,15 @@ function control() {
924
915
  });
925
916
  },
926
917
  render: ({ position, action }) => {
927
- const colors = {
928
- [PlotAction.IDLE]: Color.BLUE.withAlpha(.4),
929
- [PlotAction.HOVER]: Color.BLUE.withAlpha(.6),
930
- [PlotAction.ACTIVE]: Color.AQUA.withAlpha(1)
931
- };
932
918
  return {
933
919
  position,
934
920
  point: {
935
921
  pixelSize: 8,
936
- color: colors[action],
922
+ color: {
923
+ [PlotAction.IDLE]: Color.BLUE.withAlpha(.4),
924
+ [PlotAction.HOVER]: Color.BLUE.withAlpha(.6),
925
+ [PlotAction.ACTIVE]: Color.AQUA.withAlpha(1)
926
+ }[action],
937
927
  disableDepthTestDistance: Number.POSITIVE_INFINITY,
938
928
  outlineWidth: 1,
939
929
  outlineColor: Color.WHITE.withAlpha(.4)
@@ -980,16 +970,15 @@ function interval() {
980
970
  },
981
971
  render: ({ position, action, active }) => {
982
972
  if (!active) return;
983
- const colors = {
984
- [PlotAction.IDLE]: Color.GREEN.withAlpha(.4),
985
- [PlotAction.HOVER]: Color.GREEN.withAlpha(.6),
986
- [PlotAction.ACTIVE]: Color.GREEN.withAlpha(1)
987
- };
988
973
  return {
989
974
  position,
990
975
  point: {
991
976
  pixelSize: 6,
992
- color: colors[action],
977
+ color: {
978
+ [PlotAction.IDLE]: Color.GREEN.withAlpha(.4),
979
+ [PlotAction.HOVER]: Color.GREEN.withAlpha(.6),
980
+ [PlotAction.ACTIVE]: Color.GREEN.withAlpha(1)
981
+ }[action],
993
982
  disableDepthTestDistance: Number.POSITIVE_INFINITY,
994
983
  outlineWidth: 1,
995
984
  outlineColor: Color.WHITE.withAlpha(.4)
@@ -1034,16 +1023,15 @@ function intervalNonclosed() {
1034
1023
  });
1035
1024
  },
1036
1025
  render: ({ position, action }) => {
1037
- const colors = {
1038
- [PlotAction.IDLE]: Color.GREEN.withAlpha(.4),
1039
- [PlotAction.HOVER]: Color.GREEN.withAlpha(.6),
1040
- [PlotAction.ACTIVE]: Color.GREEN.withAlpha(1)
1041
- };
1042
1026
  return {
1043
1027
  position,
1044
1028
  point: {
1045
1029
  pixelSize: 6,
1046
- color: colors[action],
1030
+ color: {
1031
+ [PlotAction.IDLE]: Color.GREEN.withAlpha(.4),
1032
+ [PlotAction.HOVER]: Color.GREEN.withAlpha(.6),
1033
+ [PlotAction.ACTIVE]: Color.GREEN.withAlpha(1)
1034
+ }[action],
1047
1035
  disableDepthTestDistance: Number.POSITIVE_INFINITY,
1048
1036
  outlineWidth: 1,
1049
1037
  outlineColor: Color.WHITE.withAlpha(.4)
@@ -1068,10 +1056,7 @@ function moved() {
1068
1056
  const positions = packable.positions ?? [];
1069
1057
  if (positions.length === 0) return [];
1070
1058
  else if (positions.length === 1) return [positions[0]];
1071
- else {
1072
- const center = Rectangle.center(Rectangle.fromCartesianArray(positions));
1073
- return [toCartesian3(center)];
1074
- }
1059
+ else return [toCartesian3(Rectangle.center(Rectangle.fromCartesianArray(positions)))];
1075
1060
  },
1076
1061
  onDrag({ viewer, sampled, packable, event, lockCamera, dragging }) {
1077
1062
  dragging && lockCamera();
@@ -1087,18 +1072,17 @@ function moved() {
1087
1072
  });
1088
1073
  },
1089
1074
  render: ({ position, action }) => {
1090
- const colors = {
1091
- [PlotAction.IDLE]: Color.WHITE,
1092
- [PlotAction.HOVER]: Color.WHITE,
1093
- [PlotAction.ACTIVE]: Color.AQUA.withAlpha(1)
1094
- };
1095
1075
  return {
1096
1076
  position,
1097
1077
  billboard: {
1098
1078
  image: svg,
1099
1079
  width: 20,
1100
1080
  height: 20,
1101
- color: colors[action],
1081
+ color: {
1082
+ [PlotAction.IDLE]: Color.WHITE,
1083
+ [PlotAction.HOVER]: Color.WHITE,
1084
+ [PlotAction.ACTIVE]: Color.AQUA.withAlpha(1)
1085
+ }[action],
1102
1086
  pixelOffset: new Cartesian3(0, -20),
1103
1087
  horizontalOrigin: HorizontalOrigin.CENTER,
1104
1088
  verticalOrigin: VerticalOrigin.BOTTOM,
@@ -1168,12 +1152,12 @@ async function clampToHeightMostDetailedByTilesetOrTerrain(options) {
1168
1152
  else resolve([]);
1169
1153
  });
1170
1154
  const [tilesetPositions, terrainPositions] = await Promise.all([tilesetPromise, terrainPromise]);
1171
- const resluts = [];
1155
+ const results = [];
1172
1156
  positions.forEach((item, index) => {
1173
1157
  const position = tilesetPositions[index] || terrainPositions[index] ? Ellipsoid.WGS84.cartographicToCartesian(terrainPositions[index]) : item.clone();
1174
- resluts.push(position);
1158
+ results.push(position);
1175
1159
  });
1176
- return resluts;
1160
+ return results;
1177
1161
  }
1178
1162
 
1179
1163
  //#endregion
@@ -1202,8 +1186,7 @@ async function triangleGrid(positions, options) {
1202
1186
  const bbox = Rectangle.fromCartesianArray(positions);
1203
1187
  const vertical = bbox.north - bbox.south;
1204
1188
  const horizontal = bbox.east - bbox.west;
1205
- const max = Math.max(horizontal, vertical);
1206
- const granularity = max / density;
1189
+ const granularity = Math.max(horizontal, vertical) / density;
1207
1190
  const polygonGeometry = PolygonGeometry.fromPositions({
1208
1191
  positions,
1209
1192
  vertexFormat: PerInstanceColorAppearance.FLAT_VERTEX_FORMAT,
@@ -1222,13 +1205,12 @@ async function triangleGrid(positions, options) {
1222
1205
  }
1223
1206
  if (clampToGround) {
1224
1207
  if (!scene) throw new Error("scene is required on `clampToGround == true`.");
1225
- const detaileds = await clampToHeightMostDetailedByTilesetOrTerrain({
1208
+ cartesian3List = await clampToHeightMostDetailedByTilesetOrTerrain({
1226
1209
  scene,
1227
1210
  terrainProvider,
1228
1211
  positions: cartesian3List,
1229
1212
  classificationType
1230
1213
  });
1231
- cartesian3List = detaileds;
1232
1214
  }
1233
1215
  const grid = [];
1234
1216
  while (cartesian3List?.length) {
@@ -1276,18 +1258,14 @@ async function area(positions, options) {
1276
1258
  if (positions.length < 2) throw new Error("positions.length must >= 2");
1277
1259
  const { density, scene, clampToGround, classificationType, terrainProvider } = defaultOptions$1(options);
1278
1260
  if (density <= 0) throw new Error("options.density must > 0");
1279
- if (!clampToGround) {
1280
- const triangles$1 = tesselate(positions);
1281
- return triangles$1.reduce((count, current) => count += triangleArea(...current), 0);
1282
- }
1283
- const triangles = await triangleGrid(positions, {
1261
+ if (!clampToGround) return tesselate(positions).reduce((count, current) => count += triangleArea(...current), 0);
1262
+ return (await triangleGrid(positions, {
1284
1263
  density,
1285
1264
  scene,
1286
1265
  clampToGround,
1287
1266
  classificationType,
1288
1267
  terrainProvider
1289
- });
1290
- return triangles.reduce((count, current) => count += triangleArea(...current), 0);
1268
+ })).reduce((count, current) => count += triangleArea(...current), 0);
1291
1269
  }
1292
1270
 
1293
1271
  //#endregion
@@ -1305,13 +1283,12 @@ async function lerpArray(options) {
1305
1283
  result.push(end.clone());
1306
1284
  if (!clampToGround) return result;
1307
1285
  if (!scene) throw new Error("scene is required on `clampToGround == true`.");
1308
- const detaileds = await clampToHeightMostDetailedByTilesetOrTerrain({
1286
+ return await clampToHeightMostDetailedByTilesetOrTerrain({
1309
1287
  scene,
1310
1288
  terrainProvider,
1311
1289
  positions: result,
1312
1290
  classificationType
1313
1291
  });
1314
- return detaileds;
1315
1292
  }
1316
1293
 
1317
1294
  //#endregion
@@ -1367,8 +1344,7 @@ async function distance(positions, options) {
1367
1344
  terrainProvider: _options.terrainProvider
1368
1345
  });
1369
1346
  });
1370
- const detaileds = await Promise.all(positionListPromises);
1371
- const stagePromises = detaileds.map(async (positions$1) => {
1347
+ const stagePromises = (await Promise.all(positionListPromises)).map(async (positions$1) => {
1372
1348
  const { count: count$1 } = await distance(positions$1);
1373
1349
  return count$1;
1374
1350
  });
@@ -1438,7 +1414,7 @@ const schemeMeasureDistance = new PlotScheme({
1438
1414
  } })] };
1439
1415
  },
1440
1416
  render(context) {
1441
- const entity = context.previous.entities[0];
1417
+ context.previous.entities[0];
1442
1418
  const { mouse, packable, previous } = context;
1443
1419
  const entities = previous.entities;
1444
1420
  const positions = [...packable.positions ?? []];
@@ -1476,6 +1452,9 @@ const schemeMeasureDistance = new PlotScheme({
1476
1452
 
1477
1453
  //#endregion
1478
1454
  //#region scheme/Billboard.ts
1455
+ /**
1456
+ * billboard标绘配置
1457
+ */
1479
1458
  const PlotSchemeBillboard = new PlotScheme({
1480
1459
  type: "Billboard",
1481
1460
  complete: (packable) => packable.positions.length >= 1,
@@ -1498,6 +1477,9 @@ const PlotSchemeBillboard = new PlotScheme({
1498
1477
 
1499
1478
  //#endregion
1500
1479
  //#region scheme/BillboardPinBuilder.ts
1480
+ /**
1481
+ * billboard-pin-builder标绘配置
1482
+ */
1501
1483
  const PlotSchemeBillboardPinBuilder = new PlotScheme({
1502
1484
  type: "BillboardPinBuilder",
1503
1485
  complete: (packable) => packable.positions.length >= 1,
@@ -1515,6 +1497,9 @@ const PlotSchemeBillboardPinBuilder = new PlotScheme({
1515
1497
 
1516
1498
  //#endregion
1517
1499
  //#region scheme/Cylinder.ts
1500
+ /**
1501
+ * cylinder标绘配置
1502
+ */
1518
1503
  const PlotSchemeCylinder = new PlotScheme({
1519
1504
  type: "Cylinder",
1520
1505
  complete: (packable) => packable.positions.length >= 2,
@@ -1541,6 +1526,9 @@ const PlotSchemeCylinder = new PlotScheme({
1541
1526
 
1542
1527
  //#endregion
1543
1528
  //#region scheme/Ellipse.ts
1529
+ /**
1530
+ * ellipse标绘配置 圆形扩散波
1531
+ */
1544
1532
  const PlotSchemeEllipse = new PlotScheme({
1545
1533
  type: "Ellipse",
1546
1534
  complete: (packable) => packable.positions.length >= 2,
@@ -1567,6 +1555,9 @@ const PlotSchemeEllipse = new PlotScheme({
1567
1555
 
1568
1556
  //#endregion
1569
1557
  //#region scheme/Label.ts
1558
+ /**
1559
+ * 基础label标绘配置
1560
+ */
1570
1561
  const PlotSchemeLabel = new PlotScheme({
1571
1562
  type: "Label",
1572
1563
  complete: (packable) => packable.positions.length >= 1,
@@ -1584,6 +1575,9 @@ const PlotSchemeLabel = new PlotScheme({
1584
1575
 
1585
1576
  //#endregion
1586
1577
  //#region scheme/Point.ts
1578
+ /**
1579
+ * 基础point标绘配置
1580
+ */
1587
1581
  const PlotSchemePoint = new PlotScheme({
1588
1582
  type: "Point",
1589
1583
  complete: (packable) => packable.positions.length >= 1,
@@ -1604,6 +1598,9 @@ const PlotSchemePoint = new PlotScheme({
1604
1598
 
1605
1599
  //#endregion
1606
1600
  //#region scheme/Polygon.ts
1601
+ /**
1602
+ * 基础Polygon标绘配置
1603
+ */
1607
1604
  const PlotSchemePolygon = new PlotScheme({
1608
1605
  type: "Polygon",
1609
1606
  allowManualComplete: (packable) => packable.positions.length >= 2,
@@ -1641,930 +1638,10 @@ const PlotSchemePolygon = new PlotScheme({
1641
1638
  });
1642
1639
 
1643
1640
  //#endregion
1644
- //#region geom/helper.ts
1645
- const FITTING_COUNT = 100;
1646
- const HALF_PI = Math.PI / 2;
1647
- const ZERO_TOLERANCE = 1e-4;
1648
- const TWO_PI = Math.PI * 2;
1649
- /**
1650
- * 计算两个坐标之间的距离
1651
- * @param coord1
1652
- * @param coord2
1653
- */
1654
- function mathDistance(coord1, coord2) {
1655
- return Math.hypot(coord1[0] - coord2[0], coord1[1] - coord2[1]);
1656
- }
1657
- /**
1658
- * 计算点集合的总距离
1659
- * @param points
1660
- */
1661
- function wholeDistance(points) {
1662
- let distance$1 = 0;
1663
- if (points && Array.isArray(points) && points.length > 0) points.forEach((item, index) => {
1664
- if (index < points.length - 1) distance$1 += mathDistance(item, points[index + 1]);
1665
- });
1666
- return distance$1;
1667
- }
1668
- /**
1669
- * 获取基础长度
1670
- * @param points
1671
- */
1672
- const getBaseLength = (points) => wholeDistance(points) ** .99;
1673
- /**
1674
- * 求取两个坐标的中间坐标
1675
- * @param coord1
1676
- * @param coord2
1677
- */
1678
- function mid(coord1, coord2) {
1679
- return [(coord1[0] + coord2[0]) / 2, (coord1[1] + coord2[1]) / 2];
1680
- }
1681
- /**
1682
- * 通过三个点确定一个圆的中心点
1683
- * @param coord1
1684
- * @param coord2
1685
- * @param coord3
1686
- */
1687
- function getCircleCenterOfThreeCoords(coord1, coord2, coord3) {
1688
- const coordA = [(coord1[0] + coord2[0]) / 2, (coord1[1] + coord2[1]) / 2];
1689
- const coordB = [coordA[0] - coord1[1] + coord2[1], coordA[1] + coord1[0] - coord2[0]];
1690
- const coordC = [(coord1[0] + coord3[0]) / 2, (coord1[1] + coord3[1]) / 2];
1691
- const coordD = [coordC[0] - coord1[1] + coord3[1], coordC[1] + coord1[0] - coord3[0]];
1692
- return getIntersectCoord(coordA, coordB, coordC, coordD);
1693
- }
1694
- /**
1695
- * 获取交集的点
1696
- * @param coordA
1697
- * @param coordB
1698
- * @param coordC
1699
- * @param coordD
1700
- */
1701
- function getIntersectCoord(coordA, coordB, coordC, coordD) {
1702
- if (coordA[1] === coordB[1]) {
1703
- const f$1 = (coordD[0] - coordC[0]) / (coordD[1] - coordC[1]);
1704
- const x$1 = f$1 * (coordA[1] - coordC[1]) + coordC[0];
1705
- const y$1 = coordA[1];
1706
- return [x$1, y$1];
1707
- }
1708
- if (coordC[1] === coordD[1]) {
1709
- const e$1 = (coordB[0] - coordA[0]) / (coordB[1] - coordA[1]);
1710
- const x$1 = e$1 * (coordC[1] - coordA[1]) + coordA[0];
1711
- const y$1 = coordC[1];
1712
- return [x$1, y$1];
1713
- }
1714
- const e = (coordB[0] - coordA[0]) / (coordB[1] - coordA[1]);
1715
- const f = (coordD[0] - coordC[0]) / (coordD[1] - coordC[1]);
1716
- const y = (e * coordA[1] - coordA[0] - f * coordC[1] + coordC[0]) / (e - f);
1717
- const x = e * y - e * coordA[1] + coordA[0];
1718
- return [x, y];
1719
- }
1720
- /**
1721
- * 获取方位角(地平经度)
1722
- * @param startCoord
1723
- * @param endCoord
1724
- */
1725
- function getAzimuth(startCoord, endCoord) {
1726
- let azimuth = 0;
1727
- const angle = Math.asin(Math.abs(endCoord[1] - startCoord[1]) / mathDistance(startCoord, endCoord));
1728
- if (endCoord[1] >= startCoord[1] && endCoord[0] >= startCoord[0]) azimuth = angle + Math.PI;
1729
- else if (endCoord[1] >= startCoord[1] && endCoord[0] < startCoord[0]) azimuth = Math.PI * 2 - angle;
1730
- else if (endCoord[1] < startCoord[1] && endCoord[0] < startCoord[0]) azimuth = angle;
1731
- else if (endCoord[1] < startCoord[1] && endCoord[0] >= startCoord[0]) azimuth = Math.PI - angle;
1732
- return azimuth;
1733
- }
1734
- /**
1735
- * 通过三个点获取方位角
1736
- * @param coordA
1737
- * @param coordB
1738
- * @param coordC
1739
- */
1740
- function getAngleOfThreeCoords(coordA, coordB, coordC) {
1741
- const angle = getAzimuth(coordB, coordA) - getAzimuth(coordB, coordC);
1742
- return angle < 0 ? angle + Math.PI * 2 : angle;
1743
- }
1744
- /**
1745
- * 判断是否是顺时针
1746
- * @param coord1
1747
- * @param coord2
1748
- * @param coord3
1749
- */
1750
- function isClockWise(coord1, coord2, coord3) {
1751
- return (coord3[1] - coord1[1]) * (coord2[0] - coord1[0]) > (coord2[1] - coord1[1]) * (coord3[0] - coord1[0]);
1752
- }
1753
- /**
1754
- * 获取立方值
1755
- */
1756
- function getCubicValue(t, startCoord, coord1, coord2, endCoord) {
1757
- t = Math.max(Math.min(t, 1), 0);
1758
- const [tp, t2] = [1 - t, t * t];
1759
- const t3 = t2 * t;
1760
- const tp2 = tp * tp;
1761
- const tp3 = tp2 * tp;
1762
- const x = tp3 * startCoord[0] + 3 * tp2 * t * coord1[0] + 3 * tp * t2 * coord2[0] + t3 * endCoord[0];
1763
- const y = tp3 * startCoord[1] + 3 * tp2 * t * coord1[1] + 3 * tp * t2 * coord2[1] + t3 * endCoord[1];
1764
- return [x, y];
1765
- }
1766
- /**
1767
- * 根据起止点和旋转方向求取第三个点
1768
- * @param startCoord
1769
- * @param endCoord
1770
- * @param angle
1771
- * @param distance
1772
- * @param clockWise
1773
- */
1774
- function getThirdCoord(startCoord, endCoord, angle, distance$1, clockWise) {
1775
- const azimuth = getAzimuth(startCoord, endCoord);
1776
- const alpha = clockWise ? azimuth + angle : azimuth - angle;
1777
- const dx = distance$1 * Math.cos(alpha);
1778
- const dy = distance$1 * Math.sin(alpha);
1779
- return [endCoord[0] + dx, endCoord[1] + dy];
1780
- }
1781
- /**
1782
- * 插值弓形线段点
1783
- * @param center
1784
- * @param radius
1785
- * @param startAngle
1786
- * @param endAngle
1787
- */
1788
- function getArcCoords(center, radius, startAngle, endAngle) {
1789
- let [x, y, coords, angleDiff] = [
1790
- 0,
1791
- 0,
1792
- [],
1793
- endAngle - startAngle
1794
- ];
1795
- angleDiff = angleDiff < 0 ? angleDiff + Math.PI * 2 : angleDiff;
1796
- for (let i = 0; i <= 100; i++) {
1797
- const angle = startAngle + angleDiff * i / 100;
1798
- x = center[0] + radius * Math.cos(angle);
1799
- y = center[1] + radius * Math.sin(angle);
1800
- coords.push([x, y]);
1801
- }
1802
- return coords;
1803
- }
1804
- /**
1805
- * getBisectorNormals
1806
- * @param t
1807
- * @param coord1
1808
- * @param coord2
1809
- * @param coord3
1810
- */
1811
- function getBisectorNormals(t, coord1, coord2, coord3) {
1812
- const normal = getNormal(coord1, coord2, coord3);
1813
- let [bisectorNormalRight, bisectorNormalLeft, dt, x, y] = [
1814
- [0, 0],
1815
- [0, 0],
1816
- 0,
1817
- 0,
1818
- 0
1819
- ];
1820
- const dist = Math.hypot(normal[0], normal[1]);
1821
- const uX = normal[0] / dist;
1822
- const uY = normal[1] / dist;
1823
- const d1 = mathDistance(coord1, coord2);
1824
- const d2 = mathDistance(coord2, coord3);
1825
- if (dist > ZERO_TOLERANCE) if (isClockWise(coord1, coord2, coord3)) {
1826
- dt = t * d1;
1827
- x = coord2[0] - dt * uY;
1828
- y = coord2[1] + dt * uX;
1829
- bisectorNormalRight = [x, y];
1830
- dt = t * d2;
1831
- x = coord2[0] + dt * uY;
1832
- y = coord2[1] - dt * uX;
1833
- bisectorNormalLeft = [x, y];
1834
- } else {
1835
- dt = t * d1;
1836
- x = coord2[0] + dt * uY;
1837
- y = coord2[1] - dt * uX;
1838
- bisectorNormalRight = [x, y];
1839
- dt = t * d2;
1840
- x = coord2[0] - dt * uY;
1841
- y = coord2[1] + dt * uX;
1842
- bisectorNormalLeft = [x, y];
1843
- }
1844
- else {
1845
- x = coord2[0] + t * (coord1[0] - coord2[0]);
1846
- y = coord2[1] + t * (coord1[1] - coord2[1]);
1847
- bisectorNormalRight = [x, y];
1848
- x = coord2[0] + t * (coord3[0] - coord2[0]);
1849
- y = coord2[1] + t * (coord3[1] - coord2[1]);
1850
- bisectorNormalLeft = [x, y];
1851
- }
1852
- return [bisectorNormalRight, bisectorNormalLeft];
1853
- }
1854
- /**
1855
- * 获取默认三点的内切圆
1856
- * @param coord1
1857
- * @param coord2
1858
- * @param coord3
1859
- */
1860
- function getNormal(coord1, coord2, coord3) {
1861
- let dX1 = coord1[0] - coord2[0];
1862
- let dY1 = coord1[1] - coord2[1];
1863
- const d1 = Math.hypot(dX1, dY1);
1864
- dX1 /= d1;
1865
- dY1 /= d1;
1866
- let dX2 = coord3[0] - coord2[0];
1867
- let dY2 = coord3[1] - coord2[1];
1868
- const d2 = Math.hypot(dX2, dY2);
1869
- dX2 /= d2;
1870
- dY2 /= d2;
1871
- const uX = dX1 + dX2;
1872
- const uY = dY1 + dY2;
1873
- return [uX, uY];
1874
- }
1875
- /**
1876
- * 贝塞尔曲线
1877
- * @param points
1878
- */
1879
- function getBezierCoords(points) {
1880
- if (points.length <= 2) return points;
1881
- const bezierCoords = [];
1882
- const n = points.length - 1;
1883
- for (let t = 0; t <= 1; t += .01) {
1884
- let [x, y] = [0, 0];
1885
- for (let index = 0; index <= n; index++) {
1886
- const factor = getBinomialFactor(n, index);
1887
- const a = t ** index;
1888
- const b = (1 - t) ** (n - index);
1889
- x += factor * a * b * points[index][0];
1890
- y += factor * a * b * points[index][1];
1891
- }
1892
- bezierCoords.push([x, y]);
1893
- }
1894
- bezierCoords.push(points[n]);
1895
- return bezierCoords;
1896
- }
1897
- /**
1898
- * 获取阶乘数据
1899
- * @param n
1900
- */
1901
- function getFactorial(n) {
1902
- let result = 1;
1903
- switch (true) {
1904
- case n <= 1:
1905
- result = 1;
1906
- break;
1907
- case n === 2:
1908
- result = 2;
1909
- break;
1910
- case n === 3:
1911
- result = 6;
1912
- break;
1913
- case n === 24:
1914
- result = 24;
1915
- break;
1916
- case n === 5:
1917
- result = 120;
1918
- break;
1919
- default:
1920
- for (let i = 1; i <= n; i++) result *= i;
1921
- break;
1922
- }
1923
- return result;
1924
- }
1925
- /**
1926
- * 获取二项分布
1927
- * @param n
1928
- * @param index
1929
- */
1930
- function getBinomialFactor(n, index) {
1931
- return getFactorial(n) / (getFactorial(index) * getFactorial(n - index));
1932
- }
1933
- /**
1934
- * 插值线性点
1935
- * @param points
1936
- */
1937
- function getQBSplineCoords(points) {
1938
- if (points.length <= 2) return points;
1939
- const [n, bSplineCoords] = [2, []];
1940
- const m = points.length - n - 1;
1941
- bSplineCoords.push(points[0]);
1942
- for (let i = 0; i <= m; i++) for (let t = 0; t <= 1; t += .05) {
1943
- let [x, y] = [0, 0];
1944
- for (let k = 0; k <= n; k++) {
1945
- const factor = getQuadricBSplineFactor(k, t);
1946
- x += factor * points[i + k][0];
1947
- y += factor * points[i + k][1];
1948
- }
1949
- bSplineCoords.push([x, y]);
1950
- }
1951
- bSplineCoords.push(points.at(-1));
1952
- return bSplineCoords;
1953
- }
1954
- /**
1955
- * 得到二次线性因子
1956
- * @param k
1957
- * @param t
1958
- */
1959
- function getQuadricBSplineFactor(k, t) {
1960
- let res = 0;
1961
- if (k === 0) res = (t - 1) ** 2 / 2;
1962
- else if (k === 1) res = (-2 * t ** 2 + 2 * t + 1) / 2;
1963
- else if (k === 2) res = t ** 2 / 2;
1964
- return res;
1965
- }
1966
-
1967
- //#endregion
1968
- //#region geom/arc.ts
1969
- /**
1970
- * 标绘画弓形算法,继承线要素相关方法和属性
1971
- */
1972
- function arc(coords) {
1973
- const coordlength = coords.length;
1974
- if (coordlength <= 2) throw new Error("coords.length must >= 3");
1975
- else {
1976
- let [coord1, coord2, coord3, startAngle, endAngle] = [
1977
- coords[0],
1978
- coords[1],
1979
- coords[2],
1980
- 0,
1981
- 0
1982
- ];
1983
- const center = getCircleCenterOfThreeCoords(coord1, coord2, coord3);
1984
- const radius = mathDistance(coord1, center);
1985
- const angle1 = getAzimuth(coord1, center);
1986
- const angle2 = getAzimuth(coord2, center);
1987
- if (isClockWise(coord1, coord2, coord3)) {
1988
- startAngle = angle2;
1989
- endAngle = angle1;
1990
- } else {
1991
- startAngle = angle1;
1992
- endAngle = angle2;
1993
- }
1994
- return getArcCoords(center, radius, startAngle, endAngle);
1995
- }
1996
- }
1997
-
1998
- //#endregion
1999
- //#region geom/arrowAttackDirection.ts
2000
- /**
2001
- * 尖曲箭头
2002
- */
2003
- function arrowAttackDirection(coords, options = {}) {
2004
- const coordLength = coords.length;
2005
- if (coordLength < 3) throw new Error("coords.length must >= 3");
2006
- else {
2007
- let [tailLeft, tailRight] = [coords[0], coords[1]];
2008
- if (isClockWise(coords[0], coords[1], coords[2])) {
2009
- tailLeft = coords[1];
2010
- tailRight = coords[0];
2011
- }
2012
- const midTail = mid(tailLeft, tailRight);
2013
- const boneCoords = [midTail].concat(coords.slice(2));
2014
- const headCoords = getArrowHeadCoords(boneCoords, {
2015
- tailLeft,
2016
- tailRight,
2017
- ...options
2018
- });
2019
- if (headCoords && headCoords.length > 4) {
2020
- const [neckLeft, neckRight] = [headCoords[0], headCoords[4]];
2021
- const tailWidthFactor = mathDistance(tailLeft, tailRight) / getBaseLength(boneCoords);
2022
- const bodyCoords = getArrowBodyCoords(boneCoords, neckLeft, neckRight, tailWidthFactor);
2023
- const coordlength = bodyCoords.length;
2024
- let leftCoords = [tailLeft].concat(bodyCoords.slice(0, coordlength / 2));
2025
- leftCoords.push(neckLeft);
2026
- let rightCoords = [tailRight].concat(bodyCoords.slice(coordlength / 2, coordlength));
2027
- rightCoords.push(neckRight);
2028
- leftCoords = getQBSplineCoords(leftCoords);
2029
- rightCoords = getQBSplineCoords(rightCoords);
2030
- return leftCoords.concat(headCoords, rightCoords.reverse());
2031
- } else return [];
2032
- }
2033
- }
2034
- /**
2035
- * 插值头部点
2036
- */
2037
- function getArrowHeadCoords(points, options) {
2038
- const { tailLeft, tailRight, headHeightFactor = .18, headWidthFactor = .3, neckHeightFactor = .85, neckWidthFactor = .15, headTailFactor = .8 } = options;
2039
- let len = getBaseLength(points);
2040
- let headHeight = len * headHeightFactor;
2041
- const headCoord = points.at(-1);
2042
- len = mathDistance(headCoord, points.at(-2));
2043
- let tailWidth = 0;
2044
- if (tailLeft && tailRight) tailWidth = mathDistance(tailLeft, tailRight);
2045
- if (headHeight > tailWidth * headTailFactor) headHeight = tailWidth * headTailFactor;
2046
- const headWidth = headHeight * headWidthFactor;
2047
- const neckWidth = headHeight * neckWidthFactor;
2048
- headHeight = Math.min(headHeight, len);
2049
- const neckHeight = headHeight * neckHeightFactor;
2050
- const headEndCoord = getThirdCoord(points.at(-2), headCoord, 0, headHeight, true);
2051
- const neckEndCoord = getThirdCoord(points.at(-2), headCoord, 0, neckHeight, true);
2052
- const headLeft = getThirdCoord(headCoord, headEndCoord, HALF_PI, headWidth, false);
2053
- const headRight = getThirdCoord(headCoord, headEndCoord, HALF_PI, headWidth, true);
2054
- const neckLeft = getThirdCoord(headCoord, neckEndCoord, HALF_PI, neckWidth, false);
2055
- const neckRight = getThirdCoord(headCoord, neckEndCoord, HALF_PI, neckWidth, true);
2056
- return [
2057
- neckLeft,
2058
- headLeft,
2059
- headCoord,
2060
- headRight,
2061
- neckRight
2062
- ];
2063
- }
2064
- /**
2065
- * 插值面部分数据
2066
- * @param points
2067
- * @param neckLeft
2068
- * @param neckRight
2069
- * @param tailWidthFactor
2070
- */
2071
- function getArrowBodyCoords(points, neckLeft, neckRight, tailWidthFactor) {
2072
- const allLen = wholeDistance(points);
2073
- const len = getBaseLength(points);
2074
- const tailWidth = len * tailWidthFactor;
2075
- const neckWidth = mathDistance(neckLeft, neckRight);
2076
- const widthDif = (tailWidth - neckWidth) / 2;
2077
- let tempLen = 0;
2078
- const leftBodyCoords = [];
2079
- const rightBodyCoords = [];
2080
- for (let i = 1; i < points.length - 1; i++) {
2081
- const angle = getAngleOfThreeCoords(points[i - 1], points[i], points[i + 1]) / 2;
2082
- tempLen += mathDistance(points[i - 1], points[i]);
2083
- const w = (tailWidth / 2 - tempLen / allLen * widthDif) / Math.sin(angle);
2084
- const left = getThirdCoord(points[i - 1], points[i], Math.PI - angle, w, true);
2085
- const right = getThirdCoord(points[i - 1], points[i], angle, w, false);
2086
- leftBodyCoords.push(left);
2087
- rightBodyCoords.push(right);
2088
- }
2089
- return leftBodyCoords.concat(rightBodyCoords);
2090
- }
2091
-
2092
- //#endregion
2093
- //#region geom/arrowAttackDirectionTailed.ts
2094
- /**
2095
- * 燕尾尖曲箭头
2096
- */
2097
- function arrowAttackDirectionTailed(coords, options = {}) {
2098
- const { headHeightFactor = .18, headWidthFactor = .3, neckHeightFactor = .85, neckWidthFactor = .15, tailWidthFactor = .1, swallowTailFactor = 1 } = options;
2099
- const coordLength = coords.length;
2100
- if (coordLength < 3) throw new Error("coords.length must >= 3");
2101
- let [tailLeft, tailRight] = [coords[0], coords[1]];
2102
- if (isClockWise(coords[0], coords[1], coords[2])) {
2103
- tailLeft = coords[1];
2104
- tailRight = coords[0];
2105
- }
2106
- const midTail = mid(tailLeft, tailRight);
2107
- const boneCoords = [midTail].concat(coords.slice(2));
2108
- const headCoords = getArrowHeadCoords(boneCoords, {
2109
- tailLeft,
2110
- tailRight,
2111
- headHeightFactor,
2112
- headWidthFactor,
2113
- neckWidthFactor,
2114
- neckHeightFactor
2115
- });
2116
- if (headCoords && headCoords.length > 4) {
2117
- const [neckLeft, neckRight] = [headCoords[0], headCoords[4]];
2118
- const tailWidth = mathDistance(tailLeft, tailRight);
2119
- const allLen = getBaseLength(boneCoords);
2120
- const len = allLen * tailWidthFactor * swallowTailFactor;
2121
- const swallowTailCoord = getThirdCoord(boneCoords[1], boneCoords[0], 0, len, true);
2122
- const factor = tailWidth / allLen;
2123
- const bodyCoords = getArrowBodyCoords(boneCoords, neckLeft, neckRight, factor);
2124
- const coordlength = bodyCoords.length;
2125
- let leftCoords = [tailLeft].concat(bodyCoords.slice(0, coordlength / 2));
2126
- leftCoords.push(neckLeft);
2127
- let rightCoords = [tailRight].concat(bodyCoords.slice(coordlength / 2, coordlength));
2128
- rightCoords.push(neckRight);
2129
- leftCoords = getQBSplineCoords(leftCoords);
2130
- rightCoords = getQBSplineCoords(rightCoords);
2131
- return leftCoords.concat(headCoords, rightCoords.reverse(), [swallowTailCoord, leftCoords[0]]);
2132
- } else return [];
2133
- }
2134
-
2135
- //#endregion
2136
- //#region geom/arrowClamped.ts
2137
- /**
2138
- * 钳击箭头 有效点位长度3,4,5
2139
- */
2140
- function arrowClamped(coords) {
2141
- const options = {
2142
- headHeightFactor: .25,
2143
- headWidthFactor: .3,
2144
- neckHeightFactor: .85,
2145
- neckWidthFactor: .15
2146
- };
2147
- if (coords.length < 3) throw new Error(`coords.length must >= 3`);
2148
- const [coord1, coord2, coord3] = coords;
2149
- let tempCoord4, connCoord;
2150
- if (coords.length === 3) {
2151
- tempCoord4 = getTempCoord4(coord1, coord2, coord3);
2152
- connCoord = mid(coord1, coord2);
2153
- } else if (coords.length === 4) {
2154
- tempCoord4 = coords[3];
2155
- connCoord = mid(coord1, coord2);
2156
- } else {
2157
- tempCoord4 = coords[3];
2158
- connCoord = coords[4];
2159
- }
2160
- let leftArrowCoords;
2161
- let rightArrowCoords;
2162
- if (isClockWise(coord1, coord2, coord3)) {
2163
- leftArrowCoords = getArrowCoords(coord1, connCoord, tempCoord4, false, options);
2164
- rightArrowCoords = getArrowCoords(connCoord, coord2, coord3, true, options);
2165
- } else {
2166
- leftArrowCoords = getArrowCoords(coord2, connCoord, coord3, false, options);
2167
- rightArrowCoords = getArrowCoords(connCoord, coord1, tempCoord4, true, options);
2168
- }
2169
- const m = leftArrowCoords.length;
2170
- const t = (m - 5) / 2;
2171
- const llBodyCoords = leftArrowCoords.slice(0, t);
2172
- const lArrowCoords = leftArrowCoords.slice(t, t + 5);
2173
- let lrBodyCoords = leftArrowCoords.slice(t + 5, m);
2174
- let rlBodyCoords = rightArrowCoords.slice(0, t);
2175
- const rArrowCoords = rightArrowCoords.slice(t, t + 5);
2176
- const rrBodyCoords = rightArrowCoords.slice(t + 5, m);
2177
- rlBodyCoords = getBezierCoords(rlBodyCoords);
2178
- const bodyCoords = getBezierCoords(rrBodyCoords.concat(llBodyCoords.slice(1)));
2179
- lrBodyCoords = getBezierCoords(lrBodyCoords);
2180
- return rlBodyCoords.concat(rArrowCoords, bodyCoords, lArrowCoords, lrBodyCoords);
2181
- }
2182
- /**
2183
- * 插值箭形上的点
2184
- * @param coord1 - Wgs84坐标
2185
- * @param coord2 - Wgs84坐标
2186
- * @param coord3 - Wgs84坐标
2187
- * @param clockWise - 是否顺时针
2188
- */
2189
- function getArrowCoords(coord1, coord2, coord3, clockWise, options) {
2190
- const midCoord = mid(coord1, coord2);
2191
- const len = mathDistance(midCoord, coord3);
2192
- let midCoord1 = getThirdCoord(coord3, midCoord, 0, len * .3, true);
2193
- let midCoord2 = getThirdCoord(coord3, midCoord, 0, len * .5, true);
2194
- midCoord1 = getThirdCoord(midCoord, midCoord1, HALF_PI, len / 5, clockWise);
2195
- midCoord2 = getThirdCoord(midCoord, midCoord2, HALF_PI, len / 4, clockWise);
2196
- const coords = [
2197
- midCoord,
2198
- midCoord1,
2199
- midCoord2,
2200
- coord3
2201
- ];
2202
- const arrowCoords = getArrowHeadCoords$1(coords, options);
2203
- if (arrowCoords && Array.isArray(arrowCoords) && arrowCoords.length > 0) {
2204
- const [neckLeftCoord, neckRightCoord] = [arrowCoords[0], arrowCoords[4]];
2205
- const tailWidthFactor = mathDistance(coord1, coord2) / getBaseLength(coords) / 2;
2206
- const bodyCoords = getArrowBodyCoords$1(coords, neckLeftCoord, neckRightCoord, tailWidthFactor);
2207
- const n = bodyCoords.length;
2208
- let lCoords = bodyCoords.slice(0, n / 2);
2209
- let rCoords = bodyCoords.slice(n / 2, n);
2210
- lCoords.push(neckLeftCoord);
2211
- rCoords.push(neckRightCoord);
2212
- lCoords = lCoords.reverse();
2213
- lCoords.push(coord2);
2214
- rCoords = rCoords.reverse();
2215
- rCoords.push(coord1);
2216
- return lCoords.reverse().concat(arrowCoords, rCoords);
2217
- } else throw new Error("插值出错");
2218
- }
2219
- /**
2220
- * 插值头部点
2221
- * @param coords
2222
- */
2223
- function getArrowHeadCoords$1(coords, options) {
2224
- const { headHeightFactor, headWidthFactor, neckWidthFactor, neckHeightFactor } = options;
2225
- const len = getBaseLength(coords);
2226
- const headHeight = len * headHeightFactor;
2227
- const headCoord = coords.at(-1);
2228
- const headWidth = headHeight * headWidthFactor;
2229
- const neckWidth = headHeight * neckWidthFactor;
2230
- const neckHeight = headHeight * neckHeightFactor;
2231
- const headEndCoord = getThirdCoord(coords.at(-2), headCoord, 0, headHeight, true);
2232
- const neckEndCoord = getThirdCoord(coords.at(-2), headCoord, 0, neckHeight, true);
2233
- const headLeft = getThirdCoord(headCoord, headEndCoord, HALF_PI, headWidth, false);
2234
- const headRight = getThirdCoord(headCoord, headEndCoord, HALF_PI, headWidth, true);
2235
- const neckLeft = getThirdCoord(headCoord, neckEndCoord, HALF_PI, neckWidth, false);
2236
- const neckRight = getThirdCoord(headCoord, neckEndCoord, HALF_PI, neckWidth, true);
2237
- return [
2238
- neckLeft,
2239
- headLeft,
2240
- headCoord,
2241
- headRight,
2242
- neckRight
2243
- ];
2244
- }
2245
- /**
2246
- * 插值面部分数据
2247
- * @param coords
2248
- * @param neckLeft
2249
- * @param neckRight
2250
- * @param tailWidthFactor
2251
- */
2252
- function getArrowBodyCoords$1(coords, neckLeft, neckRight, tailWidthFactor) {
2253
- const allLen = wholeDistance(coords);
2254
- const len = getBaseLength(coords);
2255
- const tailWidth = len * tailWidthFactor;
2256
- const neckWidth = mathDistance(neckLeft, neckRight);
2257
- const widthDif = (tailWidth - neckWidth) / 2;
2258
- let tempLen = 0;
2259
- const leftBodyCoords = [];
2260
- const rightBodyCoords = [];
2261
- for (let i = 1; i < coords.length - 1; i++) {
2262
- const angle = getAngleOfThreeCoords(coords[i - 1], coords[i], coords[i + 1]) / 2;
2263
- tempLen += mathDistance(coords[i - 1], coords[i]);
2264
- const w = (tailWidth / 2 - tempLen / allLen * widthDif) / Math.sin(angle);
2265
- const left = getThirdCoord(coords[i - 1], coords[i], Math.PI - angle, w, true);
2266
- const right = getThirdCoord(coords[i - 1], coords[i], angle, w, false);
2267
- leftBodyCoords.push(left);
2268
- rightBodyCoords.push(right);
2269
- }
2270
- return leftBodyCoords.concat(rightBodyCoords);
2271
- }
2272
- /**
2273
- * 获取对称点
2274
- * @param lineCoord1
2275
- * @param lineCoord2
2276
- * @param coord
2277
- */
2278
- function getTempCoord4(lineCoord1, lineCoord2, coord) {
2279
- const midCoord = mid(lineCoord1, lineCoord2);
2280
- const len = mathDistance(midCoord, coord);
2281
- const angle = getAngleOfThreeCoords(lineCoord1, midCoord, coord);
2282
- if (angle < HALF_PI) {
2283
- const distance1 = len * Math.sin(angle);
2284
- const distance2 = len * Math.cos(angle);
2285
- const mid$1 = getThirdCoord(lineCoord1, midCoord, HALF_PI, distance1, false);
2286
- return getThirdCoord(midCoord, mid$1, HALF_PI, distance2, true);
2287
- } else if (angle >= HALF_PI && angle < Math.PI) {
2288
- const distance1 = len * Math.sin(Math.PI - angle);
2289
- const distance2 = len * Math.cos(Math.PI - angle);
2290
- const mid$1 = getThirdCoord(lineCoord1, midCoord, HALF_PI, distance1, false);
2291
- return getThirdCoord(midCoord, mid$1, HALF_PI, distance2, false);
2292
- } else if (angle >= Math.PI && angle < Math.PI * 1.5) {
2293
- const distance1 = len * Math.sin(angle - Math.PI);
2294
- const distance2 = len * Math.cos(angle - Math.PI);
2295
- const mid$1 = getThirdCoord(lineCoord1, midCoord, HALF_PI, distance1, true);
2296
- return getThirdCoord(midCoord, mid$1, HALF_PI, distance2, true);
2297
- } else {
2298
- const distance1 = len * Math.sin(Math.PI * 2 - angle);
2299
- const distance2 = len * Math.cos(Math.PI * 2 - angle);
2300
- const mid$1 = getThirdCoord(lineCoord1, midCoord, HALF_PI, distance1, true);
2301
- return getThirdCoord(midCoord, mid$1, HALF_PI, distance2, false);
2302
- }
2303
- }
2304
-
2305
- //#endregion
2306
- //#region geom/arrowStraightSharp.ts
2307
- /**
2308
- * 尖箭头
2309
- *
2310
- */
2311
- function arrowStraightSharp(coords, options = {}) {
2312
- const { tailWidthFactor = .1, neckWidthFactor = .2, headWidthFactor = .25, headAngle = Math.PI / 8.5, neckAngle = Math.PI / 13 } = options;
2313
- const coordlength = coords.length;
2314
- if (coordlength < 2) throw new Error("coords.length must >= 2");
2315
- const [coord1, coord2] = [coords[0], coords[1]];
2316
- const len = getBaseLength(coords);
2317
- const tailWidth = len * tailWidthFactor;
2318
- const neckWidth = len * neckWidthFactor;
2319
- const headWidth = len * headWidthFactor;
2320
- const tailLeft = getThirdCoord(coord2, coord1, HALF_PI, tailWidth, true);
2321
- const tailRight = getThirdCoord(coord2, coord1, HALF_PI, tailWidth, false);
2322
- const headLeft = getThirdCoord(coord1, coord2, headAngle, headWidth, false);
2323
- const headRight = getThirdCoord(coord1, coord2, headAngle, headWidth, true);
2324
- const neckLeft = getThirdCoord(coord1, coord2, neckAngle, neckWidth, false);
2325
- const neckRight = getThirdCoord(coord1, coord2, neckAngle, neckWidth, true);
2326
- const pList = [
2327
- tailLeft,
2328
- neckLeft,
2329
- headLeft,
2330
- coord2,
2331
- headRight,
2332
- neckRight,
2333
- tailRight
2334
- ];
2335
- return pList;
2336
- }
2337
-
2338
- //#endregion
2339
- //#region geom/arrowStraight.ts
2340
- /**
2341
- * 直箭头
2342
- */
2343
- function arrowStraight(coords) {
2344
- const tailWidthFactor = .05;
2345
- const neckWidthFactor = .1;
2346
- const headWidthFactor = .15;
2347
- const headAngle = Math.PI / 4;
2348
- const neckAngle = Math.PI * .17741;
2349
- return arrowStraightSharp(coords, {
2350
- tailWidthFactor,
2351
- neckWidthFactor,
2352
- headWidthFactor,
2353
- headAngle,
2354
- neckAngle
2355
- });
2356
- }
2357
-
2358
- //#endregion
2359
- //#region geom/arrowUnitCombatOperation.ts
2360
- /**
2361
- * 分队战斗行动(尖曲箭头)
2362
- */
2363
- function arrowUnitCombatOperation(coords, options = {}) {
2364
- const { headHeightFactor = .18, headWidthFactor = .3, neckHeightFactor = .85, neckWidthFactor = .15, tailWidthFactor = .1 } = options;
2365
- const coordlength = coords.length;
2366
- if (coordlength < 2) throw new Error("coords.length must >= 2");
2367
- else {
2368
- const allLen = getBaseLength(coords);
2369
- const tailWidth = allLen * tailWidthFactor;
2370
- const tailLeft = getThirdCoord(coords[1], coords[0], HALF_PI, tailWidth, false);
2371
- const tailRight = getThirdCoord(coords[1], coords[0], HALF_PI, tailWidth, true);
2372
- const headCoords = getArrowHeadCoords(coords, {
2373
- tailLeft,
2374
- tailRight,
2375
- headHeightFactor,
2376
- headWidthFactor,
2377
- neckWidthFactor,
2378
- neckHeightFactor
2379
- });
2380
- if (headCoords && headCoords.length > 4) {
2381
- const neckLeft = headCoords[0];
2382
- const neckRight = headCoords[4];
2383
- const bodyCoords = getArrowBodyCoords(coords, neckLeft, neckRight, tailWidthFactor);
2384
- const coordlength$1 = bodyCoords.length;
2385
- let leftCoords = [tailLeft].concat(bodyCoords.slice(0, coordlength$1 / 2));
2386
- leftCoords.push(neckLeft);
2387
- let rightCoords = [tailRight].concat(bodyCoords.slice(coordlength$1 / 2, coordlength$1));
2388
- rightCoords.push(neckRight);
2389
- leftCoords = getQBSplineCoords(leftCoords);
2390
- rightCoords = getQBSplineCoords(rightCoords);
2391
- return leftCoords.concat(headCoords, rightCoords.reverse());
2392
- } else return [];
2393
- }
2394
- }
2395
-
2396
- //#endregion
2397
- //#region geom/arrowUnitCombatOperationTailed.ts
2398
- /**
2399
- * 燕尾尖箭头
2400
- */
2401
- function arrowUnitCombatOperationTailed(coords, options = {}) {
2402
- const { headHeightFactor = .18, headWidthFactor = .3, neckHeightFactor = .85, neckWidthFactor = .15, tailWidthFactor = .1, swallowTailFactor = 1 } = options;
2403
- const coordlength = coords.length;
2404
- if (coordlength < 2) throw new Error("coords.length must >= 2");
2405
- const allLen = getBaseLength(coords);
2406
- const tailWidth = allLen * tailWidthFactor;
2407
- const tailLeft = getThirdCoord(coords[1], coords[0], HALF_PI, tailWidth, false);
2408
- const tailRight = getThirdCoord(coords[1], coords[0], HALF_PI, tailWidth, true);
2409
- const len = tailWidth * swallowTailFactor;
2410
- const swallowTailCoord = getThirdCoord(coords[1], coords[0], 0, len, true);
2411
- const tailCoords = [
2412
- tailLeft,
2413
- swallowTailCoord,
2414
- tailRight
2415
- ];
2416
- const headCoords = getArrowHeadCoords(coords, {
2417
- tailLeft: tailCoords[0],
2418
- tailRight: tailCoords[2],
2419
- headHeightFactor,
2420
- headWidthFactor,
2421
- neckWidthFactor,
2422
- neckHeightFactor
2423
- });
2424
- if (headCoords && headCoords.length > 4) {
2425
- const neckLeft = headCoords[0];
2426
- const neckRight = headCoords[4];
2427
- const bodyCoords = getArrowBodyCoords(coords, neckLeft, neckRight, tailWidthFactor);
2428
- const coordlength$1 = bodyCoords.length;
2429
- let leftCoords = [tailCoords[0]].concat(bodyCoords.slice(0, coordlength$1 / 2));
2430
- leftCoords.push(neckLeft);
2431
- let rightCoords = [tailCoords[2]].concat(bodyCoords.slice(coordlength$1 / 2, coordlength$1));
2432
- rightCoords.push(neckRight);
2433
- leftCoords = getQBSplineCoords(leftCoords);
2434
- rightCoords = getQBSplineCoords(rightCoords);
2435
- return leftCoords.concat(headCoords, rightCoords.reverse(), [tailCoords[1], leftCoords[0]]);
2436
- }
2437
- return [];
2438
- }
2439
-
2440
- //#endregion
2441
- //#region geom/assemblingPlace.ts
2442
- /**
2443
- * 集结地
2444
- *
2445
- */
2446
- function assemblingPlace(coords) {
2447
- if (coords.length < 3) throw new Error(`coords.length must >= 3`);
2448
- const t = .4;
2449
- const midCoord = mid(coords[0], coords[2]);
2450
- coords.push(midCoord, coords[0], coords[1]);
2451
- let normals = [];
2452
- const pList = [];
2453
- for (let i = 0; i < coords.length - 2; i++) {
2454
- const coord1 = coords[i];
2455
- const coord2 = coords[i + 1];
2456
- const coord3 = coords[i + 2];
2457
- const normalCoords = getBisectorNormals(t, coord1, coord2, coord3);
2458
- normals = normals.concat(normalCoords);
2459
- }
2460
- const count = normals.length;
2461
- normals = [normals[count - 1]].concat(normals.slice(0, count - 1));
2462
- for (let i = 0; i < coords.length - 2; i++) {
2463
- const coord1 = coords[i];
2464
- const coord2 = coords[i + 1];
2465
- pList.push(coord1);
2466
- for (let t$1 = 0; t$1 <= FITTING_COUNT; t$1++) {
2467
- const coord = getCubicValue(t$1 / FITTING_COUNT, coord1, normals[i * 2], normals[i * 2 + 1], coord2);
2468
- pList.push(coord);
2469
- }
2470
- pList.push(coord2);
2471
- }
2472
- return pList;
2473
- }
2474
-
2475
- //#endregion
2476
- //#region geom/flagCurve.ts
2477
- /**
2478
- * 曲线旗标
2479
- */
2480
- function flagCurve(coords) {
2481
- const coordlength = coords.length;
2482
- if (coordlength < 2) throw new Error("coords.length must >= 2");
2483
- return calculatePonits(coords);
2484
- }
2485
- /**
2486
- * 插值点数据
2487
- * @param coords
2488
- */
2489
- function calculatePonits(coords) {
2490
- let components = [];
2491
- if (coords.length > 1) {
2492
- const startCoord = coords[0];
2493
- const endCoord = coords.at(-1);
2494
- const coord1 = startCoord;
2495
- const coord2 = [(endCoord[0] - startCoord[0]) / 4 + startCoord[0], (endCoord[1] - startCoord[1]) / 8 + startCoord[1]];
2496
- const coord3 = [(startCoord[0] + endCoord[0]) / 2, startCoord[1]];
2497
- const coord4 = [(endCoord[0] - startCoord[0]) * 3 / 4 + startCoord[0], -(endCoord[1] - startCoord[1]) / 8 + startCoord[1]];
2498
- const coord5 = [endCoord[0], startCoord[1]];
2499
- const coord6 = [endCoord[0], (startCoord[1] + endCoord[1]) / 2];
2500
- const coord7 = [(endCoord[0] - startCoord[0]) * 3 / 4 + startCoord[0], (endCoord[1] - startCoord[1]) * 3 / 8 + startCoord[1]];
2501
- const coord8 = [(startCoord[0] + endCoord[0]) / 2, (startCoord[1] + endCoord[1]) / 2];
2502
- const coord9 = [(endCoord[0] - startCoord[0]) / 4 + startCoord[0], (endCoord[1] - startCoord[1]) * 5 / 8 + startCoord[1]];
2503
- const coord10 = [startCoord[0], (startCoord[1] + endCoord[1]) / 2];
2504
- const coord11 = [startCoord[0], endCoord[1]];
2505
- const curve1 = getBezierCoords([
2506
- coord1,
2507
- coord2,
2508
- coord3,
2509
- coord4,
2510
- coord5
2511
- ]);
2512
- const curve2 = getBezierCoords([
2513
- coord6,
2514
- coord7,
2515
- coord8,
2516
- coord9,
2517
- coord10
2518
- ]);
2519
- components = curve1.concat(curve2);
2520
- components.push(coord11);
2521
- }
2522
- return components;
2523
- }
2524
-
2525
- //#endregion
2526
- //#region geom/flagRect.ts
2527
- /**
2528
- * 直角旗标(使用两个控制点直接创建直角旗标)
2529
- */
2530
- function flagRect(coords) {
2531
- if (coords.length < 2) throw new Error("coords.length must >= 2");
2532
- const [startCoord, endCoord] = coords;
2533
- const coord1 = [endCoord[0], startCoord[1]];
2534
- const coord2 = [endCoord[0], (startCoord[1] + endCoord[1]) / 2];
2535
- const coord3 = [startCoord[0], (startCoord[1] + endCoord[1]) / 2];
2536
- const coord4 = [startCoord[0], endCoord[1]];
2537
- return [
2538
- startCoord,
2539
- coord1,
2540
- coord2,
2541
- coord3,
2542
- coord4
2543
- ];
2544
- }
2545
-
2546
- //#endregion
2547
- //#region geom/flagTriangle.ts
1641
+ //#region scheme/PolygonArc.ts
2548
1642
  /**
2549
- * 三角旗标(使用两个控制点直接创建三角旗标)
1643
+ * 弓形
2550
1644
  */
2551
- function flagTriangle(coords) {
2552
- const coordlength = coords.length;
2553
- if (coordlength < 2) throw new Error("coords.length must >= 2");
2554
- const [startCoord, endCoord] = coords;
2555
- const coord1 = [endCoord[0], (startCoord[1] + endCoord[1]) / 2];
2556
- const coord2 = [startCoord[0], (startCoord[1] + endCoord[1]) / 2];
2557
- const coord3 = [startCoord[0], endCoord[1]];
2558
- return [
2559
- startCoord,
2560
- coord1,
2561
- coord2,
2562
- coord3
2563
- ];
2564
- }
2565
-
2566
- //#endregion
2567
- //#region scheme/PolygonArc.ts
2568
1645
  const PlotSchemePolygonArc = new PlotScheme({
2569
1646
  type: "PolygonArc",
2570
1647
  complete: (packable) => packable.positions.length >= 3,
@@ -2581,8 +1658,7 @@ const PlotSchemePolygonArc = new PlotScheme({
2581
1658
  entity.polygon.hierarchy = void 0;
2582
1659
  return context.previous;
2583
1660
  }
2584
- const positions = arc(coords).map((item) => toCartesian3(item));
2585
- const hierarchy = new PolygonHierarchy(positions);
1661
+ const hierarchy = new PolygonHierarchy(arc(coords).map((item) => toCartesian3(item)));
2586
1662
  entity.polygon.hierarchy = new CallbackProperty(() => hierarchy, false);
2587
1663
  return { entities: [entity] };
2588
1664
  }
@@ -2610,8 +1686,7 @@ const PlotSchemePolygonArrowAttackDirection = new PlotScheme({
2610
1686
  entity.polygon.hierarchy = void 0;
2611
1687
  return context.previous;
2612
1688
  }
2613
- const positions = arrowAttackDirection(coords).map((item) => toCartesian3(item));
2614
- const hierarchy = new PolygonHierarchy(positions);
1689
+ const hierarchy = new PolygonHierarchy(arrowAttackDirection(coords).map((item) => toCartesian3(item)));
2615
1690
  entity.polygon.hierarchy = new CallbackProperty(() => hierarchy, false);
2616
1691
  return { entities: [entity] };
2617
1692
  }
@@ -2639,8 +1714,7 @@ const PlotSchemePolygonArrowAttackDirectionTailed = new PlotScheme({
2639
1714
  entity.polygon.hierarchy = void 0;
2640
1715
  return context.previous;
2641
1716
  }
2642
- const positions = arrowAttackDirectionTailed(coords).map((item) => toCartesian3(item));
2643
- const hierarchy = new PolygonHierarchy(positions);
1717
+ const hierarchy = new PolygonHierarchy(arrowAttackDirectionTailed(coords).map((item) => toCartesian3(item)));
2644
1718
  entity.polygon.hierarchy = new CallbackProperty(() => hierarchy, false);
2645
1719
  return { entities: [entity] };
2646
1720
  }
@@ -2664,8 +1738,7 @@ const PlotSchemePolygonArrowClamped = new PlotScheme({
2664
1738
  }
2665
1739
  const coords = points.map((e) => toCoord(e));
2666
1740
  if (coords.length >= 3) {
2667
- const positions = arrowClamped(coords);
2668
- const hierarchy = new PolygonHierarchy(positions.map((item) => toCartesian3(item)));
1741
+ const hierarchy = new PolygonHierarchy(arrowClamped(coords).map((item) => toCartesian3(item)));
2669
1742
  entity.polygon.hierarchy = new CallbackProperty(() => hierarchy, false);
2670
1743
  } else entity.polygon.hierarchy = void 0;
2671
1744
  return { entities: [entity] };
@@ -2690,8 +1763,7 @@ const PlotSchemePolygonArrowStraight = new PlotScheme({
2690
1763
  }
2691
1764
  const coords = points.map((e) => toCoord(e));
2692
1765
  if (coords.length >= 2) {
2693
- const positions = arrowStraight(coords);
2694
- const hierarchy = new PolygonHierarchy(positions.map((item) => toCartesian3(item)));
1766
+ const hierarchy = new PolygonHierarchy(arrowStraight(coords).map((item) => toCartesian3(item)));
2695
1767
  entity.polygon.hierarchy = new CallbackProperty(() => hierarchy, false);
2696
1768
  } else entity.polygon.hierarchy = void 0;
2697
1769
  return { entities: [entity] };
@@ -2716,8 +1788,7 @@ const PlotSchemePolygonArrowStraightSharp = new PlotScheme({
2716
1788
  }
2717
1789
  const coords = points.map((e) => toCoord(e));
2718
1790
  if (coords.length >= 2) {
2719
- const positions = arrowStraightSharp(coords);
2720
- const hierarchy = new PolygonHierarchy(positions.map((item) => toCartesian3(item)));
1791
+ const hierarchy = new PolygonHierarchy(arrowStraightSharp(coords).map((item) => toCartesian3(item)));
2721
1792
  entity.polygon.hierarchy = new CallbackProperty(() => hierarchy, false);
2722
1793
  } else entity.polygon.hierarchy = void 0;
2723
1794
  return { entities: [entity] };
@@ -2746,8 +1817,7 @@ const PlotSchemePolygonArrowUnitCombatOperation = new PlotScheme({
2746
1817
  entity.polygon.hierarchy = void 0;
2747
1818
  return context.previous;
2748
1819
  }
2749
- const positions = arrowUnitCombatOperation(coords).map((item) => toCartesian3(item));
2750
- const hierarchy = new PolygonHierarchy(positions);
1820
+ const hierarchy = new PolygonHierarchy(arrowUnitCombatOperation(coords).map((item) => toCartesian3(item)));
2751
1821
  entity.polygon.hierarchy = new CallbackProperty(() => hierarchy, false);
2752
1822
  return { entities: [entity] };
2753
1823
  }
@@ -2775,8 +1845,7 @@ const PlotSchemePolygonArrowUnitCombatOperationTailed = new PlotScheme({
2775
1845
  entity.polygon.hierarchy = void 0;
2776
1846
  return context.previous;
2777
1847
  }
2778
- const positions = arrowUnitCombatOperationTailed(coords).map((item) => toCartesian3(item));
2779
- const hierarchy = new PolygonHierarchy(positions);
1848
+ const hierarchy = new PolygonHierarchy(arrowUnitCombatOperationTailed(coords).map((item) => toCartesian3(item)));
2780
1849
  entity.polygon.hierarchy = new CallbackProperty(() => hierarchy, false);
2781
1850
  return { entities: [entity] };
2782
1851
  }
@@ -2804,83 +1873,15 @@ const PlotSchemePolygonAssemblingPlace = new PlotScheme({
2804
1873
  entity.polygon.hierarchy = void 0;
2805
1874
  return context.previous;
2806
1875
  }
2807
- const positions = assemblingPlace(coords).map((item) => toCartesian3(item));
2808
- const hierarchy = new PolygonHierarchy(positions);
2809
- entity.polygon.hierarchy = new CallbackProperty(() => hierarchy, false);
2810
- return { entities: [entity] };
2811
- }
2812
- });
2813
-
2814
- //#endregion
2815
- //#region scheme/PolygonFlagCurve.ts
2816
- const PlotSchemePolygonFlagCurve = new PlotScheme({
2817
- type: "PolygonFlagCurve",
2818
- complete: (packable) => packable.positions.length >= 2,
2819
- skeletons: [moved, control],
2820
- initRender() {
2821
- return { entities: [new Entity({ polygon: {} })] };
2822
- },
2823
- render(context) {
2824
- const entity = context.previous.entities[0];
2825
- const points = context.packable.positions;
2826
- context.mouse && points.push(context.mouse.clone());
2827
- const coords = points.map((e) => toCoord(e));
2828
- if (coords.length < 2) {
2829
- entity.polygon.hierarchy = void 0;
2830
- return context.previous;
2831
- }
2832
- const positions = flagCurve(coords).map((item) => toCartesian3(item));
2833
- const hierarchy = new PolygonHierarchy(positions);
2834
- entity.polygon.hierarchy = new CallbackProperty(() => hierarchy, false);
2835
- return { entities: [entity] };
2836
- }
2837
- });
2838
-
2839
- //#endregion
2840
- //#region scheme/PolygonFlagRect.ts
2841
- const PlotSchemePolygonFlagRect = new PlotScheme({
2842
- type: "PolygonFlagRect",
2843
- complete: (packable) => packable.positions.length >= 2,
2844
- skeletons: [moved, control],
2845
- initRender() {
2846
- return { entities: [new Entity({ polygon: {} })] };
2847
- },
2848
- render(context) {
2849
- const entity = context.previous.entities[0];
2850
- const points = context.packable.positions;
2851
- context.mouse && points.push(context.mouse.clone());
2852
- const coords = points.map((e) => toCoord(e));
2853
- if (coords.length < 2) {
2854
- entity.polygon.hierarchy = void 0;
2855
- return context.previous;
2856
- }
2857
- const positions = flagRect(coords).map((item) => toCartesian3(item));
2858
- const hierarchy = new PolygonHierarchy(positions);
2859
- entity.polygon.hierarchy = new CallbackProperty(() => hierarchy, false);
2860
- return { entities: [entity] };
2861
- }
2862
- });
2863
-
2864
- //#endregion
2865
- //#region scheme/PolygonFlagTriangle.ts
2866
- const PlotSchemePolygonFlagTriangle = new PlotScheme({
2867
- type: "PolygonFlagTriangle",
2868
- complete: (packable) => packable.positions.length >= 2,
2869
- skeletons: [moved, control],
2870
- initRender() {
2871
- return { entities: [new Entity({ polygon: {} })] };
2872
- },
2873
- render(context) {
2874
- const entity = context.previous.entities[0];
2875
- const points = context.packable.positions;
2876
- context.mouse && points.push(context.mouse.clone());
2877
- const coords = points.map((e) => toCoord(e));
2878
- if (coords.length < 2) {
2879
- entity.polygon.hierarchy = void 0;
2880
- return context.previous;
1876
+ if (coords.length === 2) {
1877
+ const c0 = toCartographic(coords[0]);
1878
+ const c1 = toCartographic(coords[1]);
1879
+ const latitude = c0.latitude;
1880
+ const height = c0.height;
1881
+ const longitude = c1.longitude - (c0.longitude - c1.longitude);
1882
+ coords.push(toCoord(new Cartographic(longitude, latitude, height)));
2881
1883
  }
2882
- const positions = flagTriangle(coords).map((item) => toCartesian3(item));
2883
- const hierarchy = new PolygonHierarchy(positions);
1884
+ const hierarchy = new PolygonHierarchy(assemblingPlace(coords).map((item) => toCartesian3(item)));
2884
1885
  entity.polygon.hierarchy = new CallbackProperty(() => hierarchy, false);
2885
1886
  return { entities: [entity] };
2886
1887
  }
@@ -2888,6 +1889,9 @@ const PlotSchemePolygonFlagTriangle = new PlotScheme({
2888
1889
 
2889
1890
  //#endregion
2890
1891
  //#region scheme/PolygonSmooth.ts
1892
+ /**
1893
+ * polygon-smooth 标绘配置 平滑闭合面
1894
+ */
2891
1895
  const PlotSchemePolygonSmooth = new PlotScheme({
2892
1896
  type: "PolygonSmooth",
2893
1897
  allowManualComplete: (packable) => packable.positions.length >= 3,
@@ -2910,9 +1914,8 @@ const PlotSchemePolygonSmooth = new PlotScheme({
2910
1914
  }
2911
1915
  const wgs84s = positions.map((e) => toCoord(e));
2912
1916
  wgs84s.push(wgs84s[0]);
2913
- const { features } = turf$1.polygonSmooth(turf$1.polygon([wgs84s]), { iterations: 3 });
2914
- const cartesians = features[0].geometry.coordinates[0].map((item) => toCartesian3(item)).filter((e) => !!e);
2915
- const hierarchy = new PolygonHierarchy(cartesians);
1917
+ const { features } = turf.polygonSmooth(turf.polygon([wgs84s]), { iterations: 3 });
1918
+ const hierarchy = new PolygonHierarchy(features[0].geometry.coordinates[0].map((item) => toCartesian3(item)).filter((e) => !!e));
2916
1919
  entity.polygon.hierarchy = new CallbackProperty(() => hierarchy, false);
2917
1920
  return { entities: [entity] };
2918
1921
  }
@@ -2920,6 +1923,9 @@ const PlotSchemePolygonSmooth = new PlotScheme({
2920
1923
 
2921
1924
  //#endregion
2922
1925
  //#region scheme/Polyline.ts
1926
+ /**
1927
+ * polyline
1928
+ */
2923
1929
  const PlotSchemePolyline = new PlotScheme({
2924
1930
  type: "Polyline",
2925
1931
  allowManualComplete: (packable) => packable.positions.length > 1,
@@ -2947,6 +1953,9 @@ const PlotSchemePolyline = new PlotScheme({
2947
1953
 
2948
1954
  //#endregion
2949
1955
  //#region scheme/PolylineCurve.ts
1956
+ /**
1957
+ * polyline-Curve
1958
+ */
2950
1959
  const PlotSchemePolylineCurve = new PlotScheme({
2951
1960
  type: "PolylineCurve",
2952
1961
  allowManualComplete: (packable) => packable.positions.length > 1,
@@ -2979,6 +1988,9 @@ const PlotSchemePolylineCurve = new PlotScheme({
2979
1988
 
2980
1989
  //#endregion
2981
1990
  //#region scheme/Rectangle.ts
1991
+ /**
1992
+ * rectangle
1993
+ */
2982
1994
  const PlotSchemeRectangle = new PlotScheme({
2983
1995
  type: "Rectangle",
2984
1996
  complete: (packable) => packable.positions.length >= 2,
@@ -3002,5 +2014,5 @@ const PlotSchemeRectangle = new PlotScheme({
3002
2014
  });
3003
2015
 
3004
2016
  //#endregion
3005
- export { PlotAction, PlotFeature, PlotScheme, PlotSchemeBillboard, PlotSchemeBillboardPinBuilder, PlotSchemeCylinder, PlotSchemeEllipse, PlotSchemeLabel, PlotSchemePoint, PlotSchemePolygon, PlotSchemePolygonArc, PlotSchemePolygonArrowAttackDirection, PlotSchemePolygonArrowAttackDirectionTailed, PlotSchemePolygonArrowClamped, PlotSchemePolygonArrowStraight, PlotSchemePolygonArrowStraightSharp, PlotSchemePolygonArrowUnitCombatOperation, PlotSchemePolygonArrowUnitCombatOperationTailed, PlotSchemePolygonAssemblingPlace, PlotSchemePolygonFlagCurve, PlotSchemePolygonFlagRect, PlotSchemePolygonFlagTriangle, PlotSchemePolygonSmooth, PlotSchemePolyline, PlotSchemePolylineCurve, PlotSchemeRectangle, PlotSkeletonEntity, SampledPlotProperty, SampledPlotStrategy, control, interval, intervalNonclosed, moved, schemeMeasureArea, schemeMeasureDistance, usePlot };
2017
+ export { PlotAction, PlotFeature, PlotScheme, PlotSchemeBillboard, PlotSchemeBillboardPinBuilder, PlotSchemeCylinder, PlotSchemeEllipse, PlotSchemeLabel, PlotSchemePoint, PlotSchemePolygon, PlotSchemePolygonArc, PlotSchemePolygonArrowAttackDirection, PlotSchemePolygonArrowAttackDirectionTailed, PlotSchemePolygonArrowClamped, PlotSchemePolygonArrowStraight, PlotSchemePolygonArrowStraightSharp, PlotSchemePolygonArrowUnitCombatOperation, PlotSchemePolygonArrowUnitCombatOperationTailed, PlotSchemePolygonAssemblingPlace, PlotSchemePolygonSmooth, PlotSchemePolyline, PlotSchemePolylineCurve, PlotSchemeRectangle, PlotSkeletonEntity, SampledPlotProperty, SampledPlotStrategy, control, interval, intervalNonclosed, moved, schemeMeasureArea, schemeMeasureDistance, usePlot };
3006
2018
  //# sourceMappingURL=index.mjs.map