@antv/l7-layers 2.16.0 → 2.16.1

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 (242) hide show
  1. package/es/Geometry/index.js +31 -9
  2. package/es/Geometry/models/billboard.js +89 -51
  3. package/es/Geometry/models/plane.js +143 -81
  4. package/es/Geometry/models/sprite.js +118 -60
  5. package/es/canvas/index.js +33 -10
  6. package/es/canvas/models/canvas.js +97 -41
  7. package/es/citybuliding/building.js +27 -8
  8. package/es/citybuliding/models/build.js +82 -57
  9. package/es/core/BaseLayer.js +485 -321
  10. package/es/core/BaseModel.js +126 -97
  11. package/es/core/LayerPickService.js +32 -21
  12. package/es/core/TextureService.js +13 -0
  13. package/es/core/interface.js +24 -17
  14. package/es/core/shape/Path.js +20 -13
  15. package/es/core/shape/extrude.js +31 -10
  16. package/es/core/triangulation.js +114 -54
  17. package/es/earth/index.js +33 -9
  18. package/es/earth/models/atmosphere.js +54 -30
  19. package/es/earth/models/base.js +85 -47
  20. package/es/earth/models/bloomsphere.js +54 -30
  21. package/es/earth/utils.js +13 -9
  22. package/es/heatmap/index.js +40 -10
  23. package/es/heatmap/models/grid.js +52 -28
  24. package/es/heatmap/models/grid3d.js +52 -28
  25. package/es/heatmap/models/heatmap.js +146 -91
  26. package/es/heatmap/models/hexagon.js +52 -28
  27. package/es/heatmap/triangulation.js +4 -0
  28. package/es/image/index.js +28 -9
  29. package/es/image/models/image.js +100 -66
  30. package/es/index.js +17 -9
  31. package/es/line/index.js +34 -9
  32. package/es/line/models/arc.js +118 -66
  33. package/es/line/models/arc_3d.js +108 -60
  34. package/es/line/models/earthArc_3d.js +111 -63
  35. package/es/line/models/great_circle.js +100 -56
  36. package/es/line/models/half.js +77 -46
  37. package/es/line/models/line.js +148 -94
  38. package/es/line/models/linearline.js +80 -45
  39. package/es/line/models/simpleLine.js +74 -41
  40. package/es/line/models/wall.js +92 -52
  41. package/es/mask/index.js +28 -9
  42. package/es/mask/models/fill.js +54 -29
  43. package/es/plugins/DataMappingPlugin.js +117 -80
  44. package/es/plugins/DataSourcePlugin.js +68 -45
  45. package/es/plugins/FeatureScalePlugin.js +122 -67
  46. package/es/plugins/LayerAnimateStylePlugin.js +5 -0
  47. package/es/plugins/LayerMaskPlugin.js +11 -3
  48. package/es/plugins/LayerModelPlugin.js +104 -67
  49. package/es/plugins/LayerStylePlugin.js +9 -3
  50. package/es/plugins/LightingPlugin.js +18 -12
  51. package/es/plugins/MultiPassRendererPlugin.js +16 -11
  52. package/es/plugins/PixelPickingPlugin.js +21 -12
  53. package/es/plugins/RegisterStyleAttributePlugin.js +12 -5
  54. package/es/plugins/ShaderUniformPlugin.js +27 -13
  55. package/es/plugins/UpdateModelPlugin.js +5 -0
  56. package/es/plugins/UpdateStyleAttributePlugin.js +11 -5
  57. package/es/point/index.js +77 -26
  58. package/es/point/models/earthExtrude.js +102 -61
  59. package/es/point/models/earthFill.js +87 -57
  60. package/es/point/models/extrude.js +101 -60
  61. package/es/point/models/fill.js +100 -70
  62. package/es/point/models/fillmage.js +107 -63
  63. package/es/point/models/image.js +88 -48
  64. package/es/point/models/index.js +2 -2
  65. package/es/point/models/normal.js +54 -30
  66. package/es/point/models/radar.js +64 -40
  67. package/es/point/models/simplePoint.js +69 -41
  68. package/es/point/models/text.js +301 -198
  69. package/es/point/shape/extrude.js +13 -4
  70. package/es/polygon/index.js +40 -11
  71. package/es/polygon/models/extrude.js +92 -48
  72. package/es/polygon/models/fill.js +88 -54
  73. package/es/polygon/models/index.js +2 -3
  74. package/es/polygon/models/ocean.js +76 -42
  75. package/es/polygon/models/water.js +71 -37
  76. package/es/raster/buffers/triangulation.js +4 -2
  77. package/es/raster/index.js +32 -9
  78. package/es/raster/models/raster.js +116 -80
  79. package/es/raster/models/rasterRgb.js +127 -84
  80. package/es/raster/models/rasterTerrainRgb.js +84 -56
  81. package/es/tile/interaction/getRasterData.js +20 -14
  82. package/es/tile/interaction/utils.js +9 -7
  83. package/es/tile/manager/base.js +96 -63
  84. package/es/tile/service/TileLayerService.js +55 -33
  85. package/es/tile/service/TilePickService.js +40 -26
  86. package/es/tile/service/TileSourceService.js +7 -3
  87. package/es/tile/tileFactory/DebugTile.js +46 -29
  88. package/es/tile/tileFactory/ImageTile.js +38 -20
  89. package/es/tile/tileFactory/MaskTile.js +43 -22
  90. package/es/tile/tileFactory/RasterRGBTile.js +42 -22
  91. package/es/tile/tileFactory/RasterTerrainRGBTile.js +38 -20
  92. package/es/tile/tileFactory/RasterTile.js +53 -30
  93. package/es/tile/tileFactory/Tile.js +97 -63
  94. package/es/tile/tileFactory/VectorTile.js +68 -41
  95. package/es/tile/tileFactory/index.js +11 -0
  96. package/es/tile/tileFactory/layers/TileDebugLayer.js +27 -6
  97. package/es/tile/tileFactory/util.js +3 -0
  98. package/es/tile/tileLayer/BaseLayer.js +146 -105
  99. package/es/tile/utils.js +1 -1
  100. package/es/utils/blend.js +2 -0
  101. package/es/utils/collision-index.js +16 -9
  102. package/es/utils/dataMappingStyle.js +18 -8
  103. package/es/utils/extrude_polyline.js +149 -101
  104. package/es/utils/grid-index.js +27 -2
  105. package/es/utils/identityScale.js +8 -0
  106. package/es/utils/layerData.js +44 -30
  107. package/es/utils/multiPassRender.js +13 -11
  108. package/es/utils/polylineNormal.js +37 -31
  109. package/es/utils/simpleLine.js +16 -2
  110. package/es/utils/stencil.js +3 -2
  111. package/es/utils/symbol-layout.js +53 -27
  112. package/es/wind/index.js +29 -9
  113. package/es/wind/models/utils.js +51 -26
  114. package/es/wind/models/wind.js +147 -101
  115. package/es/wind/models/windRender.js +66 -53
  116. package/lib/Geometry/index.js +38 -9
  117. package/lib/Geometry/models/billboard.js +97 -51
  118. package/lib/Geometry/models/index.js +5 -0
  119. package/lib/Geometry/models/plane.js +151 -79
  120. package/lib/Geometry/models/sprite.js +127 -60
  121. package/lib/canvas/index.js +40 -10
  122. package/lib/canvas/models/canvas.js +101 -41
  123. package/lib/canvas/models/index.js +3 -0
  124. package/lib/citybuliding/building.js +35 -8
  125. package/lib/citybuliding/models/build.js +92 -57
  126. package/lib/core/BaseLayer.js +479 -321
  127. package/lib/core/BaseModel.js +139 -97
  128. package/lib/core/LayerPickService.js +37 -21
  129. package/lib/core/TextureService.js +16 -0
  130. package/lib/core/interface.js +31 -21
  131. package/lib/core/schema.js +1 -0
  132. package/lib/core/shape/Path.js +31 -14
  133. package/lib/core/shape/extrude.js +54 -10
  134. package/lib/core/triangulation.js +153 -53
  135. package/lib/earth/index.js +43 -9
  136. package/lib/earth/models/atmosphere.js +63 -30
  137. package/lib/earth/models/base.js +90 -47
  138. package/lib/earth/models/bloomsphere.js +63 -30
  139. package/lib/earth/utils.js +31 -7
  140. package/lib/heatmap/index.js +48 -10
  141. package/lib/heatmap/models/grid.js +60 -28
  142. package/lib/heatmap/models/grid3d.js +60 -28
  143. package/lib/heatmap/models/heatmap.js +162 -91
  144. package/lib/heatmap/models/hexagon.js +60 -28
  145. package/lib/heatmap/models/index.js +6 -0
  146. package/lib/heatmap/triangulation.js +5 -0
  147. package/lib/image/index.js +36 -9
  148. package/lib/image/models/image.js +109 -66
  149. package/lib/image/models/index.js +3 -0
  150. package/lib/index.js +61 -7
  151. package/lib/line/index.js +40 -9
  152. package/lib/line/models/arc.js +128 -64
  153. package/lib/line/models/arc_3d.js +119 -58
  154. package/lib/line/models/earthArc_3d.js +122 -61
  155. package/lib/line/models/great_circle.js +111 -56
  156. package/lib/line/models/half.js +87 -46
  157. package/lib/line/models/index.js +11 -0
  158. package/lib/line/models/line.js +156 -92
  159. package/lib/line/models/linearline.js +92 -45
  160. package/lib/line/models/simpleLine.js +84 -41
  161. package/lib/line/models/wall.js +103 -52
  162. package/lib/mask/index.js +36 -9
  163. package/lib/mask/models/fill.js +63 -29
  164. package/lib/mask/models/index.js +3 -0
  165. package/lib/plugins/DataMappingPlugin.js +128 -80
  166. package/lib/plugins/DataSourcePlugin.js +76 -45
  167. package/lib/plugins/FeatureScalePlugin.js +138 -67
  168. package/lib/plugins/LayerAnimateStylePlugin.js +10 -0
  169. package/lib/plugins/LayerMaskPlugin.js +17 -4
  170. package/lib/plugins/LayerModelPlugin.js +113 -68
  171. package/lib/plugins/LayerStylePlugin.js +14 -4
  172. package/lib/plugins/LightingPlugin.js +25 -12
  173. package/lib/plugins/MultiPassRendererPlugin.js +22 -11
  174. package/lib/plugins/PixelPickingPlugin.js +27 -12
  175. package/lib/plugins/RegisterStyleAttributePlugin.js +19 -5
  176. package/lib/plugins/ShaderUniformPlugin.js +34 -13
  177. package/lib/plugins/UpdateModelPlugin.js +10 -1
  178. package/lib/plugins/UpdateStyleAttributePlugin.js +16 -5
  179. package/lib/point/index.js +83 -26
  180. package/lib/point/models/earthExtrude.js +113 -61
  181. package/lib/point/models/earthFill.js +117 -57
  182. package/lib/point/models/extrude.js +111 -60
  183. package/lib/point/models/fill.js +109 -68
  184. package/lib/point/models/fillmage.js +115 -61
  185. package/lib/point/models/image.js +98 -48
  186. package/lib/point/models/index.js +12 -1
  187. package/lib/point/models/normal.js +64 -30
  188. package/lib/point/models/radar.js +74 -40
  189. package/lib/point/models/simplePoint.js +79 -41
  190. package/lib/point/models/text.js +309 -198
  191. package/lib/point/shape/extrude.js +20 -4
  192. package/lib/polygon/index.js +48 -11
  193. package/lib/polygon/models/extrude.js +103 -48
  194. package/lib/polygon/models/fill.js +98 -54
  195. package/lib/polygon/models/index.js +14 -2
  196. package/lib/polygon/models/ocean.js +88 -42
  197. package/lib/polygon/models/water.js +82 -37
  198. package/lib/raster/buffers/triangulation.js +7 -3
  199. package/lib/raster/index.js +40 -9
  200. package/lib/raster/models/index.js +5 -0
  201. package/lib/raster/models/raster.js +125 -80
  202. package/lib/raster/models/rasterRgb.js +139 -84
  203. package/lib/raster/models/rasterTerrainRgb.js +93 -56
  204. package/lib/tile/interaction/getRasterData.js +25 -14
  205. package/lib/tile/interaction/utils.js +19 -7
  206. package/lib/tile/manager/base.js +104 -63
  207. package/lib/tile/service/TileLayerService.js +60 -33
  208. package/lib/tile/service/TilePickService.js +48 -26
  209. package/lib/tile/service/TileSourceService.js +16 -2
  210. package/lib/tile/style/utils.js +3 -0
  211. package/lib/tile/tileFactory/DebugTile.js +54 -29
  212. package/lib/tile/tileFactory/ImageTile.js +46 -20
  213. package/lib/tile/tileFactory/MaskTile.js +51 -22
  214. package/lib/tile/tileFactory/RasterRGBTile.js +50 -22
  215. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +46 -20
  216. package/lib/tile/tileFactory/RasterTile.js +63 -30
  217. package/lib/tile/tileFactory/Tile.js +102 -63
  218. package/lib/tile/tileFactory/VectorTile.js +76 -41
  219. package/lib/tile/tileFactory/index.js +25 -0
  220. package/lib/tile/tileFactory/layers/TileDebugLayer.js +32 -6
  221. package/lib/tile/tileFactory/util.js +9 -0
  222. package/lib/tile/tileLayer/BaseLayer.js +153 -105
  223. package/lib/tile/utils.js +5 -1
  224. package/lib/utils/blend.js +5 -0
  225. package/lib/utils/collision-index.js +25 -9
  226. package/lib/utils/dataMappingStyle.js +19 -8
  227. package/lib/utils/extrude_polyline.js +181 -101
  228. package/lib/utils/grid-index.js +28 -2
  229. package/lib/utils/identityScale.js +9 -0
  230. package/lib/utils/layerData.js +49 -30
  231. package/lib/utils/multiPassRender.js +16 -11
  232. package/lib/utils/polylineNormal.js +66 -31
  233. package/lib/utils/simpleLine.js +21 -2
  234. package/lib/utils/stencil.js +4 -0
  235. package/lib/utils/symbol-layout.js +55 -27
  236. package/lib/wind/index.js +37 -9
  237. package/lib/wind/models/index.js +3 -0
  238. package/lib/wind/models/utils.js +62 -26
  239. package/lib/wind/models/wind.js +157 -101
  240. package/lib/wind/models/windRender.js +71 -53
  241. package/lib/wind/models/windShader.js +1 -0
  242. package/package.json +7 -7
@@ -3,7 +3,9 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
5
5
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
6
+
6
7
  var _scaleMap, _dec, _class;
8
+
7
9
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
10
  import { IDebugLog, ILayerStage, ScaleTypes, StyleScaleType } from '@antv/l7-core';
9
11
  import { extent } from 'd3-array';
@@ -18,75 +20,96 @@ var scaleMap = (_scaleMap = {}, _defineProperty(_scaleMap, ScaleTypes.LINEAR, d3
18
20
  /**
19
21
  * 根据 Source 原始数据为指定字段创建 Scale,保存在 StyleAttribute 上,供下游插件使用
20
22
  */
23
+
21
24
  var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function () {
22
25
  function FeatureScalePlugin() {
23
26
  _classCallCheck(this, FeatureScalePlugin);
27
+
24
28
  _defineProperty(this, "scaleOptions", {});
25
29
  }
30
+
26
31
  _createClass(FeatureScalePlugin, [{
27
32
  key: "apply",
28
33
  value: function apply(layer, _ref) {
29
34
  var _this = this;
35
+
30
36
  var styleAttributeService = _ref.styleAttributeService;
31
37
  layer.hooks.init.tapPromise('FeatureScalePlugin', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
32
38
  var _layer$getSource;
39
+
33
40
  var attributes, dataArray;
34
41
  return _regeneratorRuntime.wrap(function _callee$(_context) {
35
- while (1) switch (_context.prev = _context.next) {
36
- case 0:
37
- layer.log(IDebugLog.ScaleInitStart, ILayerStage.INIT);
38
- _this.scaleOptions = layer.getScaleOptions();
39
- attributes = styleAttributeService.getLayerStyleAttributes();
40
- dataArray = (_layer$getSource = layer.getSource()) === null || _layer$getSource === void 0 ? void 0 : _layer$getSource.data.dataArray;
41
- if (!(Array.isArray(dataArray) && dataArray.length === 0)) {
42
- _context.next = 8;
43
- break;
44
- }
45
- return _context.abrupt("return");
46
- case 8:
47
- _this.caculateScalesForAttributes(attributes || [], dataArray);
48
- case 9:
49
- layer.log(IDebugLog.ScaleInitEnd, ILayerStage.INIT);
50
- case 10:
51
- case "end":
52
- return _context.stop();
53
- }
54
- }, _callee);
55
- })));
56
-
57
- // 检测数据是否需要更新
58
- layer.hooks.beforeRenderData.tapPromise('FeatureScalePlugin', /*#__PURE__*/function () {
59
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(flag) {
60
- var attributes, dataArray;
61
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
62
- while (1) switch (_context2.prev = _context2.next) {
42
+ while (1) {
43
+ switch (_context.prev = _context.next) {
63
44
  case 0:
64
- if (flag) {
65
- _context2.next = 2;
66
- break;
67
- }
68
- return _context2.abrupt("return", flag);
69
- case 2:
70
- layer.log(IDebugLog.ScaleInitStart, ILayerStage.UPDATE);
45
+ layer.log(IDebugLog.ScaleInitStart, ILayerStage.INIT);
71
46
  _this.scaleOptions = layer.getScaleOptions();
72
47
  attributes = styleAttributeService.getLayerStyleAttributes();
73
- dataArray = layer.getSource().data.dataArray;
48
+ dataArray = (_layer$getSource = layer.getSource()) === null || _layer$getSource === void 0 ? void 0 : _layer$getSource.data.dataArray;
49
+
74
50
  if (!(Array.isArray(dataArray) && dataArray.length === 0)) {
75
- _context2.next = 8;
51
+ _context.next = 8;
76
52
  break;
77
53
  }
78
- return _context2.abrupt("return", true);
54
+
55
+ return _context.abrupt("return");
56
+
79
57
  case 8:
80
58
  _this.caculateScalesForAttributes(attributes || [], dataArray);
81
- layer.log(IDebugLog.ScaleInitEnd, ILayerStage.UPDATE);
82
- layer.layerModelNeedUpdate = true;
83
- return _context2.abrupt("return", true);
84
- case 12:
59
+
60
+ case 9:
61
+ layer.log(IDebugLog.ScaleInitEnd, ILayerStage.INIT);
62
+
63
+ case 10:
85
64
  case "end":
86
- return _context2.stop();
65
+ return _context.stop();
66
+ }
67
+ }
68
+ }, _callee);
69
+ }))); // 检测数据是否需要更新
70
+
71
+ layer.hooks.beforeRenderData.tapPromise('FeatureScalePlugin', /*#__PURE__*/function () {
72
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(flag) {
73
+ var attributes, dataArray;
74
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
75
+ while (1) {
76
+ switch (_context2.prev = _context2.next) {
77
+ case 0:
78
+ if (flag) {
79
+ _context2.next = 2;
80
+ break;
81
+ }
82
+
83
+ return _context2.abrupt("return", flag);
84
+
85
+ case 2:
86
+ layer.log(IDebugLog.ScaleInitStart, ILayerStage.UPDATE);
87
+ _this.scaleOptions = layer.getScaleOptions();
88
+ attributes = styleAttributeService.getLayerStyleAttributes();
89
+ dataArray = layer.getSource().data.dataArray;
90
+
91
+ if (!(Array.isArray(dataArray) && dataArray.length === 0)) {
92
+ _context2.next = 8;
93
+ break;
94
+ }
95
+
96
+ return _context2.abrupt("return", true);
97
+
98
+ case 8:
99
+ _this.caculateScalesForAttributes(attributes || [], dataArray);
100
+
101
+ layer.log(IDebugLog.ScaleInitEnd, ILayerStage.UPDATE);
102
+ layer.layerModelNeedUpdate = true;
103
+ return _context2.abrupt("return", true);
104
+
105
+ case 12:
106
+ case "end":
107
+ return _context2.stop();
108
+ }
87
109
  }
88
110
  }, _callee2);
89
111
  }));
112
+
90
113
  return function (_x) {
91
114
  return _ref3.apply(this, arguments);
92
115
  };
@@ -95,16 +118,20 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
95
118
  if (layer.layerModelNeedUpdate) {
96
119
  return;
97
120
  }
121
+
98
122
  _this.scaleOptions = layer.getScaleOptions();
99
123
  var attributes = styleAttributeService.getLayerStyleAttributes();
100
124
  var dataArray = layer.getSource().data.dataArray;
125
+
101
126
  if (Array.isArray(dataArray) && dataArray.length === 0) {
102
127
  return;
103
128
  }
129
+
104
130
  if (attributes) {
105
131
  var attributesToRescale = attributes.filter(function (attribute) {
106
132
  return attribute.needRescale;
107
133
  });
134
+
108
135
  if (attributesToRescale.length) {
109
136
  _this.caculateScalesForAttributes(attributesToRescale, dataArray);
110
137
  }
@@ -120,28 +147,30 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
120
147
  key: "caculateScalesForAttributes",
121
148
  value: function caculateScalesForAttributes(attributes, dataArray) {
122
149
  var _this2 = this;
150
+
123
151
  attributes.forEach(function (attribute) {
124
152
  if (attribute.scale) {
125
153
  // 创建Scale
126
- var attributeScale = attribute.scale;
127
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
154
+ var attributeScale = attribute.scale; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
155
+
128
156
  attributeScale.names = _this2.parseFields(attribute.scale.field || []);
129
- var scales = [];
130
- // 为每个字段创建 Scale
157
+ var scales = []; // 为每个字段创建 Scale
158
+
131
159
  attributeScale.names.forEach(function (field) {
132
160
  var _attribute$scale;
161
+
133
162
  scales.push(_this2.createScale(field, attribute.name, (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.values, dataArray));
134
- });
163
+ }); // 为scales 设置值区间 Range
135
164
 
136
- // 为scales 设置值区间 Range
137
165
  if (scales.some(function (scale) {
138
166
  return scale.type === StyleScaleType.VARIABLE;
139
167
  })) {
140
168
  attributeScale.type = StyleScaleType.VARIABLE;
141
169
  scales.forEach(function (scale) {
170
+ var _scale$option;
171
+
142
172
  // 如果设置了回调, 这不需要设置range
143
173
  if (!attributeScale.callback && attributeScale.values !== 'text') {
144
- var _scale$option;
145
174
  switch ((_scale$option = scale.option) === null || _scale$option === void 0 ? void 0 : _scale$option.type) {
146
175
  case ScaleTypes.LOG:
147
176
  case ScaleTypes.LINEAR:
@@ -150,29 +179,36 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
150
179
  var tick = scale.scale.ticks(attributeScale.values.length);
151
180
  scale.scale.domain(tick);
152
181
  }
182
+
153
183
  attributeScale.values ? scale.scale.range(attributeScale.values) : scale.scale.range(scale.option.domain);
154
184
  break;
185
+
155
186
  case ScaleTypes.QUANTILE:
156
187
  case ScaleTypes.QUANTIZE:
157
188
  case ScaleTypes.THRESHOLD:
158
189
  scale.scale.range(attributeScale.values); //
190
+
159
191
  break;
192
+
160
193
  case ScaleTypes.IDENTITY:
161
194
  // 不做处理xe
162
195
  break;
196
+
163
197
  case ScaleTypes.CAT:
164
198
  attributeScale.values ? scale.scale.range(attributeScale.values) : scale.scale.range(scale.option.domain);
165
199
  break;
200
+
166
201
  case ScaleTypes.DIVERGING:
167
202
  case ScaleTypes.SEQUENTIAL:
168
- scale.scale.interpolator(
169
- // @ts-ignore
203
+ scale.scale.interpolator( // @ts-ignore
170
204
  d3interpolate.interpolateRgbBasis(attributeScale.values));
171
205
  break;
172
206
  }
173
207
  }
208
+
174
209
  if (attributeScale.values === 'text') {
175
210
  var _scale$option2;
211
+
176
212
  scale.scale.range((_scale$option2 = scale.option) === null || _scale$option2 === void 0 ? void 0 : _scale$option2.domain);
177
213
  }
178
214
  });
@@ -183,6 +219,7 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
183
219
  return scale.scale(attributeScale.names[index]);
184
220
  });
185
221
  }
222
+
186
223
  attributeScale.scalers = scales.map(function (scale) {
187
224
  return {
188
225
  field: scale.field,
@@ -194,27 +231,30 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
194
231
  }
195
232
  });
196
233
  }
197
-
198
234
  /**
199
235
  * @example
200
236
  * 'w*h' => ['w', 'h']
201
237
  * 'w' => ['w']
202
238
  */
239
+
203
240
  }, {
204
241
  key: "parseFields",
205
242
  value: function parseFields(field) {
206
243
  if (Array.isArray(field)) {
207
244
  return field;
208
245
  }
246
+
209
247
  if (isString(field)) {
210
248
  return field.split('*');
211
249
  }
250
+
212
251
  return [field];
213
252
  }
214
253
  }, {
215
254
  key: "createScale",
216
255
  value: function createScale(field, name, values, data) {
217
256
  var _this$scaleOptions$na, _find;
257
+
218
258
  // scale 支持根据视觉通道和字段
219
259
  var scaleOption = this.scaleOptions[name] && ((_this$scaleOptions$na = this.scaleOptions[name]) === null || _this$scaleOptions$na === void 0 ? void 0 : _this$scaleOptions$na.field) === field ? this.scaleOptions[name] // TODO zi
220
260
  : this.scaleOptions[field];
@@ -224,6 +264,7 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
224
264
  type: StyleScaleType.VARIABLE,
225
265
  option: scaleOption
226
266
  };
267
+
227
268
  if (!data || !data.length) {
228
269
  if (scaleOption && scaleOption.type) {
229
270
  styleScale.scale = this.createDefaultScale(scaleOption);
@@ -231,39 +272,46 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
231
272
  styleScale.scale = d3.scaleOrdinal([field]);
232
273
  styleScale.type = StyleScaleType.CONSTANT;
233
274
  }
275
+
234
276
  return styleScale;
235
- }
236
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
277
+ } // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
278
+
279
+
237
280
  var firstValue = (_find = data.find(function (d) {
238
281
  return !isNil(d[field]);
239
- })) === null || _find === void 0 ? void 0 : _find[field];
240
- // 常量 Scale
282
+ })) === null || _find === void 0 ? void 0 : _find[field]; // 常量 Scale
283
+
241
284
  if (this.isNumber(field) || isNil(firstValue) && !scaleOption) {
242
285
  styleScale.scale = d3.scaleOrdinal([field]);
243
286
  styleScale.type = StyleScaleType.CONSTANT;
244
287
  } else {
245
288
  // 根据数据类型判断 默认等分位,时间,和枚举类型
246
289
  var type = scaleOption && scaleOption.type || this.getDefaultType(firstValue);
290
+
247
291
  if (values === 'text') {
248
292
  // text 为内置变 如果是文本则为cat
249
293
  type = ScaleTypes.CAT;
250
294
  }
295
+
251
296
  var cfg = this.createScaleConfig(type, field, scaleOption, data);
252
297
  styleScale.scale = this.createDefaultScale(cfg);
253
298
  styleScale.option = cfg;
254
299
  }
300
+
255
301
  return styleScale;
256
302
  }
257
303
  }, {
258
304
  key: "getDefaultType",
259
305
  value: function getDefaultType(firstValue) {
260
306
  var type = ScaleTypes.LINEAR;
307
+
261
308
  if (typeof firstValue === 'string') {
262
309
  type = dateRegex.test(firstValue) ? ScaleTypes.TIME : ScaleTypes.CAT;
263
310
  }
311
+
264
312
  return type;
265
- }
266
- // 生成Scale 默认配置
313
+ } // 生成Scale 默认配置
314
+
267
315
  }, {
268
316
  key: "createScaleConfig",
269
317
  value: function createScaleConfig(type, field, scaleOption, data) {
@@ -273,6 +321,7 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
273
321
  var values = (data === null || data === void 0 ? void 0 : data.map(function (item) {
274
322
  return item[field];
275
323
  })) || [];
324
+
276
325
  if (scaleOption !== null && scaleOption !== void 0 && scaleOption.domain) {
277
326
  cfg.domain = scaleOption === null || scaleOption === void 0 ? void 0 : scaleOption.domain;
278
327
  } else if (type === ScaleTypes.CAT || type === ScaleTypes.IDENTITY) {
@@ -287,36 +336,42 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
287
336
  // linear/Power/log
288
337
  cfg.domain = extent(values);
289
338
  }
339
+
290
340
  return _objectSpread(_objectSpread({}, cfg), scaleOption);
291
- }
341
+ } // 创建Scale 实例
292
342
 
293
- // 创建Scale 实例
294
343
  }, {
295
344
  key: "createDefaultScale",
296
345
  value: function createDefaultScale(_ref4) {
297
346
  var type = _ref4.type,
298
- domain = _ref4.domain,
299
- unknown = _ref4.unknown,
300
- clamp = _ref4.clamp,
301
- nice = _ref4.nice;
347
+ domain = _ref4.domain,
348
+ unknown = _ref4.unknown,
349
+ clamp = _ref4.clamp,
350
+ nice = _ref4.nice;
302
351
  // @ts-ignore
303
352
  var scale = scaleMap[type]();
353
+
304
354
  if (domain && scale.domain) {
305
355
  scale.domain(domain);
306
356
  }
357
+
307
358
  if (unknown) {
308
359
  scale.unknown(unknown);
309
360
  }
361
+
310
362
  if (clamp !== undefined && scale.clamp) {
311
363
  scale.clamp(clamp);
312
364
  }
365
+
313
366
  if (nice !== undefined && scale.nice) {
314
367
  scale.nice(nice);
315
- }
316
- // TODO 其他属性支持
368
+ } // TODO 其他属性支持
369
+
370
+
317
371
  return scale;
318
372
  }
319
373
  }]);
374
+
320
375
  return FeatureScalePlugin;
321
376
  }()) || _class);
322
377
  export { FeatureScalePlugin as default };
@@ -1,19 +1,23 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+
4
5
  var _dec, _class;
6
+
5
7
  import { injectable } from 'inversify';
6
8
  import 'reflect-metadata';
7
9
  var LayerAnimateStylePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function () {
8
10
  function LayerAnimateStylePlugin() {
9
11
  _classCallCheck(this, LayerAnimateStylePlugin);
10
12
  }
13
+
11
14
  _createClass(LayerAnimateStylePlugin, [{
12
15
  key: "apply",
13
16
  value: function apply(layer) {
14
17
  layer.hooks.beforeRender.tap('LayerAnimateStylePlugin', function () {
15
18
  // @ts-ignore
16
19
  var animateStatus = layer.animateStatus;
20
+
17
21
  if (animateStatus) {
18
22
  layer.models.forEach(function (model) {
19
23
  model.addUniforms(_objectSpread({}, layer.layerModel.getAnimateUniforms()));
@@ -22,6 +26,7 @@ var LayerAnimateStylePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/f
22
26
  });
23
27
  }
24
28
  }]);
29
+
25
30
  return LayerAnimateStylePlugin;
26
31
  }()) || _class);
27
32
  export { LayerAnimateStylePlugin as default };
@@ -1,27 +1,34 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+
4
5
  var _dec, _class;
6
+
5
7
  import { injectable } from 'inversify';
6
8
  import 'reflect-metadata';
7
9
  /**
8
10
  * 更新图层样式,初始图层相关配置
9
11
  */
12
+
10
13
  var LayerStylePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function () {
11
14
  function LayerStylePlugin() {
12
15
  _classCallCheck(this, LayerStylePlugin);
13
16
  }
17
+
14
18
  _createClass(LayerStylePlugin, [{
15
19
  key: "apply",
16
20
  value: function apply(layer) {
17
21
  layer.hooks.afterInit.tap('LayerMaskPlugin', function () {
18
22
  var _layer$getLayerConfig = layer.getLayerConfig(),
19
- maskLayers = _layer$getLayerConfig.maskLayers,
20
- enableMask = _layer$getLayerConfig.enableMask;
21
- // mask 初始化
23
+ maskLayers = _layer$getLayerConfig.maskLayers,
24
+ enableMask = _layer$getLayerConfig.enableMask; // mask 初始化
25
+
26
+
22
27
  if (!layer.tileLayer && maskLayers && maskLayers.length > 0) {
23
28
  var _layer$masks;
29
+
24
30
  (_layer$masks = layer.masks).push.apply(_layer$masks, _toConsumableArray(maskLayers));
31
+
25
32
  layer.updateLayerConfig({
26
33
  mask: true && enableMask
27
34
  });
@@ -29,6 +36,7 @@ var LayerStylePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function
29
36
  });
30
37
  }
31
38
  }]);
39
+
32
40
  return LayerStylePlugin;
33
41
  }()) || _class);
34
42
  export { LayerStylePlugin as default };