@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.
- package/es/Geometry/models/plane.d.ts +1 -0
- package/es/citybuliding/building.js +1 -1
- package/es/core/BaseLayer.js +10 -3
- package/es/core/interface.d.ts +26 -48
- package/es/core/interface.js +3 -0
- package/es/core/schema.d.ts +3 -3
- package/es/core/triangulation.d.ts +4 -3
- package/es/core/triangulation.js +54 -39
- package/es/heatmap/models/heatmap.js +1 -1
- package/es/image/models/image.js +7 -1
- package/es/line/index.js +4 -1
- package/es/line/models/arc.js +1 -1
- package/es/line/models/simpleLine.js +1 -1
- package/es/line/shaders/line_arc_vert.glsl +5 -3
- package/es/line/shaders/simple/simpleline_vert.glsl +1 -0
- package/es/plugins/FeatureScalePlugin.js +0 -1
- package/es/point/index.js +3 -1
- package/es/point/models/fill.js +5 -2
- package/es/point/models/fillmage.js +9 -3
- package/es/point/models/image.js +8 -2
- package/es/point/models/radar.js +2 -3
- package/es/point/models/tile.js +1 -1
- package/es/point/shaders/fill_vert.glsl +13 -6
- package/es/point/shaders/image/fillImage_vert.glsl +13 -5
- package/es/point/shaders/image_vert.glsl +17 -8
- package/es/polygon/index.js +4 -1
- package/es/raster/index.js +3 -1
- package/es/tile/manager/tileLayerManager.d.ts +3 -2
- package/es/tile/manager/tileLayerManager.js +5 -2
- package/es/tile/models/tileModel.js +4 -3
- package/es/tile/tileFactory/base.d.ts +1 -1
- package/es/tile/tileFactory/base.js +32 -5
- package/es/tile/tileFactory/vectorLayer.d.ts +3 -1
- package/es/tile/tileFactory/vectorLayer.js +22 -1
- package/es/tile/tileLayer/baseTileLayer.d.ts +1 -1
- package/es/tile/tileLayer/baseTileLayer.js +3 -2
- package/es/tile/utils.d.ts +2 -0
- package/es/tile/utils.js +5 -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 -809
- 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 +412 -213
- 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 -123
- package/lib/image/models/index.js +15 -32
- package/lib/index.js +263 -97
- package/lib/line/index.js +131 -83
- 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/line/shaders/line_arc_vert.glsl +5 -3
- package/lib/line/shaders/simple/simpleline_vert.glsl +1 -0
- 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 -241
- 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 -148
- 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 -273
- package/lib/point/models/fillmage.js +365 -252
- package/lib/point/models/image.js +241 -164
- package/lib/point/models/index.js +46 -52
- package/lib/point/models/normal.js +183 -134
- package/lib/point/models/radar.js +304 -212
- 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/shaders/fill_vert.glsl +13 -6
- package/lib/point/shaders/image/fillImage_vert.glsl +13 -5
- package/lib/point/shaders/image_vert.glsl +17 -8
- package/lib/point/shape/extrude.js +56 -52
- package/lib/polygon/index.js +154 -100
- 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 -74
- 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 +314 -227
- package/lib/tile/manager/tilePickerManager.js +192 -123
- package/lib/tile/models/tileModel.js +71 -51
- package/lib/tile/tileFactory/base.js +433 -292
- 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 +169 -95
- package/lib/tile/tileLayer/baseTileLayer.js +420 -220
- package/lib/tile/tmsTileLayer.js +110 -67
- package/lib/tile/utils.js +113 -87
- 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 +7 -6
|
@@ -1,322 +1,536 @@
|
|
|
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) {
|
|
185
|
+
pos.push(point[0], point[1], point[2], point[3], 0, totalDistance);
|
|
128
186
|
});
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
|
|
149
|
-
|
|
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
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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,
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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,
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
|
|
192
|
-
|
|
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
|
-
|
|
202
|
-
|
|
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
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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(
|
|
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
|
-
|
|
380
|
+
var coordinates = feature.coordinates;
|
|
381
|
+
|
|
267
382
|
if (coordinates.length === 2) {
|
|
268
383
|
coordinates.push(0);
|
|
269
384
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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
|
-
|
|
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
|
-
|
|
297
|
-
|
|
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
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
-
|
|
314
|
-
|
|
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
|
-
|
|
319
|
-
|
|
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
|
-
|
|
329
|
-
segments:
|
|
543
|
+
var earthmesh = (0, _utils.primitiveSphere)(_utils.EARTH_RADIUS + _utils.EARTH_RADIUS_OUTER, {
|
|
544
|
+
segments: _utils.EARTH_SEGMENTS
|
|
330
545
|
});
|
|
331
|
-
|
|
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
|
+
}
|