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