@antv/l7-layers 2.15.2 → 2.15.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 +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 +320 -484
  10. package/es/core/BaseModel.js +97 -126
  11. package/es/core/LayerPickService.js +21 -32
  12. package/es/core/TextureService.js +0 -13
  13. package/es/core/interface.js +17 -24
  14. package/es/core/shape/Path.js +13 -20
  15. package/es/core/shape/extrude.js +10 -31
  16. package/es/core/triangulation.js +54 -114
  17. package/es/earth/index.js +9 -33
  18. package/es/earth/models/atmosphere.js +30 -54
  19. package/es/earth/models/base.js +47 -85
  20. package/es/earth/models/bloomsphere.js +30 -54
  21. package/es/earth/utils.js +9 -13
  22. package/es/heatmap/index.js +10 -40
  23. package/es/heatmap/models/grid.js +28 -52
  24. package/es/heatmap/models/grid3d.js +28 -52
  25. package/es/heatmap/models/heatmap.js +91 -146
  26. package/es/heatmap/models/hexagon.js +28 -52
  27. package/es/heatmap/triangulation.js +0 -4
  28. package/es/image/index.js +9 -28
  29. package/es/image/models/image.js +66 -100
  30. package/es/index.js +9 -17
  31. package/es/line/index.js +9 -34
  32. package/es/line/models/arc.js +66 -118
  33. package/es/line/models/arc_3d.js +60 -108
  34. package/es/line/models/earthArc_3d.js +63 -111
  35. package/es/line/models/great_circle.js +56 -100
  36. package/es/line/models/half.js +46 -77
  37. package/es/line/models/line.js +94 -148
  38. package/es/line/models/linearline.js +45 -80
  39. package/es/line/models/simpleLine.js +41 -74
  40. package/es/line/models/wall.js +52 -92
  41. package/es/mask/index.js +9 -28
  42. package/es/mask/models/fill.js +29 -54
  43. package/es/plugins/DataMappingPlugin.js +80 -117
  44. package/es/plugins/DataSourcePlugin.js +45 -68
  45. package/es/plugins/FeatureScalePlugin.js +67 -122
  46. package/es/plugins/LayerAnimateStylePlugin.js +0 -5
  47. package/es/plugins/LayerMaskPlugin.js +3 -11
  48. package/es/plugins/LayerModelPlugin.js +67 -104
  49. package/es/plugins/LayerStylePlugin.js +3 -9
  50. package/es/plugins/LightingPlugin.js +12 -18
  51. package/es/plugins/MultiPassRendererPlugin.js +11 -16
  52. package/es/plugins/PixelPickingPlugin.js +12 -21
  53. package/es/plugins/RegisterStyleAttributePlugin.js +5 -12
  54. package/es/plugins/ShaderUniformPlugin.js +13 -27
  55. package/es/plugins/UpdateModelPlugin.js +0 -5
  56. package/es/plugins/UpdateStyleAttributePlugin.js +5 -11
  57. package/es/point/index.js +26 -77
  58. package/es/point/models/earthExtrude.js +61 -102
  59. package/es/point/models/earthFill.js +57 -87
  60. package/es/point/models/extrude.js +60 -101
  61. package/es/point/models/fill.js +70 -100
  62. package/es/point/models/fillmage.js +63 -107
  63. package/es/point/models/image.js +48 -88
  64. package/es/point/models/index.js +2 -2
  65. package/es/point/models/normal.js +30 -54
  66. package/es/point/models/radar.js +40 -64
  67. package/es/point/models/simplePoint.js +41 -69
  68. package/es/point/models/text.js +197 -299
  69. package/es/point/shape/extrude.js +4 -13
  70. package/es/polygon/index.js +11 -40
  71. package/es/polygon/models/extrude.js +48 -92
  72. package/es/polygon/models/fill.js +54 -88
  73. package/es/polygon/models/index.js +3 -2
  74. package/es/polygon/models/ocean.js +42 -76
  75. package/es/polygon/models/water.js +37 -71
  76. package/es/raster/buffers/triangulation.js +2 -4
  77. package/es/raster/index.js +9 -32
  78. package/es/raster/models/raster.js +80 -116
  79. package/es/raster/models/rasterRgb.js +84 -127
  80. package/es/raster/models/rasterTerrainRgb.js +56 -84
  81. package/es/tile/interaction/getRasterData.js +14 -20
  82. package/es/tile/interaction/utils.js +7 -9
  83. package/es/tile/manager/base.js +63 -96
  84. package/es/tile/service/TileLayerService.js +30 -52
  85. package/es/tile/service/TilePickService.js +26 -40
  86. package/es/tile/service/TileSourceService.js +3 -7
  87. package/es/tile/tileFactory/DebugTile.js +28 -45
  88. package/es/tile/tileFactory/ImageTile.js +20 -38
  89. package/es/tile/tileFactory/MaskTile.js +22 -43
  90. package/es/tile/tileFactory/RasterRGBTile.js +22 -42
  91. package/es/tile/tileFactory/RasterTerrainRGBTile.js +20 -38
  92. package/es/tile/tileFactory/RasterTile.js +30 -53
  93. package/es/tile/tileFactory/Tile.js +63 -97
  94. package/es/tile/tileFactory/VectorTile.js +41 -68
  95. package/es/tile/tileFactory/index.js +0 -11
  96. package/es/tile/tileFactory/layers/TileDebugLayer.js +6 -27
  97. package/es/tile/tileFactory/util.js +0 -3
  98. package/es/tile/tileLayer/BaseLayer.js +105 -146
  99. package/es/tile/utils.js +1 -1
  100. package/es/utils/blend.js +0 -2
  101. package/es/utils/collision-index.js +9 -16
  102. package/es/utils/dataMappingStyle.js +8 -18
  103. package/es/utils/extrude_polyline.js +101 -149
  104. package/es/utils/grid-index.js +2 -27
  105. package/es/utils/identityScale.js +0 -8
  106. package/es/utils/layerData.js +30 -44
  107. package/es/utils/multiPassRender.js +11 -13
  108. package/es/utils/polylineNormal.js +31 -37
  109. package/es/utils/simpleLine.js +2 -16
  110. package/es/utils/stencil.js +2 -3
  111. package/es/utils/symbol-layout.js +27 -53
  112. package/es/wind/index.js +9 -29
  113. package/es/wind/models/utils.js +26 -51
  114. package/es/wind/models/wind.js +101 -147
  115. package/es/wind/models/windRender.js +53 -66
  116. package/lib/Geometry/index.js +9 -38
  117. package/lib/Geometry/models/billboard.js +51 -97
  118. package/lib/Geometry/models/index.js +0 -5
  119. package/lib/Geometry/models/plane.js +79 -151
  120. package/lib/Geometry/models/sprite.js +60 -127
  121. package/lib/canvas/index.js +10 -40
  122. package/lib/canvas/models/canvas.js +41 -101
  123. package/lib/canvas/models/index.js +0 -3
  124. package/lib/citybuliding/building.js +8 -35
  125. package/lib/citybuliding/models/build.js +57 -92
  126. package/lib/core/BaseLayer.js +320 -478
  127. package/lib/core/BaseModel.js +97 -139
  128. package/lib/core/LayerPickService.js +21 -37
  129. package/lib/core/TextureService.js +0 -16
  130. package/lib/core/interface.js +21 -31
  131. package/lib/core/schema.js +0 -1
  132. package/lib/core/shape/Path.js +14 -31
  133. package/lib/core/shape/extrude.js +10 -54
  134. package/lib/core/triangulation.js +53 -153
  135. package/lib/earth/index.js +9 -43
  136. package/lib/earth/models/atmosphere.js +30 -63
  137. package/lib/earth/models/base.js +47 -90
  138. package/lib/earth/models/bloomsphere.js +30 -63
  139. package/lib/earth/utils.js +7 -31
  140. package/lib/heatmap/index.js +10 -48
  141. package/lib/heatmap/models/grid.js +28 -60
  142. package/lib/heatmap/models/grid3d.js +28 -60
  143. package/lib/heatmap/models/heatmap.js +91 -162
  144. package/lib/heatmap/models/hexagon.js +28 -60
  145. package/lib/heatmap/models/index.js +0 -6
  146. package/lib/heatmap/triangulation.js +0 -5
  147. package/lib/image/index.js +9 -36
  148. package/lib/image/models/image.js +66 -109
  149. package/lib/image/models/index.js +0 -3
  150. package/lib/index.js +7 -61
  151. package/lib/line/index.js +9 -40
  152. package/lib/line/models/arc.js +64 -128
  153. package/lib/line/models/arc_3d.js +58 -119
  154. package/lib/line/models/earthArc_3d.js +61 -122
  155. package/lib/line/models/great_circle.js +56 -111
  156. package/lib/line/models/half.js +46 -87
  157. package/lib/line/models/index.js +0 -11
  158. package/lib/line/models/line.js +92 -156
  159. package/lib/line/models/linearline.js +45 -92
  160. package/lib/line/models/simpleLine.js +41 -84
  161. package/lib/line/models/wall.js +52 -103
  162. package/lib/mask/index.js +9 -36
  163. package/lib/mask/models/fill.js +29 -63
  164. package/lib/mask/models/index.js +0 -3
  165. package/lib/plugins/DataMappingPlugin.js +80 -128
  166. package/lib/plugins/DataSourcePlugin.js +45 -76
  167. package/lib/plugins/FeatureScalePlugin.js +67 -138
  168. package/lib/plugins/LayerAnimateStylePlugin.js +0 -10
  169. package/lib/plugins/LayerMaskPlugin.js +4 -17
  170. package/lib/plugins/LayerModelPlugin.js +68 -113
  171. package/lib/plugins/LayerStylePlugin.js +4 -14
  172. package/lib/plugins/LightingPlugin.js +12 -25
  173. package/lib/plugins/MultiPassRendererPlugin.js +11 -22
  174. package/lib/plugins/PixelPickingPlugin.js +12 -27
  175. package/lib/plugins/RegisterStyleAttributePlugin.js +5 -19
  176. package/lib/plugins/ShaderUniformPlugin.js +13 -34
  177. package/lib/plugins/UpdateModelPlugin.js +1 -10
  178. package/lib/plugins/UpdateStyleAttributePlugin.js +5 -16
  179. package/lib/point/index.js +26 -83
  180. package/lib/point/models/earthExtrude.js +61 -113
  181. package/lib/point/models/earthFill.js +57 -117
  182. package/lib/point/models/extrude.js +60 -111
  183. package/lib/point/models/fill.js +68 -109
  184. package/lib/point/models/fillmage.js +61 -115
  185. package/lib/point/models/image.js +48 -98
  186. package/lib/point/models/index.js +1 -12
  187. package/lib/point/models/normal.js +30 -64
  188. package/lib/point/models/radar.js +40 -74
  189. package/lib/point/models/simplePoint.js +41 -79
  190. package/lib/point/models/text.js +197 -307
  191. package/lib/point/shape/extrude.js +4 -20
  192. package/lib/polygon/index.js +11 -48
  193. package/lib/polygon/models/extrude.js +48 -103
  194. package/lib/polygon/models/fill.js +54 -98
  195. package/lib/polygon/models/index.js +2 -14
  196. package/lib/polygon/models/ocean.js +42 -88
  197. package/lib/polygon/models/water.js +37 -82
  198. package/lib/raster/buffers/triangulation.js +3 -7
  199. package/lib/raster/index.js +9 -40
  200. package/lib/raster/models/index.js +0 -5
  201. package/lib/raster/models/raster.js +80 -125
  202. package/lib/raster/models/rasterRgb.js +84 -139
  203. package/lib/raster/models/rasterTerrainRgb.js +56 -93
  204. package/lib/tile/interaction/getRasterData.js +14 -25
  205. package/lib/tile/interaction/utils.js +7 -19
  206. package/lib/tile/manager/base.js +63 -104
  207. package/lib/tile/service/TileLayerService.js +30 -57
  208. package/lib/tile/service/TilePickService.js +26 -48
  209. package/lib/tile/service/TileSourceService.js +2 -16
  210. package/lib/tile/style/utils.js +0 -3
  211. package/lib/tile/tileFactory/DebugTile.js +28 -53
  212. package/lib/tile/tileFactory/ImageTile.js +20 -46
  213. package/lib/tile/tileFactory/MaskTile.js +22 -51
  214. package/lib/tile/tileFactory/RasterRGBTile.js +22 -50
  215. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +20 -46
  216. package/lib/tile/tileFactory/RasterTile.js +30 -63
  217. package/lib/tile/tileFactory/Tile.js +63 -102
  218. package/lib/tile/tileFactory/VectorTile.js +41 -76
  219. package/lib/tile/tileFactory/index.js +0 -25
  220. package/lib/tile/tileFactory/layers/TileDebugLayer.js +6 -32
  221. package/lib/tile/tileFactory/util.js +0 -9
  222. package/lib/tile/tileLayer/BaseLayer.js +105 -153
  223. package/lib/tile/utils.js +1 -5
  224. package/lib/utils/blend.js +0 -5
  225. package/lib/utils/collision-index.js +9 -25
  226. package/lib/utils/dataMappingStyle.js +8 -19
  227. package/lib/utils/extrude_polyline.js +101 -181
  228. package/lib/utils/grid-index.js +2 -28
  229. package/lib/utils/identityScale.js +0 -9
  230. package/lib/utils/layerData.js +30 -49
  231. package/lib/utils/multiPassRender.js +11 -16
  232. package/lib/utils/polylineNormal.js +31 -66
  233. package/lib/utils/simpleLine.js +2 -21
  234. package/lib/utils/stencil.js +0 -4
  235. package/lib/utils/symbol-layout.js +27 -55
  236. package/lib/wind/index.js +9 -37
  237. package/lib/wind/models/index.js +0 -3
  238. package/lib/wind/models/utils.js +26 -62
  239. package/lib/wind/models/wind.js +101 -157
  240. package/lib/wind/models/windRender.js +53 -71
  241. package/lib/wind/models/windShader.js +0 -1
  242. package/package.json +7 -7
@@ -1,13 +1,9 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
-
5
4
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
6
-
7
5
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
-
9
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
10
-
6
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
7
  /**
12
8
  * 网格索引,相比 @mapbox/grid-index,在简单计算碰撞检测结果时效率更高
13
9
  * @see https://zhuanlan.zhihu.com/p/74373214
@@ -15,17 +11,13 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
15
11
  var GridIndex = /*#__PURE__*/function () {
16
12
  function GridIndex(width, height, cellSize) {
17
13
  _classCallCheck(this, GridIndex);
18
-
19
14
  _defineProperty(this, "boxCells", []);
20
-
21
15
  var boxCells = this.boxCells;
22
16
  this.xCellCount = Math.ceil(width / cellSize);
23
17
  this.yCellCount = Math.ceil(height / cellSize);
24
-
25
18
  for (var i = 0; i < this.xCellCount * this.yCellCount; i++) {
26
19
  boxCells.push([]);
27
20
  }
28
-
29
21
  this.boxKeys = [];
30
22
  this.bboxes = [];
31
23
  this.width = width;
@@ -34,7 +26,6 @@ var GridIndex = /*#__PURE__*/function () {
34
26
  this.yScale = this.yCellCount / height;
35
27
  this.boxUid = 0;
36
28
  }
37
-
38
29
  _createClass(GridIndex, [{
39
30
  key: "insert",
40
31
  value: function insert(key, x1, y1, x2, y2) {
@@ -66,15 +57,12 @@ var GridIndex = /*#__PURE__*/function () {
66
57
  if (x2 < 0 || x1 > this.width || y2 < 0 || y1 > this.height) {
67
58
  return hitTest ? false : [];
68
59
  }
69
-
70
60
  var result = [];
71
-
72
61
  if (x1 <= 0 && y1 <= 0 && this.width <= x2 && this.height <= y2) {
73
62
  // 这一步是高效的关键,后续精确碰撞检测结果在计算文本可见性时并不需要
74
63
  if (hitTest) {
75
64
  return true;
76
65
  }
77
-
78
66
  for (var boxUid = 0; boxUid < this.boxKeys.length; boxUid++) {
79
67
  result.push({
80
68
  key: this.boxKeys[boxUid],
@@ -84,10 +72,8 @@ var GridIndex = /*#__PURE__*/function () {
84
72
  y2: this.bboxes[boxUid * 4 + 3]
85
73
  });
86
74
  }
87
-
88
75
  return predicate ? result.filter(predicate) : result;
89
76
  }
90
-
91
77
  var queryArgs = {
92
78
  hitTest: hitTest,
93
79
  seenUids: {
@@ -103,27 +89,21 @@ var GridIndex = /*#__PURE__*/function () {
103
89
  value: function queryCell(x1, y1, x2, y2, cellIndex, result, queryArgs, predicate) {
104
90
  var seenUids = queryArgs.seenUids;
105
91
  var boxCell = this.boxCells[cellIndex];
106
-
107
92
  if (boxCell !== null) {
108
93
  var bboxes = this.bboxes;
109
-
110
94
  var _iterator = _createForOfIteratorHelper(boxCell),
111
- _step;
112
-
95
+ _step;
113
96
  try {
114
97
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
115
98
  var boxUid = _step.value;
116
-
117
99
  if (!seenUids.box[boxUid]) {
118
100
  seenUids.box[boxUid] = true;
119
101
  var offset = boxUid * 4;
120
-
121
102
  if (x1 <= bboxes[offset + 2] && y1 <= bboxes[offset + 3] && x2 >= bboxes[offset + 0] && y2 >= bboxes[offset + 1] && (!predicate || predicate(this.boxKeys[boxUid]))) {
122
103
  if (queryArgs.hitTest) {
123
104
  result.push(true);
124
105
  return true;
125
106
  }
126
-
127
107
  result.push({
128
108
  key: this.boxKeys[boxUid],
129
109
  x1: bboxes[offset],
@@ -140,7 +120,6 @@ var GridIndex = /*#__PURE__*/function () {
140
120
  _iterator.f();
141
121
  }
142
122
  }
143
-
144
123
  return false;
145
124
  }
146
125
  }, {
@@ -150,11 +129,9 @@ var GridIndex = /*#__PURE__*/function () {
150
129
  var cy1 = this.convertToYCellCoord(y1);
151
130
  var cx2 = this.convertToXCellCoord(x2);
152
131
  var cy2 = this.convertToYCellCoord(y2);
153
-
154
132
  for (var x = cx1; x <= cx2; x++) {
155
133
  for (var y = cy1; y <= cy2; y++) {
156
134
  var cellIndex = this.xCellCount * y + x;
157
-
158
135
  if (fn.call(this, x1, y1, x2, y2, cellIndex, arg1, arg2, predicate)) {
159
136
  return;
160
137
  }
@@ -172,8 +149,6 @@ var GridIndex = /*#__PURE__*/function () {
172
149
  return Math.max(0, Math.min(this.yCellCount - 1, Math.floor(y * this.yScale)));
173
150
  }
174
151
  }]);
175
-
176
152
  return GridIndex;
177
153
  }();
178
-
179
154
  export default GridIndex;
@@ -1,34 +1,26 @@
1
1
  export default function identity(d) {
2
2
  var unknown;
3
3
  var domain = [];
4
-
5
4
  function scale(x) {
6
5
  return x == null ? unknown : x;
7
6
  }
8
-
9
7
  scale.invert = scale;
10
-
11
8
  scale.domain = scale.range = function (v) {
12
9
  if (v) {
13
10
  domain = v;
14
11
  return v;
15
12
  }
16
-
17
13
  return domain;
18
14
  };
19
-
20
15
  scale.unknown = function (v) {
21
16
  if (v) {
22
17
  unknown = v;
23
18
  return v;
24
19
  }
25
-
26
20
  return unknown;
27
21
  };
28
-
29
22
  scale.copy = function () {
30
23
  return identity(d).unknown(unknown);
31
24
  };
32
-
33
25
  return scale;
34
26
  }
@@ -2,53 +2,49 @@ import { Version } from '@antv/l7-maps';
2
2
  import Source from '@antv/l7-source';
3
3
  import { normalize, rgb2arr } from '@antv/l7-utils';
4
4
  import { cloneDeep } from 'lodash';
5
-
6
5
  function getArrowPoints(p1, p2) {
7
6
  var dir = [p2[0] - p1[0], p2[1] - p1[1]];
8
7
  var normalizeDir = normalize(dir);
9
8
  var arrowPoint = [p1[0] + normalizeDir[0] * 0.0001, p1[1] + normalizeDir[1] * 0.0001];
10
9
  return arrowPoint;
11
10
  }
12
-
13
11
  function adjustData2Amap2Coordinates(mappedData, mapService, layer) {
14
12
  // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移
15
13
  if (mappedData.length > 0 && mapService.version === Version['GAODE2.x']) {
16
14
  var layerCenter = layer.coordCenter;
17
-
18
15
  if (typeof mappedData[0].coordinates[0] === 'number') {
19
16
  // 单个的点数据
20
17
  // @ts-ignore
21
- mappedData // 避免经纬度被重复计算导致坐标位置偏移
18
+ mappedData
19
+ // 避免经纬度被重复计算导致坐标位置偏移
22
20
  .filter(function (d) {
23
21
  return !d.originCoordinates;
24
22
  }).map(function (d) {
25
- d.version = Version['GAODE2.x']; // @ts-ignore
26
-
23
+ d.version = Version['GAODE2.x'];
24
+ // @ts-ignore
27
25
  d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
28
26
  // @ts-ignore
29
27
  // d.coordinates = mapService.lngLatToCoord(d.coordinates);
30
-
31
28
  d.coordinates = mapService.lngLatToCoordByLayer(d.coordinates, layerCenter);
32
29
  });
33
30
  } else {
34
31
  // 连续的线、面数据
35
32
  // @ts-ignore
36
- mappedData // 避免经纬度被重复计算导致坐标位置偏移
33
+ mappedData
34
+ // 避免经纬度被重复计算导致坐标位置偏移
37
35
  .filter(function (d) {
38
36
  return !d.originCoordinates;
39
37
  }).map(function (d) {
40
- d.version = Version['GAODE2.x']; // @ts-ignore
41
-
38
+ d.version = Version['GAODE2.x'];
39
+ // @ts-ignore
42
40
  d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
43
41
  // @ts-ignore
44
42
  // d.coordinates = mapService.lngLatToCoords(d.coordinates);
45
-
46
43
  d.coordinates = mapService.lngLatToCoordsByLayer(d.coordinates, layerCenter);
47
44
  });
48
45
  }
49
46
  }
50
47
  }
51
-
52
48
  function adjustData2SimpleCoordinates(mappedData, mapService) {
53
49
  if (mappedData.length > 0 && mapService.version === Version.SIMPLE) {
54
50
  mappedData.map(function (d) {
@@ -59,12 +55,10 @@ function adjustData2SimpleCoordinates(mappedData, mapService) {
59
55
  });
60
56
  }
61
57
  }
62
-
63
58
  function unProjectCoordinates(coordinates, mapService) {
64
59
  if (typeof coordinates[0] === 'number') {
65
60
  return mapService.simpleMapCoord.unproject(coordinates);
66
61
  }
67
-
68
62
  if (coordinates[0] && coordinates[0][0] instanceof Array) {
69
63
  // @ts-ignore
70
64
  var coords = [];
@@ -73,38 +67,33 @@ function unProjectCoordinates(coordinates, mapService) {
73
67
  var c1 = [];
74
68
  coord.map(function (co) {
75
69
  c1.push(mapService.simpleMapCoord.unproject(co));
76
- }); // @ts-ignore
77
-
70
+ });
71
+ // @ts-ignore
78
72
  coords.push(c1);
79
- }); // @ts-ignore
80
-
73
+ });
74
+ // @ts-ignore
81
75
  return coords;
82
76
  } else {
83
77
  // @ts-ignore
84
- var _coords = []; // @ts-ignore
85
-
78
+ var _coords = [];
79
+ // @ts-ignore
86
80
  coordinates.map(function (coord) {
87
81
  _coords.push(mapService.simpleMapCoord.unproject(coord));
88
- }); // @ts-ignore
89
-
82
+ });
83
+ // @ts-ignore
90
84
  return _coords;
91
85
  }
92
86
  }
93
-
94
87
  function applyAttributeMapping(attribute, record) {
95
88
  var _attribute$scale;
96
-
97
89
  if (!attribute.scale) {
98
90
  return [];
99
91
  }
100
-
101
92
  var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
102
93
  var params = [];
103
94
  scalers.forEach(function (_ref) {
104
95
  var _attribute$scale2;
105
-
106
96
  var field = _ref.field;
107
-
108
97
  if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
109
98
  // TODO:多字段,常量
110
99
  params.push(record[field]);
@@ -113,14 +102,12 @@ function applyAttributeMapping(attribute, record) {
113
102
  var mappingResult = attribute.mapping ? attribute.mapping(params) : [];
114
103
  return mappingResult;
115
104
  }
116
-
117
105
  function mapping(attributes, data, fontService, mapService, layer) {
118
106
  var _ref2 = layer === null || layer === void 0 ? void 0 : layer.getLayerConfig(),
119
- _ref2$arrow = _ref2.arrow,
120
- arrow = _ref2$arrow === void 0 ? {
121
- enable: false
122
- } : _ref2$arrow;
123
-
107
+ _ref2$arrow = _ref2.arrow,
108
+ arrow = _ref2$arrow === void 0 ? {
109
+ enable: false
110
+ } : _ref2$arrow;
124
111
  var mappedData = data.map(function (record) {
125
112
  var encodeRecord = {
126
113
  id: record._id,
@@ -130,38 +117,37 @@ function mapping(attributes, data, fontService, mapService, layer) {
130
117
  return attribute.scale !== undefined;
131
118
  }).forEach(function (attribute) {
132
119
  var values = applyAttributeMapping(attribute, record);
133
- attribute.needRemapping = false; // TODO: 支持每个属性配置 postprocess
120
+ attribute.needRemapping = false;
134
121
 
122
+ // TODO: 支持每个属性配置 postprocess
135
123
  if (attribute.name === 'color') {
136
124
  values = values.map(function (c) {
137
125
  return rgb2arr(c);
138
126
  });
139
- } // @ts-ignore
140
-
141
-
142
- encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values; // 增加对 layer/text/iconfont unicode 映射的解析
127
+ }
128
+ // @ts-ignore
129
+ encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values;
143
130
 
131
+ // 增加对 layer/text/iconfont unicode 映射的解析
144
132
  if (attribute.name === 'shape') {
145
133
  encodeRecord.shape = fontService.getIconFontKey(encodeRecord[attribute.name]);
146
134
  }
147
135
  });
148
-
149
136
  if (encodeRecord.shape === 'line' && arrow.enable) {
150
137
  // 只有在线图层且支持配置箭头的时候进行插入顶点的处理
151
138
  var coords = encodeRecord.coordinates;
152
139
  var arrowPoint = getArrowPoints(coords[0], coords[1]);
153
140
  encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
154
141
  }
155
-
156
142
  return encodeRecord;
157
- }); // 调整数据兼容 Amap2.0
158
-
159
- adjustData2Amap2Coordinates(mappedData, mapService, layer); // 调整数据兼容 SimpleCoordinates
143
+ });
144
+ // 调整数据兼容 Amap2.0
145
+ adjustData2Amap2Coordinates(mappedData, mapService, layer);
160
146
 
147
+ // 调整数据兼容 SimpleCoordinates
161
148
  adjustData2SimpleCoordinates(mappedData, mapService);
162
149
  return mappedData;
163
150
  }
164
-
165
151
  export function calculateData(layer, fontService, mapService, styleAttributeService, data, options) {
166
152
  var source = new Source(data, options);
167
153
  var attributes = styleAttributeService.getLayerStyleAttributes() || [];
@@ -1,5 +1,4 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
-
3
2
  /**
4
3
  * 'blurH' -> ['blurH', {}]
5
4
  */
@@ -8,42 +7,41 @@ export function normalizePasses(passes) {
8
7
  if (typeof pass === 'string') {
9
8
  pass = [pass, {}];
10
9
  }
11
-
12
10
  return pass;
13
11
  });
14
12
  }
13
+
15
14
  /**
16
15
  * 默认添加 ClearPass、RenderPass
17
16
  * 以及 PostProcessing 中的最后一个 CopyPass
18
17
  */
19
-
20
18
  export function createMultiPassRenderer(layer, passes, postProcessingPassFactory, normalPassFactory) {
21
19
  var multiPassRenderer = layer.multiPassRenderer;
22
-
23
20
  var _layer$getLayerConfig = layer.getLayerConfig(),
24
- enableTAA = _layer$getLayerConfig.enableTAA; // picking pass if enabled
21
+ enableTAA = _layer$getLayerConfig.enableTAA;
22
+
23
+ // picking pass if enabled
25
24
  // if (enablePicking) {
26
25
  // multiPassRenderer.add(normalPassFactory('pixelPicking'));
27
26
  // }
28
- // use TAA pass if enabled instead of render pass
29
-
30
27
 
28
+ // use TAA pass if enabled instead of render pass
31
29
  if (enableTAA) {
32
30
  multiPassRenderer.add(normalPassFactory('taa'));
33
31
  } else {
34
32
  // render all layers in this pass
35
33
  multiPassRenderer.add(normalPassFactory('render'));
36
- } // post processing
37
-
34
+ }
38
35
 
36
+ // post processing
39
37
  normalizePasses(passes).forEach(function (pass) {
40
38
  var _pass = _slicedToArray(pass, 2),
41
- passName = _pass[0],
42
- initializationOptions = _pass[1];
43
-
39
+ passName = _pass[0],
40
+ initializationOptions = _pass[1];
44
41
  multiPassRenderer.add(postProcessingPassFactory(passName), initializationOptions);
45
- }); // 末尾为固定的 CopyPass
42
+ });
46
43
 
44
+ // 末尾为固定的 CopyPass
47
45
  multiPassRenderer.add(postProcessingPassFactory('copy'));
48
46
  return multiPassRenderer;
49
47
  }
@@ -18,29 +18,24 @@ export function direction(out, a, b) {
18
18
  vec2.normalize(out, out);
19
19
  return out;
20
20
  }
21
-
22
21
  function extrusions(positions, out, miters, point, normal, scale) {
23
22
  addNext(out, miters, normal, -scale);
24
23
  addNext(out, miters, normal, scale);
25
24
  positions.push(point[0], point[1], 0);
26
25
  positions.push(point[0], point[1], 0);
27
26
  }
28
-
29
27
  function addNext(out, miters, normal, length) {
30
28
  out.push(normal[0], normal[1], 0);
31
29
  miters.push(length);
32
30
  }
33
-
34
31
  function lineSegmentDistance(b1, a1) {
35
32
  var dx = a1[0] - b1[0];
36
33
  var dy = a1[1] - b1[1];
37
34
  return Math.sqrt(dx * dx + dy * dy);
38
35
  }
39
-
40
36
  function isPointEqual(a, b) {
41
37
  return a[0] === b[0] && a[1] === b[1];
42
38
  }
43
-
44
39
  export default function (points, closed, indexOffset) {
45
40
  var isDash = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
46
41
  var lineA = vec2.fromValues(0, 0);
@@ -57,55 +52,46 @@ export default function (points, closed, indexOffset) {
57
52
  var attrIndex = [];
58
53
  var miters = [];
59
54
  var attrDistance = [0, 0];
60
-
61
55
  if (closed) {
62
56
  points = points.slice();
63
57
  points.push(points[0]);
64
58
  }
65
-
66
59
  var total = points.length;
67
-
68
60
  for (var i = 1; i < total; i++) {
69
61
  var index = count;
70
62
  var last = vec2.fromValues(points[i - 1][0], points[i - 1][1]);
71
63
  var cur = vec2.fromValues(points[i][0], points[i][1]);
72
- var next = i < points.length - 1 ? vec2.fromValues(points[i + 1][0], points[i + 1][1]) : null; // 如果当前点和前一点相同,跳过
73
-
64
+ var next = i < points.length - 1 ? vec2.fromValues(points[i + 1][0], points[i + 1][1]) : null;
65
+ // 如果当前点和前一点相同,跳过
74
66
  if (isPointEqual(last, cur)) {
75
67
  continue;
76
68
  }
77
-
78
69
  if (next) {
79
- var nextIndex = i + 1; // 找到不相同的下一点
80
-
70
+ var nextIndex = i + 1;
71
+ // 找到不相同的下一点
81
72
  while (next && isPointEqual(cur, next)) {
82
73
  next = nextIndex < points.length - 1 ? vec2.fromValues(points[++nextIndex][0], points[nextIndex][1]) : null;
83
74
  }
84
75
  }
85
-
86
76
  var d = 0;
87
77
  var flatCur = aProjectFlat([cur[0], cur[1]]);
88
78
  var flatLast = aProjectFlat([last[0], last[1]]);
89
-
90
79
  if (isDash) {
91
80
  var lineDistance = lineSegmentDistance(flatCur, flatLast);
92
81
  d = lineDistance + attrDistance[attrDistance.length - 1];
93
82
  }
94
-
95
83
  direction(lineA, flatCur, flatLast);
96
-
97
84
  if (!lineNormal) {
98
85
  lineNormal = vec2.create();
99
86
  computeNormal(lineNormal, lineA);
100
87
  }
101
-
102
88
  if (!started) {
103
89
  started = true;
104
90
  extrusions(attrPos, out, miters, last, lineNormal, 1);
105
91
  }
92
+ attrIndex.push(index + 0, index + 2, index + 1);
106
93
 
107
- attrIndex.push(index + 0, index + 2, index + 1); // no miter, simple segment
108
-
94
+ // no miter, simple segment
109
95
  if (!next) {
110
96
  // reset normal
111
97
  computeNormal(lineNormal, lineA);
@@ -114,14 +100,18 @@ export default function (points, closed, indexOffset) {
114
100
  attrIndex.push(index + 1, index + 2, index + 3);
115
101
  count += 2;
116
102
  } else {
117
- var flatNext = aProjectFlat([next[0], next[1]]); // get unit dir of next line
118
-
119
- direction(lineB, flatNext, flatCur); // stores tangent & miter
103
+ var flatNext = aProjectFlat([next[0], next[1]]);
104
+ // get unit dir of next line
105
+ direction(lineB, flatNext, flatCur);
120
106
 
121
- var miterLen = computeMiter(tangent, vec2.fromValues(miter[0], miter[1]), lineA, lineB, 1); // get orientation
107
+ // stores tangent & miter
108
+ var miterLen = computeMiter(tangent, vec2.fromValues(miter[0], miter[1]), lineA, lineB, 1);
122
109
 
110
+ // get orientation
123
111
  var flip = vec2.dot(tangent, lineNormal) < 0 ? -1 : 1;
124
- var bevel = Math.abs(miterLen) > miterLimit; // 处理前后两条线段重合的情况,这种情况不需要使用任何接头(miter/bevel)。
112
+ var bevel = Math.abs(miterLen) > miterLimit;
113
+
114
+ // 处理前后两条线段重合的情况,这种情况不需要使用任何接头(miter/bevel)。
125
115
  // 理论上这种情况下 miterLen = Infinity,本应通过 isFinite(miterLen) 判断,
126
116
  // 但是 AMap 投影变换后丢失精度,只能通过一个阈值(1000)判断。
127
117
 
@@ -133,31 +123,35 @@ export default function (points, closed, indexOffset) {
133
123
  vec2.copy(lineNormal, tmp); // store normal for next round
134
124
 
135
125
  extrusions(attrPos, out, miters, cur, lineNormal, 1);
136
- attrDistance.push(d, d, d, d); // the miter is now the normal for our next join
126
+ attrDistance.push(d, d, d, d);
137
127
 
128
+ // the miter is now the normal for our next join
138
129
  count += 4;
139
130
  continue;
140
131
  }
141
-
142
132
  if (bevel) {
143
- miterLen = miterLimit; // next two points in our first segment
133
+ miterLen = miterLimit;
144
134
 
135
+ // next two points in our first segment
145
136
  extrusions(attrPos, out, miters, cur, lineNormal, 1);
146
- attrIndex.push(index + 1, index + 2, index + 3); // now add the bevel triangle
137
+ attrIndex.push(index + 1, index + 2, index + 3);
147
138
 
139
+ // now add the bevel triangle
148
140
  attrIndex.push.apply(attrIndex, _toConsumableArray(flip === 1 ? [index + 2, index + 4, index + 5] : [index + 4, index + 5, index + 3]));
149
141
  computeNormal(tmp, lineB);
150
142
  vec2.copy(lineNormal, tmp); // store normal for next round
151
143
 
152
144
  extrusions(attrPos, out, miters, cur, lineNormal, 1);
153
- attrDistance.push(d, d, d, d); // the miter is now the normal for our next join
145
+ attrDistance.push(d, d, d, d);
154
146
 
147
+ // the miter is now the normal for our next join
155
148
  count += 4;
156
149
  } else {
157
150
  // next two points in our first segment
158
151
  extrusions(attrPos, out, miters, cur, lineNormal, 1);
159
- attrIndex.push(index + 1, index + 2, index + 3); // now add the miter triangles
152
+ attrIndex.push(index + 1, index + 2, index + 3);
160
153
 
154
+ // now add the miter triangles
161
155
  addNext(out, miters, lineNormal, miterLen * -flip);
162
156
  attrPos.push(cur[0], cur[1], 0);
163
157
  attrIndex.push(index + 2, index + 4, index + 3);
@@ -166,18 +160,18 @@ export default function (points, closed, indexOffset) {
166
160
  vec2.copy(lineNormal, tmp); // store normal for next round
167
161
 
168
162
  extrusions(attrPos, out, miters, cur, lineNormal, 1);
169
- attrDistance.push(d, d, d, d, d); // the miter is now the normal for our next join
163
+ attrDistance.push(d, d, d, d, d);
170
164
 
165
+ // the miter is now the normal for our next join
171
166
  count += 5;
172
167
  }
173
168
  }
174
169
  }
175
-
176
170
  var pickData = [];
177
-
178
171
  for (var _i = 0; _i < miters.length; _i++) {
179
172
  var totalDistance = attrDistance[attrDistance.length - 1];
180
- pickData.push(attrPos[_i * 3], attrPos[_i * 3 + 1], attrPos[_i * 3 + 2], attrDistance[_i], // dash
173
+ pickData.push(attrPos[_i * 3], attrPos[_i * 3 + 1], attrPos[_i * 3 + 2], attrDistance[_i],
174
+ // dash
181
175
  miters[_i], totalDistance // dash
182
176
  );
183
177
  }
@@ -186,6 +180,6 @@ export default function (points, closed, indexOffset) {
186
180
  normals: out,
187
181
  attrIndex: attrIndex,
188
182
  attrPos: pickData // [x,y,z, distance, miter ,t0tal ]
189
-
190
183
  };
191
- } // [x,y,z, distance, miter ]
184
+ }
185
+ // [x,y,z, distance, miter ]
@@ -9,17 +9,12 @@ export function direction(out, a, b) {
9
9
  vec2.normalize(out, out);
10
10
  return out;
11
11
  }
12
-
13
12
  var ExtrudePolyline = /*#__PURE__*/function () {
14
13
  function ExtrudePolyline() {
15
14
  _classCallCheck(this, ExtrudePolyline);
16
-
17
15
  _defineProperty(this, "started", false);
18
-
19
16
  _defineProperty(this, "totalDistance", 0);
20
-
21
17
  _defineProperty(this, "currentIndex", 0);
22
-
23
18
  this.complex = {
24
19
  positions: [],
25
20
  indices: [],
@@ -27,32 +22,26 @@ var ExtrudePolyline = /*#__PURE__*/function () {
27
22
  indexes: []
28
23
  };
29
24
  }
30
-
31
25
  _createClass(ExtrudePolyline, [{
32
26
  key: "simpleExtrude",
33
27
  value: function simpleExtrude(points) {
34
28
  var complex = this.complex;
35
-
36
29
  if (points.length <= 1) {
37
30
  return complex;
38
31
  }
39
-
40
32
  this.started = false;
41
33
  this.totalDistance = 0;
42
34
  var total = points.length;
43
35
  var count = complex.startIndex;
44
-
45
36
  for (var i = 1; i < total; i++) {
46
37
  var last = points[i - 1];
47
38
  var cur = points[i];
48
39
  var amt = this.simpleSegment(complex, count, last, cur);
49
40
  count += amt;
50
41
  }
51
-
52
42
  for (var _i = 0; _i < complex.positions.length / 6; _i++) {
53
43
  complex.positions[_i * 6 + 5] = this.totalDistance;
54
44
  }
55
-
56
45
  return complex;
57
46
  }
58
47
  }, {
@@ -66,12 +55,10 @@ var ExtrudePolyline = /*#__PURE__*/function () {
66
55
  direction(lineA, flatCur, flatLast);
67
56
  var segmentDistance = this.lineSegmentDistance(flatCur, flatLast);
68
57
  this.totalDistance += segmentDistance;
69
-
70
58
  if (!this.started) {
71
59
  this.started = true;
72
60
  this.extrusions(positions, last, this.totalDistance - segmentDistance);
73
61
  }
74
-
75
62
  this.extrusions(positions, cur, this.totalDistance);
76
63
  indices.push(index + 0, index + 1, index + 2);
77
64
  indices.push(index + 2, index + 1, index + 3);
@@ -80,7 +67,8 @@ var ExtrudePolyline = /*#__PURE__*/function () {
80
67
  }
81
68
  }, {
82
69
  key: "extrusions",
83
- value: function extrusions(positions, point, // 顶点
70
+ value: function extrusions(positions, point,
71
+ // 顶点
84
72
  distanceRadio) {
85
73
  positions.push(point[0], point[1], point[2] | 0, distanceRadio, 0, point[2] | 0);
86
74
  this.complex.indexes.push(this.currentIndex);
@@ -96,8 +84,6 @@ var ExtrudePolyline = /*#__PURE__*/function () {
96
84
  return Math.sqrt(dx * dx + dy * dy);
97
85
  }
98
86
  }]);
99
-
100
87
  return ExtrudePolyline;
101
88
  }();
102
-
103
89
  export { ExtrudePolyline as default };