@antv/l7-layers 2.17.3 → 2.17.4

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