@antv/l7-layers 2.9.23 → 2.9.25
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/es/Geometry/models/plane.d.ts +1 -0
- package/es/citybuliding/building.js +1 -1
- package/es/core/BaseLayer.js +10 -3
- package/es/core/interface.d.ts +26 -48
- package/es/core/interface.js +3 -0
- package/es/core/schema.d.ts +3 -3
- package/es/core/triangulation.d.ts +4 -3
- package/es/core/triangulation.js +54 -39
- package/es/heatmap/models/heatmap.js +1 -1
- package/es/image/models/image.js +7 -1
- package/es/line/index.js +4 -1
- package/es/line/models/arc.js +1 -1
- package/es/line/models/simpleLine.js +1 -1
- package/es/line/shaders/line_arc_vert.glsl +5 -3
- package/es/line/shaders/simple/simpleline_vert.glsl +1 -0
- package/es/plugins/FeatureScalePlugin.js +0 -1
- package/es/point/index.js +3 -1
- package/es/point/models/fill.js +5 -2
- package/es/point/models/fillmage.js +9 -3
- package/es/point/models/image.js +8 -2
- package/es/point/models/radar.js +2 -3
- package/es/point/models/tile.js +1 -1
- package/es/point/shaders/fill_vert.glsl +13 -6
- package/es/point/shaders/image/fillImage_vert.glsl +13 -5
- package/es/point/shaders/image_vert.glsl +17 -8
- package/es/polygon/index.js +4 -1
- package/es/raster/index.js +3 -1
- package/es/tile/manager/tileLayerManager.d.ts +3 -2
- package/es/tile/manager/tileLayerManager.js +5 -2
- package/es/tile/models/tileModel.js +4 -3
- package/es/tile/tileFactory/base.d.ts +1 -1
- package/es/tile/tileFactory/base.js +32 -5
- package/es/tile/tileFactory/vectorLayer.d.ts +3 -1
- package/es/tile/tileFactory/vectorLayer.js +22 -1
- package/es/tile/tileLayer/baseTileLayer.d.ts +1 -1
- package/es/tile/tileLayer/baseTileLayer.js +3 -2
- package/es/tile/utils.d.ts +2 -0
- package/es/tile/utils.js +5 -1
- package/lib/Geometry/index.js +114 -77
- package/lib/Geometry/models/billboard.js +232 -181
- package/lib/Geometry/models/index.js +18 -34
- package/lib/Geometry/models/plane.js +407 -278
- package/lib/Geometry/models/sprite.js +291 -189
- package/lib/canvas/index.js +101 -66
- package/lib/canvas/models/canvas.js +207 -140
- package/lib/canvas/models/index.js +12 -30
- package/lib/citybuliding/building.js +98 -63
- package/lib/citybuliding/models/build.js +192 -146
- package/lib/core/BaseLayer.js +1331 -809
- package/lib/core/BaseModel.js +457 -279
- package/lib/core/interface.js +40 -53
- package/lib/core/schema.js +21 -39
- package/lib/core/shape/Path.js +67 -79
- package/lib/core/shape/extrude.js +132 -91
- package/lib/core/triangulation.js +412 -213
- package/lib/earth/index.js +100 -62
- package/lib/earth/models/atmosphere.js +146 -112
- package/lib/earth/models/base.js +210 -150
- package/lib/earth/models/bloomsphere.js +146 -112
- package/lib/earth/utils.js +111 -91
- package/lib/heatmap/index.js +149 -92
- package/lib/heatmap/models/grid.js +118 -91
- package/lib/heatmap/models/grid3d.js +155 -123
- package/lib/heatmap/models/heatmap.js +475 -338
- package/lib/heatmap/models/hexagon.js +121 -92
- package/lib/heatmap/models/index.js +22 -37
- package/lib/heatmap/triangulation.js +31 -47
- package/lib/image/index.js +111 -74
- package/lib/image/models/dataImage.js +232 -174
- package/lib/image/models/image.js +175 -123
- package/lib/image/models/index.js +15 -32
- package/lib/index.js +263 -97
- package/lib/line/index.js +131 -83
- package/lib/line/models/arc.js +352 -237
- package/lib/line/models/arc_3d.js +334 -228
- package/lib/line/models/earthArc_3d.js +336 -228
- package/lib/line/models/great_circle.js +291 -200
- package/lib/line/models/half.js +286 -201
- package/lib/line/models/index.js +42 -50
- package/lib/line/models/line.js +428 -299
- package/lib/line/models/linearline.js +277 -203
- package/lib/line/models/simpleLine.js +239 -175
- package/lib/line/models/tile.js +348 -237
- package/lib/line/models/wall.js +327 -235
- package/lib/line/shaders/line_arc_vert.glsl +5 -3
- package/lib/line/shaders/simple/simpleline_vert.glsl +1 -0
- package/lib/mask/index.js +92 -59
- package/lib/mask/models/fill.js +134 -82
- package/lib/mask/models/index.js +12 -30
- package/lib/plugins/DataMappingPlugin.js +342 -224
- package/lib/plugins/DataSourcePlugin.js +102 -87
- package/lib/plugins/FeatureScalePlugin.js +330 -241
- package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
- package/lib/plugins/LayerModelPlugin.js +80 -73
- package/lib/plugins/LayerStylePlugin.js +48 -51
- package/lib/plugins/LightingPlugin.js +80 -68
- package/lib/plugins/MultiPassRendererPlugin.js +91 -65
- package/lib/plugins/PixelPickingPlugin.js +150 -109
- package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
- package/lib/plugins/ShaderUniformPlugin.js +118 -99
- package/lib/plugins/UpdateModelPlugin.js +40 -47
- package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
- package/lib/point/index.js +226 -148
- package/lib/point/models/earthExtrude.js +279 -201
- package/lib/point/models/earthFill.js +287 -202
- package/lib/point/models/extrude.js +299 -203
- package/lib/point/models/fill.js +406 -273
- package/lib/point/models/fillmage.js +365 -252
- package/lib/point/models/image.js +241 -164
- package/lib/point/models/index.js +46 -52
- package/lib/point/models/normal.js +183 -134
- package/lib/point/models/radar.js +304 -212
- package/lib/point/models/simplePoint.js +194 -142
- package/lib/point/models/text.js +608 -385
- package/lib/point/models/tile.js +314 -223
- package/lib/point/shaders/fill_vert.glsl +13 -6
- package/lib/point/shaders/image/fillImage_vert.glsl +13 -5
- package/lib/point/shaders/image_vert.glsl +17 -8
- package/lib/point/shape/extrude.js +56 -52
- package/lib/polygon/index.js +154 -100
- package/lib/polygon/models/extrude.js +311 -223
- package/lib/polygon/models/fill.js +215 -153
- package/lib/polygon/models/index.js +46 -52
- package/lib/polygon/models/ocean.js +244 -173
- package/lib/polygon/models/tile.js +144 -100
- package/lib/polygon/models/water.js +222 -153
- package/lib/raster/buffers/triangulation.js +27 -40
- package/lib/raster/index.js +115 -74
- package/lib/raster/models/index.js +16 -33
- package/lib/raster/models/raster.js +178 -135
- package/lib/raster/raster.js +187 -132
- package/lib/tile/interface.js +4 -16
- package/lib/tile/manager/tileConfigManager.js +125 -86
- package/lib/tile/manager/tileLayerManager.js +314 -227
- package/lib/tile/manager/tilePickerManager.js +192 -123
- package/lib/tile/models/tileModel.js +71 -51
- package/lib/tile/tileFactory/base.js +433 -292
- package/lib/tile/tileFactory/index.js +51 -49
- package/lib/tile/tileFactory/line.js +65 -50
- package/lib/tile/tileFactory/point.js +65 -50
- package/lib/tile/tileFactory/polygon.js +65 -50
- package/lib/tile/tileFactory/raster.js +66 -54
- package/lib/tile/tileFactory/rasterData.js +88 -76
- package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
- package/lib/tile/tileFactory/vectorLayer.js +169 -95
- package/lib/tile/tileLayer/baseTileLayer.js +420 -220
- package/lib/tile/tmsTileLayer.js +110 -67
- package/lib/tile/utils.js +113 -87
- package/lib/utils/blend.js +59 -79
- package/lib/utils/collision-index.js +107 -64
- package/lib/utils/dataMappingStyle.js +105 -60
- package/lib/utils/extrude_polyline.js +600 -398
- package/lib/utils/grid-index.js +163 -111
- package/lib/utils/layerData.js +130 -99
- package/lib/utils/multiPassRender.js +49 -41
- package/lib/utils/polylineNormal.js +148 -96
- package/lib/utils/simpleLine.js +100 -85
- package/lib/utils/symbol-layout.js +219 -116
- package/lib/utils/updateShape.js +15 -41
- package/lib/wind/index.js +109 -71
- package/lib/wind/models/index.js +12 -30
- package/lib/wind/models/utils.js +144 -105
- package/lib/wind/models/wind.js +333 -224
- package/lib/wind/models/windRender.js +329 -218
- package/lib/wind/models/windShader.js +23 -181
- package/package.json +7 -6
|
@@ -1,75 +1,118 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
-
|
|
22
|
-
// src/utils/collision-index.ts
|
|
23
|
-
var collision_index_exports = {};
|
|
24
|
-
__export(collision_index_exports, {
|
|
25
|
-
default: () => CollisionIndex
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
26
7
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
+
|
|
18
|
+
var _glMatrix = require("gl-matrix");
|
|
19
|
+
|
|
20
|
+
var _gridIndex = _interopRequireDefault(require("./grid-index"));
|
|
21
|
+
|
|
22
|
+
// @mapbox/grid-index 并没有类似 hitTest 的单纯获取碰撞检测结果的方法,query 将导致计算大量多余的包围盒结果,因此使用改良版
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 基于网格实现文本避让,大幅提升包围盒碰撞检测效率
|
|
26
|
+
* @see https://zhuanlan.zhihu.com/p/74373214
|
|
27
|
+
*/
|
|
28
|
+
var CollisionIndex = /*#__PURE__*/function () {
|
|
29
|
+
function CollisionIndex(width, height) {
|
|
30
|
+
(0, _classCallCheck2.default)(this, CollisionIndex);
|
|
31
|
+
(0, _defineProperty2.default)(this, "viewportPadding", 100);
|
|
33
32
|
this.width = width;
|
|
34
33
|
this.height = height;
|
|
35
|
-
this.viewportPadding = Math.max(width, height);
|
|
36
|
-
|
|
34
|
+
this.viewportPadding = Math.max(width, height); // 创建网格索引
|
|
35
|
+
|
|
36
|
+
this.grid = new _gridIndex.default(width + this.viewportPadding, height + this.viewportPadding, 25);
|
|
37
37
|
this.screenRightBoundary = width + this.viewportPadding;
|
|
38
38
|
this.screenBottomBoundary = height + this.viewportPadding;
|
|
39
39
|
this.gridRightBoundary = width + 2 * this.viewportPadding;
|
|
40
40
|
this.gridBottomBoundary = height + 2 * this.viewportPadding;
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
|
|
43
|
+
(0, _createClass2.default)(CollisionIndex, [{
|
|
44
|
+
key: "placeCollisionBox",
|
|
45
|
+
value: function placeCollisionBox(collisionBox) {
|
|
46
|
+
// const projectedPoint = this.project(
|
|
47
|
+
// mvpMatrix,
|
|
48
|
+
// collisionBox.anchorPointX,
|
|
49
|
+
// collisionBox.anchorPointY,
|
|
50
|
+
// );
|
|
51
|
+
var tlX = collisionBox.x1 + collisionBox.anchorPointX + this.viewportPadding;
|
|
52
|
+
var tlY = collisionBox.y1 + collisionBox.anchorPointY + this.viewportPadding;
|
|
53
|
+
var brX = collisionBox.x2 + collisionBox.anchorPointX + this.viewportPadding;
|
|
54
|
+
var brY = collisionBox.y2 + collisionBox.anchorPointY + this.viewportPadding;
|
|
55
|
+
|
|
56
|
+
if (!this.isInsideGrid(tlX, tlY, brX, brY) || this.grid.hitTest(tlX, tlY, brX, brY)) {
|
|
57
|
+
return {
|
|
58
|
+
box: []
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
48
62
|
return {
|
|
49
|
-
box: []
|
|
63
|
+
box: [tlX, tlY, brX, brY]
|
|
50
64
|
};
|
|
51
65
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
}, {
|
|
67
|
+
key: "insertCollisionBox",
|
|
68
|
+
value: function insertCollisionBox(box, featureIndex) {
|
|
69
|
+
var key = {
|
|
70
|
+
featureIndex: featureIndex
|
|
71
|
+
};
|
|
72
|
+
this.grid.insert(key, box[0], box[1], box[2], box[3]);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 后续碰撞检测都需要投影到 viewport 坐标系
|
|
76
|
+
* @param {THREE.Matrix4} mvpMatrix mvp矩阵
|
|
77
|
+
* @param {number} x P20 平面坐标X
|
|
78
|
+
* @param {number} y P20 平面坐标Y
|
|
79
|
+
* @return {Point} projectedPoint
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
}, {
|
|
83
|
+
key: "project",
|
|
84
|
+
value: function project(mvpMatrix, x, y) {
|
|
85
|
+
var point = _glMatrix.vec4.fromValues(x, y, 0, 1);
|
|
86
|
+
|
|
87
|
+
var out = _glMatrix.vec4.create(); // @ts-ignore
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
var mat = _glMatrix.mat4.fromValues.apply(_glMatrix.mat4, (0, _toConsumableArray2.default)(mvpMatrix));
|
|
91
|
+
|
|
92
|
+
_glMatrix.vec4.transformMat4(out, point, mat); // GL 坐标系[-1, 1] -> viewport 坐标系[width, height]
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
x: (out[0] / out[3] + 1) / 2 * this.width + this.viewportPadding,
|
|
97
|
+
y: (-out[1] / out[3] + 1) / 2 * this.height + this.viewportPadding
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* 判断包围盒是否在整个网格内,需要加上 buffer
|
|
102
|
+
* @param {number} x1 x1
|
|
103
|
+
* @param {number} y1 y1
|
|
104
|
+
* @param {number} x2 x2
|
|
105
|
+
* @param {number} y2 y2
|
|
106
|
+
* @return {Point} isInside
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
}, {
|
|
110
|
+
key: "isInsideGrid",
|
|
111
|
+
value: function isInsideGrid(x1, y1, x2, y2) {
|
|
112
|
+
return x2 >= 0 && x1 < this.gridRightBoundary && y2 >= 0 && y1 < this.gridBottomBoundary;
|
|
113
|
+
}
|
|
114
|
+
}]);
|
|
115
|
+
return CollisionIndex;
|
|
116
|
+
}();
|
|
117
|
+
|
|
118
|
+
exports.default = CollisionIndex;
|
|
@@ -1,106 +1,151 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/utils/dataMappingStyle.ts
|
|
20
|
-
var dataMappingStyle_exports = {};
|
|
21
|
-
__export(dataMappingStyle_exports, {
|
|
22
|
-
handleStyleColor: () => handleStyleColor,
|
|
23
|
-
handleStyleDataMapping: () => handleStyleDataMapping,
|
|
24
|
-
handleStyleFloat: () => handleStyleFloat
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
25
5
|
});
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
exports.handleStyleColor = handleStyleColor;
|
|
7
|
+
exports.handleStyleDataMapping = handleStyleDataMapping;
|
|
8
|
+
exports.handleStyleFloat = handleStyleFloat;
|
|
9
|
+
|
|
10
|
+
var _lodash = require("lodash");
|
|
11
|
+
|
|
12
|
+
// 画布默认的宽度
|
|
13
|
+
var WIDTH = 1024;
|
|
14
|
+
/**
|
|
15
|
+
* 当 style 中使用的 opacity 不是常数的时候根据数据进行映射
|
|
16
|
+
* @param field
|
|
17
|
+
* @param values
|
|
18
|
+
* @param updateOptions
|
|
19
|
+
*/
|
|
20
|
+
|
|
28
21
|
function registerStyleAttribute(fieldName, layer, field, values, updateOptions) {
|
|
29
22
|
layer.updateStyleAttribute(fieldName, field, values, updateOptions);
|
|
30
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* 当样式发生变化时判断是否需要进行数据映射
|
|
26
|
+
* @param configToUpdate
|
|
27
|
+
* @param layer
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
|
|
31
31
|
function handleStyleDataMapping(configToUpdate, layer) {
|
|
32
32
|
if (configToUpdate.opacity) {
|
|
33
|
-
|
|
33
|
+
// 处理 style 中 opacity 属性的数据映射
|
|
34
|
+
handleStyleFloat('opacity', layer, configToUpdate.opacity);
|
|
34
35
|
}
|
|
36
|
+
|
|
35
37
|
if (configToUpdate.strokeWidth) {
|
|
36
|
-
|
|
38
|
+
// 处理 style 中 strokeWidth 属性的数据映射
|
|
39
|
+
handleStyleFloat('strokeWidth', layer, configToUpdate.strokeWidth);
|
|
37
40
|
}
|
|
41
|
+
|
|
38
42
|
if (configToUpdate.strokeOpacity) {
|
|
39
|
-
|
|
43
|
+
// 处理 style 中 strokeOpacity 属性的数据映射
|
|
44
|
+
handleStyleFloat('strokeOpacity', layer, configToUpdate.strokeOpacity);
|
|
40
45
|
}
|
|
46
|
+
|
|
41
47
|
if (configToUpdate.stroke) {
|
|
42
|
-
|
|
48
|
+
// 处理 style 中 stroke (strokeColor) 属性的数据映射
|
|
49
|
+
handleStyleColor('stroke', layer, configToUpdate.stroke);
|
|
43
50
|
}
|
|
51
|
+
|
|
44
52
|
if (configToUpdate.offsets) {
|
|
45
|
-
|
|
53
|
+
// 处理 style 中 offsets 属性的数据映射
|
|
54
|
+
handleStyleOffsets('offsets', layer, configToUpdate.offsets);
|
|
46
55
|
}
|
|
56
|
+
|
|
47
57
|
if (configToUpdate.textOffset) {
|
|
48
|
-
|
|
58
|
+
// 处理 style 中 textOffset 属性的数据映射
|
|
59
|
+
handleStyleOffsets('textOffset', layer, configToUpdate.textOffset);
|
|
49
60
|
}
|
|
61
|
+
|
|
50
62
|
if (configToUpdate.thetaOffset) {
|
|
51
|
-
|
|
63
|
+
// 处理 style 中 thetaOffset 属性的数据映射
|
|
64
|
+
handleStyleFloat('thetaOffset', layer, configToUpdate.thetaOffset);
|
|
52
65
|
}
|
|
53
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* 根据传入参数 float 的类型和值做相应的操作
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
|
|
54
72
|
function handleStyleFloat(fieldName, layer, styleFloat) {
|
|
55
|
-
if ((0,
|
|
56
|
-
|
|
73
|
+
if ((0, _lodash.isString)(styleFloat)) {
|
|
74
|
+
// 如果传入的 styleFloat 是 string 类型,那么就认为其对应的是传入数据的字段
|
|
75
|
+
registerStyleAttribute(fieldName, layer, styleFloat, function (value) {
|
|
57
76
|
return value;
|
|
58
77
|
});
|
|
59
|
-
} else if ((0,
|
|
60
|
-
|
|
78
|
+
} else if ((0, _lodash.isNumber)(styleFloat)) {
|
|
79
|
+
// 传入 number、默认值处理
|
|
80
|
+
registerStyleAttribute(fieldName, layer, [styleFloat], undefined);
|
|
61
81
|
} else if (Array.isArray(styleFloat) && styleFloat.length === 2) {
|
|
62
|
-
|
|
82
|
+
// 传入的 styleFloat 是长度为 2 的数组
|
|
83
|
+
if ((0, _lodash.isString)(styleFloat[0]) && (0, _lodash.isFunction)(styleFloat[1])) {
|
|
84
|
+
// 字段回调函数 [string, callback]
|
|
63
85
|
registerStyleAttribute(fieldName, layer, styleFloat[0], styleFloat[1]);
|
|
64
|
-
} else if ((0,
|
|
86
|
+
} else if ((0, _lodash.isString)(styleFloat[0]) && Array.isArray(styleFloat[1]) && (0, _lodash.isNumber)(styleFloat[1][0]) && (0, _lodash.isNumber)(styleFloat[1][1])) {
|
|
87
|
+
// 字段映射 [string, [start: number, end: number]]
|
|
65
88
|
registerStyleAttribute(fieldName, layer, styleFloat[0], styleFloat[1]);
|
|
66
89
|
} else {
|
|
67
|
-
|
|
90
|
+
// 兼容
|
|
91
|
+
registerStyleAttribute(fieldName, layer, [1.0], undefined);
|
|
68
92
|
}
|
|
69
93
|
} else {
|
|
70
|
-
|
|
94
|
+
// 兼容
|
|
95
|
+
registerStyleAttribute(fieldName, layer, [1.0], undefined);
|
|
71
96
|
}
|
|
72
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* 根据传入参数 offsets 的类型和值做相应的操作
|
|
100
|
+
* @param fieldName
|
|
101
|
+
* @param layer
|
|
102
|
+
* @param styleOffsets
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
|
|
73
106
|
function handleStyleOffsets(fieldName, layer, styleOffsets) {
|
|
74
|
-
if ((0,
|
|
75
|
-
|
|
107
|
+
if ((0, _lodash.isString)(styleOffsets)) {
|
|
108
|
+
// 如果传入的 styleOffsets 是 string 类型,那么就认为其对应的是传入数据的字段
|
|
109
|
+
registerStyleAttribute(fieldName, layer, styleOffsets, function (value) {
|
|
76
110
|
return value;
|
|
77
111
|
});
|
|
78
|
-
} else if (Array.isArray(styleOffsets) && styleOffsets.length === 2 && (0,
|
|
112
|
+
} else if (Array.isArray(styleOffsets) && styleOffsets.length === 2 && (0, _lodash.isString)(styleOffsets[0]) && (0, _lodash.isFunction)(styleOffsets[1])) {
|
|
113
|
+
// 字段回调函数 [string, callback]
|
|
79
114
|
registerStyleAttribute(fieldName, layer, styleOffsets[0], styleOffsets[1]);
|
|
80
|
-
} else if (Array.isArray(styleOffsets) && styleOffsets.length === 2 && (0,
|
|
81
|
-
|
|
115
|
+
} else if (Array.isArray(styleOffsets) && styleOffsets.length === 2 && (0, _lodash.isNumber)(styleOffsets[0]) && (0, _lodash.isNumber)(styleOffsets[1])) {
|
|
116
|
+
// 字段映射 [string, [start: number, end: number]]
|
|
117
|
+
registerStyleAttribute(fieldName, layer, styleOffsets, undefined);
|
|
82
118
|
} else {
|
|
83
|
-
|
|
119
|
+
// 兼容
|
|
120
|
+
registerStyleAttribute(fieldName, layer, [0, 0], undefined);
|
|
84
121
|
}
|
|
85
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* 根据传入参数 stroke / color 的类型和值做相应的操作
|
|
125
|
+
* @param fieldName
|
|
126
|
+
* @param layer
|
|
127
|
+
* @param styleColor
|
|
128
|
+
*/
|
|
129
|
+
|
|
130
|
+
|
|
86
131
|
function handleStyleColor(fieldName, layer, styleColor) {
|
|
87
|
-
if ((0,
|
|
88
|
-
|
|
132
|
+
if ((0, _lodash.isString)(styleColor)) {
|
|
133
|
+
// 如果传入的 styleColor 是 string 类型,那么就认为其是颜色值
|
|
134
|
+
registerStyleAttribute(fieldName, layer, styleColor, undefined);
|
|
89
135
|
} else if (Array.isArray(styleColor) && styleColor.length === 2) {
|
|
90
|
-
|
|
136
|
+
// 传入的 styleColor 是长度为 2 的数组
|
|
137
|
+
if ((0, _lodash.isString)(styleColor[0]) && (0, _lodash.isFunction)(styleColor[1])) {
|
|
138
|
+
// 字段回调函数 [string, callback]
|
|
91
139
|
registerStyleAttribute(fieldName, layer, styleColor[0], styleColor[1]);
|
|
92
|
-
} else if ((0,
|
|
140
|
+
} else if ((0, _lodash.isString)(styleColor[0]) && Array.isArray(styleColor[1]) && styleColor[1].length > 0) {
|
|
141
|
+
// 字段映射 [string, [start: string, end: string]]
|
|
93
142
|
registerStyleAttribute(fieldName, layer, styleColor[0], styleColor[1]);
|
|
94
143
|
} else {
|
|
95
|
-
|
|
144
|
+
// 兼容
|
|
145
|
+
registerStyleAttribute(fieldName, layer, '#fff', undefined);
|
|
96
146
|
}
|
|
97
147
|
} else {
|
|
98
|
-
|
|
148
|
+
// 兼容
|
|
149
|
+
registerStyleAttribute(fieldName, layer, '#fff', undefined);
|
|
99
150
|
}
|
|
100
|
-
}
|
|
101
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
-
0 && (module.exports = {
|
|
103
|
-
handleStyleColor,
|
|
104
|
-
handleStyleDataMapping,
|
|
105
|
-
handleStyleFloat
|
|
106
|
-
});
|
|
151
|
+
}
|