deeptwins-engine-3d 0.1.70 → 0.1.72

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/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.70");
76
+ console.log('DeepTwinsEngine3D Version:', "0.1.72");
77
77
  export var DeepTwinsEngine3D = /*#__PURE__*/_createClass(function DeepTwinsEngine3D() {
78
78
  _classCallCheck(this, DeepTwinsEngine3D);
79
79
  });
80
- _defineProperty(DeepTwinsEngine3D, "Version", "0.1.70");
80
+ _defineProperty(DeepTwinsEngine3D, "Version", "0.1.72");
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 与裁剪面的交集,避免多面重叠时误裁。
@@ -45,12 +45,13 @@ import ImageryLayer from './ImageryLayer';
45
45
  * @remarks API 文档
46
46
  * - `source`:必填,Cesium.UrlTemplateImageryProvider 原生配置。
47
47
  * - `layerOptions`:可选,Cesium.ImageryLayer 原生配置。
48
- * - `bounds`:可选,数据范围 `[minX, minY, maxX, maxY]`,未传时默认使用 turf 计算 clipFeature bbox。
49
- * - `dataCrs`:可选,bounds 与 clipFeature 的原始坐标系,默认 `EPSG:4326`。
50
- * - `renderCrs`:可选,bounds、clipFeature 和瓦片范围使用的坐标系,默认 `EPSG:4326`,支持 `GCJ02/gcj02/gcj-02`。
48
+ * - `bounds`:可选,瓦片范围 `[minX, minY, maxX, maxY]`。
49
+ * - `dataCrs`:可选,bounds 的原始坐标系,默认 `EPSG:4326`。
50
+ * - `clipFeatureCrs`:可选,clipFeature 的原始坐标系,默认跟随 dataCrs。
51
+ * - `renderCrs`:可选,bounds、clipFeature 和瓦片范围转换后的目标坐标系,默认 `EPSG:4326`。
51
52
  * - `projectionDefs`:可选,自定义 proj4 坐标系定义。
52
53
  * - `clipFeature`:可选,GeoJSON Polygon/MultiPolygon/Feature/FeatureCollection。
53
- * - `autoFitBounds`:可选,创建后自动将相机定位到最终渲染范围,需同时传入 `map`。
54
+ * - `autoFitBounds`:可选,创建后自动将相机定位到最终范围,需同时传入 `map`。
54
55
  * - `debug`:可选,`true` 使用 console.debug,函数则接收结构化调试事件。
55
56
  */
56
57
  /** 通用范围格式:[minX, minY, maxX, maxY]。 */
@@ -71,13 +72,19 @@ export type CustomRasterLayerDebugEvent = {
71
72
  level?: number;
72
73
  /** 当前瓦片范围,格式为 [west, south, east, north]。 */
73
74
  bbox?: CustomRasterBounds;
74
- /** 用户传入的原始数据范围。 */
75
+ /** 用户传入的原始瓦片范围。 */
75
76
  bounds?: CustomRasterBounds;
76
- /** 转换到 renderCrs 后的数据范围。 */
77
+ /** bounds 转换到 renderCrs 后的瓦片范围。 */
78
+ tileBounds?: CustomRasterBounds;
79
+ /** clipFeature 转换到 renderCrs 后通过 turf.bbox 生成的裁剪范围。 */
80
+ clipBounds?: CustomRasterBounds;
81
+ /** 最终用于瓦片调度的渲染范围。 */
77
82
  renderBounds?: CustomRasterBounds;
78
- /** 原始数据坐标系。 */
83
+ /** bounds 原始坐标系。 */
79
84
  dataCrs?: string;
80
- /** bounds、clipFeature 和瓦片范围使用的坐标系。 */
85
+ /** clipFeature 原始坐标系。 */
86
+ clipFeatureCrs?: string;
87
+ /** bounds、clipFeature 和瓦片范围转换后的目标坐标系。 */
81
88
  renderCrs?: string;
82
89
  /** 裁剪或丢弃原因。 */
83
90
  reason?: string;
@@ -108,11 +115,13 @@ export type CustomRasterLayerOptions = {
108
115
  source: CustomRasterSourceOptions;
109
116
  /** Cesium.ImageryLayer 原生配置。 */
110
117
  layerOptions?: Cesium.ImageryLayer.ConstructorOptions;
111
- /** 数据范围,格式为 [minX, minY, maxX, maxY];未传时默认使用 clipFeature bbox。 */
118
+ /** 瓦片范围,格式为 [minX, minY, maxX, maxY],坐标系跟随 dataCrs。 */
112
119
  bounds?: CustomRasterBounds;
113
- /** bounds 和 clipFeature 的原始坐标系,默认 EPSG:4326。 */
120
+ /** bounds 的原始坐标系,默认 EPSG:4326。 */
114
121
  dataCrs?: string;
115
- /** bounds、clipFeature 和瓦片范围使用的坐标系,默认 EPSG:4326。 */
122
+ /** clipFeature 的原始坐标系,默认跟随 dataCrs。 */
123
+ clipFeatureCrs?: string;
124
+ /** bounds、clipFeature 和瓦片范围转换后的目标坐标系,默认 EPSG:4326。 */
116
125
  renderCrs?: string;
117
126
  /** 自定义 proj4 坐标系定义,key 可为 EPSG:xxxx 或其他 proj4 名称。 */
118
127
  projectionDefs?: Record<string, string>;
@@ -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 与裁剪面的交集,避免多面重叠时误裁。
@@ -76,12 +76,13 @@ import ImageryLayer from "./ImageryLayer";
76
76
  * @remarks API 文档
77
77
  * - `source`:必填,Cesium.UrlTemplateImageryProvider 原生配置。
78
78
  * - `layerOptions`:可选,Cesium.ImageryLayer 原生配置。
79
- * - `bounds`:可选,数据范围 `[minX, minY, maxX, maxY]`,未传时默认使用 turf 计算 clipFeature bbox。
80
- * - `dataCrs`:可选,bounds 与 clipFeature 的原始坐标系,默认 `EPSG:4326`。
81
- * - `renderCrs`:可选,bounds、clipFeature 和瓦片范围使用的坐标系,默认 `EPSG:4326`,支持 `GCJ02/gcj02/gcj-02`。
79
+ * - `bounds`:可选,瓦片范围 `[minX, minY, maxX, maxY]`。
80
+ * - `dataCrs`:可选,bounds 的原始坐标系,默认 `EPSG:4326`。
81
+ * - `clipFeatureCrs`:可选,clipFeature 的原始坐标系,默认跟随 dataCrs。
82
+ * - `renderCrs`:可选,bounds、clipFeature 和瓦片范围转换后的目标坐标系,默认 `EPSG:4326`。
82
83
  * - `projectionDefs`:可选,自定义 proj4 坐标系定义。
83
84
  * - `clipFeature`:可选,GeoJSON Polygon/MultiPolygon/Feature/FeatureCollection。
84
- * - `autoFitBounds`:可选,创建后自动将相机定位到最终渲染范围,需同时传入 `map`。
85
+ * - `autoFitBounds`:可选,创建后自动将相机定位到最终范围,需同时传入 `map`。
85
86
  * - `debug`:可选,`true` 使用 console.debug,函数则接收结构化调试事件。
86
87
  */
87
88
 
@@ -434,7 +435,7 @@ var collectPolygonFeatures = function collectPolygonFeatures(geoJson) {
434
435
  return [];
435
436
  };
436
437
 
437
- /** 使用 turf 计算裁剪面的 bbox,作为未显式传 bounds 时的默认调度范围。 */
438
+ /** 使用 turf 计算裁剪面的 bbox,作为裁剪范围。 */
438
439
  var getClipFeatureBounds = function getClipFeatureBounds(clipFeatures) {
439
440
  if (!clipFeatures.length) {
440
441
  return undefined;
@@ -465,6 +466,7 @@ var CustomRasterLayer = /*#__PURE__*/function (_ImageryLayer) {
465
466
  var _super = _createSuper(CustomRasterLayer);
466
467
  /** 创建通用栅格图层。 */
467
468
  function CustomRasterLayer(options) {
469
+ var _options$map;
468
470
  var _this;
469
471
  _classCallCheck(this, CustomRasterLayer);
470
472
  if (!(options !== null && options !== void 0 && options.source)) {
@@ -472,17 +474,18 @@ var CustomRasterLayer = /*#__PURE__*/function (_ImageryLayer) {
472
474
  }
473
475
  registerProjectionDefs(options.projectionDefs);
474
476
  var dataCrs = normalizeCrs(options.dataCrs || DEFAULT_CRS);
477
+ var clipFeatureCrs = normalizeCrs(options.clipFeatureCrs || dataCrs);
475
478
  var renderCrs = normalizeCrs(options.renderCrs || DEFAULT_CRS);
476
- var transformedClipFeature = transformGeoJson(options.clipFeature, dataCrs, renderCrs);
479
+ var transformedClipFeature = transformGeoJson(options.clipFeature, clipFeatureCrs, renderCrs);
477
480
  var clipFeatures = collectPolygonFeatures(transformedClipFeature);
478
481
  var _options$source = options.source,
479
482
  sourceTilingSchemeOption = _options$source.tilingScheme,
480
483
  sourceOptionsRest = _objectWithoutProperties(_options$source, _excluded);
481
- var renderBounds = options.bounds ? transformBounds(options.bounds, dataCrs, renderCrs) : undefined;
482
- if (!renderBounds && !sourceOptionsRest.rectangle) {
483
- renderBounds = getClipFeatureBounds(clipFeatures);
484
- }
485
- var fitBounds = renderBounds || (sourceOptionsRest.rectangle ? rectangleToBounds(sourceOptionsRest.rectangle) : undefined);
484
+ var tileBounds = options.bounds ? transformBounds(options.bounds, dataCrs, renderCrs) : undefined;
485
+ var clipBounds = getClipFeatureBounds(clipFeatures);
486
+ var renderBounds = clipBounds || tileBounds;
487
+ var sourceRectangleBounds = sourceOptionsRest.rectangle ? rectangleToBounds(sourceOptionsRest.rectangle) : undefined;
488
+ var fitBounds = clipBounds || tileBounds || sourceRectangleBounds;
486
489
  var tilingScheme = createRenderTilingScheme(createSourceTilingScheme(sourceTilingSchemeOption), renderCrs);
487
490
  var sourceOptions = _objectSpread(_objectSpread({}, sourceOptionsRest), {}, {
488
491
  tilingScheme: tilingScheme
@@ -507,15 +510,18 @@ var CustomRasterLayer = /*#__PURE__*/function (_ImageryLayer) {
507
510
  _this._debug = options.debug;
508
511
  _this._clipFeatures = clipFeatures;
509
512
  _this._fitBounds = fitBounds;
510
- _this._mapContext = options.map._mapContext;
513
+ _this._mapContext = (_options$map = options.map) === null || _options$map === void 0 ? void 0 : _options$map._mapContext;
511
514
  _this.logDebug({
512
515
  type: 'range',
513
516
  bounds: options.bounds,
517
+ tileBounds: tileBounds,
518
+ clipBounds: clipBounds,
514
519
  renderBounds: renderBounds,
515
520
  dataCrs: dataCrs,
521
+ clipFeatureCrs: clipFeatureCrs,
516
522
  renderCrs: renderCrs
517
523
  });
518
- if (options.autoFitBounds) {
524
+ if (options.autoFitBounds && normalizeBounds(fitBounds)) {
519
525
  _this.fitToBounds(options.map, options.fitBoundsOptions);
520
526
  }
521
527
  return _this;