@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.
- package/es/heatmap/models/heatmap.js +1 -1
- package/es/tile/utils.js +1 -1
- package/lib/Geometry/index.js +114 -77
- package/lib/Geometry/models/billboard.js +232 -181
- package/lib/Geometry/models/index.js +18 -34
- package/lib/Geometry/models/plane.js +407 -278
- package/lib/Geometry/models/sprite.js +291 -189
- package/lib/canvas/index.js +101 -66
- package/lib/canvas/models/canvas.js +207 -140
- package/lib/canvas/models/index.js +12 -30
- package/lib/citybuliding/building.js +98 -63
- package/lib/citybuliding/models/build.js +192 -146
- package/lib/core/BaseLayer.js +1331 -814
- package/lib/core/BaseModel.js +457 -279
- package/lib/core/interface.js +40 -53
- package/lib/core/schema.js +21 -39
- package/lib/core/shape/Path.js +67 -79
- package/lib/core/shape/extrude.js +132 -91
- package/lib/core/triangulation.js +378 -196
- package/lib/earth/index.js +100 -62
- package/lib/earth/models/atmosphere.js +146 -112
- package/lib/earth/models/base.js +210 -150
- package/lib/earth/models/bloomsphere.js +146 -112
- package/lib/earth/utils.js +111 -91
- package/lib/heatmap/index.js +149 -92
- package/lib/heatmap/models/grid.js +118 -91
- package/lib/heatmap/models/grid3d.js +155 -123
- package/lib/heatmap/models/heatmap.js +475 -338
- package/lib/heatmap/models/hexagon.js +121 -92
- package/lib/heatmap/models/index.js +22 -37
- package/lib/heatmap/triangulation.js +31 -47
- package/lib/image/index.js +111 -74
- package/lib/image/models/dataImage.js +232 -174
- package/lib/image/models/image.js +175 -128
- package/lib/image/models/index.js +15 -32
- package/lib/index.js +263 -97
- package/lib/line/index.js +131 -85
- package/lib/line/models/arc.js +352 -237
- package/lib/line/models/arc_3d.js +334 -228
- package/lib/line/models/earthArc_3d.js +336 -228
- package/lib/line/models/great_circle.js +291 -200
- package/lib/line/models/half.js +286 -201
- package/lib/line/models/index.js +42 -50
- package/lib/line/models/line.js +428 -299
- package/lib/line/models/linearline.js +277 -203
- package/lib/line/models/simpleLine.js +239 -175
- package/lib/line/models/tile.js +348 -237
- package/lib/line/models/wall.js +327 -235
- package/lib/mask/index.js +92 -59
- package/lib/mask/models/fill.js +134 -82
- package/lib/mask/models/index.js +12 -30
- package/lib/plugins/DataMappingPlugin.js +342 -224
- package/lib/plugins/DataSourcePlugin.js +102 -87
- package/lib/plugins/FeatureScalePlugin.js +330 -240
- package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
- package/lib/plugins/LayerModelPlugin.js +80 -73
- package/lib/plugins/LayerStylePlugin.js +48 -51
- package/lib/plugins/LightingPlugin.js +80 -68
- package/lib/plugins/MultiPassRendererPlugin.js +91 -65
- package/lib/plugins/PixelPickingPlugin.js +150 -109
- package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
- package/lib/plugins/ShaderUniformPlugin.js +118 -99
- package/lib/plugins/UpdateModelPlugin.js +40 -47
- package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
- package/lib/point/index.js +226 -150
- package/lib/point/models/earthExtrude.js +279 -201
- package/lib/point/models/earthFill.js +287 -202
- package/lib/point/models/extrude.js +299 -203
- package/lib/point/models/fill.js +406 -275
- package/lib/point/models/fillmage.js +365 -256
- package/lib/point/models/image.js +241 -168
- package/lib/point/models/index.js +46 -52
- package/lib/point/models/normal.js +183 -134
- package/lib/point/models/radar.js +304 -211
- package/lib/point/models/simplePoint.js +194 -142
- package/lib/point/models/text.js +608 -385
- package/lib/point/models/tile.js +314 -223
- package/lib/point/shape/extrude.js +56 -52
- package/lib/polygon/index.js +154 -102
- package/lib/polygon/models/extrude.js +311 -223
- package/lib/polygon/models/fill.js +215 -153
- package/lib/polygon/models/index.js +46 -52
- package/lib/polygon/models/ocean.js +244 -173
- package/lib/polygon/models/tile.js +144 -100
- package/lib/polygon/models/water.js +222 -153
- package/lib/raster/buffers/triangulation.js +27 -40
- package/lib/raster/index.js +115 -75
- package/lib/raster/models/index.js +16 -33
- package/lib/raster/models/raster.js +178 -135
- package/lib/raster/raster.js +187 -132
- package/lib/tile/interface.js +4 -16
- package/lib/tile/manager/tileConfigManager.js +125 -86
- package/lib/tile/manager/tileLayerManager.js +313 -229
- package/lib/tile/manager/tilePickerManager.js +192 -123
- package/lib/tile/models/tileModel.js +71 -52
- package/lib/tile/tileFactory/base.js +432 -309
- package/lib/tile/tileFactory/index.js +51 -49
- package/lib/tile/tileFactory/line.js +65 -50
- package/lib/tile/tileFactory/point.js +65 -50
- package/lib/tile/tileFactory/polygon.js +65 -50
- package/lib/tile/tileFactory/raster.js +66 -54
- package/lib/tile/tileFactory/rasterData.js +88 -76
- package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
- package/lib/tile/tileFactory/vectorLayer.js +168 -109
- package/lib/tile/tileLayer/baseTileLayer.js +420 -221
- package/lib/tile/tmsTileLayer.js +110 -67
- package/lib/tile/utils.js +110 -92
- package/lib/utils/blend.js +59 -79
- package/lib/utils/collision-index.js +107 -64
- package/lib/utils/dataMappingStyle.js +105 -60
- package/lib/utils/extrude_polyline.js +600 -398
- package/lib/utils/grid-index.js +163 -111
- package/lib/utils/layerData.js +130 -99
- package/lib/utils/multiPassRender.js +49 -41
- package/lib/utils/polylineNormal.js +148 -96
- package/lib/utils/simpleLine.js +100 -85
- package/lib/utils/symbol-layout.js +219 -116
- package/lib/utils/updateShape.js +15 -41
- package/lib/wind/index.js +109 -71
- package/lib/wind/models/index.js +12 -30
- package/lib/wind/models/utils.js +144 -105
- package/lib/wind/models/wind.js +333 -224
- package/lib/wind/models/windRender.js +329 -218
- package/lib/wind/models/windShader.js +23 -181
- package/package.json +6 -6
|
@@ -1,130 +1,187 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
56
|
+
var coordinates = (0, _l7Utils.calculateCentroid)(feature.coordinates);
|
|
52
57
|
return {
|
|
53
|
-
vertices: [
|
|
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
|
-
|
|
60
|
-
|
|
70
|
+
var coordinates = (0, _l7Utils.calculateCentroid)(feature.coordinates);
|
|
71
|
+
var xyz = (0, _utils.lglt2xyz)(coordinates);
|
|
61
72
|
return {
|
|
62
|
-
vertices: [
|
|
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
|
-
|
|
69
|
-
|
|
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
|
-
|
|
106
|
+
var coordinates = (0, _l7Utils.calculateCentroid)(feature.coordinates);
|
|
79
107
|
return {
|
|
80
|
-
vertices:
|
|
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
|
-
|
|
87
|
-
|
|
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:
|
|
129
|
+
join: 'bevel'
|
|
90
130
|
});
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
139
|
+
|
|
140
|
+
var path2 = originCoordinates; // 计算法线
|
|
141
|
+
|
|
97
142
|
if (!Array.isArray(path2[0][0])) {
|
|
98
143
|
path2 = [originCoordinates];
|
|
99
144
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
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
|
-
|
|
159
|
+
|
|
160
|
+
path.forEach(function (item) {
|
|
111
161
|
line.extrude(item);
|
|
112
162
|
});
|
|
113
163
|
}
|
|
114
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
140
|
-
|
|
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
|
-
|
|
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
|
-
|
|
159
|
-
|
|
220
|
+
var results = [];
|
|
221
|
+
var point = pushDis(points[0], distance);
|
|
160
222
|
results.push(point);
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
227
|
+
var mulPoint = pushDis(points[i], distance);
|
|
165
228
|
results.push(mulPoint);
|
|
166
229
|
results.push(mulPoint);
|
|
167
230
|
}
|
|
168
|
-
|
|
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
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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,
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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,
|
|
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
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
|
|
209
|
-
|
|
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
|
-
|
|
219
|
-
|
|
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
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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(
|
|
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
|
-
|
|
380
|
+
var coordinates = feature.coordinates;
|
|
381
|
+
|
|
284
382
|
if (coordinates.length === 2) {
|
|
285
383
|
coordinates.push(0);
|
|
286
384
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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
|
-
|
|
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
|
-
|
|
314
|
-
|
|
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
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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
|
-
|
|
331
|
-
|
|
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
|
-
|
|
336
|
-
|
|
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
|
-
|
|
346
|
-
segments:
|
|
543
|
+
var earthmesh = (0, _utils.primitiveSphere)(_utils.EARTH_RADIUS + _utils.EARTH_RADIUS_OUTER, {
|
|
544
|
+
segments: _utils.EARTH_SEGMENTS
|
|
347
545
|
});
|
|
348
|
-
|
|
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
|
+
}
|