@antv/l7-layers 2.17.4 → 2.17.6

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 (250) hide show
  1. package/es/Geometry/index.js +9 -31
  2. package/es/Geometry/models/billboard.js +51 -89
  3. package/es/Geometry/models/plane.js +81 -143
  4. package/es/Geometry/models/sprite.js +60 -118
  5. package/es/canvas/index.js +10 -33
  6. package/es/canvas/models/canvas.js +41 -97
  7. package/es/citybuliding/building.js +8 -27
  8. package/es/citybuliding/models/build.js +57 -82
  9. package/es/core/BaseLayer.js +325 -483
  10. package/es/core/BaseModel.js +51 -80
  11. package/es/core/CommonStyleAttribute.js +2 -5
  12. package/es/core/LayerPickService.js +21 -32
  13. package/es/core/TextureService.js +0 -13
  14. package/es/core/interface.js +17 -24
  15. package/es/core/shape/Path.js +13 -20
  16. package/es/core/shape/extrude.js +27 -39
  17. package/es/core/triangulation.js +99 -136
  18. package/es/earth/index.js +9 -33
  19. package/es/earth/models/atmosphere.js +30 -54
  20. package/es/earth/models/base.js +47 -85
  21. package/es/earth/models/bloomsphere.js +30 -54
  22. package/es/earth/utils.js +9 -13
  23. package/es/heatmap/index.js +10 -40
  24. package/es/heatmap/models/grid.js +28 -52
  25. package/es/heatmap/models/grid3d.js +28 -52
  26. package/es/heatmap/models/heatmap.js +92 -149
  27. package/es/heatmap/models/hexagon.js +28 -52
  28. package/es/heatmap/triangulation.js +0 -4
  29. package/es/image/index.js +9 -28
  30. package/es/image/models/image.js +66 -100
  31. package/es/index.js +9 -17
  32. package/es/line/index.js +9 -35
  33. package/es/line/models/arc.js +63 -112
  34. package/es/line/models/arc_3d.js +58 -102
  35. package/es/line/models/earthArc_3d.js +60 -105
  36. package/es/line/models/flow.js +36 -60
  37. package/es/line/models/great_circle.js +53 -94
  38. package/es/line/models/line.js +92 -144
  39. package/es/line/models/linearline.js +42 -74
  40. package/es/line/models/simpleLine.js +38 -67
  41. package/es/line/models/wall.js +52 -92
  42. package/es/line/shaders/dash/line_dash_vert.glsl +1 -2
  43. package/es/line/shaders/line_frag.glsl +1 -3
  44. package/es/line/shaders/line_vert.glsl +2 -0
  45. package/es/line/shaders/linear/line_linear_frag.glsl +1 -1
  46. package/es/mask/index.js +9 -28
  47. package/es/mask/models/fill.js +29 -54
  48. package/es/plugins/DataMappingPlugin.js +78 -114
  49. package/es/plugins/DataSourcePlugin.js +45 -68
  50. package/es/plugins/FeatureScalePlugin.js +67 -122
  51. package/es/plugins/LayerAnimateStylePlugin.js +0 -5
  52. package/es/plugins/LayerMaskPlugin.js +3 -11
  53. package/es/plugins/LayerModelPlugin.js +69 -118
  54. package/es/plugins/LayerStylePlugin.js +4 -9
  55. package/es/plugins/LightingPlugin.js +12 -18
  56. package/es/plugins/MultiPassRendererPlugin.js +11 -16
  57. package/es/plugins/PixelPickingPlugin.js +12 -21
  58. package/es/plugins/RegisterStyleAttributePlugin.js +5 -12
  59. package/es/plugins/ShaderUniformPlugin.js +13 -27
  60. package/es/plugins/UpdateModelPlugin.js +0 -5
  61. package/es/plugins/UpdateStyleAttributePlugin.js +5 -11
  62. package/es/point/index.js +26 -78
  63. package/es/point/models/earthExtrude.js +58 -95
  64. package/es/point/models/earthFill.js +52 -80
  65. package/es/point/models/extrude.js +57 -94
  66. package/es/point/models/fill.js +56 -81
  67. package/es/point/models/fillmage.js +60 -100
  68. package/es/point/models/image.js +47 -83
  69. package/es/point/models/index.js +2 -2
  70. package/es/point/models/normal.js +30 -54
  71. package/es/point/models/radar.js +38 -63
  72. package/es/point/models/simplePoint.js +38 -62
  73. package/es/point/models/text.js +199 -296
  74. package/es/point/shape/extrude.js +4 -13
  75. package/es/polygon/index.js +11 -41
  76. package/es/polygon/models/extrude.js +87 -135
  77. package/es/polygon/models/fill.js +50 -79
  78. package/es/polygon/models/index.js +3 -2
  79. package/es/polygon/models/ocean.js +42 -76
  80. package/es/polygon/models/water.js +37 -71
  81. package/es/raster/buffers/triangulation.js +2 -4
  82. package/es/raster/index.js +9 -32
  83. package/es/raster/models/raster.js +80 -116
  84. package/es/raster/models/rasterRgb.js +84 -127
  85. package/es/raster/models/rasterTerrainRgb.js +56 -84
  86. package/es/tile/interaction/getRasterData.js +14 -20
  87. package/es/tile/interaction/utils.js +7 -9
  88. package/es/tile/manager/base.js +63 -96
  89. package/es/tile/service/TileLayerService.js +33 -55
  90. package/es/tile/service/TilePickService.js +26 -40
  91. package/es/tile/service/TileSourceService.js +3 -7
  92. package/es/tile/tileFactory/DebugTile.js +29 -46
  93. package/es/tile/tileFactory/ImageTile.js +20 -38
  94. package/es/tile/tileFactory/MaskTile.js +22 -43
  95. package/es/tile/tileFactory/RasterRGBTile.js +22 -42
  96. package/es/tile/tileFactory/RasterTerrainRGBTile.js +20 -38
  97. package/es/tile/tileFactory/RasterTile.js +30 -53
  98. package/es/tile/tileFactory/Tile.js +63 -97
  99. package/es/tile/tileFactory/VectorTile.js +41 -68
  100. package/es/tile/tileFactory/index.js +0 -11
  101. package/es/tile/tileFactory/layers/TileDebugLayer.js +6 -27
  102. package/es/tile/tileFactory/util.js +0 -3
  103. package/es/tile/tileLayer/BaseLayer.js +105 -146
  104. package/es/tile/utils.js +1 -1
  105. package/es/utils/blend.js +0 -2
  106. package/es/utils/collision-index.js +9 -16
  107. package/es/utils/extrude_polyline.js +101 -149
  108. package/es/utils/grid-index.js +2 -27
  109. package/es/utils/identityScale.js +0 -8
  110. package/es/utils/layerData.js +30 -44
  111. package/es/utils/multiPassRender.js +11 -13
  112. package/es/utils/polylineNormal.js +31 -37
  113. package/es/utils/simpleLine.js +2 -16
  114. package/es/utils/stencil.js +2 -3
  115. package/es/utils/symbol-layout.js +27 -53
  116. package/es/wind/index.js +9 -29
  117. package/es/wind/models/utils.js +26 -51
  118. package/es/wind/models/wind.js +101 -147
  119. package/es/wind/models/windRender.js +53 -66
  120. package/lib/Geometry/index.js +9 -38
  121. package/lib/Geometry/models/billboard.js +51 -97
  122. package/lib/Geometry/models/index.js +0 -5
  123. package/lib/Geometry/models/plane.js +79 -151
  124. package/lib/Geometry/models/sprite.js +60 -127
  125. package/lib/canvas/index.js +10 -40
  126. package/lib/canvas/models/canvas.js +41 -101
  127. package/lib/canvas/models/index.js +0 -3
  128. package/lib/citybuliding/building.js +8 -35
  129. package/lib/citybuliding/models/build.js +57 -92
  130. package/lib/core/BaseLayer.js +325 -474
  131. package/lib/core/BaseModel.js +51 -90
  132. package/lib/core/CommonStyleAttribute.js +2 -7
  133. package/lib/core/LayerPickService.js +21 -37
  134. package/lib/core/TextureService.js +0 -16
  135. package/lib/core/interface.js +21 -31
  136. package/lib/core/schema.js +0 -1
  137. package/lib/core/shape/Path.js +14 -31
  138. package/lib/core/shape/extrude.js +27 -62
  139. package/lib/core/triangulation.js +98 -177
  140. package/lib/earth/index.js +9 -43
  141. package/lib/earth/models/atmosphere.js +30 -63
  142. package/lib/earth/models/base.js +47 -90
  143. package/lib/earth/models/bloomsphere.js +30 -63
  144. package/lib/earth/utils.js +7 -31
  145. package/lib/heatmap/index.js +10 -48
  146. package/lib/heatmap/models/grid.js +28 -60
  147. package/lib/heatmap/models/grid3d.js +28 -60
  148. package/lib/heatmap/models/heatmap.js +92 -166
  149. package/lib/heatmap/models/hexagon.js +28 -60
  150. package/lib/heatmap/models/index.js +0 -6
  151. package/lib/heatmap/triangulation.js +0 -5
  152. package/lib/image/index.js +9 -36
  153. package/lib/image/models/image.js +66 -109
  154. package/lib/image/models/index.js +0 -3
  155. package/lib/index.js +7 -61
  156. package/lib/line/index.js +9 -40
  157. package/lib/line/models/arc.js +61 -122
  158. package/lib/line/models/arc_3d.js +56 -113
  159. package/lib/line/models/earthArc_3d.js +58 -115
  160. package/lib/line/models/flow.js +36 -70
  161. package/lib/line/models/great_circle.js +53 -104
  162. package/lib/line/models/index.js +0 -11
  163. package/lib/line/models/line.js +90 -152
  164. package/lib/line/models/linearline.js +42 -86
  165. package/lib/line/models/simpleLine.js +38 -77
  166. package/lib/line/models/wall.js +52 -103
  167. package/lib/line/shaders/dash/line_dash_vert.glsl +1 -2
  168. package/lib/line/shaders/line_frag.glsl +1 -3
  169. package/lib/line/shaders/line_vert.glsl +2 -0
  170. package/lib/line/shaders/linear/line_linear_frag.glsl +1 -1
  171. package/lib/mask/index.js +9 -36
  172. package/lib/mask/models/fill.js +29 -63
  173. package/lib/mask/models/index.js +0 -3
  174. package/lib/plugins/DataMappingPlugin.js +78 -125
  175. package/lib/plugins/DataSourcePlugin.js +45 -76
  176. package/lib/plugins/FeatureScalePlugin.js +67 -138
  177. package/lib/plugins/LayerAnimateStylePlugin.js +0 -10
  178. package/lib/plugins/LayerMaskPlugin.js +4 -17
  179. package/lib/plugins/LayerModelPlugin.js +70 -127
  180. package/lib/plugins/LayerStylePlugin.js +5 -14
  181. package/lib/plugins/LightingPlugin.js +12 -25
  182. package/lib/plugins/MultiPassRendererPlugin.js +11 -22
  183. package/lib/plugins/PixelPickingPlugin.js +12 -27
  184. package/lib/plugins/RegisterStyleAttributePlugin.js +5 -19
  185. package/lib/plugins/ShaderUniformPlugin.js +13 -34
  186. package/lib/plugins/UpdateModelPlugin.js +1 -10
  187. package/lib/plugins/UpdateStyleAttributePlugin.js +5 -16
  188. package/lib/point/index.js +26 -83
  189. package/lib/point/models/earthExtrude.js +58 -106
  190. package/lib/point/models/earthFill.js +52 -110
  191. package/lib/point/models/extrude.js +57 -103
  192. package/lib/point/models/fill.js +54 -90
  193. package/lib/point/models/fillmage.js +58 -107
  194. package/lib/point/models/image.js +47 -92
  195. package/lib/point/models/index.js +1 -12
  196. package/lib/point/models/normal.js +30 -64
  197. package/lib/point/models/radar.js +38 -72
  198. package/lib/point/models/simplePoint.js +38 -72
  199. package/lib/point/models/text.js +199 -305
  200. package/lib/point/shape/extrude.js +4 -20
  201. package/lib/polygon/index.js +11 -48
  202. package/lib/polygon/models/extrude.js +87 -146
  203. package/lib/polygon/models/fill.js +50 -89
  204. package/lib/polygon/models/index.js +2 -14
  205. package/lib/polygon/models/ocean.js +42 -88
  206. package/lib/polygon/models/water.js +37 -82
  207. package/lib/raster/buffers/triangulation.js +3 -7
  208. package/lib/raster/index.js +9 -40
  209. package/lib/raster/models/index.js +0 -5
  210. package/lib/raster/models/raster.js +80 -125
  211. package/lib/raster/models/rasterRgb.js +84 -139
  212. package/lib/raster/models/rasterTerrainRgb.js +56 -93
  213. package/lib/tile/interaction/getRasterData.js +14 -25
  214. package/lib/tile/interaction/utils.js +7 -19
  215. package/lib/tile/manager/base.js +63 -104
  216. package/lib/tile/service/TileLayerService.js +33 -60
  217. package/lib/tile/service/TilePickService.js +26 -48
  218. package/lib/tile/service/TileSourceService.js +2 -16
  219. package/lib/tile/style/utils.js +0 -3
  220. package/lib/tile/tileFactory/DebugTile.js +29 -54
  221. package/lib/tile/tileFactory/ImageTile.js +20 -46
  222. package/lib/tile/tileFactory/MaskTile.js +22 -51
  223. package/lib/tile/tileFactory/RasterRGBTile.js +22 -50
  224. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +20 -46
  225. package/lib/tile/tileFactory/RasterTile.js +30 -63
  226. package/lib/tile/tileFactory/Tile.js +63 -102
  227. package/lib/tile/tileFactory/VectorTile.js +41 -76
  228. package/lib/tile/tileFactory/index.js +0 -25
  229. package/lib/tile/tileFactory/layers/TileDebugLayer.js +6 -32
  230. package/lib/tile/tileFactory/util.js +0 -9
  231. package/lib/tile/tileLayer/BaseLayer.js +105 -153
  232. package/lib/tile/utils.js +1 -5
  233. package/lib/utils/blend.js +0 -5
  234. package/lib/utils/collision-index.js +9 -25
  235. package/lib/utils/extrude_polyline.js +101 -181
  236. package/lib/utils/grid-index.js +2 -28
  237. package/lib/utils/identityScale.js +0 -9
  238. package/lib/utils/layerData.js +30 -49
  239. package/lib/utils/multiPassRender.js +11 -16
  240. package/lib/utils/polylineNormal.js +31 -66
  241. package/lib/utils/simpleLine.js +2 -21
  242. package/lib/utils/stencil.js +0 -4
  243. package/lib/utils/symbol-layout.js +27 -55
  244. package/lib/wind/index.js +9 -37
  245. package/lib/wind/models/index.js +0 -3
  246. package/lib/wind/models/utils.js +26 -62
  247. package/lib/wind/models/wind.js +101 -157
  248. package/lib/wind/models/windRender.js +53 -71
  249. package/lib/wind/models/windShader.js +0 -1
  250. package/package.json +7 -7
@@ -6,9 +6,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
6
6
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
7
  import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
8
8
  import _initializerWarningHelper from "@babel/runtime/helpers/esm/initializerWarningHelper";
9
-
10
9
  var _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2;
11
-
12
10
  import _regeneratorRuntime from "@babel/runtime/regenerator";
13
11
  import { IDebugLog, ILayerStage, TYPES } from '@antv/l7-core';
14
12
  import { Version } from '@antv/l7-maps';
@@ -19,35 +17,27 @@ import 'reflect-metadata';
19
17
  var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService), _dec3 = inject(TYPES.IFontService), _dec(_class = (_class2 = /*#__PURE__*/function () {
20
18
  function DataMappingPlugin() {
21
19
  _classCallCheck(this, DataMappingPlugin);
22
-
23
20
  _initializerDefineProperty(this, "mapService", _descriptor, this);
24
-
25
21
  _initializerDefineProperty(this, "fontService", _descriptor2, this);
26
22
  }
27
-
28
23
  _createClass(DataMappingPlugin, [{
29
24
  key: "apply",
30
25
  value: function apply(layer, _ref) {
31
26
  var _this = this;
32
-
33
27
  var styleAttributeService = _ref.styleAttributeService;
34
28
  layer.hooks.init.tapPromise('DataMappingPlugin', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
35
29
  return _regeneratorRuntime.wrap(function _callee$(_context) {
36
- while (1) {
37
- switch (_context.prev = _context.next) {
38
- case 0:
39
- layer.log(IDebugLog.MappingStart, ILayerStage.INIT); // 初始化重新生成 map
40
-
41
- _this.generateMaping(layer, {
42
- styleAttributeService: styleAttributeService
43
- });
44
-
45
- layer.log(IDebugLog.MappingEnd, ILayerStage.INIT);
46
-
47
- case 3:
48
- case "end":
49
- return _context.stop();
50
- }
30
+ while (1) switch (_context.prev = _context.next) {
31
+ case 0:
32
+ layer.log(IDebugLog.MappingStart, ILayerStage.INIT);
33
+ // 初始化重新生成 map
34
+ _this.generateMaping(layer, {
35
+ styleAttributeService: styleAttributeService
36
+ });
37
+ layer.log(IDebugLog.MappingEnd, ILayerStage.INIT);
38
+ case 3:
39
+ case "end":
40
+ return _context.stop();
51
41
  }
52
42
  }, _callee);
53
43
  })));
@@ -55,106 +45,95 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
55
45
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(flag) {
56
46
  var mappingResult;
57
47
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
58
- while (1) {
59
- switch (_context2.prev = _context2.next) {
60
- case 0:
61
- if (flag) {
62
- _context2.next = 2;
63
- break;
64
- }
65
-
66
- return _context2.abrupt("return", flag);
67
-
68
- case 2:
69
- layer.dataState.dataMappingNeedUpdate = false;
70
- layer.log(IDebugLog.MappingStart, ILayerStage.UPDATE);
71
- mappingResult = _this.generateMaping(layer, {
72
- styleAttributeService: styleAttributeService
73
- });
74
- layer.log(IDebugLog.MappingEnd, ILayerStage.UPDATE);
75
- return _context2.abrupt("return", mappingResult);
76
-
77
- case 7:
78
- case "end":
79
- return _context2.stop();
80
- }
48
+ while (1) switch (_context2.prev = _context2.next) {
49
+ case 0:
50
+ if (flag) {
51
+ _context2.next = 2;
52
+ break;
53
+ }
54
+ return _context2.abrupt("return", flag);
55
+ case 2:
56
+ layer.dataState.dataMappingNeedUpdate = false;
57
+ layer.log(IDebugLog.MappingStart, ILayerStage.UPDATE);
58
+ mappingResult = _this.generateMaping(layer, {
59
+ styleAttributeService: styleAttributeService
60
+ });
61
+ layer.log(IDebugLog.MappingEnd, ILayerStage.UPDATE);
62
+ return _context2.abrupt("return", mappingResult);
63
+ case 7:
64
+ case "end":
65
+ return _context2.stop();
81
66
  }
82
67
  }, _callee2);
83
68
  }));
84
-
85
69
  return function (_x) {
86
70
  return _ref3.apply(this, arguments);
87
71
  };
88
- }()); // remapping before render
72
+ }());
89
73
 
74
+ // remapping before render
90
75
  layer.hooks.beforeRender.tap('DataMappingPlugin', function () {
91
76
  var source = layer.getSource();
92
-
93
77
  if (layer.layerModelNeedUpdate || !source || !source.inited) {
94
78
  return;
95
79
  }
96
-
97
80
  var attributes = styleAttributeService.getLayerStyleAttributes() || [];
98
81
  var filter = styleAttributeService.getLayerStyleAttribute('filter');
99
- var dataArray = source.data.dataArray; // TODO 数据为空的情况
100
-
82
+ var dataArray = source.data.dataArray;
83
+ // TODO 数据为空的情况
101
84
  if (Array.isArray(dataArray) && dataArray.length === 0) {
102
85
  return;
103
86
  }
104
-
105
87
  var attributesToRemapping = attributes.filter(function (attribute) {
106
88
  return attribute.needRemapping;
107
89
  } // 如果filter变化
108
90
  );
109
- var filterData = dataArray; // 数据过滤完 再执行数据映射
110
91
 
92
+ var filterData = dataArray;
93
+ // 数据过滤完 再执行数据映射
111
94
  if (filter !== null && filter !== void 0 && filter.needRemapping && filter !== null && filter !== void 0 && filter.scale) {
112
95
  filterData = dataArray.filter(function (record) {
113
96
  return _this.applyAttributeMapping(filter, record)[0];
114
97
  });
115
98
  }
116
-
117
99
  if (attributesToRemapping.length) {
118
100
  // 过滤数据
119
101
  var encodeData = _this.mapping(layer, attributesToRemapping, filterData, layer.getEncodedData() // TODO 优化
120
102
  );
121
103
 
122
104
  layer.setEncodedData(encodeData);
123
- } // 处理文本更新,更新文字形状
124
- // layer.emit('remapping', null);
105
+ }
125
106
 
107
+ // 处理文本更新,更新文字形状
108
+ // layer.emit('remapping', null);
126
109
  });
127
110
  }
128
111
  }, {
129
112
  key: "generateMaping",
130
113
  value: function generateMaping(layer, _ref4) {
131
114
  var _this2 = this;
132
-
133
115
  var styleAttributeService = _ref4.styleAttributeService;
134
116
  var attributes = styleAttributeService.getLayerStyleAttributes() || [];
135
117
  var filter = styleAttributeService.getLayerStyleAttribute('filter');
136
118
  var dataArray = layer.getSource().data.dataArray;
137
- var filterData = dataArray; // 数据过滤完 再执行数据映射
138
-
119
+ var filterData = dataArray;
120
+ // 数据过滤完 再执行数据映射
139
121
  if (filter !== null && filter !== void 0 && filter.scale) {
140
122
  filterData = dataArray.filter(function (record) {
141
123
  return _this2.applyAttributeMapping(filter, record)[0];
142
124
  });
143
- } // Tip: layer 对数据做处理
125
+ }
126
+ // Tip: layer 对数据做处理
144
127
  // 数据处理 在数据进行 mapping 生成 encodeData 之前对数据进行处理
145
128
  // 在各个 layer 中继承
146
129
 
147
-
148
130
  filterData = layer.processData(filterData); // 目前只有简单线需要处理
149
-
150
131
  var encodeData = this.mapping(layer, attributes, filterData, undefined);
151
132
  layer.setEncodedData(encodeData);
152
-
153
133
  if (dataArray.length === 0 && layer.encodeDataLength === 0) {
154
134
  return false;
155
- } // 对外暴露事件
156
-
157
-
135
+ }
136
+ // 对外暴露事件
158
137
  layer.emit('dataUpdate', null);
159
138
  return true;
160
139
  }
@@ -162,13 +141,11 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
162
141
  key: "mapping",
163
142
  value: function mapping(layer, attributes, data, predata) {
164
143
  var _this3 = this;
165
-
166
144
  var _ref5 = layer.getLayerConfig(),
167
- _ref5$arrow = _ref5.arrow,
168
- arrow = _ref5$arrow === void 0 ? {
169
- enable: false
170
- } : _ref5$arrow;
171
-
145
+ _ref5$arrow = _ref5.arrow,
146
+ arrow = _ref5$arrow === void 0 ? {
147
+ enable: false
148
+ } : _ref5$arrow;
172
149
  var usedAttributes = attributes.filter(function (attribute) {
173
150
  return attribute.scale !== undefined;
174
151
  }).filter(function (attribute) {
@@ -176,52 +153,47 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
176
153
  });
177
154
  var mappedData = data.map(function (record, i) {
178
155
  var preRecord = predata ? predata[i] : {};
179
-
180
156
  var encodeRecord = _objectSpread({
181
157
  id: record._id,
182
158
  coordinates: record.coordinates
183
159
  }, preRecord);
184
-
185
160
  usedAttributes.forEach(function (attribute) {
186
- var values = _this3.applyAttributeMapping(attribute, record); // TODO: 支持每个属性配置 postprocess}
187
-
188
-
161
+ var values = _this3.applyAttributeMapping(attribute, record);
162
+ // TODO: 支持每个属性配置 postprocess}
189
163
  if (attribute.name === 'color' || attribute.name === 'stroke') {
190
164
  values = values.map(function (c) {
191
165
  return rgb2arr(c);
192
166
  });
193
- } // @ts-ignore
194
-
195
-
196
- encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values; // 增加对 layer/text/iconfont unicode 映射的解析
167
+ }
168
+ // @ts-ignore
169
+ encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values;
197
170
 
171
+ // 增加对 layer/text/iconfont unicode 映射的解析
198
172
  if (attribute.name === 'shape') {
199
173
  encodeRecord.shape = _this3.fontService.getIconFontKey(encodeRecord[attribute.name]);
200
174
  }
201
175
  });
202
-
203
176
  if (arrow.enable && encodeRecord.shape === 'line') {
204
177
  // 只有在线图层且支持配置箭头的时候进行插入顶点的处理
205
- var coords = encodeRecord.coordinates; // @ts-ignore
206
-
178
+ var coords = encodeRecord.coordinates;
179
+ // @ts-ignore
207
180
  if (layer.arrowInsertCount < layer.encodeDataLength) {
208
181
  // Tip: arrowInsert 的判断用于确保每一条线数据 arrow 的属性点只会被植入一次
209
182
  var arrowPoint = _this3.getArrowPoints(coords[0], coords[1]);
210
-
211
- encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint); // @ts-ignore
212
-
183
+ encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
184
+ // @ts-ignore
213
185
  layer.arrowInsertCount++;
214
186
  }
215
187
  }
216
-
217
188
  return encodeRecord;
218
189
  });
219
190
  attributes.forEach(function (attribute) {
220
191
  attribute.needRemapping = false;
221
- }); // 调整数据兼容 Amap2.0
222
-
223
- this.adjustData2Amap2Coordinates(mappedData, layer); // 调整数据兼容 SimpleCoordinates
192
+ });
193
+ // 调整数据兼容 Amap2.0
194
+ this.adjustData2Amap2Coordinates(mappedData, layer);
224
195
 
196
+ // 调整数据兼容 SimpleCoordinates
225
197
  this.adjustData2SimpleCoordinates(mappedData);
226
198
  return mappedData;
227
199
  }
@@ -229,22 +201,21 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
229
201
  key: "adjustData2Amap2Coordinates",
230
202
  value: function adjustData2Amap2Coordinates(mappedData, layer) {
231
203
  var _this4 = this;
232
-
233
204
  // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移
234
205
  if (mappedData.length > 0 && this.mapService.version === Version['GAODE2.x']) {
235
- var layerCenter = layer.coordCenter || layer.getSource().center; // 单个的点数据
206
+ var layerCenter = layer.coordCenter || layer.getSource().center;
207
+ // 单个的点数据
236
208
  // @ts-ignore
237
-
238
- mappedData // TODO: 避免经纬度被重复计算导致坐标位置偏移
209
+ mappedData
210
+ // TODO: 避免经纬度被重复计算导致坐标位置偏移
239
211
  .filter(function (d) {
240
212
  return !d.originCoordinates;
241
213
  }).map(function (d) {
242
- d.version = Version['GAODE2.x']; // @ts-ignore
243
-
214
+ d.version = Version['GAODE2.x'];
215
+ // @ts-ignore
244
216
  d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
245
217
  // @ts-ignore
246
218
  // d.coordinates = this.mapService.lngLatToCoord(d.coordinates);
247
-
248
219
  d.coordinates = _this4.mapService.coordToAMap2RelativeCoordinates(d.coordinates, layerCenter);
249
220
  });
250
221
  }
@@ -253,7 +224,6 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
253
224
  key: "adjustData2SimpleCoordinates",
254
225
  value: function adjustData2SimpleCoordinates(mappedData) {
255
226
  var _this5 = this;
256
-
257
227
  if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {
258
228
  mappedData.map(function (d) {
259
229
  if (!d.simpleCoordinate) {
@@ -267,11 +237,9 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
267
237
  key: "unProjectCoordinates",
268
238
  value: function unProjectCoordinates(coordinates) {
269
239
  var _this6 = this;
270
-
271
240
  if (typeof coordinates[0] === 'number') {
272
241
  return this.mapService.simpleMapCoord.unproject(coordinates);
273
242
  }
274
-
275
243
  if (coordinates[0] && coordinates[0][0] instanceof Array) {
276
244
  // @ts-ignore
277
245
  var coords = [];
@@ -280,20 +248,20 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
280
248
  var c1 = [];
281
249
  coord.map(function (co) {
282
250
  c1.push(_this6.mapService.simpleMapCoord.unproject(co));
283
- }); // @ts-ignore
284
-
251
+ });
252
+ // @ts-ignore
285
253
  coords.push(c1);
286
- }); // @ts-ignore
287
-
254
+ });
255
+ // @ts-ignore
288
256
  return coords;
289
257
  } else {
290
258
  // @ts-ignore
291
- var _coords = []; // @ts-ignore
292
-
259
+ var _coords = [];
260
+ // @ts-ignore
293
261
  coordinates.map(function (coord) {
294
262
  _coords.push(_this6.mapService.simpleMapCoord.unproject(coord));
295
- }); // @ts-ignore
296
-
263
+ });
264
+ // @ts-ignore
297
265
  return _coords;
298
266
  }
299
267
  }
@@ -301,25 +269,22 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
301
269
  key: "applyAttributeMapping",
302
270
  value: function applyAttributeMapping(attribute, record) {
303
271
  var _attribute$scale;
304
-
305
272
  if (!attribute.scale) {
306
273
  return [];
307
274
  }
308
-
309
275
  var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
310
276
  var params = [];
311
277
  scalers.forEach(function (_ref6) {
312
278
  var _attribute$scale2;
313
-
314
279
  var field = _ref6.field;
315
-
316
280
  if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
317
281
  // TODO:多字段,常量
318
282
  params.push(record[field]);
319
283
  }
320
284
  });
321
285
  var mappingResult = attribute.mapping ? attribute.mapping(params) : [];
322
- return mappingResult; // return attribute.mapping ? attribute.mapping(params) : [];
286
+ return mappingResult;
287
+ // return attribute.mapping ? attribute.mapping(params) : [];
323
288
  }
324
289
  }, {
325
290
  key: "getArrowPoints",
@@ -330,7 +295,6 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
330
295
  return arrowPoint;
331
296
  }
332
297
  }]);
333
-
334
298
  return DataMappingPlugin;
335
299
  }(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "mapService", [_dec2], {
336
300
  configurable: true,
@@ -1,9 +1,7 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
-
5
4
  var _dec, _class;
6
-
7
5
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
6
  import { IDebugLog, ILayerStage, TYPES } from '@antv/l7-core';
9
7
  import Source from '@antv/l7-source';
@@ -13,79 +11,64 @@ var DataSourcePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function
13
11
  function DataSourcePlugin() {
14
12
  _classCallCheck(this, DataSourcePlugin);
15
13
  }
16
-
17
14
  _createClass(DataSourcePlugin, [{
18
15
  key: "apply",
19
16
  value: function apply(layer) {
20
17
  var _this = this;
21
-
22
18
  this.mapService = layer.getContainer().get(TYPES.IMapService);
23
19
  layer.hooks.init.tapPromise('DataSourcePlugin', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
24
20
  var source, _ref2, data, options;
25
-
26
21
  return _regeneratorRuntime.wrap(function _callee$(_context) {
27
- while (1) {
28
- switch (_context.prev = _context.next) {
29
- case 0:
30
- layer.log(IDebugLog.SourceInitStart, ILayerStage.INIT);
31
- source = layer.getSource();
32
-
33
- if (!source) {
34
- // Tip: 用户没有传入 source 的时候使用图层的默认数据
35
- _ref2 = layer.sourceOption || layer.defaultSourceConfig, data = _ref2.data, options = _ref2.options;
36
- source = new Source(data, options);
37
- layer.setSource(source);
38
- }
39
-
40
- if (!source.inited) {
41
- _context.next = 8;
42
- break;
43
- }
44
-
45
- _this.updateClusterData(layer);
46
-
47
- layer.log(IDebugLog.SourceInitEnd, ILayerStage.INIT);
48
- _context.next = 10;
22
+ while (1) switch (_context.prev = _context.next) {
23
+ case 0:
24
+ layer.log(IDebugLog.SourceInitStart, ILayerStage.INIT);
25
+ source = layer.getSource();
26
+ if (!source) {
27
+ // Tip: 用户没有传入 source 的时候使用图层的默认数据
28
+ _ref2 = layer.sourceOption || layer.defaultSourceConfig, data = _ref2.data, options = _ref2.options;
29
+ source = new Source(data, options);
30
+ layer.setSource(source);
31
+ }
32
+ if (!source.inited) {
33
+ _context.next = 8;
49
34
  break;
50
-
51
- case 8:
52
- _context.next = 10;
53
- return new Promise(function (resolve) {
54
- source.on('update', function (e) {
55
- if (e.type === 'inited') {
56
- _this.updateClusterData(layer);
57
-
58
- layer.log(IDebugLog.SourceInitEnd, ILayerStage.INIT);
59
- }
60
-
61
- resolve(null);
62
- });
35
+ }
36
+ _this.updateClusterData(layer);
37
+ layer.log(IDebugLog.SourceInitEnd, ILayerStage.INIT);
38
+ _context.next = 10;
39
+ break;
40
+ case 8:
41
+ _context.next = 10;
42
+ return new Promise(function (resolve) {
43
+ source.on('update', function (e) {
44
+ if (e.type === 'inited') {
45
+ _this.updateClusterData(layer);
46
+ layer.log(IDebugLog.SourceInitEnd, ILayerStage.INIT);
47
+ }
48
+ resolve(null);
63
49
  });
64
-
65
- case 10:
66
- case "end":
67
- return _context.stop();
68
- }
50
+ });
51
+ case 10:
52
+ case "end":
53
+ return _context.stop();
69
54
  }
70
55
  }, _callee);
71
- }))); // 检测数据是否需要更新
56
+ })));
72
57
 
58
+ // 检测数据是否需要更新
73
59
  layer.hooks.beforeRenderData.tapPromise('DataSourcePlugin', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
74
60
  var neeUpdateCluster, dataSourceNeedUpdate, needScale;
75
61
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
76
- while (1) {
77
- switch (_context2.prev = _context2.next) {
78
- case 0:
79
- neeUpdateCluster = _this.updateClusterData(layer);
80
- dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
81
- layer.dataState.dataSourceNeedUpdate = false;
82
- needScale = neeUpdateCluster || dataSourceNeedUpdate;
83
- return _context2.abrupt("return", needScale);
84
-
85
- case 5:
86
- case "end":
87
- return _context2.stop();
88
- }
62
+ while (1) switch (_context2.prev = _context2.next) {
63
+ case 0:
64
+ neeUpdateCluster = _this.updateClusterData(layer);
65
+ dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
66
+ layer.dataState.dataSourceNeedUpdate = false;
67
+ needScale = neeUpdateCluster || dataSourceNeedUpdate;
68
+ return _context2.abrupt("return", needScale);
69
+ case 5:
70
+ case "end":
71
+ return _context2.stop();
89
72
  }
90
73
  }, _callee2);
91
74
  })));
@@ -97,33 +80,27 @@ var DataSourcePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function
97
80
  if (layer.isTileLayer || layer.tileLayer || !layer.getSource()) {
98
81
  return false;
99
82
  }
100
-
101
83
  var source = layer.getSource();
102
84
  var cluster = source.cluster;
103
85
  var _source$clusterOption = source.clusterOptions.zoom,
104
- zoom = _source$clusterOption === void 0 ? 0 : _source$clusterOption;
86
+ zoom = _source$clusterOption === void 0 ? 0 : _source$clusterOption;
105
87
  var newZoom = this.mapService.getZoom() - 1;
106
88
  var dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
107
-
108
89
  if (cluster && dataSourceNeedUpdate) {
109
90
  // 数据发生更新
110
91
  source.updateClusterData(Math.floor(newZoom));
111
- } // 如果 dataSource 有更新,跳过 zoom 的判断,直接更新一次
112
-
113
-
92
+ }
93
+ // 如果 dataSource 有更新,跳过 zoom 的判断,直接更新一次
114
94
  if (cluster && Math.abs(layer.clusterZoom - newZoom) >= 1) {
115
95
  if (zoom !== Math.floor(newZoom)) {
116
96
  source.updateClusterData(Math.floor(newZoom));
117
97
  }
118
-
119
98
  layer.clusterZoom = newZoom;
120
99
  return true;
121
100
  }
122
-
123
101
  return false;
124
102
  }
125
103
  }]);
126
-
127
104
  return DataSourcePlugin;
128
105
  }()) || _class);
129
106
  export { DataSourcePlugin as default };