@antv/l7-layers 2.9.25-alpha.0 → 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 (125) hide show
  1. package/es/heatmap/models/heatmap.js +1 -1
  2. package/es/tile/utils.js +1 -1
  3. package/lib/Geometry/index.js +114 -77
  4. package/lib/Geometry/models/billboard.js +232 -181
  5. package/lib/Geometry/models/index.js +18 -34
  6. package/lib/Geometry/models/plane.js +407 -278
  7. package/lib/Geometry/models/sprite.js +291 -189
  8. package/lib/canvas/index.js +101 -66
  9. package/lib/canvas/models/canvas.js +207 -140
  10. package/lib/canvas/models/index.js +12 -30
  11. package/lib/citybuliding/building.js +98 -63
  12. package/lib/citybuliding/models/build.js +192 -146
  13. package/lib/core/BaseLayer.js +1331 -814
  14. package/lib/core/BaseModel.js +457 -279
  15. package/lib/core/interface.js +40 -53
  16. package/lib/core/schema.js +21 -39
  17. package/lib/core/shape/Path.js +67 -79
  18. package/lib/core/shape/extrude.js +132 -91
  19. package/lib/core/triangulation.js +378 -196
  20. package/lib/earth/index.js +100 -62
  21. package/lib/earth/models/atmosphere.js +146 -112
  22. package/lib/earth/models/base.js +210 -150
  23. package/lib/earth/models/bloomsphere.js +146 -112
  24. package/lib/earth/utils.js +111 -91
  25. package/lib/heatmap/index.js +149 -92
  26. package/lib/heatmap/models/grid.js +118 -91
  27. package/lib/heatmap/models/grid3d.js +155 -123
  28. package/lib/heatmap/models/heatmap.js +475 -338
  29. package/lib/heatmap/models/hexagon.js +121 -92
  30. package/lib/heatmap/models/index.js +22 -37
  31. package/lib/heatmap/triangulation.js +31 -47
  32. package/lib/image/index.js +111 -74
  33. package/lib/image/models/dataImage.js +232 -174
  34. package/lib/image/models/image.js +175 -128
  35. package/lib/image/models/index.js +15 -32
  36. package/lib/index.js +263 -97
  37. package/lib/line/index.js +131 -85
  38. package/lib/line/models/arc.js +352 -237
  39. package/lib/line/models/arc_3d.js +334 -228
  40. package/lib/line/models/earthArc_3d.js +336 -228
  41. package/lib/line/models/great_circle.js +291 -200
  42. package/lib/line/models/half.js +286 -201
  43. package/lib/line/models/index.js +42 -50
  44. package/lib/line/models/line.js +428 -299
  45. package/lib/line/models/linearline.js +277 -203
  46. package/lib/line/models/simpleLine.js +239 -175
  47. package/lib/line/models/tile.js +348 -237
  48. package/lib/line/models/wall.js +327 -235
  49. package/lib/mask/index.js +92 -59
  50. package/lib/mask/models/fill.js +134 -82
  51. package/lib/mask/models/index.js +12 -30
  52. package/lib/plugins/DataMappingPlugin.js +342 -224
  53. package/lib/plugins/DataSourcePlugin.js +102 -87
  54. package/lib/plugins/FeatureScalePlugin.js +330 -240
  55. package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
  56. package/lib/plugins/LayerModelPlugin.js +80 -73
  57. package/lib/plugins/LayerStylePlugin.js +48 -51
  58. package/lib/plugins/LightingPlugin.js +80 -68
  59. package/lib/plugins/MultiPassRendererPlugin.js +91 -65
  60. package/lib/plugins/PixelPickingPlugin.js +150 -109
  61. package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
  62. package/lib/plugins/ShaderUniformPlugin.js +118 -99
  63. package/lib/plugins/UpdateModelPlugin.js +40 -47
  64. package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
  65. package/lib/point/index.js +226 -150
  66. package/lib/point/models/earthExtrude.js +279 -201
  67. package/lib/point/models/earthFill.js +287 -202
  68. package/lib/point/models/extrude.js +299 -203
  69. package/lib/point/models/fill.js +406 -275
  70. package/lib/point/models/fillmage.js +365 -256
  71. package/lib/point/models/image.js +241 -168
  72. package/lib/point/models/index.js +46 -52
  73. package/lib/point/models/normal.js +183 -134
  74. package/lib/point/models/radar.js +304 -211
  75. package/lib/point/models/simplePoint.js +194 -142
  76. package/lib/point/models/text.js +608 -385
  77. package/lib/point/models/tile.js +314 -223
  78. package/lib/point/shape/extrude.js +56 -52
  79. package/lib/polygon/index.js +154 -102
  80. package/lib/polygon/models/extrude.js +311 -223
  81. package/lib/polygon/models/fill.js +215 -153
  82. package/lib/polygon/models/index.js +46 -52
  83. package/lib/polygon/models/ocean.js +244 -173
  84. package/lib/polygon/models/tile.js +144 -100
  85. package/lib/polygon/models/water.js +222 -153
  86. package/lib/raster/buffers/triangulation.js +27 -40
  87. package/lib/raster/index.js +115 -75
  88. package/lib/raster/models/index.js +16 -33
  89. package/lib/raster/models/raster.js +178 -135
  90. package/lib/raster/raster.js +187 -132
  91. package/lib/tile/interface.js +4 -16
  92. package/lib/tile/manager/tileConfigManager.js +125 -86
  93. package/lib/tile/manager/tileLayerManager.js +313 -229
  94. package/lib/tile/manager/tilePickerManager.js +192 -123
  95. package/lib/tile/models/tileModel.js +71 -52
  96. package/lib/tile/tileFactory/base.js +432 -309
  97. package/lib/tile/tileFactory/index.js +51 -49
  98. package/lib/tile/tileFactory/line.js +65 -50
  99. package/lib/tile/tileFactory/point.js +65 -50
  100. package/lib/tile/tileFactory/polygon.js +65 -50
  101. package/lib/tile/tileFactory/raster.js +66 -54
  102. package/lib/tile/tileFactory/rasterData.js +88 -76
  103. package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
  104. package/lib/tile/tileFactory/vectorLayer.js +168 -109
  105. package/lib/tile/tileLayer/baseTileLayer.js +420 -221
  106. package/lib/tile/tmsTileLayer.js +110 -67
  107. package/lib/tile/utils.js +110 -92
  108. package/lib/utils/blend.js +59 -79
  109. package/lib/utils/collision-index.js +107 -64
  110. package/lib/utils/dataMappingStyle.js +105 -60
  111. package/lib/utils/extrude_polyline.js +600 -398
  112. package/lib/utils/grid-index.js +163 -111
  113. package/lib/utils/layerData.js +130 -99
  114. package/lib/utils/multiPassRender.js +49 -41
  115. package/lib/utils/polylineNormal.js +148 -96
  116. package/lib/utils/simpleLine.js +100 -85
  117. package/lib/utils/symbol-layout.js +219 -116
  118. package/lib/utils/updateShape.js +15 -41
  119. package/lib/wind/index.js +109 -71
  120. package/lib/wind/models/index.js +12 -30
  121. package/lib/wind/models/utils.js +144 -105
  122. package/lib/wind/models/wind.js +333 -224
  123. package/lib/wind/models/windRender.js +329 -218
  124. package/lib/wind/models/windShader.js +23 -181
  125. package/package.json +6 -6
@@ -1,130 +1,187 @@
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/core/triangulation.ts
23
- var triangulation_exports = {};
24
- __export(triangulation_exports, {
25
- GlobelPointFillTriangulation: () => GlobelPointFillTriangulation,
26
- HeatmapGridTriangulation: () => HeatmapGridTriangulation,
27
- HeatmapTriangulation: () => HeatmapTriangulation,
28
- LineArcTriangulation: () => LineArcTriangulation,
29
- LineTriangulation: () => LineTriangulation,
30
- PointExtrudeTriangulation: () => PointExtrudeTriangulation,
31
- PointFillTriangulation: () => PointFillTriangulation,
32
- PointImageTriangulation: () => PointImageTriangulation,
33
- PolygonExtrudeTriangulation: () => PolygonExtrudeTriangulation,
34
- RasterImageTriangulation: () => RasterImageTriangulation,
35
- SimpleLineTriangulation: () => SimpleLineTriangulation,
36
- earthOuterTriangulation: () => earthOuterTriangulation,
37
- earthTriangulation: () => earthTriangulation,
38
- polygonTriangulation: () => polygonTriangulation,
39
- polygonTriangulationWithCenter: () => polygonTriangulationWithCenter
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
40
9
  });
41
- module.exports = __toCommonJS(triangulation_exports);
42
- var import_l7_utils = require("@antv/l7-utils");
43
- var import_earcut = __toESM(require("earcut"));
44
- var import_gl_matrix = require("gl-matrix");
45
- var import_utils = require("../earth/utils");
46
- var import_extrude_polyline = __toESM(require("../utils/extrude_polyline"));
47
- var import_extrude = __toESM(require("./shape/extrude"));
48
- var import_Path = require("./shape/Path");
10
+ exports.GlobelPointFillTriangulation = GlobelPointFillTriangulation;
11
+ exports.HeatmapGridTriangulation = HeatmapGridTriangulation;
12
+ exports.HeatmapTriangulation = HeatmapTriangulation;
13
+ exports.LineArcTriangulation = LineArcTriangulation;
14
+ exports.LineTriangulation = LineTriangulation;
15
+ exports.PointExtrudeTriangulation = PointExtrudeTriangulation;
16
+ exports.PointFillTriangulation = PointFillTriangulation;
17
+ exports.PointImageTriangulation = PointImageTriangulation;
18
+ exports.PolygonExtrudeTriangulation = PolygonExtrudeTriangulation;
19
+ exports.RasterImageTriangulation = RasterImageTriangulation;
20
+ exports.SimpleLineTriangulation = SimpleLineTriangulation;
21
+ exports.earthOuterTriangulation = earthOuterTriangulation;
22
+ exports.earthTriangulation = earthTriangulation;
23
+ exports.polygonTriangulation = polygonTriangulation;
24
+ exports.polygonTriangulationWithCenter = polygonTriangulationWithCenter;
25
+
26
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
27
+
28
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
29
+
30
+ var _l7Utils = require("@antv/l7-utils");
31
+
32
+ var _earcut = _interopRequireDefault(require("earcut"));
33
+
34
+ var _glMatrix = require("gl-matrix");
35
+
36
+ var _utils = require("../earth/utils");
37
+
38
+ var _extrude_polyline = _interopRequireDefault(require("../utils/extrude_polyline"));
39
+
40
+ var _extrude = _interopRequireWildcard(require("./shape/extrude"));
41
+
42
+ var _Path = require("./shape/Path");
43
+
44
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
45
+
46
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
47
+
48
+ // @ts-ignore
49
49
  var GeometryCache = {};
50
+ /**
51
+ * 计算2D 填充点图顶点
52
+ * @param feature 映射feature
53
+ */
54
+
50
55
  function PointFillTriangulation(feature) {
51
- const coordinates = (0, import_l7_utils.calculateCentroid)(feature.coordinates);
56
+ var coordinates = (0, _l7Utils.calculateCentroid)(feature.coordinates);
52
57
  return {
53
- vertices: [...coordinates, ...coordinates, ...coordinates, ...coordinates],
58
+ vertices: [].concat((0, _toConsumableArray2.default)(coordinates), (0, _toConsumableArray2.default)(coordinates), (0, _toConsumableArray2.default)(coordinates), (0, _toConsumableArray2.default)(coordinates)),
54
59
  indices: [0, 1, 2, 2, 3, 0],
55
60
  size: coordinates.length
56
61
  };
57
62
  }
63
+ /**
64
+ * 计算2D 填充点图顶点 (地球模式)
65
+ * @param feature 映射feature
66
+ */
67
+
68
+
58
69
  function GlobelPointFillTriangulation(feature) {
59
- const coordinates = (0, import_l7_utils.calculateCentroid)(feature.coordinates);
60
- const xyz = (0, import_utils.lglt2xyz)(coordinates);
70
+ var coordinates = (0, _l7Utils.calculateCentroid)(feature.coordinates);
71
+ var xyz = (0, _utils.lglt2xyz)(coordinates);
61
72
  return {
62
- vertices: [...xyz, ...xyz, ...xyz, ...xyz],
73
+ vertices: [].concat((0, _toConsumableArray2.default)(xyz), (0, _toConsumableArray2.default)(xyz), (0, _toConsumableArray2.default)(xyz), (0, _toConsumableArray2.default)(xyz)),
63
74
  indices: [0, 1, 2, 2, 3, 0],
64
75
  size: xyz.length
65
76
  };
66
77
  }
78
+ /**
79
+ * 计算3D 拉伸点图
80
+ * @param feature 映射feature
81
+ */
82
+
83
+
67
84
  function PointExtrudeTriangulation(feature) {
68
- const { shape } = feature;
69
- const { positions, index, normals } = getGeometry(shape, false);
85
+ var shape = feature.shape;
86
+
87
+ var _getGeometry = getGeometry(shape, false),
88
+ positions = _getGeometry.positions,
89
+ index = _getGeometry.index,
90
+ normals = _getGeometry.normals;
91
+
70
92
  return {
71
93
  vertices: positions,
72
94
  indices: index,
73
- normals,
95
+ normals: normals,
74
96
  size: 5
75
97
  };
76
98
  }
99
+ /**
100
+ * 计算图片标注
101
+ * @param feature 映射feature
102
+ */
103
+
104
+
77
105
  function PointImageTriangulation(feature) {
78
- const coordinates = (0, import_l7_utils.calculateCentroid)(feature.coordinates);
106
+ var coordinates = (0, _l7Utils.calculateCentroid)(feature.coordinates);
79
107
  return {
80
- vertices: [...coordinates],
108
+ vertices: (0, _toConsumableArray2.default)(coordinates),
81
109
  indices: [0],
82
110
  size: coordinates.length
83
111
  };
84
112
  }
113
+ /**
114
+ * 线三角化
115
+ * @param feature 映射feature
116
+ */
117
+
118
+
85
119
  function LineTriangulation(feature) {
86
- const { coordinates, originCoordinates, version } = feature;
87
- const line = new import_extrude_polyline.default({
120
+ var coordinates = feature.coordinates,
121
+ originCoordinates = feature.originCoordinates,
122
+ version = feature.version; // let path = coordinates as number[][][] | number[][];
123
+ // if (!Array.isArray(path[0][0])) {
124
+ // path = [coordinates] as number[][][];
125
+ // }
126
+
127
+ var line = new _extrude_polyline.default({
88
128
  dash: true,
89
- join: "bevel"
129
+ join: 'bevel'
90
130
  });
91
- if (version === "GAODE2.x") {
92
- let path1 = coordinates;
131
+
132
+ if (version === 'GAODE2.x') {
133
+ // 处理高德2.0几何体构建
134
+ var path1 = coordinates; // 计算位置
135
+
93
136
  if (!Array.isArray(path1[0][0])) {
94
137
  path1 = [coordinates];
95
138
  }
96
- let path2 = originCoordinates;
139
+
140
+ var path2 = originCoordinates; // 计算法线
141
+
97
142
  if (!Array.isArray(path2[0][0])) {
98
143
  path2 = [originCoordinates];
99
144
  }
100
- for (let i = 0; i < path1.length; i++) {
101
- const item1 = path1[i];
102
- const item2 = path2[i];
145
+
146
+ for (var i = 0; i < path1.length; i++) {
147
+ // 高德2.0在计算线时,需要使用经纬度计算发现,使用 customCoords.lnglatToCoords 计算的数据来计算顶点的位置
148
+ var item1 = path1[i];
149
+ var item2 = path2[i];
103
150
  line.extrude_gaode2(item1, item2);
104
151
  }
105
152
  } else {
106
- let path = coordinates;
153
+ // 处理非高德2.0的几何体构建
154
+ var path = coordinates;
155
+
107
156
  if (path[0] && !Array.isArray(path[0][0])) {
108
157
  path = [coordinates];
109
158
  }
110
- path.forEach((item) => {
159
+
160
+ path.forEach(function (item) {
111
161
  line.extrude(item);
112
162
  });
113
163
  }
114
- const linebuffer = line.complex;
164
+
165
+ var linebuffer = line.complex;
115
166
  return {
116
167
  vertices: linebuffer.positions,
168
+ // [ x,y,z, distance, miter,total ]
117
169
  indices: linebuffer.indices,
118
170
  normals: linebuffer.normals,
119
171
  indexes: linebuffer.indexes,
120
172
  size: 6
121
173
  };
122
174
  }
175
+
123
176
  function SimpleLineTriangulation(feature) {
124
- const { coordinates } = feature;
125
- const pos = [];
126
- const { results, totalDistance } = getSimpleLineVertices(coordinates);
127
- results.map((point) => {
177
+ var coordinates = feature.coordinates;
178
+ var pos = [];
179
+
180
+ var _getSimpleLineVertice = getSimpleLineVertices(coordinates),
181
+ results = _getSimpleLineVertice.results,
182
+ totalDistance = _getSimpleLineVertice.totalDistance;
183
+
184
+ results.map(function (point) {
128
185
  pos.push(point[0], point[1], point[2], point[3], 0, totalDistance);
129
186
  });
130
187
  return {
@@ -135,205 +192,345 @@ function SimpleLineTriangulation(feature) {
135
192
  count: results.length
136
193
  };
137
194
  }
195
+
138
196
  function lineSegmentDistance(b1, a1) {
139
- const dx = a1[0] - b1[0];
140
- const dy = a1[1] - b1[1];
197
+ var dx = a1[0] - b1[0];
198
+ var dy = a1[1] - b1[1];
141
199
  return Math.sqrt(dx * dx + dy * dy);
142
200
  }
201
+
143
202
  function pushDis(point, n) {
144
203
  if (point.length < 3) {
145
204
  point.push(0);
146
205
  }
206
+
147
207
  point.push(n);
148
208
  return point;
149
209
  }
210
+
150
211
  function getSimpleLineVertices(points) {
151
- let distance = 0;
212
+ var distance = 0;
213
+
152
214
  if (points.length < 2) {
153
215
  return {
154
216
  results: points,
155
217
  totalDistance: 0
156
218
  };
157
219
  } else {
158
- const results = [];
159
- const point = pushDis(points[0], distance);
220
+ var results = [];
221
+ var point = pushDis(points[0], distance);
160
222
  results.push(point);
161
- for (let i = 1; i < points.length - 1; i++) {
162
- const subDistance = lineSegmentDistance(points[i - 1], points[i]);
223
+
224
+ for (var i = 1; i < points.length - 1; i++) {
225
+ var subDistance = lineSegmentDistance(points[i - 1], points[i]);
163
226
  distance += subDistance;
164
- const mulPoint = pushDis(points[i], distance);
227
+ var mulPoint = pushDis(points[i], distance);
165
228
  results.push(mulPoint);
166
229
  results.push(mulPoint);
167
230
  }
168
- const pointDistance = lineSegmentDistance(points[points.length - 2], points[points.length - 1]);
231
+
232
+ var pointDistance = lineSegmentDistance(points[points.length - 2], points[points.length - 1]);
169
233
  distance += pointDistance;
170
234
  results.push(pushDis(points[points.length - 1], distance));
171
235
  return {
172
- results,
236
+ results: results,
173
237
  totalDistance: distance
174
238
  };
175
239
  }
176
240
  }
241
+
177
242
  function polygonTriangulation(feature) {
178
- const { coordinates } = feature;
179
- const flattengeo = import_earcut.default.flatten(coordinates);
180
- const { vertices, dimensions, holes } = flattengeo;
243
+ var coordinates = feature.coordinates;
244
+
245
+ var flattengeo = _earcut.default.flatten(coordinates);
246
+
247
+ var vertices = flattengeo.vertices,
248
+ dimensions = flattengeo.dimensions,
249
+ holes = flattengeo.holes;
181
250
  return {
182
- indices: (0, import_earcut.default)(vertices, holes, dimensions),
183
- vertices,
251
+ indices: (0, _earcut.default)(vertices, holes, dimensions),
252
+ vertices: vertices,
184
253
  size: dimensions
185
254
  };
186
- }
255
+ } // TODO:构建几何图形(带有中心点和大小)
256
+
257
+
187
258
  function polygonTriangulationWithCenter(feature) {
188
- const { coordinates } = feature;
189
- const flattengeo = import_earcut.default.flatten(coordinates);
190
- const { vertices, dimensions, holes } = flattengeo;
259
+ var coordinates = feature.coordinates;
260
+
261
+ var flattengeo = _earcut.default.flatten(coordinates);
262
+
263
+ var vertices = flattengeo.vertices,
264
+ dimensions = flattengeo.dimensions,
265
+ holes = flattengeo.holes;
191
266
  return {
192
- indices: (0, import_earcut.default)(vertices, holes, dimensions),
267
+ indices: (0, _earcut.default)(vertices, holes, dimensions),
193
268
  vertices: getVerticesWithCenter(vertices),
194
269
  size: dimensions + 4
195
270
  };
196
271
  }
272
+
197
273
  function getVerticesWithCenter(vertices) {
198
- const verticesWithCenter = [];
199
- const { center, radius } = (0, import_l7_utils.calculatePointsCenterAndRadius)(vertices);
200
- for (let i = 0; i < vertices.length; i += 2) {
201
- const lng = vertices[i];
202
- const lat = vertices[i + 1];
203
- verticesWithCenter.push(lng, lat, 0, ...center, radius);
274
+ var verticesWithCenter = [];
275
+
276
+ var _calculatePointsCente = (0, _l7Utils.calculatePointsCenterAndRadius)(vertices),
277
+ center = _calculatePointsCente.center,
278
+ radius = _calculatePointsCente.radius;
279
+
280
+ for (var i = 0; i < vertices.length; i += 2) {
281
+ var lng = vertices[i];
282
+ var lat = vertices[i + 1];
283
+ verticesWithCenter.push.apply(verticesWithCenter, [lng, lat, 0].concat((0, _toConsumableArray2.default)(center), [radius]));
204
284
  }
285
+
205
286
  return verticesWithCenter;
206
287
  }
288
+
207
289
  function PolygonExtrudeTriangulation(feature) {
208
- const coordinates = feature.coordinates;
209
- const { positions, index, normals } = (0, import_extrude.extrude_PolygonNormal)(coordinates, true);
290
+ var coordinates = feature.coordinates;
291
+
292
+ var _extrude_PolygonNorma = (0, _extrude.extrude_PolygonNormal)(coordinates, true),
293
+ positions = _extrude_PolygonNorma.positions,
294
+ index = _extrude_PolygonNorma.index,
295
+ normals = _extrude_PolygonNorma.normals;
296
+
210
297
  return {
211
298
  vertices: positions,
299
+ // [ x, y, z, uv.x,uv.y ]
212
300
  indices: index,
213
- normals,
301
+ normals: normals,
214
302
  size: 5
215
303
  };
216
304
  }
305
+
217
306
  function HeatmapGridTriangulation(feature) {
218
- const { shape } = feature;
219
- const { positions, index } = getHeatmapGeometry(shape);
307
+ var shape = feature.shape;
308
+
309
+ var _getHeatmapGeometry = getHeatmapGeometry(shape),
310
+ positions = _getHeatmapGeometry.positions,
311
+ index = _getHeatmapGeometry.index;
312
+
220
313
  return {
221
314
  vertices: positions,
315
+ // [ x, y, z ] 多边形顶点
222
316
  indices: index,
223
317
  size: 3
224
318
  };
225
319
  }
320
+ /**
321
+ * 图片图层顶点构造
322
+ * @param feature 数据
323
+ */
324
+
325
+
226
326
  function RasterImageTriangulation(feature) {
227
- const coordinates = feature.coordinates;
228
- const positions = [
229
- ...coordinates[0],
230
- 0,
231
- 0,
232
- 1,
233
- coordinates[1][0],
234
- coordinates[0][1],
235
- 0,
236
- 1,
237
- 1,
238
- ...coordinates[1],
239
- 0,
240
- 1,
241
- 0,
242
- ...coordinates[0],
243
- 0,
244
- 0,
245
- 1,
246
- ...coordinates[1],
247
- 0,
248
- 1,
249
- 0,
250
- coordinates[0][0],
251
- coordinates[1][1],
252
- 0,
253
- 0,
254
- 0
255
- ];
256
- const indexs = [0, 1, 2, 3, 4, 5];
327
+ var coordinates = feature.coordinates; // [ x, y, z. uv.x, uv.y]
328
+
329
+ var positions = [].concat((0, _toConsumableArray2.default)(coordinates[0]), [0, 0, 1, coordinates[1][0], coordinates[0][1], 0, 1, 1], (0, _toConsumableArray2.default)(coordinates[1]), [0, 1, 0], (0, _toConsumableArray2.default)(coordinates[0]), [0, 0, 1], (0, _toConsumableArray2.default)(coordinates[1]), [0, 1, 0, coordinates[0][0], coordinates[1][1], 0, 0, 0]);
330
+ var indexs = [0, 1, 2, 3, 4, 5];
257
331
  return {
258
332
  vertices: positions,
259
333
  indices: indexs,
260
334
  size: 5
261
335
  };
262
336
  }
337
+ /**
338
+ * 计算3D弧线顶点
339
+ * @param feature 映射数据
340
+ * @param segNum 弧线线段数
341
+ */
342
+
343
+
263
344
  function LineArcTriangulation(feature, segmentNumber) {
264
- const segNum = segmentNumber ? segmentNumber : 30;
265
- const coordinates = feature.coordinates;
266
- const positions = [];
267
- const indexArray = [];
268
- for (let i = 0; i < segNum; i++) {
345
+ var segNum = segmentNumber ? segmentNumber : 30;
346
+ var coordinates = feature.coordinates;
347
+ var positions = [];
348
+ var indexArray = [];
349
+
350
+ var _loop = function _loop(i) {
351
+ // 上线两个顶点
352
+ // [ x, y, z, sx,sy, tx,ty]
269
353
  positions.push(i, 1, i, coordinates[0][0], coordinates[0][1], coordinates[1][0], coordinates[1][1], i, -1, i, coordinates[0][0], coordinates[0][1], coordinates[1][0], coordinates[1][1]);
354
+
270
355
  if (i !== segNum - 1) {
271
- indexArray.push(...[0, 1, 2, 1, 3, 2].map((v) => {
356
+ indexArray.push.apply(indexArray, (0, _toConsumableArray2.default)([0, 1, 2, 1, 3, 2].map(function (v) {
272
357
  return i * 2 + v;
273
- }));
358
+ })));
274
359
  }
360
+ };
361
+
362
+ for (var i = 0; i < segNum; i++) {
363
+ _loop(i);
275
364
  }
365
+
276
366
  return {
277
367
  vertices: positions,
278
368
  indices: indexArray,
279
369
  size: 7
280
370
  };
281
371
  }
372
+ /**
373
+ * 构建热力图密度图的顶点
374
+ * @param feature
375
+ * @returns
376
+ */
377
+
378
+
282
379
  function HeatmapTriangulation(feature) {
283
- const coordinates = feature.coordinates;
380
+ var coordinates = feature.coordinates;
381
+
284
382
  if (coordinates.length === 2) {
285
383
  coordinates.push(0);
286
384
  }
287
- const size = feature.size;
288
- const dir = addDir(-1, 1);
289
- const dir1 = addDir(1, 1);
290
- const dir2 = addDir(-1, -1);
291
- const dir3 = addDir(1, -1);
292
- const positions = [
293
- ...coordinates,
294
- ...dir,
295
- ...coordinates,
296
- ...dir2,
297
- ...coordinates,
298
- ...dir3,
299
- ...coordinates,
300
- ...dir1
301
- ];
302
- const indexArray = [0, 1, 2, 3, 0, 2];
385
+
386
+ var size = feature.size;
387
+ var dir = addDir(-1, 1);
388
+ var dir1 = addDir(1, 1);
389
+ var dir2 = addDir(-1, -1);
390
+ var dir3 = addDir(1, -1); // [x,y,z, dirx ,diry, weight]
391
+
392
+ var positions = [].concat((0, _toConsumableArray2.default)(coordinates), (0, _toConsumableArray2.default)(dir), (0, _toConsumableArray2.default)(coordinates), (0, _toConsumableArray2.default)(dir2), (0, _toConsumableArray2.default)(coordinates), (0, _toConsumableArray2.default)(dir3), (0, _toConsumableArray2.default)(coordinates), (0, _toConsumableArray2.default)(dir1));
393
+ var indexArray = [0, 1, 2, 3, 0, 2];
303
394
  return {
304
395
  vertices: positions,
305
396
  indices: indexArray,
306
397
  size: 5
307
398
  };
308
399
  }
309
- function getGeometry(shape, needFlat = false) {
400
+ /**
401
+ * 点图层3d geomerty
402
+ * @param shape 3D形状
403
+ */
404
+
405
+
406
+ function getGeometry(shape) {
407
+ var needFlat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
408
+
310
409
  if (GeometryCache && GeometryCache[shape]) {
311
410
  return GeometryCache[shape];
312
411
  }
313
- const path = import_Path.geometryShape[shape] ? import_Path.geometryShape[shape]() : import_Path.geometryShape.cylinder();
314
- const geometry = (0, import_extrude.extrude_PolygonNormal)([path], needFlat);
412
+
413
+ var path = _Path.geometryShape[shape] ? _Path.geometryShape[shape]() : _Path.geometryShape.cylinder();
414
+ var geometry = (0, _extrude.extrude_PolygonNormal)([path], needFlat);
315
415
  GeometryCache[shape] = geometry;
316
416
  return geometry;
317
417
  }
418
+
419
+ function computeVertexNormals(positions, indexArray) {
420
+ var dim = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
421
+ var needFlat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
422
+ var normals = new Float32Array(positions.length / dim * 3);
423
+ var vA;
424
+ var vB;
425
+ var vC;
426
+
427
+ var cb = _glMatrix.vec3.create();
428
+
429
+ var ab = _glMatrix.vec3.create();
430
+
431
+ var normal = _glMatrix.vec3.create();
432
+
433
+ for (var i = 0, li = indexArray.length; i < li; i += 3) {
434
+ vA = indexArray[i + 0] * 3;
435
+ vB = indexArray[i + 1] * 3;
436
+ vC = indexArray[i + 2] * 3;
437
+ var p1 = [positions[vA], positions[vA + 1]];
438
+ var p2 = [positions[vB], positions[vB + 1]];
439
+ var p3 = [positions[vC], positions[vC + 1]];
440
+
441
+ if (needFlat) {
442
+ p1 = (0, _l7Utils.lngLatToMeters)(p1);
443
+ p2 = (0, _l7Utils.lngLatToMeters)(p2);
444
+ p3 = (0, _l7Utils.lngLatToMeters)(p3);
445
+ }
446
+
447
+ var _p = p1,
448
+ _p2 = (0, _slicedToArray2.default)(_p, 2),
449
+ ax = _p2[0],
450
+ ay = _p2[1];
451
+
452
+ var pA = _glMatrix.vec3.fromValues(ax, ay, positions[vA + 2]);
453
+
454
+ var _p3 = p2,
455
+ _p4 = (0, _slicedToArray2.default)(_p3, 2),
456
+ bx = _p4[0],
457
+ by = _p4[1];
458
+
459
+ var pB = _glMatrix.vec3.fromValues(bx, by, positions[vB + 2]);
460
+
461
+ var _p5 = p3,
462
+ _p6 = (0, _slicedToArray2.default)(_p5, 2),
463
+ cx = _p6[0],
464
+ cy = _p6[1];
465
+
466
+ var pC = _glMatrix.vec3.fromValues(cx, cy, positions[vC + 2]);
467
+
468
+ _glMatrix.vec3.sub(cb, pC, pB);
469
+
470
+ _glMatrix.vec3.sub(ab, pA, pB);
471
+
472
+ _glMatrix.vec3.cross(normal, cb, ab);
473
+
474
+ normals[vA] += cb[0];
475
+ normals[vA + 1] += cb[1];
476
+ normals[vA + 2] += cb[2];
477
+ normals[vB] += cb[0];
478
+ normals[vB + 1] += cb[1];
479
+ normals[vB + 2] += cb[2];
480
+ normals[vC] += cb[0];
481
+ normals[vC + 1] += cb[1];
482
+ normals[vC + 2] += cb[2];
483
+ }
484
+
485
+ normalizeNormals(normals);
486
+ return normals;
487
+ }
488
+
489
+ function normalizeNormals(normals) {
490
+ for (var i = 0, li = normals.length; i < li; i += 3) {
491
+ var normal = _glMatrix.vec3.fromValues(normals[i], normals[i + 1], normals[i + 2]);
492
+
493
+ var newNormal = _glMatrix.vec3.create();
494
+
495
+ _glMatrix.vec3.normalize(newNormal, normal);
496
+
497
+ normals.set(newNormal, i);
498
+ }
499
+ }
500
+
501
+ function checkIsClosed(points) {
502
+ var p1 = points[0][0];
503
+ var p2 = points[0][points[0].length - 1];
504
+ return p1[0] === p2[0] && p1[1] === p2[1];
505
+ }
506
+
318
507
  function getHeatmapGeometry(shape) {
319
- const shape3d = [
320
- "cylinder",
321
- "triangleColumn",
322
- "hexagonColumn",
323
- "squareColumn"
324
- ];
325
- const path = import_Path.geometryShape[shape] ? import_Path.geometryShape[shape]() : import_Path.geometryShape.circle();
326
- const geometry = shape3d.indexOf(shape) === -1 ? (0, import_extrude.fillPolygon)([path]) : (0, import_extrude.default)([path]);
508
+ var shape3d = ['cylinder', 'triangleColumn', 'hexagonColumn', 'squareColumn'];
509
+ var path = _Path.geometryShape[shape] ? _Path.geometryShape[shape]() : _Path.geometryShape.circle();
510
+ var geometry = shape3d.indexOf(shape) === -1 ? (0, _extrude.fillPolygon)([path]) : (0, _extrude.default)([path]); // const geometry = fillPolygon([path]);
511
+
327
512
  return geometry;
328
- }
513
+ } // 热力图计算范围
514
+
515
+
329
516
  function addDir(dirX, dirY) {
330
- const x = (dirX + 1) / 2;
331
- const y = (dirY + 1) / 2;
517
+ var x = (dirX + 1) / 2;
518
+ var y = (dirY + 1) / 2;
332
519
  return [x, y];
333
520
  }
521
+ /**
522
+ * 构建地球三角网格
523
+ * @returns
524
+ */
525
+
526
+
334
527
  function earthTriangulation() {
335
- const earthmesh = (0, import_utils.primitiveSphere)(import_utils.EARTH_RADIUS, { segments: import_utils.EARTH_SEGMENTS });
336
- const { positionsArr, indicesArr, normalArr } = earthmesh;
528
+ var earthmesh = (0, _utils.primitiveSphere)(_utils.EARTH_RADIUS, {
529
+ segments: _utils.EARTH_SEGMENTS
530
+ });
531
+ var positionsArr = earthmesh.positionsArr,
532
+ indicesArr = earthmesh.indicesArr,
533
+ normalArr = earthmesh.normalArr;
337
534
  return {
338
535
  vertices: positionsArr,
339
536
  indices: indicesArr,
@@ -341,33 +538,18 @@ function earthTriangulation() {
341
538
  normals: normalArr
342
539
  };
343
540
  }
541
+
344
542
  function earthOuterTriangulation() {
345
- const earthmesh = (0, import_utils.primitiveSphere)(import_utils.EARTH_RADIUS + import_utils.EARTH_RADIUS_OUTER, {
346
- segments: import_utils.EARTH_SEGMENTS
543
+ var earthmesh = (0, _utils.primitiveSphere)(_utils.EARTH_RADIUS + _utils.EARTH_RADIUS_OUTER, {
544
+ segments: _utils.EARTH_SEGMENTS
347
545
  });
348
- const { positionsArr, indicesArr, normalArr } = earthmesh;
546
+ var positionsArr = earthmesh.positionsArr,
547
+ indicesArr = earthmesh.indicesArr,
548
+ normalArr = earthmesh.normalArr;
349
549
  return {
350
550
  vertices: positionsArr,
351
551
  indices: indicesArr,
352
552
  size: 5,
353
553
  normals: normalArr
354
554
  };
355
- }
356
- // Annotate the CommonJS export names for ESM import in node:
357
- 0 && (module.exports = {
358
- GlobelPointFillTriangulation,
359
- HeatmapGridTriangulation,
360
- HeatmapTriangulation,
361
- LineArcTriangulation,
362
- LineTriangulation,
363
- PointExtrudeTriangulation,
364
- PointFillTriangulation,
365
- PointImageTriangulation,
366
- PolygonExtrudeTriangulation,
367
- RasterImageTriangulation,
368
- SimpleLineTriangulation,
369
- earthOuterTriangulation,
370
- earthTriangulation,
371
- polygonTriangulation,
372
- polygonTriangulationWithCenter
373
- });
555
+ }