@jorgmoritz/gis-manager 0.1.28 → 0.1.29

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/vue/index.js CHANGED
@@ -6674,6 +6674,98 @@ function renderFlightPath(CesiumNS, viewer, options) {
6674
6674
  }
6675
6675
  return entity;
6676
6676
  }
6677
+ function renderFlightPathPreview(CesiumNS, viewer, options) {
6678
+ const C = CesiumNS;
6679
+ const entity = renderFlightPath(CesiumNS, viewer, options);
6680
+ const vertexLabelManager = entity._vertexLabelManager;
6681
+ let selectedWaypointIndex = options.initialSelectedIndex ?? null;
6682
+ const polyline = entity.polyline;
6683
+ let positions = [];
6684
+ if (polyline && polyline.positions) {
6685
+ const posValue = polyline.positions.getValue?.(C.JulianDate.now());
6686
+ if (Array.isArray(posValue)) {
6687
+ positions = posValue;
6688
+ }
6689
+ }
6690
+ let waypointDataArray = [];
6691
+ try {
6692
+ const adapterOptions = {
6693
+ CesiumNS,
6694
+ ...options.adapterOptions
6695
+ };
6696
+ const converted = convertSinoflyWayline(options.data, adapterOptions);
6697
+ if (converted && converted.waypointData) {
6698
+ waypointDataArray = [...converted.waypointData].sort((a, b) => a.index - b.index);
6699
+ }
6700
+ } catch (e) {
6701
+ console.warn("[renderFlightPathPreview] \u65E0\u6CD5\u83B7\u53D6\u822A\u70B9\u6570\u636E:", e);
6702
+ }
6703
+ const hasHiddenClimb = entity.properties?._hasHiddenClimb?.getValue?.() ?? false;
6704
+ const hiddenClimbIndex = hasHiddenClimb ? 1 : void 0;
6705
+ const updateWaypointHighlight = (newIndex) => {
6706
+ if (!vertexLabelManager || positions.length === 0) return;
6707
+ const editedIndices = /* @__PURE__ */ new Set();
6708
+ vertexLabelManager.recreateAllLabels(positions, editedIndices, newIndex ?? void 0);
6709
+ };
6710
+ if (selectedWaypointIndex !== null) {
6711
+ updateWaypointHighlight(selectedWaypointIndex);
6712
+ }
6713
+ const handler = new C.ScreenSpaceEventHandler(viewer.scene.canvas);
6714
+ handler.setInputAction((movement) => {
6715
+ const pickedObject = viewer.scene.pick(movement.position);
6716
+ if (C.defined(pickedObject) && pickedObject.id) {
6717
+ const pickedEntity = pickedObject.id;
6718
+ const properties = pickedEntity.properties;
6719
+ if (properties) {
6720
+ const type = properties._type?.getValue?.(C.JulianDate.now());
6721
+ const ownerId = properties._ownerId?.getValue?.(C.JulianDate.now());
6722
+ const vertexIndex = properties._vertexIndex?.getValue?.(C.JulianDate.now());
6723
+ if (type === "vertex-label" && ownerId === entity.id && vertexIndex !== void 0) {
6724
+ let displayIndex = vertexIndex;
6725
+ if (hiddenClimbIndex === 1) {
6726
+ if (vertexIndex >= 2) {
6727
+ displayIndex = vertexIndex - 2;
6728
+ }
6729
+ } else {
6730
+ displayIndex = vertexIndex;
6731
+ }
6732
+ selectedWaypointIndex = vertexIndex;
6733
+ updateWaypointHighlight(selectedWaypointIndex);
6734
+ if (options.onWaypointClick) {
6735
+ const waypointData = waypointDataArray.find((wp) => wp.index === vertexIndex);
6736
+ options.onWaypointClick(displayIndex, waypointData);
6737
+ }
6738
+ }
6739
+ }
6740
+ }
6741
+ }, C.ScreenSpaceEventType.LEFT_CLICK);
6742
+ const controller = {
6743
+ setSelectedWaypoint: (index) => {
6744
+ if (index === null) {
6745
+ selectedWaypointIndex = null;
6746
+ updateWaypointHighlight(null);
6747
+ return;
6748
+ }
6749
+ let actualIndex = index;
6750
+ if (hiddenClimbIndex === 1) {
6751
+ actualIndex = index + 2;
6752
+ }
6753
+ selectedWaypointIndex = actualIndex;
6754
+ updateWaypointHighlight(selectedWaypointIndex);
6755
+ },
6756
+ getSelectedWaypoint: () => {
6757
+ if (selectedWaypointIndex === null) return null;
6758
+ if (hiddenClimbIndex === 1) {
6759
+ return selectedWaypointIndex >= 2 ? selectedWaypointIndex - 2 : null;
6760
+ }
6761
+ return selectedWaypointIndex;
6762
+ },
6763
+ destroy: () => {
6764
+ handler.destroy();
6765
+ }
6766
+ };
6767
+ return { entity, controller };
6768
+ }
6677
6769
 
6678
6770
  // src/core/CZMLPathManager.ts
6679
6771
  var _CZMLPathManager = class _CZMLPathManager {
@@ -6757,6 +6849,37 @@ var _CZMLPathManager = class _CZMLPathManager {
6757
6849
  renderFlightPath(options) {
6758
6850
  return renderFlightPath(this.CesiumNS, this.viewer, options);
6759
6851
  }
6852
+ /**
6853
+ * 预览模式渲染飞航路线:支持航点点击高亮
6854
+ *
6855
+ * 与 renderFlightPath 不同,此方法返回一个控制器对象,支持:
6856
+ * - 航点点击事件回调
6857
+ * - 程序化设置选中航点(高亮显示)
6858
+ * - 列表与地图双向联动
6859
+ *
6860
+ * @param options 预览选项
6861
+ * @returns 包含实体和控制器的对象
6862
+ *
6863
+ * @example
6864
+ * ```typescript
6865
+ * const { entity, controller } = pathManager.renderFlightPathPreview({
6866
+ * data: sinoflyData,
6867
+ * onWaypointClick: (index, waypoint) => {
6868
+ * console.log('点击了航点', index, waypoint);
6869
+ * },
6870
+ * initialSelectedIndex: 0
6871
+ * });
6872
+ *
6873
+ * // 程序化设置选中航点
6874
+ * controller.setSelectedWaypoint(2);
6875
+ *
6876
+ * // 销毁
6877
+ * controller.destroy();
6878
+ * ```
6879
+ */
6880
+ renderFlightPathPreview(options) {
6881
+ return renderFlightPathPreview(this.CesiumNS, this.viewer, options);
6882
+ }
6760
6883
  resolveEntity(entityOrId) {
6761
6884
  return typeof entityOrId === "string" ? this.viewer.entities.getById(entityOrId) : entityOrId;
6762
6885
  }
@@ -9646,6 +9769,20 @@ var CZMLManager = class {
9646
9769
  renderFlightPath(options) {
9647
9770
  return this.pathMgr.renderFlightPath(options);
9648
9771
  }
9772
+ /**
9773
+ * 预览模式渲染飞航路线:支持航点点击高亮
9774
+ *
9775
+ * 与 renderFlightPath 不同,此方法返回一个控制器对象,支持:
9776
+ * - 航点点击事件回调
9777
+ * - 程序化设置选中航点(高亮显示)
9778
+ * - 列表与地图双向联动
9779
+ *
9780
+ * @param options 预览选项
9781
+ * @returns 包含实体和控制器的对象
9782
+ */
9783
+ renderFlightPathPreview(options) {
9784
+ return this.pathMgr.renderFlightPathPreview(options);
9785
+ }
9649
9786
  addPathSample(entityOrId, sample) {
9650
9787
  return this.pathMgr.addPathSample(entityOrId, sample);
9651
9788
  }