@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,322 +1,536 @@
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, originCoordinates, version } = feature;
125
- const line = new import_extrude_polyline.default({
126
- dash: true,
127
- join: "bevel"
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) {
185
+ pos.push(point[0], point[1], point[2], point[3], 0, totalDistance);
128
186
  });
129
- if (version === "GAODE2.x") {
130
- let path1 = coordinates;
131
- if (!Array.isArray(path1[0][0])) {
132
- path1 = [coordinates];
133
- }
134
- let path2 = originCoordinates;
135
- if (!Array.isArray(path2[0][0])) {
136
- path2 = [originCoordinates];
137
- }
138
- for (let i = 0; i < path1.length; i++) {
139
- const item1 = path1[i];
140
- const item2 = path2[i];
141
- line.simpleExtrude_gaode2(item1, item2);
142
- }
187
+ return {
188
+ vertices: pos,
189
+ indices: [],
190
+ normals: [],
191
+ size: 6,
192
+ count: results.length
193
+ };
194
+ }
195
+
196
+ function lineSegmentDistance(b1, a1) {
197
+ var dx = a1[0] - b1[0];
198
+ var dy = a1[1] - b1[1];
199
+ return Math.sqrt(dx * dx + dy * dy);
200
+ }
201
+
202
+ function pushDis(point, n) {
203
+ if (point.length < 3) {
204
+ point.push(0);
205
+ }
206
+
207
+ point.push(n);
208
+ return point;
209
+ }
210
+
211
+ function getSimpleLineVertices(points) {
212
+ var distance = 0;
213
+
214
+ if (points.length < 2) {
215
+ return {
216
+ results: points,
217
+ totalDistance: 0
218
+ };
143
219
  } else {
144
- let path = coordinates;
145
- if (path[0] && !Array.isArray(path[0][0])) {
146
- path = [coordinates];
220
+ var results = [];
221
+ var point = pushDis(points[0], distance);
222
+ results.push(point);
223
+
224
+ for (var i = 1; i < points.length - 1; i++) {
225
+ var subDistance = lineSegmentDistance(points[i - 1], points[i]);
226
+ distance += subDistance;
227
+ var mulPoint = pushDis(points[i], distance);
228
+ results.push(mulPoint);
229
+ results.push(mulPoint);
147
230
  }
148
- path.forEach((item) => {
149
- line.simpleExtrude(item);
150
- });
231
+
232
+ var pointDistance = lineSegmentDistance(points[points.length - 2], points[points.length - 1]);
233
+ distance += pointDistance;
234
+ results.push(pushDis(points[points.length - 1], distance));
235
+ return {
236
+ results: results,
237
+ totalDistance: distance
238
+ };
151
239
  }
152
- const linebuffer = line.complex;
153
- return {
154
- vertices: linebuffer.positions,
155
- indices: linebuffer.indices,
156
- normals: linebuffer.normals,
157
- size: 6
158
- };
159
240
  }
241
+
160
242
  function polygonTriangulation(feature) {
161
- const { coordinates } = feature;
162
- const flattengeo = import_earcut.default.flatten(coordinates);
163
- 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;
164
250
  return {
165
- indices: (0, import_earcut.default)(vertices, holes, dimensions),
166
- vertices,
251
+ indices: (0, _earcut.default)(vertices, holes, dimensions),
252
+ vertices: vertices,
167
253
  size: dimensions
168
254
  };
169
- }
255
+ } // TODO:构建几何图形(带有中心点和大小)
256
+
257
+
170
258
  function polygonTriangulationWithCenter(feature) {
171
- const { coordinates } = feature;
172
- const flattengeo = import_earcut.default.flatten(coordinates);
173
- 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;
174
266
  return {
175
- indices: (0, import_earcut.default)(vertices, holes, dimensions),
267
+ indices: (0, _earcut.default)(vertices, holes, dimensions),
176
268
  vertices: getVerticesWithCenter(vertices),
177
269
  size: dimensions + 4
178
270
  };
179
271
  }
272
+
180
273
  function getVerticesWithCenter(vertices) {
181
- const verticesWithCenter = [];
182
- const { center, radius } = (0, import_l7_utils.calculatePointsCenterAndRadius)(vertices);
183
- for (let i = 0; i < vertices.length; i += 2) {
184
- const lng = vertices[i];
185
- const lat = vertices[i + 1];
186
- 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]));
187
284
  }
285
+
188
286
  return verticesWithCenter;
189
287
  }
288
+
190
289
  function PolygonExtrudeTriangulation(feature) {
191
- const coordinates = feature.coordinates;
192
- 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
+
193
297
  return {
194
298
  vertices: positions,
299
+ // [ x, y, z, uv.x,uv.y ]
195
300
  indices: index,
196
- normals,
301
+ normals: normals,
197
302
  size: 5
198
303
  };
199
304
  }
305
+
200
306
  function HeatmapGridTriangulation(feature) {
201
- const { shape } = feature;
202
- 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
+
203
313
  return {
204
314
  vertices: positions,
315
+ // [ x, y, z ] 多边形顶点
205
316
  indices: index,
206
317
  size: 3
207
318
  };
208
319
  }
320
+ /**
321
+ * 图片图层顶点构造
322
+ * @param feature 数据
323
+ */
324
+
325
+
209
326
  function RasterImageTriangulation(feature) {
210
- const coordinates = feature.coordinates;
211
- const positions = [
212
- ...coordinates[0],
213
- 0,
214
- 0,
215
- 1,
216
- coordinates[1][0],
217
- coordinates[0][1],
218
- 0,
219
- 1,
220
- 1,
221
- ...coordinates[1],
222
- 0,
223
- 1,
224
- 0,
225
- ...coordinates[0],
226
- 0,
227
- 0,
228
- 1,
229
- ...coordinates[1],
230
- 0,
231
- 1,
232
- 0,
233
- coordinates[0][0],
234
- coordinates[1][1],
235
- 0,
236
- 0,
237
- 0
238
- ];
239
- 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];
240
331
  return {
241
332
  vertices: positions,
242
333
  indices: indexs,
243
334
  size: 5
244
335
  };
245
336
  }
337
+ /**
338
+ * 计算3D弧线顶点
339
+ * @param feature 映射数据
340
+ * @param segNum 弧线线段数
341
+ */
342
+
343
+
246
344
  function LineArcTriangulation(feature, segmentNumber) {
247
- const segNum = segmentNumber ? segmentNumber : 30;
248
- const coordinates = feature.coordinates;
249
- const positions = [];
250
- const indexArray = [];
251
- 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]
252
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
+
253
355
  if (i !== segNum - 1) {
254
- 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) {
255
357
  return i * 2 + v;
256
- }));
358
+ })));
257
359
  }
360
+ };
361
+
362
+ for (var i = 0; i < segNum; i++) {
363
+ _loop(i);
258
364
  }
365
+
259
366
  return {
260
367
  vertices: positions,
261
368
  indices: indexArray,
262
369
  size: 7
263
370
  };
264
371
  }
372
+ /**
373
+ * 构建热力图密度图的顶点
374
+ * @param feature
375
+ * @returns
376
+ */
377
+
378
+
265
379
  function HeatmapTriangulation(feature) {
266
- const coordinates = feature.coordinates;
380
+ var coordinates = feature.coordinates;
381
+
267
382
  if (coordinates.length === 2) {
268
383
  coordinates.push(0);
269
384
  }
270
- const size = feature.size;
271
- const dir = addDir(-1, 1);
272
- const dir1 = addDir(1, 1);
273
- const dir2 = addDir(-1, -1);
274
- const dir3 = addDir(1, -1);
275
- const positions = [
276
- ...coordinates,
277
- ...dir,
278
- ...coordinates,
279
- ...dir2,
280
- ...coordinates,
281
- ...dir3,
282
- ...coordinates,
283
- ...dir1
284
- ];
285
- 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];
286
394
  return {
287
395
  vertices: positions,
288
396
  indices: indexArray,
289
397
  size: 5
290
398
  };
291
399
  }
292
- 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
+
293
409
  if (GeometryCache && GeometryCache[shape]) {
294
410
  return GeometryCache[shape];
295
411
  }
296
- const path = import_Path.geometryShape[shape] ? import_Path.geometryShape[shape]() : import_Path.geometryShape.cylinder();
297
- 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);
298
415
  GeometryCache[shape] = geometry;
299
416
  return geometry;
300
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
+
301
507
  function getHeatmapGeometry(shape) {
302
- const shape3d = [
303
- "cylinder",
304
- "triangleColumn",
305
- "hexagonColumn",
306
- "squareColumn"
307
- ];
308
- const path = import_Path.geometryShape[shape] ? import_Path.geometryShape[shape]() : import_Path.geometryShape.circle();
309
- 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
+
310
512
  return geometry;
311
- }
513
+ } // 热力图计算范围
514
+
515
+
312
516
  function addDir(dirX, dirY) {
313
- const x = (dirX + 1) / 2;
314
- const y = (dirY + 1) / 2;
517
+ var x = (dirX + 1) / 2;
518
+ var y = (dirY + 1) / 2;
315
519
  return [x, y];
316
520
  }
521
+ /**
522
+ * 构建地球三角网格
523
+ * @returns
524
+ */
525
+
526
+
317
527
  function earthTriangulation() {
318
- const earthmesh = (0, import_utils.primitiveSphere)(import_utils.EARTH_RADIUS, { segments: import_utils.EARTH_SEGMENTS });
319
- 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;
320
534
  return {
321
535
  vertices: positionsArr,
322
536
  indices: indicesArr,
@@ -324,33 +538,18 @@ function earthTriangulation() {
324
538
  normals: normalArr
325
539
  };
326
540
  }
541
+
327
542
  function earthOuterTriangulation() {
328
- const earthmesh = (0, import_utils.primitiveSphere)(import_utils.EARTH_RADIUS + import_utils.EARTH_RADIUS_OUTER, {
329
- segments: import_utils.EARTH_SEGMENTS
543
+ var earthmesh = (0, _utils.primitiveSphere)(_utils.EARTH_RADIUS + _utils.EARTH_RADIUS_OUTER, {
544
+ segments: _utils.EARTH_SEGMENTS
330
545
  });
331
- const { positionsArr, indicesArr, normalArr } = earthmesh;
546
+ var positionsArr = earthmesh.positionsArr,
547
+ indicesArr = earthmesh.indicesArr,
548
+ normalArr = earthmesh.normalArr;
332
549
  return {
333
550
  vertices: positionsArr,
334
551
  indices: indicesArr,
335
552
  size: 5,
336
553
  normals: normalArr
337
554
  };
338
- }
339
- // Annotate the CommonJS export names for ESM import in node:
340
- 0 && (module.exports = {
341
- GlobelPointFillTriangulation,
342
- HeatmapGridTriangulation,
343
- HeatmapTriangulation,
344
- LineArcTriangulation,
345
- LineTriangulation,
346
- PointExtrudeTriangulation,
347
- PointFillTriangulation,
348
- PointImageTriangulation,
349
- PolygonExtrudeTriangulation,
350
- RasterImageTriangulation,
351
- SimpleLineTriangulation,
352
- earthOuterTriangulation,
353
- earthTriangulation,
354
- polygonTriangulation,
355
- polygonTriangulationWithCenter
356
- });
555
+ }