@antv/l7-layers 2.16.0 → 2.16.1

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