deeptwins-engine-3d 0.1.72 → 0.1.74

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.
@@ -572,7 +572,8 @@ export var DEFAULT_BASE_LAYER = {
572
572
  maximumLevel: 18,
573
573
  credit: 'gd_img'
574
574
  }, {
575
- url: 'https://webst02.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scale=1&style=8',
575
+ url: 'https://webst0{s}.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scale=1&style=8',
576
+ subdomains: ['1', '2', '3', '4'],
576
577
  minimumLevel: 1,
577
578
  maximumLevel: 18,
578
579
  credit: 'gd_img_zj'
@@ -593,7 +594,8 @@ export var DEFAULT_BASE_LAYER = {
593
594
  name: '高德电子+注记',
594
595
  type: 'raster',
595
596
  layers: [{
596
- url: 'https://wprd02.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scl=1&style=7',
597
+ url: 'http://webrd0{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}',
598
+ subdomains: ['1', '2', '3', '4'],
597
599
  minimumLevel: 1,
598
600
  maximumLevel: 18,
599
601
  credit: 'gd_vec_zj'
package/dist/esm/index.js CHANGED
@@ -73,11 +73,11 @@ DEEP_TWINS_BASE_URL && (window.CESIUM_BASE_URL = DEEP_TWINS_BASE_URL);
73
73
  // 全局加载css
74
74
  loadCss(Cesium.buildModuleUrl('Widgets/widgets.css'));
75
75
  // 打印版本信息
76
- console.log('DeepTwinsEngine3D Version:', "0.1.72");
76
+ console.log('DeepTwinsEngine3D Version:', "0.1.74");
77
77
  export var DeepTwinsEngine3D = /*#__PURE__*/_createClass(function DeepTwinsEngine3D() {
78
78
  _classCallCheck(this, DeepTwinsEngine3D);
79
79
  });
80
- _defineProperty(DeepTwinsEngine3D, "Version", "0.1.72");
80
+ _defineProperty(DeepTwinsEngine3D, "Version", "0.1.74");
81
81
  _defineProperty(DeepTwinsEngine3D, "Map", Map);
82
82
  _defineProperty(DeepTwinsEngine3D, "GroundSkyBox", GroundSkyBox);
83
83
  _defineProperty(DeepTwinsEngine3D, "RasterLayer", RasterLayer);
@@ -52,12 +52,14 @@ import ImageryLayer from './ImageryLayer';
52
52
  * - `projectionDefs`:可选,自定义 proj4 坐标系定义。
53
53
  * - `clipFeature`:可选,GeoJSON Polygon/MultiPolygon/Feature/FeatureCollection。
54
54
  * - `autoFitBounds`:可选,创建后自动将相机定位到最终范围,需同时传入 `map`。
55
- * - `debug`:可选,`true` 使用 console.debug,函数则接收结构化调试事件。
55
+ * - `debug`:可选,`true` 使用 console.log 输出调试信息,函数则接收结构化调试事件。
56
56
  */
57
57
  /** 通用范围格式:[minX, minY, maxX, maxY]。 */
58
58
  export type CustomRasterBounds = [number, number, number, number];
59
59
  /** 调试事件类型,覆盖范围初始化、瓦片加载和裁剪决策。 */
60
60
  export type CustomRasterLayerDebugEventType = 'range' | 'tile-loaded' | 'tile-kept' | 'tile-clipped' | 'tile-discarded' | 'tile-error';
61
+ /** 瓦片 debug 状态。 */
62
+ export type CustomRasterLayerDebugStatus = 'loaded' | 'kept' | 'clipped' | 'filtered' | 'error';
61
63
  /** debug 回调收到的结构化事件。 */
62
64
  export type CustomRasterLayerDebugEvent = {
63
65
  /** 事件类型。 */
@@ -70,6 +72,16 @@ export type CustomRasterLayerDebugEvent = {
70
72
  y?: number;
71
73
  /** 瓦片层级。 */
72
74
  level?: number;
75
+ /** 瓦片标识,格式为 z/x/y。 */
76
+ tileKey?: string;
77
+ /** 瓦片是否已进入加载流程。 */
78
+ loaded?: boolean;
79
+ /** 瓦片是否被裁剪。 */
80
+ clipped?: boolean;
81
+ /** 瓦片是否被过滤为空透明瓦片。 */
82
+ filtered?: boolean;
83
+ /** 瓦片处理状态。 */
84
+ status?: CustomRasterLayerDebugStatus;
73
85
  /** 当前瓦片范围,格式为 [west, south, east, north]。 */
74
86
  bbox?: CustomRasterBounds;
75
87
  /** 用户传入的原始瓦片范围。 */
@@ -80,6 +92,8 @@ export type CustomRasterLayerDebugEvent = {
80
92
  clipBounds?: CustomRasterBounds;
81
93
  /** 最终用于瓦片调度的渲染范围。 */
82
94
  renderBounds?: CustomRasterBounds;
95
+ /** 转换到 renderCrs 后的裁剪 GeoJSON。 */
96
+ clipFeature?: any;
83
97
  /** bounds 原始坐标系。 */
84
98
  dataCrs?: string;
85
99
  /** clipFeature 原始坐标系。 */
@@ -96,7 +110,7 @@ export type CustomRasterLayerDebugEvent = {
96
110
  height: number;
97
111
  };
98
112
  };
99
- /** debug 配置:关闭、console.debug 输出,或自定义事件处理函数。 */
113
+ /** debug 配置:关闭、console.log 输出,或自定义事件处理函数。 */
100
114
  export type CustomRasterLayerDebug = boolean | ((event: CustomRasterLayerDebugEvent) => void);
101
115
  /** 内置切片方案名称,或 Cesium 原生 TilingScheme 实例。 */
102
116
  export type CustomRasterTilingSchemeOption = 'webMercator' | 'geographic' | Cesium.TilingScheme;
@@ -187,6 +201,10 @@ export default class CustomRasterLayer extends ImageryLayer {
187
201
  private geometryToPathArray;
188
202
  /** 按 path 坐标裁剪当前瓦片画布。 */
189
203
  private clip;
204
+ private getTileKey;
205
+ private getDebugStatus;
206
+ private normalizeDebugEvent;
207
+ private logBuiltInDebug;
190
208
  /** 输出结构化 debug 事件。 */
191
209
  private logDebug;
192
210
  }
@@ -83,16 +83,18 @@ import ImageryLayer from "./ImageryLayer";
83
83
  * - `projectionDefs`:可选,自定义 proj4 坐标系定义。
84
84
  * - `clipFeature`:可选,GeoJSON Polygon/MultiPolygon/Feature/FeatureCollection。
85
85
  * - `autoFitBounds`:可选,创建后自动将相机定位到最终范围,需同时传入 `map`。
86
- * - `debug`:可选,`true` 使用 console.debug,函数则接收结构化调试事件。
86
+ * - `debug`:可选,`true` 使用 console.log 输出调试信息,函数则接收结构化调试事件。
87
87
  */
88
88
 
89
89
  /** 通用范围格式:[minX, minY, maxX, maxY]。 */
90
90
 
91
91
  /** 调试事件类型,覆盖范围初始化、瓦片加载和裁剪决策。 */
92
92
 
93
+ /** 瓦片 debug 状态。 */
94
+
93
95
  /** debug 回调收到的结构化事件。 */
94
96
 
95
- /** debug 配置:关闭、console.debug 输出,或自定义事件处理函数。 */
97
+ /** debug 配置:关闭、console.log 输出,或自定义事件处理函数。 */
96
98
 
97
99
  /** 内置切片方案名称,或 Cesium 原生 TilingScheme 实例。 */
98
100
 
@@ -454,6 +456,28 @@ var getImageSize = function getImageSize(image) {
454
456
  height: image.height
455
457
  };
456
458
  };
459
+ var DEBUG_STATUS_STYLES = {
460
+ loaded: {
461
+ label: '瓦片已加载',
462
+ consoleColor: '#16a34a'
463
+ },
464
+ kept: {
465
+ label: '瓦片已保留',
466
+ consoleColor: '#16a34a'
467
+ },
468
+ clipped: {
469
+ label: '瓦片已裁剪',
470
+ consoleColor: '#eab308'
471
+ },
472
+ filtered: {
473
+ label: '瓦片已过滤',
474
+ consoleColor: '#dc2626'
475
+ },
476
+ error: {
477
+ label: '瓦片处理异常',
478
+ consoleColor: '#b91c1c'
479
+ }
480
+ };
457
481
 
458
482
  /**
459
483
  * 通用自定义栅格图层。
@@ -517,6 +541,7 @@ var CustomRasterLayer = /*#__PURE__*/function (_ImageryLayer) {
517
541
  tileBounds: tileBounds,
518
542
  clipBounds: clipBounds,
519
543
  renderBounds: renderBounds,
544
+ clipFeature: transformedClipFeature,
520
545
  dataCrs: dataCrs,
521
546
  clipFeatureCrs: clipFeatureCrs,
522
547
  renderCrs: renderCrs
@@ -756,6 +781,94 @@ var CustomRasterLayer = /*#__PURE__*/function (_ImageryLayer) {
756
781
  context.fill();
757
782
  context.restore();
758
783
  }
784
+ }, {
785
+ key: "getTileKey",
786
+ value: function getTileKey(event) {
787
+ if (event.x === undefined || event.y === undefined || event.level === undefined) {
788
+ return undefined;
789
+ }
790
+ return "".concat(event.level, "/").concat(event.x, "/").concat(event.y);
791
+ }
792
+ }, {
793
+ key: "getDebugStatus",
794
+ value: function getDebugStatus(event) {
795
+ if (event.status) {
796
+ return event.status;
797
+ }
798
+ if (event.type === 'tile-loaded') {
799
+ return 'loaded';
800
+ }
801
+ if (event.type === 'tile-kept') {
802
+ return 'kept';
803
+ }
804
+ if (event.type === 'tile-clipped') {
805
+ return 'clipped';
806
+ }
807
+ if (event.type === 'tile-discarded') {
808
+ return 'filtered';
809
+ }
810
+ if (event.type === 'tile-error') {
811
+ return 'error';
812
+ }
813
+ return undefined;
814
+ }
815
+ }, {
816
+ key: "normalizeDebugEvent",
817
+ value: function normalizeDebugEvent(event) {
818
+ var status = this.getDebugStatus(event);
819
+ return _objectSpread(_objectSpread(_objectSpread({}, event), this.getTileKey(event) ? {
820
+ tileKey: this.getTileKey(event)
821
+ } : {}), status ? {
822
+ status: status,
823
+ loaded: true,
824
+ clipped: status === 'clipped',
825
+ filtered: status === 'filtered'
826
+ } : {});
827
+ }
828
+ }, {
829
+ key: "logBuiltInDebug",
830
+ value: function logBuiltInDebug(event) {
831
+ if (event.type === 'range') {
832
+ console.log('[CustomRasterLayer] 渲染范围/裁剪范围', {
833
+ renderBounds: event.renderBounds,
834
+ clipBounds: event.clipBounds,
835
+ clipFeature: event.clipFeature,
836
+ tileBounds: event.tileBounds,
837
+ bounds: event.bounds,
838
+ dataCrs: event.dataCrs,
839
+ clipFeatureCrs: event.clipFeatureCrs,
840
+ renderCrs: event.renderCrs
841
+ });
842
+ return;
843
+ }
844
+ if (!event.status) {
845
+ return;
846
+ }
847
+ if (event.type === 'tile-loaded' && this._clipFeatures.length) {
848
+ return;
849
+ }
850
+ var style = DEBUG_STATUS_STYLES[event.status];
851
+ var title = "[CustomRasterLayer] ".concat(style.label);
852
+ var consoleStyle = "color: ".concat(style.consoleColor, "; font-weight: bold;");
853
+ var tileInfo = "z=".concat(event.level, " x=").concat(event.x, " y=").concat(event.y);
854
+ if (event.type === 'tile-error') {
855
+ console.error("%c".concat(title, " ").concat(tileInfo), consoleStyle, event.error, event);
856
+ return;
857
+ }
858
+ console.log("%c".concat(title, " ").concat(tileInfo), consoleStyle, {
859
+ tileKey: event.tileKey,
860
+ z: event.level,
861
+ x: event.x,
862
+ y: event.y,
863
+ loaded: event.loaded,
864
+ clipped: event.clipped,
865
+ filtered: event.filtered,
866
+ status: event.status,
867
+ reason: event.reason,
868
+ bbox: event.bbox,
869
+ imageSize: event.imageSize
870
+ });
871
+ }
759
872
 
760
873
  /** 输出结构化 debug 事件。 */
761
874
  }, {
@@ -764,14 +877,14 @@ var CustomRasterLayer = /*#__PURE__*/function (_ImageryLayer) {
764
877
  if (!this._debug) {
765
878
  return;
766
879
  }
767
- var debugEvent = _objectSpread({
880
+ var debugEvent = this.normalizeDebugEvent(_objectSpread({
768
881
  layerId: this.id
769
- }, event);
882
+ }, event));
770
883
  if (typeof this._debug === 'function') {
771
884
  this._debug(debugEvent);
772
885
  return;
773
886
  }
774
- console.debug('[CustomRasterLayer]', debugEvent);
887
+ this.logBuiltInDebug(debugEvent);
775
888
  }
776
889
  }]);
777
890
  return CustomRasterLayer;