@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.
Files changed (166) hide show
  1. package/es/Geometry/models/plane.d.ts +1 -0
  2. package/es/citybuliding/building.js +1 -1
  3. package/es/core/BaseLayer.js +10 -3
  4. package/es/core/interface.d.ts +26 -48
  5. package/es/core/interface.js +3 -0
  6. package/es/core/schema.d.ts +3 -3
  7. package/es/core/triangulation.d.ts +4 -3
  8. package/es/core/triangulation.js +54 -39
  9. package/es/heatmap/models/heatmap.js +1 -1
  10. package/es/image/models/image.js +7 -1
  11. package/es/line/index.js +4 -1
  12. package/es/line/models/arc.js +1 -1
  13. package/es/line/models/simpleLine.js +1 -1
  14. package/es/line/shaders/line_arc_vert.glsl +5 -3
  15. package/es/line/shaders/simple/simpleline_vert.glsl +1 -0
  16. package/es/plugins/FeatureScalePlugin.js +0 -1
  17. package/es/point/index.js +3 -1
  18. package/es/point/models/fill.js +5 -2
  19. package/es/point/models/fillmage.js +9 -3
  20. package/es/point/models/image.js +8 -2
  21. package/es/point/models/radar.js +2 -3
  22. package/es/point/models/tile.js +1 -1
  23. package/es/point/shaders/fill_vert.glsl +13 -6
  24. package/es/point/shaders/image/fillImage_vert.glsl +13 -5
  25. package/es/point/shaders/image_vert.glsl +17 -8
  26. package/es/polygon/index.js +4 -1
  27. package/es/raster/index.js +3 -1
  28. package/es/tile/manager/tileLayerManager.d.ts +3 -2
  29. package/es/tile/manager/tileLayerManager.js +5 -2
  30. package/es/tile/models/tileModel.js +4 -3
  31. package/es/tile/tileFactory/base.d.ts +1 -1
  32. package/es/tile/tileFactory/base.js +32 -5
  33. package/es/tile/tileFactory/vectorLayer.d.ts +3 -1
  34. package/es/tile/tileFactory/vectorLayer.js +22 -1
  35. package/es/tile/tileLayer/baseTileLayer.d.ts +1 -1
  36. package/es/tile/tileLayer/baseTileLayer.js +3 -2
  37. package/es/tile/utils.d.ts +2 -0
  38. package/es/tile/utils.js +5 -1
  39. package/lib/Geometry/index.js +114 -77
  40. package/lib/Geometry/models/billboard.js +232 -181
  41. package/lib/Geometry/models/index.js +18 -34
  42. package/lib/Geometry/models/plane.js +407 -278
  43. package/lib/Geometry/models/sprite.js +291 -189
  44. package/lib/canvas/index.js +101 -66
  45. package/lib/canvas/models/canvas.js +207 -140
  46. package/lib/canvas/models/index.js +12 -30
  47. package/lib/citybuliding/building.js +98 -63
  48. package/lib/citybuliding/models/build.js +192 -146
  49. package/lib/core/BaseLayer.js +1331 -809
  50. package/lib/core/BaseModel.js +457 -279
  51. package/lib/core/interface.js +40 -53
  52. package/lib/core/schema.js +21 -39
  53. package/lib/core/shape/Path.js +67 -79
  54. package/lib/core/shape/extrude.js +132 -91
  55. package/lib/core/triangulation.js +412 -213
  56. package/lib/earth/index.js +100 -62
  57. package/lib/earth/models/atmosphere.js +146 -112
  58. package/lib/earth/models/base.js +210 -150
  59. package/lib/earth/models/bloomsphere.js +146 -112
  60. package/lib/earth/utils.js +111 -91
  61. package/lib/heatmap/index.js +149 -92
  62. package/lib/heatmap/models/grid.js +118 -91
  63. package/lib/heatmap/models/grid3d.js +155 -123
  64. package/lib/heatmap/models/heatmap.js +475 -338
  65. package/lib/heatmap/models/hexagon.js +121 -92
  66. package/lib/heatmap/models/index.js +22 -37
  67. package/lib/heatmap/triangulation.js +31 -47
  68. package/lib/image/index.js +111 -74
  69. package/lib/image/models/dataImage.js +232 -174
  70. package/lib/image/models/image.js +175 -123
  71. package/lib/image/models/index.js +15 -32
  72. package/lib/index.js +263 -97
  73. package/lib/line/index.js +131 -83
  74. package/lib/line/models/arc.js +352 -237
  75. package/lib/line/models/arc_3d.js +334 -228
  76. package/lib/line/models/earthArc_3d.js +336 -228
  77. package/lib/line/models/great_circle.js +291 -200
  78. package/lib/line/models/half.js +286 -201
  79. package/lib/line/models/index.js +42 -50
  80. package/lib/line/models/line.js +428 -299
  81. package/lib/line/models/linearline.js +277 -203
  82. package/lib/line/models/simpleLine.js +239 -175
  83. package/lib/line/models/tile.js +348 -237
  84. package/lib/line/models/wall.js +327 -235
  85. package/lib/line/shaders/line_arc_vert.glsl +5 -3
  86. package/lib/line/shaders/simple/simpleline_vert.glsl +1 -0
  87. package/lib/mask/index.js +92 -59
  88. package/lib/mask/models/fill.js +134 -82
  89. package/lib/mask/models/index.js +12 -30
  90. package/lib/plugins/DataMappingPlugin.js +342 -224
  91. package/lib/plugins/DataSourcePlugin.js +102 -87
  92. package/lib/plugins/FeatureScalePlugin.js +330 -241
  93. package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
  94. package/lib/plugins/LayerModelPlugin.js +80 -73
  95. package/lib/plugins/LayerStylePlugin.js +48 -51
  96. package/lib/plugins/LightingPlugin.js +80 -68
  97. package/lib/plugins/MultiPassRendererPlugin.js +91 -65
  98. package/lib/plugins/PixelPickingPlugin.js +150 -109
  99. package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
  100. package/lib/plugins/ShaderUniformPlugin.js +118 -99
  101. package/lib/plugins/UpdateModelPlugin.js +40 -47
  102. package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
  103. package/lib/point/index.js +226 -148
  104. package/lib/point/models/earthExtrude.js +279 -201
  105. package/lib/point/models/earthFill.js +287 -202
  106. package/lib/point/models/extrude.js +299 -203
  107. package/lib/point/models/fill.js +406 -273
  108. package/lib/point/models/fillmage.js +365 -252
  109. package/lib/point/models/image.js +241 -164
  110. package/lib/point/models/index.js +46 -52
  111. package/lib/point/models/normal.js +183 -134
  112. package/lib/point/models/radar.js +304 -212
  113. package/lib/point/models/simplePoint.js +194 -142
  114. package/lib/point/models/text.js +608 -385
  115. package/lib/point/models/tile.js +314 -223
  116. package/lib/point/shaders/fill_vert.glsl +13 -6
  117. package/lib/point/shaders/image/fillImage_vert.glsl +13 -5
  118. package/lib/point/shaders/image_vert.glsl +17 -8
  119. package/lib/point/shape/extrude.js +56 -52
  120. package/lib/polygon/index.js +154 -100
  121. package/lib/polygon/models/extrude.js +311 -223
  122. package/lib/polygon/models/fill.js +215 -153
  123. package/lib/polygon/models/index.js +46 -52
  124. package/lib/polygon/models/ocean.js +244 -173
  125. package/lib/polygon/models/tile.js +144 -100
  126. package/lib/polygon/models/water.js +222 -153
  127. package/lib/raster/buffers/triangulation.js +27 -40
  128. package/lib/raster/index.js +115 -74
  129. package/lib/raster/models/index.js +16 -33
  130. package/lib/raster/models/raster.js +178 -135
  131. package/lib/raster/raster.js +187 -132
  132. package/lib/tile/interface.js +4 -16
  133. package/lib/tile/manager/tileConfigManager.js +125 -86
  134. package/lib/tile/manager/tileLayerManager.js +314 -227
  135. package/lib/tile/manager/tilePickerManager.js +192 -123
  136. package/lib/tile/models/tileModel.js +71 -51
  137. package/lib/tile/tileFactory/base.js +433 -292
  138. package/lib/tile/tileFactory/index.js +51 -49
  139. package/lib/tile/tileFactory/line.js +65 -50
  140. package/lib/tile/tileFactory/point.js +65 -50
  141. package/lib/tile/tileFactory/polygon.js +65 -50
  142. package/lib/tile/tileFactory/raster.js +66 -54
  143. package/lib/tile/tileFactory/rasterData.js +88 -76
  144. package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
  145. package/lib/tile/tileFactory/vectorLayer.js +169 -95
  146. package/lib/tile/tileLayer/baseTileLayer.js +420 -220
  147. package/lib/tile/tmsTileLayer.js +110 -67
  148. package/lib/tile/utils.js +113 -87
  149. package/lib/utils/blend.js +59 -79
  150. package/lib/utils/collision-index.js +107 -64
  151. package/lib/utils/dataMappingStyle.js +105 -60
  152. package/lib/utils/extrude_polyline.js +600 -398
  153. package/lib/utils/grid-index.js +163 -111
  154. package/lib/utils/layerData.js +130 -99
  155. package/lib/utils/multiPassRender.js +49 -41
  156. package/lib/utils/polylineNormal.js +148 -96
  157. package/lib/utils/simpleLine.js +100 -85
  158. package/lib/utils/symbol-layout.js +219 -116
  159. package/lib/utils/updateShape.js +15 -41
  160. package/lib/wind/index.js +109 -71
  161. package/lib/wind/models/index.js +12 -30
  162. package/lib/wind/models/utils.js +144 -105
  163. package/lib/wind/models/wind.js +333 -224
  164. package/lib/wind/models/windRender.js +329 -218
  165. package/lib/wind/models/windShader.js +23 -181
  166. package/package.json +7 -6
@@ -1,75 +1,118 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
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
- module.exports = __toCommonJS(collision_index_exports);
28
- var import_gl_matrix = require("gl-matrix");
29
- var import_grid_index = __toESM(require("./grid-index"));
30
- var CollisionIndex = class {
31
- constructor(width, height) {
32
- this.viewportPadding = 100;
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
- this.grid = new import_grid_index.default(width + this.viewportPadding, height + this.viewportPadding, 25);
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
- placeCollisionBox(collisionBox) {
43
- const tlX = collisionBox.x1 + collisionBox.anchorPointX + this.viewportPadding;
44
- const tlY = collisionBox.y1 + collisionBox.anchorPointY + this.viewportPadding;
45
- const brX = collisionBox.x2 + collisionBox.anchorPointX + this.viewportPadding;
46
- const brY = collisionBox.y2 + collisionBox.anchorPointY + this.viewportPadding;
47
- if (!this.isInsideGrid(tlX, tlY, brX, brY) || this.grid.hitTest(tlX, tlY, brX, brY)) {
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
- return {
53
- box: [tlX, tlY, brX, brY]
54
- };
55
- }
56
- insertCollisionBox(box, featureIndex) {
57
- const key = { featureIndex };
58
- this.grid.insert(key, box[0], box[1], box[2], box[3]);
59
- }
60
- project(mvpMatrix, x, y) {
61
- const point = import_gl_matrix.vec4.fromValues(x, y, 0, 1);
62
- const out = import_gl_matrix.vec4.create();
63
- const mat = import_gl_matrix.mat4.fromValues(...mvpMatrix);
64
- import_gl_matrix.vec4.transformMat4(out, point, mat);
65
- return {
66
- x: (out[0] / out[3] + 1) / 2 * this.width + this.viewportPadding,
67
- y: (-out[1] / out[3] + 1) / 2 * this.height + this.viewportPadding
68
- };
69
- }
70
- isInsideGrid(x1, y1, x2, y2) {
71
- return x2 >= 0 && x1 < this.gridRightBoundary && y2 >= 0 && y1 < this.gridBottomBoundary;
72
- }
73
- };
74
- // Annotate the CommonJS export names for ESM import in node:
75
- 0 && (module.exports = {});
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
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
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
- module.exports = __toCommonJS(dataMappingStyle_exports);
27
- var import_lodash = require("lodash");
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
- handleStyleFloat("opacity", layer, configToUpdate.opacity);
33
+ // 处理 style 中 opacity 属性的数据映射
34
+ handleStyleFloat('opacity', layer, configToUpdate.opacity);
34
35
  }
36
+
35
37
  if (configToUpdate.strokeWidth) {
36
- handleStyleFloat("strokeWidth", layer, configToUpdate.strokeWidth);
38
+ // 处理 style 中 strokeWidth 属性的数据映射
39
+ handleStyleFloat('strokeWidth', layer, configToUpdate.strokeWidth);
37
40
  }
41
+
38
42
  if (configToUpdate.strokeOpacity) {
39
- handleStyleFloat("strokeOpacity", layer, configToUpdate.strokeOpacity);
43
+ // 处理 style 中 strokeOpacity 属性的数据映射
44
+ handleStyleFloat('strokeOpacity', layer, configToUpdate.strokeOpacity);
40
45
  }
46
+
41
47
  if (configToUpdate.stroke) {
42
- handleStyleColor("stroke", layer, configToUpdate.stroke);
48
+ // 处理 style 中 stroke (strokeColor) 属性的数据映射
49
+ handleStyleColor('stroke', layer, configToUpdate.stroke);
43
50
  }
51
+
44
52
  if (configToUpdate.offsets) {
45
- handleStyleOffsets("offsets", layer, configToUpdate.offsets);
53
+ // 处理 style 中 offsets 属性的数据映射
54
+ handleStyleOffsets('offsets', layer, configToUpdate.offsets);
46
55
  }
56
+
47
57
  if (configToUpdate.textOffset) {
48
- handleStyleOffsets("textOffset", layer, configToUpdate.textOffset);
58
+ // 处理 style 中 textOffset 属性的数据映射
59
+ handleStyleOffsets('textOffset', layer, configToUpdate.textOffset);
49
60
  }
61
+
50
62
  if (configToUpdate.thetaOffset) {
51
- handleStyleFloat("thetaOffset", layer, configToUpdate.thetaOffset);
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, import_lodash.isString)(styleFloat)) {
56
- registerStyleAttribute(fieldName, layer, styleFloat, (value) => {
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, import_lodash.isNumber)(styleFloat)) {
60
- registerStyleAttribute(fieldName, layer, [styleFloat], void 0);
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
- if ((0, import_lodash.isString)(styleFloat[0]) && (0, import_lodash.isFunction)(styleFloat[1])) {
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, import_lodash.isString)(styleFloat[0]) && Array.isArray(styleFloat[1]) && (0, import_lodash.isNumber)(styleFloat[1][0]) && (0, import_lodash.isNumber)(styleFloat[1][1])) {
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
- registerStyleAttribute(fieldName, layer, [1], void 0);
90
+ // 兼容
91
+ registerStyleAttribute(fieldName, layer, [1.0], undefined);
68
92
  }
69
93
  } else {
70
- registerStyleAttribute(fieldName, layer, [1], void 0);
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, import_lodash.isString)(styleOffsets)) {
75
- registerStyleAttribute(fieldName, layer, styleOffsets, (value) => {
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, import_lodash.isString)(styleOffsets[0]) && (0, import_lodash.isFunction)(styleOffsets[1])) {
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, import_lodash.isNumber)(styleOffsets[0]) && (0, import_lodash.isNumber)(styleOffsets[1])) {
81
- registerStyleAttribute(fieldName, layer, styleOffsets, void 0);
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
- registerStyleAttribute(fieldName, layer, [0, 0], void 0);
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, import_lodash.isString)(styleColor)) {
88
- registerStyleAttribute(fieldName, layer, styleColor, void 0);
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
- if ((0, import_lodash.isString)(styleColor[0]) && (0, import_lodash.isFunction)(styleColor[1])) {
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, import_lodash.isString)(styleColor[0]) && Array.isArray(styleColor[1]) && styleColor[1].length > 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
- registerStyleAttribute(fieldName, layer, "#fff", void 0);
144
+ // 兼容
145
+ registerStyleAttribute(fieldName, layer, '#fff', undefined);
96
146
  }
97
147
  } else {
98
- registerStyleAttribute(fieldName, layer, "#fff", void 0);
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
+ }