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