deeptwins-engine-3d 0.1.71 → 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.71");
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.71");
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);
@@ -4,7 +4,7 @@ import ImageryLayer from './ImageryLayer';
4
4
  /**
5
5
  * CustomRasterLayer 是一个通用栅格瓦片图层:
6
6
  * - 使用 Cesium.UrlTemplateImageryProvider 加载任意 URL 模板瓦片。
7
- * - 使用 proj4 将瓦片范围和裁剪 GeoJSON dataCrs 转到 renderCrs。
7
+ * - 使用 proj4 将瓦片范围和裁剪 GeoJSON 从各自 CRS 转到 renderCrs。
8
8
  * - GCJ02 渲染时按 tileLayer/test 的瓦片坐标方案计算瓦片范围。
9
9
  * - 可选按 GeoJSON 面要素裁剪瓦片。
10
10
  * - 裁剪前先求瓦片 bbox 与裁剪面的交集,避免多面重叠时误裁。
@@ -46,17 +46,20 @@ import ImageryLayer from './ImageryLayer';
46
46
  * - `source`:必填,Cesium.UrlTemplateImageryProvider 原生配置。
47
47
  * - `layerOptions`:可选,Cesium.ImageryLayer 原生配置。
48
48
  * - `bounds`:可选,瓦片范围 `[minX, minY, maxX, maxY]`。
49
- * - `dataCrs`:可选,bounds 与 clipFeature 的原始坐标系,默认 `EPSG:4326`。
49
+ * - `dataCrs`:可选,bounds 的原始坐标系,默认 `EPSG:4326`。
50
+ * - `clipFeatureCrs`:可选,clipFeature 的原始坐标系,默认跟随 dataCrs。
50
51
  * - `renderCrs`:可选,bounds、clipFeature 和瓦片范围转换后的目标坐标系,默认 `EPSG:4326`。
51
52
  * - `projectionDefs`:可选,自定义 proj4 坐标系定义。
52
53
  * - `clipFeature`:可选,GeoJSON Polygon/MultiPolygon/Feature/FeatureCollection。
53
54
  * - `autoFitBounds`:可选,创建后自动将相机定位到最终范围,需同时传入 `map`。
54
- * - `debug`:可选,`true` 使用 console.debug,函数则接收结构化调试事件。
55
+ * - `debug`:可选,`true` 使用 console.log 输出调试信息,函数则接收结构化调试事件。
55
56
  */
56
57
  /** 通用范围格式:[minX, minY, maxX, maxY]。 */
57
58
  export type CustomRasterBounds = [number, number, number, number];
58
59
  /** 调试事件类型,覆盖范围初始化、瓦片加载和裁剪决策。 */
59
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';
60
63
  /** debug 回调收到的结构化事件。 */
61
64
  export type CustomRasterLayerDebugEvent = {
62
65
  /** 事件类型。 */
@@ -69,6 +72,16 @@ export type CustomRasterLayerDebugEvent = {
69
72
  y?: number;
70
73
  /** 瓦片层级。 */
71
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;
72
85
  /** 当前瓦片范围,格式为 [west, south, east, north]。 */
73
86
  bbox?: CustomRasterBounds;
74
87
  /** 用户传入的原始瓦片范围。 */
@@ -79,8 +92,12 @@ export type CustomRasterLayerDebugEvent = {
79
92
  clipBounds?: CustomRasterBounds;
80
93
  /** 最终用于瓦片调度的渲染范围。 */
81
94
  renderBounds?: CustomRasterBounds;
82
- /** 原始数据坐标系。 */
95
+ /** 转换到 renderCrs 后的裁剪 GeoJSON。 */
96
+ clipFeature?: any;
97
+ /** bounds 原始坐标系。 */
83
98
  dataCrs?: string;
99
+ /** clipFeature 原始坐标系。 */
100
+ clipFeatureCrs?: string;
84
101
  /** bounds、clipFeature 和瓦片范围转换后的目标坐标系。 */
85
102
  renderCrs?: string;
86
103
  /** 裁剪或丢弃原因。 */
@@ -93,7 +110,7 @@ export type CustomRasterLayerDebugEvent = {
93
110
  height: number;
94
111
  };
95
112
  };
96
- /** debug 配置:关闭、console.debug 输出,或自定义事件处理函数。 */
113
+ /** debug 配置:关闭、console.log 输出,或自定义事件处理函数。 */
97
114
  export type CustomRasterLayerDebug = boolean | ((event: CustomRasterLayerDebugEvent) => void);
98
115
  /** 内置切片方案名称,或 Cesium 原生 TilingScheme 实例。 */
99
116
  export type CustomRasterTilingSchemeOption = 'webMercator' | 'geographic' | Cesium.TilingScheme;
@@ -114,8 +131,10 @@ export type CustomRasterLayerOptions = {
114
131
  layerOptions?: Cesium.ImageryLayer.ConstructorOptions;
115
132
  /** 瓦片范围,格式为 [minX, minY, maxX, maxY],坐标系跟随 dataCrs。 */
116
133
  bounds?: CustomRasterBounds;
117
- /** bounds 和 clipFeature 的原始坐标系,默认 EPSG:4326。 */
134
+ /** bounds 的原始坐标系,默认 EPSG:4326。 */
118
135
  dataCrs?: string;
136
+ /** clipFeature 的原始坐标系,默认跟随 dataCrs。 */
137
+ clipFeatureCrs?: string;
119
138
  /** bounds、clipFeature 和瓦片范围转换后的目标坐标系,默认 EPSG:4326。 */
120
139
  renderCrs?: string;
121
140
  /** 自定义 proj4 坐标系定义,key 可为 EPSG:xxxx 或其他 proj4 名称。 */
@@ -182,6 +201,10 @@ export default class CustomRasterLayer extends ImageryLayer {
182
201
  private geometryToPathArray;
183
202
  /** 按 path 坐标裁剪当前瓦片画布。 */
184
203
  private clip;
204
+ private getTileKey;
205
+ private getDebugStatus;
206
+ private normalizeDebugEvent;
207
+ private logBuiltInDebug;
185
208
  /** 输出结构化 debug 事件。 */
186
209
  private logDebug;
187
210
  }
@@ -35,7 +35,7 @@ import ImageryLayer from "./ImageryLayer";
35
35
  /**
36
36
  * CustomRasterLayer 是一个通用栅格瓦片图层:
37
37
  * - 使用 Cesium.UrlTemplateImageryProvider 加载任意 URL 模板瓦片。
38
- * - 使用 proj4 将瓦片范围和裁剪 GeoJSON dataCrs 转到 renderCrs。
38
+ * - 使用 proj4 将瓦片范围和裁剪 GeoJSON 从各自 CRS 转到 renderCrs。
39
39
  * - GCJ02 渲染时按 tileLayer/test 的瓦片坐标方案计算瓦片范围。
40
40
  * - 可选按 GeoJSON 面要素裁剪瓦片。
41
41
  * - 裁剪前先求瓦片 bbox 与裁剪面的交集,避免多面重叠时误裁。
@@ -77,21 +77,24 @@ import ImageryLayer from "./ImageryLayer";
77
77
  * - `source`:必填,Cesium.UrlTemplateImageryProvider 原生配置。
78
78
  * - `layerOptions`:可选,Cesium.ImageryLayer 原生配置。
79
79
  * - `bounds`:可选,瓦片范围 `[minX, minY, maxX, maxY]`。
80
- * - `dataCrs`:可选,bounds 与 clipFeature 的原始坐标系,默认 `EPSG:4326`。
80
+ * - `dataCrs`:可选,bounds 的原始坐标系,默认 `EPSG:4326`。
81
+ * - `clipFeatureCrs`:可选,clipFeature 的原始坐标系,默认跟随 dataCrs。
81
82
  * - `renderCrs`:可选,bounds、clipFeature 和瓦片范围转换后的目标坐标系,默认 `EPSG:4326`。
82
83
  * - `projectionDefs`:可选,自定义 proj4 坐标系定义。
83
84
  * - `clipFeature`:可选,GeoJSON Polygon/MultiPolygon/Feature/FeatureCollection。
84
85
  * - `autoFitBounds`:可选,创建后自动将相机定位到最终范围,需同时传入 `map`。
85
- * - `debug`:可选,`true` 使用 console.debug,函数则接收结构化调试事件。
86
+ * - `debug`:可选,`true` 使用 console.log 输出调试信息,函数则接收结构化调试事件。
86
87
  */
87
88
 
88
89
  /** 通用范围格式:[minX, minY, maxX, maxY]。 */
89
90
 
90
91
  /** 调试事件类型,覆盖范围初始化、瓦片加载和裁剪决策。 */
91
92
 
93
+ /** 瓦片 debug 状态。 */
94
+
92
95
  /** debug 回调收到的结构化事件。 */
93
96
 
94
- /** debug 配置:关闭、console.debug 输出,或自定义事件处理函数。 */
97
+ /** debug 配置:关闭、console.log 输出,或自定义事件处理函数。 */
95
98
 
96
99
  /** 内置切片方案名称,或 Cesium 原生 TilingScheme 实例。 */
97
100
 
@@ -453,6 +456,28 @@ var getImageSize = function getImageSize(image) {
453
456
  height: image.height
454
457
  };
455
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
+ };
456
481
 
457
482
  /**
458
483
  * 通用自定义栅格图层。
@@ -473,8 +498,9 @@ var CustomRasterLayer = /*#__PURE__*/function (_ImageryLayer) {
473
498
  }
474
499
  registerProjectionDefs(options.projectionDefs);
475
500
  var dataCrs = normalizeCrs(options.dataCrs || DEFAULT_CRS);
501
+ var clipFeatureCrs = normalizeCrs(options.clipFeatureCrs || dataCrs);
476
502
  var renderCrs = normalizeCrs(options.renderCrs || DEFAULT_CRS);
477
- var transformedClipFeature = transformGeoJson(options.clipFeature, dataCrs, renderCrs);
503
+ var transformedClipFeature = transformGeoJson(options.clipFeature, clipFeatureCrs, renderCrs);
478
504
  var clipFeatures = collectPolygonFeatures(transformedClipFeature);
479
505
  var _options$source = options.source,
480
506
  sourceTilingSchemeOption = _options$source.tilingScheme,
@@ -515,7 +541,9 @@ var CustomRasterLayer = /*#__PURE__*/function (_ImageryLayer) {
515
541
  tileBounds: tileBounds,
516
542
  clipBounds: clipBounds,
517
543
  renderBounds: renderBounds,
544
+ clipFeature: transformedClipFeature,
518
545
  dataCrs: dataCrs,
546
+ clipFeatureCrs: clipFeatureCrs,
519
547
  renderCrs: renderCrs
520
548
  });
521
549
  if (options.autoFitBounds && normalizeBounds(fitBounds)) {
@@ -753,6 +781,94 @@ var CustomRasterLayer = /*#__PURE__*/function (_ImageryLayer) {
753
781
  context.fill();
754
782
  context.restore();
755
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
+ }
756
872
 
757
873
  /** 输出结构化 debug 事件。 */
758
874
  }, {
@@ -761,14 +877,14 @@ var CustomRasterLayer = /*#__PURE__*/function (_ImageryLayer) {
761
877
  if (!this._debug) {
762
878
  return;
763
879
  }
764
- var debugEvent = _objectSpread({
880
+ var debugEvent = this.normalizeDebugEvent(_objectSpread({
765
881
  layerId: this.id
766
- }, event);
882
+ }, event));
767
883
  if (typeof this._debug === 'function') {
768
884
  this._debug(debugEvent);
769
885
  return;
770
886
  }
771
- console.debug('[CustomRasterLayer]', debugEvent);
887
+ this.logBuiltInDebug(debugEvent);
772
888
  }
773
889
  }]);
774
890
  return CustomRasterLayer;