@antv/l7-layers 2.9.23 → 2.9.25

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 (166) hide show
  1. package/es/Geometry/models/plane.d.ts +1 -0
  2. package/es/citybuliding/building.js +1 -1
  3. package/es/core/BaseLayer.js +10 -3
  4. package/es/core/interface.d.ts +26 -48
  5. package/es/core/interface.js +3 -0
  6. package/es/core/schema.d.ts +3 -3
  7. package/es/core/triangulation.d.ts +4 -3
  8. package/es/core/triangulation.js +54 -39
  9. package/es/heatmap/models/heatmap.js +1 -1
  10. package/es/image/models/image.js +7 -1
  11. package/es/line/index.js +4 -1
  12. package/es/line/models/arc.js +1 -1
  13. package/es/line/models/simpleLine.js +1 -1
  14. package/es/line/shaders/line_arc_vert.glsl +5 -3
  15. package/es/line/shaders/simple/simpleline_vert.glsl +1 -0
  16. package/es/plugins/FeatureScalePlugin.js +0 -1
  17. package/es/point/index.js +3 -1
  18. package/es/point/models/fill.js +5 -2
  19. package/es/point/models/fillmage.js +9 -3
  20. package/es/point/models/image.js +8 -2
  21. package/es/point/models/radar.js +2 -3
  22. package/es/point/models/tile.js +1 -1
  23. package/es/point/shaders/fill_vert.glsl +13 -6
  24. package/es/point/shaders/image/fillImage_vert.glsl +13 -5
  25. package/es/point/shaders/image_vert.glsl +17 -8
  26. package/es/polygon/index.js +4 -1
  27. package/es/raster/index.js +3 -1
  28. package/es/tile/manager/tileLayerManager.d.ts +3 -2
  29. package/es/tile/manager/tileLayerManager.js +5 -2
  30. package/es/tile/models/tileModel.js +4 -3
  31. package/es/tile/tileFactory/base.d.ts +1 -1
  32. package/es/tile/tileFactory/base.js +32 -5
  33. package/es/tile/tileFactory/vectorLayer.d.ts +3 -1
  34. package/es/tile/tileFactory/vectorLayer.js +22 -1
  35. package/es/tile/tileLayer/baseTileLayer.d.ts +1 -1
  36. package/es/tile/tileLayer/baseTileLayer.js +3 -2
  37. package/es/tile/utils.d.ts +2 -0
  38. package/es/tile/utils.js +5 -1
  39. package/lib/Geometry/index.js +114 -77
  40. package/lib/Geometry/models/billboard.js +232 -181
  41. package/lib/Geometry/models/index.js +18 -34
  42. package/lib/Geometry/models/plane.js +407 -278
  43. package/lib/Geometry/models/sprite.js +291 -189
  44. package/lib/canvas/index.js +101 -66
  45. package/lib/canvas/models/canvas.js +207 -140
  46. package/lib/canvas/models/index.js +12 -30
  47. package/lib/citybuliding/building.js +98 -63
  48. package/lib/citybuliding/models/build.js +192 -146
  49. package/lib/core/BaseLayer.js +1331 -809
  50. package/lib/core/BaseModel.js +457 -279
  51. package/lib/core/interface.js +40 -53
  52. package/lib/core/schema.js +21 -39
  53. package/lib/core/shape/Path.js +67 -79
  54. package/lib/core/shape/extrude.js +132 -91
  55. package/lib/core/triangulation.js +412 -213
  56. package/lib/earth/index.js +100 -62
  57. package/lib/earth/models/atmosphere.js +146 -112
  58. package/lib/earth/models/base.js +210 -150
  59. package/lib/earth/models/bloomsphere.js +146 -112
  60. package/lib/earth/utils.js +111 -91
  61. package/lib/heatmap/index.js +149 -92
  62. package/lib/heatmap/models/grid.js +118 -91
  63. package/lib/heatmap/models/grid3d.js +155 -123
  64. package/lib/heatmap/models/heatmap.js +475 -338
  65. package/lib/heatmap/models/hexagon.js +121 -92
  66. package/lib/heatmap/models/index.js +22 -37
  67. package/lib/heatmap/triangulation.js +31 -47
  68. package/lib/image/index.js +111 -74
  69. package/lib/image/models/dataImage.js +232 -174
  70. package/lib/image/models/image.js +175 -123
  71. package/lib/image/models/index.js +15 -32
  72. package/lib/index.js +263 -97
  73. package/lib/line/index.js +131 -83
  74. package/lib/line/models/arc.js +352 -237
  75. package/lib/line/models/arc_3d.js +334 -228
  76. package/lib/line/models/earthArc_3d.js +336 -228
  77. package/lib/line/models/great_circle.js +291 -200
  78. package/lib/line/models/half.js +286 -201
  79. package/lib/line/models/index.js +42 -50
  80. package/lib/line/models/line.js +428 -299
  81. package/lib/line/models/linearline.js +277 -203
  82. package/lib/line/models/simpleLine.js +239 -175
  83. package/lib/line/models/tile.js +348 -237
  84. package/lib/line/models/wall.js +327 -235
  85. package/lib/line/shaders/line_arc_vert.glsl +5 -3
  86. package/lib/line/shaders/simple/simpleline_vert.glsl +1 -0
  87. package/lib/mask/index.js +92 -59
  88. package/lib/mask/models/fill.js +134 -82
  89. package/lib/mask/models/index.js +12 -30
  90. package/lib/plugins/DataMappingPlugin.js +342 -224
  91. package/lib/plugins/DataSourcePlugin.js +102 -87
  92. package/lib/plugins/FeatureScalePlugin.js +330 -241
  93. package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
  94. package/lib/plugins/LayerModelPlugin.js +80 -73
  95. package/lib/plugins/LayerStylePlugin.js +48 -51
  96. package/lib/plugins/LightingPlugin.js +80 -68
  97. package/lib/plugins/MultiPassRendererPlugin.js +91 -65
  98. package/lib/plugins/PixelPickingPlugin.js +150 -109
  99. package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
  100. package/lib/plugins/ShaderUniformPlugin.js +118 -99
  101. package/lib/plugins/UpdateModelPlugin.js +40 -47
  102. package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
  103. package/lib/point/index.js +226 -148
  104. package/lib/point/models/earthExtrude.js +279 -201
  105. package/lib/point/models/earthFill.js +287 -202
  106. package/lib/point/models/extrude.js +299 -203
  107. package/lib/point/models/fill.js +406 -273
  108. package/lib/point/models/fillmage.js +365 -252
  109. package/lib/point/models/image.js +241 -164
  110. package/lib/point/models/index.js +46 -52
  111. package/lib/point/models/normal.js +183 -134
  112. package/lib/point/models/radar.js +304 -212
  113. package/lib/point/models/simplePoint.js +194 -142
  114. package/lib/point/models/text.js +608 -385
  115. package/lib/point/models/tile.js +314 -223
  116. package/lib/point/shaders/fill_vert.glsl +13 -6
  117. package/lib/point/shaders/image/fillImage_vert.glsl +13 -5
  118. package/lib/point/shaders/image_vert.glsl +17 -8
  119. package/lib/point/shape/extrude.js +56 -52
  120. package/lib/polygon/index.js +154 -100
  121. package/lib/polygon/models/extrude.js +311 -223
  122. package/lib/polygon/models/fill.js +215 -153
  123. package/lib/polygon/models/index.js +46 -52
  124. package/lib/polygon/models/ocean.js +244 -173
  125. package/lib/polygon/models/tile.js +144 -100
  126. package/lib/polygon/models/water.js +222 -153
  127. package/lib/raster/buffers/triangulation.js +27 -40
  128. package/lib/raster/index.js +115 -74
  129. package/lib/raster/models/index.js +16 -33
  130. package/lib/raster/models/raster.js +178 -135
  131. package/lib/raster/raster.js +187 -132
  132. package/lib/tile/interface.js +4 -16
  133. package/lib/tile/manager/tileConfigManager.js +125 -86
  134. package/lib/tile/manager/tileLayerManager.js +314 -227
  135. package/lib/tile/manager/tilePickerManager.js +192 -123
  136. package/lib/tile/models/tileModel.js +71 -51
  137. package/lib/tile/tileFactory/base.js +433 -292
  138. package/lib/tile/tileFactory/index.js +51 -49
  139. package/lib/tile/tileFactory/line.js +65 -50
  140. package/lib/tile/tileFactory/point.js +65 -50
  141. package/lib/tile/tileFactory/polygon.js +65 -50
  142. package/lib/tile/tileFactory/raster.js +66 -54
  143. package/lib/tile/tileFactory/rasterData.js +88 -76
  144. package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
  145. package/lib/tile/tileFactory/vectorLayer.js +169 -95
  146. package/lib/tile/tileLayer/baseTileLayer.js +420 -220
  147. package/lib/tile/tmsTileLayer.js +110 -67
  148. package/lib/tile/utils.js +113 -87
  149. package/lib/utils/blend.js +59 -79
  150. package/lib/utils/collision-index.js +107 -64
  151. package/lib/utils/dataMappingStyle.js +105 -60
  152. package/lib/utils/extrude_polyline.js +600 -398
  153. package/lib/utils/grid-index.js +163 -111
  154. package/lib/utils/layerData.js +130 -99
  155. package/lib/utils/multiPassRender.js +49 -41
  156. package/lib/utils/polylineNormal.js +148 -96
  157. package/lib/utils/simpleLine.js +100 -85
  158. package/lib/utils/symbol-layout.js +219 -116
  159. package/lib/utils/updateShape.js +15 -41
  160. package/lib/wind/index.js +109 -71
  161. package/lib/wind/models/index.js +12 -30
  162. package/lib/wind/models/utils.js +144 -105
  163. package/lib/wind/models/wind.js +333 -224
  164. package/lib/wind/models/windRender.js +329 -218
  165. package/lib/wind/models/windShader.js +23 -181
  166. package/package.json +7 -6
@@ -1,36 +1,40 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/utils/grid-index.ts
20
- var grid_index_exports = {};
21
- __export(grid_index_exports, {
22
- default: () => grid_index_default
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
23
7
  });
24
- module.exports = __toCommonJS(grid_index_exports);
25
- var GridIndex = class {
26
- constructor(width, height, cellSize) {
27
- this.boxCells = [];
28
- const boxCells = this.boxCells;
8
+ exports.default = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+
16
+ 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; } } }; }
17
+
18
+ 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); }
19
+
20
+ 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; }
21
+
22
+ /**
23
+ * 网格索引,相比 @mapbox/grid-index,在简单计算碰撞检测结果时效率更高
24
+ * @see https://zhuanlan.zhihu.com/p/74373214
25
+ */
26
+ var GridIndex = /*#__PURE__*/function () {
27
+ function GridIndex(width, height, cellSize) {
28
+ (0, _classCallCheck2.default)(this, GridIndex);
29
+ (0, _defineProperty2.default)(this, "boxCells", []);
30
+ var boxCells = this.boxCells;
29
31
  this.xCellCount = Math.ceil(width / cellSize);
30
32
  this.yCellCount = Math.ceil(height / cellSize);
31
- for (let i = 0; i < this.xCellCount * this.yCellCount; i++) {
33
+
34
+ for (var i = 0; i < this.xCellCount * this.yCellCount; i++) {
32
35
  boxCells.push([]);
33
36
  }
37
+
34
38
  this.boxKeys = [];
35
39
  this.bboxes = [];
36
40
  this.width = width;
@@ -39,98 +43,146 @@ var GridIndex = class {
39
43
  this.yScale = this.yCellCount / height;
40
44
  this.boxUid = 0;
41
45
  }
42
- insert(key, x1, y1, x2, y2) {
43
- this.forEachCell(x1, y1, x2, y2, this.insertBoxCell, this.boxUid++);
44
- this.boxKeys.push(key);
45
- this.bboxes.push(x1);
46
- this.bboxes.push(y1);
47
- this.bboxes.push(x2);
48
- this.bboxes.push(y2);
49
- }
50
- query(x1, y1, x2, y2, predicate) {
51
- return this.queryHitTest(x1, y1, x2, y2, false, predicate);
52
- }
53
- hitTest(x1, y1, x2, y2, predicate) {
54
- return this.queryHitTest(x1, y1, x2, y2, true, predicate);
55
- }
56
- insertBoxCell(x1, y1, x2, y2, cellIndex, uid) {
57
- this.boxCells[cellIndex].push(uid);
58
- }
59
- queryHitTest(x1, y1, x2, y2, hitTest, predicate) {
60
- if (x2 < 0 || x1 > this.width || y2 < 0 || y1 > this.height) {
61
- return hitTest ? false : [];
46
+
47
+ (0, _createClass2.default)(GridIndex, [{
48
+ key: "insert",
49
+ value: function insert(key, x1, y1, x2, y2) {
50
+ this.forEachCell(x1, y1, x2, y2, this.insertBoxCell, this.boxUid++);
51
+ this.boxKeys.push(key);
52
+ this.bboxes.push(x1);
53
+ this.bboxes.push(y1);
54
+ this.bboxes.push(x2);
55
+ this.bboxes.push(y2);
56
+ }
57
+ }, {
58
+ key: "query",
59
+ value: function query(x1, y1, x2, y2, predicate) {
60
+ return this.queryHitTest(x1, y1, x2, y2, false, predicate);
62
61
  }
63
- const result = [];
64
- if (x1 <= 0 && y1 <= 0 && this.width <= x2 && this.height <= y2) {
65
- if (hitTest) {
66
- return true;
62
+ }, {
63
+ key: "hitTest",
64
+ value: function hitTest(x1, y1, x2, y2, predicate) {
65
+ return this.queryHitTest(x1, y1, x2, y2, true, predicate);
66
+ }
67
+ }, {
68
+ key: "insertBoxCell",
69
+ value: function insertBoxCell(x1, y1, x2, y2, cellIndex, uid) {
70
+ this.boxCells[cellIndex].push(uid);
71
+ }
72
+ }, {
73
+ key: "queryHitTest",
74
+ value: function queryHitTest(x1, y1, x2, y2, hitTest, predicate) {
75
+ if (x2 < 0 || x1 > this.width || y2 < 0 || y1 > this.height) {
76
+ return hitTest ? false : [];
67
77
  }
68
- for (let boxUid = 0; boxUid < this.boxKeys.length; boxUid++) {
69
- result.push({
70
- key: this.boxKeys[boxUid],
71
- x1: this.bboxes[boxUid * 4],
72
- y1: this.bboxes[boxUid * 4 + 1],
73
- x2: this.bboxes[boxUid * 4 + 2],
74
- y2: this.bboxes[boxUid * 4 + 3]
75
- });
78
+
79
+ var result = [];
80
+
81
+ if (x1 <= 0 && y1 <= 0 && this.width <= x2 && this.height <= y2) {
82
+ // 这一步是高效的关键,后续精确碰撞检测结果在计算文本可见性时并不需要
83
+ if (hitTest) {
84
+ return true;
85
+ }
86
+
87
+ for (var boxUid = 0; boxUid < this.boxKeys.length; boxUid++) {
88
+ result.push({
89
+ key: this.boxKeys[boxUid],
90
+ x1: this.bboxes[boxUid * 4],
91
+ y1: this.bboxes[boxUid * 4 + 1],
92
+ x2: this.bboxes[boxUid * 4 + 2],
93
+ y2: this.bboxes[boxUid * 4 + 3]
94
+ });
95
+ }
96
+
97
+ return predicate ? result.filter(predicate) : result;
76
98
  }
77
- return predicate ? result.filter(predicate) : result;
99
+
100
+ var queryArgs = {
101
+ hitTest: hitTest,
102
+ seenUids: {
103
+ box: {},
104
+ circle: {}
105
+ }
106
+ };
107
+ this.forEachCell(x1, y1, x2, y2, this.queryCell, result, queryArgs, predicate);
108
+ return hitTest ? result.length > 0 : result;
78
109
  }
79
- const queryArgs = {
80
- hitTest,
81
- seenUids: { box: {}, circle: {} }
82
- };
83
- this.forEachCell(x1, y1, x2, y2, this.queryCell, result, queryArgs, predicate);
84
- return hitTest ? result.length > 0 : result;
85
- }
86
- queryCell(x1, y1, x2, y2, cellIndex, result, queryArgs, predicate) {
87
- const seenUids = queryArgs.seenUids;
88
- const boxCell = this.boxCells[cellIndex];
89
- if (boxCell !== null) {
90
- const bboxes = this.bboxes;
91
- for (const boxUid of boxCell) {
92
- if (!seenUids.box[boxUid]) {
93
- seenUids.box[boxUid] = true;
94
- const offset = boxUid * 4;
95
- if (x1 <= bboxes[offset + 2] && y1 <= bboxes[offset + 3] && x2 >= bboxes[offset + 0] && y2 >= bboxes[offset + 1] && (!predicate || predicate(this.boxKeys[boxUid]))) {
96
- if (queryArgs.hitTest) {
97
- result.push(true);
98
- return true;
110
+ }, {
111
+ key: "queryCell",
112
+ value: function queryCell(x1, y1, x2, y2, cellIndex, result, queryArgs, predicate) {
113
+ var seenUids = queryArgs.seenUids;
114
+ var boxCell = this.boxCells[cellIndex];
115
+
116
+ if (boxCell !== null) {
117
+ var bboxes = this.bboxes;
118
+
119
+ var _iterator = _createForOfIteratorHelper(boxCell),
120
+ _step;
121
+
122
+ try {
123
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
124
+ var boxUid = _step.value;
125
+
126
+ if (!seenUids.box[boxUid]) {
127
+ seenUids.box[boxUid] = true;
128
+ var offset = boxUid * 4;
129
+
130
+ if (x1 <= bboxes[offset + 2] && y1 <= bboxes[offset + 3] && x2 >= bboxes[offset + 0] && y2 >= bboxes[offset + 1] && (!predicate || predicate(this.boxKeys[boxUid]))) {
131
+ if (queryArgs.hitTest) {
132
+ result.push(true);
133
+ return true;
134
+ }
135
+
136
+ result.push({
137
+ key: this.boxKeys[boxUid],
138
+ x1: bboxes[offset],
139
+ y1: bboxes[offset + 1],
140
+ x2: bboxes[offset + 2],
141
+ y2: bboxes[offset + 3]
142
+ });
143
+ }
99
144
  }
100
- result.push({
101
- key: this.boxKeys[boxUid],
102
- x1: bboxes[offset],
103
- y1: bboxes[offset + 1],
104
- x2: bboxes[offset + 2],
105
- y2: bboxes[offset + 3]
106
- });
107
145
  }
146
+ } catch (err) {
147
+ _iterator.e(err);
148
+ } finally {
149
+ _iterator.f();
108
150
  }
109
151
  }
152
+
153
+ return false;
110
154
  }
111
- return false;
112
- }
113
- forEachCell(x1, y1, x2, y2, fn, arg1, arg2, predicate) {
114
- const cx1 = this.convertToXCellCoord(x1);
115
- const cy1 = this.convertToYCellCoord(y1);
116
- const cx2 = this.convertToXCellCoord(x2);
117
- const cy2 = this.convertToYCellCoord(y2);
118
- for (let x = cx1; x <= cx2; x++) {
119
- for (let y = cy1; y <= cy2; y++) {
120
- const cellIndex = this.xCellCount * y + x;
121
- if (fn.call(this, x1, y1, x2, y2, cellIndex, arg1, arg2, predicate)) {
122
- return;
155
+ }, {
156
+ key: "forEachCell",
157
+ value: function forEachCell(x1, y1, x2, y2, fn, arg1, arg2, predicate) {
158
+ var cx1 = this.convertToXCellCoord(x1);
159
+ var cy1 = this.convertToYCellCoord(y1);
160
+ var cx2 = this.convertToXCellCoord(x2);
161
+ var cy2 = this.convertToYCellCoord(y2);
162
+
163
+ for (var x = cx1; x <= cx2; x++) {
164
+ for (var y = cy1; y <= cy2; y++) {
165
+ var cellIndex = this.xCellCount * y + x;
166
+
167
+ if (fn.call(this, x1, y1, x2, y2, cellIndex, arg1, arg2, predicate)) {
168
+ return;
169
+ }
123
170
  }
124
171
  }
125
172
  }
126
- }
127
- convertToXCellCoord(x) {
128
- return Math.max(0, Math.min(this.xCellCount - 1, Math.floor(x * this.xScale)));
129
- }
130
- convertToYCellCoord(y) {
131
- return Math.max(0, Math.min(this.yCellCount - 1, Math.floor(y * this.yScale)));
132
- }
133
- };
134
- var grid_index_default = GridIndex;
135
- // Annotate the CommonJS export names for ESM import in node:
136
- 0 && (module.exports = {});
173
+ }, {
174
+ key: "convertToXCellCoord",
175
+ value: function convertToXCellCoord(x) {
176
+ return Math.max(0, Math.min(this.xCellCount - 1, Math.floor(x * this.xScale)));
177
+ }
178
+ }, {
179
+ key: "convertToYCellCoord",
180
+ value: function convertToYCellCoord(y) {
181
+ return Math.max(0, Math.min(this.yCellCount - 1, Math.floor(y * this.yScale)));
182
+ }
183
+ }]);
184
+ return GridIndex;
185
+ }();
186
+
187
+ var _default = GridIndex;
188
+ exports.default = _default;
@@ -1,62 +1,65 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/utils/layerData.ts
23
- var layerData_exports = {};
24
- __export(layerData_exports, {
25
- calculateData: () => calculateData
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
26
7
  });
27
- module.exports = __toCommonJS(layerData_exports);
28
- var import_l7_maps = require("@antv/l7-maps");
29
- var import_l7_source = __toESM(require("@antv/l7-source"));
30
- var import_l7_utils = require("@antv/l7-utils");
8
+ exports.calculateData = calculateData;
9
+
10
+ var _l7Maps = require("@antv/l7-maps");
11
+
12
+ var _l7Source = _interopRequireDefault(require("@antv/l7-source"));
13
+
14
+ var _l7Utils = require("@antv/l7-utils");
15
+
31
16
  function getArrowPoints(p1, p2) {
32
- const dir = [p2[0] - p1[0], p2[1] - p1[1]];
33
- const normalizeDir = (0, import_l7_utils.normalize)(dir);
34
- const arrowPoint = [
35
- p1[0] + normalizeDir[0] * 1e-4,
36
- p1[1] + normalizeDir[1] * 1e-4
37
- ];
17
+ var dir = [p2[0] - p1[0], p2[1] - p1[1]];
18
+ var normalizeDir = (0, _l7Utils.normalize)(dir);
19
+ var arrowPoint = [p1[0] + normalizeDir[0] * 0.0001, p1[1] + normalizeDir[1] * 0.0001];
38
20
  return arrowPoint;
39
21
  }
22
+
40
23
  function adjustData2Amap2Coordinates(mappedData, mapService) {
41
- if (mappedData.length > 0 && mapService.version === import_l7_maps.Version["GAODE2.x"]) {
42
- if (typeof mappedData[0].coordinates[0] === "number") {
43
- mappedData.filter((d) => !d.originCoordinates).map((d) => {
44
- d.version = import_l7_maps.Version["GAODE2.x"];
45
- d.originCoordinates = cloneDeep(d.coordinates);
46
- d.coordinates = this.mapService.lngLatToCoord(d.coordinates);
24
+ var _this = this;
25
+
26
+ // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移
27
+ if (mappedData.length > 0 && mapService.version === _l7Maps.Version['GAODE2.x']) {
28
+ if (typeof mappedData[0].coordinates[0] === 'number') {
29
+ // 单个的点数据
30
+ // @ts-ignore
31
+ mappedData // TODO: 避免经纬度被重复计算导致坐标位置偏移
32
+ .filter(function (d) {
33
+ return !d.originCoordinates;
34
+ }).map(function (d) {
35
+ d.version = _l7Maps.Version['GAODE2.x']; // @ts-ignore
36
+
37
+ d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
38
+ // @ts-ignore
39
+
40
+ d.coordinates = _this.mapService.lngLatToCoord(d.coordinates);
47
41
  });
48
42
  } else {
49
- mappedData.filter((d) => !d.originCoordinates).map((d) => {
50
- d.version = import_l7_maps.Version["GAODE2.x"];
51
- d.originCoordinates = cloneDeep(d.coordinates);
52
- d.coordinates = this.mapService.lngLatToCoords(d.coordinates);
43
+ // 连续的线、面数据
44
+ // @ts-ignore
45
+ mappedData // TODO: 避免经纬度被重复计算导致坐标位置偏移
46
+ .filter(function (d) {
47
+ return !d.originCoordinates;
48
+ }).map(function (d) {
49
+ d.version = _l7Maps.Version['GAODE2.x']; // @ts-ignore
50
+
51
+ d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
52
+ // @ts-ignore
53
+
54
+ d.coordinates = _this.mapService.lngLatToCoords(d.coordinates);
53
55
  });
54
56
  }
55
57
  }
56
58
  }
59
+
57
60
  function adjustData2SimpleCoordinates(mappedData, mapService) {
58
- if (mappedData.length > 0 && mapService.version === import_l7_maps.Version.SIMPLE) {
59
- mappedData.map((d) => {
61
+ if (mappedData.length > 0 && mapService.version === _l7Maps.Version.SIMPLE) {
62
+ mappedData.map(function (d) {
60
63
  if (!d.simpleCoordinate) {
61
64
  d.coordinates = unProjectCoordinates(d.coordinates, mapService);
62
65
  d.simpleCoordinate = true;
@@ -64,93 +67,121 @@ function adjustData2SimpleCoordinates(mappedData, mapService) {
64
67
  });
65
68
  }
66
69
  }
70
+
67
71
  function unProjectCoordinates(coordinates, mapService) {
68
- if (typeof coordinates[0] === "number") {
72
+ if (typeof coordinates[0] === 'number') {
69
73
  return mapService.simpleMapCoord.unproject(coordinates);
70
74
  }
75
+
71
76
  if (coordinates[0] && coordinates[0][0] instanceof Array) {
72
- const coords = [];
73
- coordinates.map((coord) => {
74
- const c1 = [];
75
- coord.map((co) => {
77
+ // @ts-ignore
78
+ var coords = [];
79
+ coordinates.map(function (coord) {
80
+ // @ts-ignore
81
+ var c1 = [];
82
+ coord.map(function (co) {
76
83
  c1.push(mapService.simpleMapCoord.unproject(co));
77
- });
84
+ }); // @ts-ignore
85
+
78
86
  coords.push(c1);
79
- });
87
+ }); // @ts-ignore
88
+
80
89
  return coords;
81
90
  } else {
82
- const coords = [];
83
- coordinates.map((coord) => {
84
- coords.push(mapService.simpleMapCoord.unproject(coord));
85
- });
86
- return coords;
91
+ // @ts-ignore
92
+ var _coords = []; // @ts-ignore
93
+
94
+ coordinates.map(function (coord) {
95
+ _coords.push(mapService.simpleMapCoord.unproject(coord));
96
+ }); // @ts-ignore
97
+
98
+ return _coords;
87
99
  }
88
100
  }
101
+
89
102
  function applyAttributeMapping(attribute, record, minimumColor) {
90
- var _a;
103
+ var _attribute$scale;
104
+
91
105
  if (!attribute.scale) {
92
106
  return [];
93
107
  }
94
- const scalers = ((_a = attribute == null ? void 0 : attribute.scale) == null ? void 0 : _a.scalers) || [];
95
- const params = [];
96
- scalers.forEach(({ field }) => {
97
- var _a2;
98
- if (record.hasOwnProperty(field) || ((_a2 = attribute.scale) == null ? void 0 : _a2.type) === "variable") {
108
+
109
+ var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
110
+ var params = [];
111
+ scalers.forEach(function (_ref) {
112
+ var _attribute$scale2;
113
+
114
+ var field = _ref.field;
115
+
116
+ if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
117
+ // TODO:多字段,常量
99
118
  params.push(record[field]);
100
119
  }
101
120
  });
102
- const mappingResult = attribute.mapping ? attribute.mapping(params) : [];
103
- if (attribute.name === "color" && !(0, import_l7_utils.isColor)(mappingResult[0])) {
121
+ var mappingResult = attribute.mapping ? attribute.mapping(params) : [];
122
+
123
+ if (attribute.name === 'color' && !(0, _l7Utils.isColor)(mappingResult[0])) {
104
124
  return [minimumColor];
105
125
  }
126
+
106
127
  return mappingResult;
107
128
  }
129
+
108
130
  function mapping(attributes, data, fontService, mapService, minimumColor, layer) {
109
- const {
110
- arrow = {
111
- enable: false
112
- }
113
- } = layer == null ? void 0 : layer.getLayerConfig();
114
- const mappedData = data.map((record) => {
115
- const encodeRecord = {
131
+ var _ref2 = layer === null || layer === void 0 ? void 0 : layer.getLayerConfig(),
132
+ _ref2$arrow = _ref2.arrow,
133
+ arrow = _ref2$arrow === void 0 ? {
134
+ enable: false
135
+ } : _ref2$arrow;
136
+
137
+ var mappedData = data.map(function (record) {
138
+ var encodeRecord = {
116
139
  id: record._id,
117
140
  coordinates: record.coordinates
118
141
  };
119
- attributes.filter((attribute) => attribute.scale !== void 0).forEach((attribute) => {
120
- let values = applyAttributeMapping(attribute, record, minimumColor);
121
- attribute.needRemapping = false;
122
- if (attribute.name === "color") {
123
- values = values.map((c) => {
124
- return (0, import_l7_utils.rgb2arr)(c);
142
+ attributes.filter(function (attribute) {
143
+ return attribute.scale !== undefined;
144
+ }).forEach(function (attribute) {
145
+ var values = applyAttributeMapping(attribute, record, minimumColor);
146
+ attribute.needRemapping = false; // TODO: 支持每个属性配置 postprocess
147
+
148
+ if (attribute.name === 'color') {
149
+ values = values.map(function (c) {
150
+ return (0, _l7Utils.rgb2arr)(c);
125
151
  });
126
- }
127
- encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values;
128
- if (attribute.name === "shape") {
152
+ } // @ts-ignore
153
+
154
+
155
+ encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values; // 增加对 layer/text/iconfont unicode 映射的解析
156
+
157
+ if (attribute.name === 'shape') {
129
158
  encodeRecord.shape = fontService.getIconFontKey(encodeRecord[attribute.name]);
130
159
  }
131
160
  });
132
- if (encodeRecord.shape === "line" && arrow.enable) {
133
- const coords = encodeRecord.coordinates;
134
- const arrowPoint = getArrowPoints(coords[0], coords[1]);
161
+
162
+ if (encodeRecord.shape === 'line' && arrow.enable) {
163
+ // 只有在线图层且支持配置箭头的时候进行插入顶点的处理
164
+ var coords = encodeRecord.coordinates;
165
+ var arrowPoint = getArrowPoints(coords[0], coords[1]);
135
166
  encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
136
167
  }
168
+
137
169
  return encodeRecord;
138
- });
139
- adjustData2Amap2Coordinates(mappedData, mapService);
170
+ }); // 调整数据兼容 Amap2.0
171
+
172
+ adjustData2Amap2Coordinates(mappedData, mapService); // 调整数据兼容 SimpleCoordinates
173
+
140
174
  adjustData2SimpleCoordinates(mappedData, mapService);
141
175
  return mappedData;
142
176
  }
177
+
143
178
  function calculateData(layer, fontService, mapService, styleAttributeService, data, options) {
144
- const source = new import_l7_source.default(data, options);
145
- const bottomColor = layer.getBottomColor();
146
- const attributes = styleAttributeService.getLayerStyleAttributes() || [];
147
- const { dataArray } = source.data;
148
- const filterData = dataArray;
149
- const mappedEncodeData = mapping(attributes, filterData, fontService, mapService, bottomColor, layer);
179
+ var source = new _l7Source.default(data, options);
180
+ var bottomColor = layer.getBottomColor();
181
+ var attributes = styleAttributeService.getLayerStyleAttributes() || [];
182
+ var dataArray = source.data.dataArray;
183
+ var filterData = dataArray;
184
+ var mappedEncodeData = mapping(attributes, filterData, fontService, mapService, bottomColor, layer);
150
185
  source.destroy();
151
186
  return mappedEncodeData;
152
- }
153
- // Annotate the CommonJS export names for ESM import in node:
154
- 0 && (module.exports = {
155
- calculateData
156
- });
187
+ }