@antv/l7-layers 2.17.4 → 2.17.6
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 +9 -31
- package/es/Geometry/models/billboard.js +51 -89
- package/es/Geometry/models/plane.js +81 -143
- package/es/Geometry/models/sprite.js +60 -118
- package/es/canvas/index.js +10 -33
- package/es/canvas/models/canvas.js +41 -97
- package/es/citybuliding/building.js +8 -27
- package/es/citybuliding/models/build.js +57 -82
- package/es/core/BaseLayer.js +325 -483
- package/es/core/BaseModel.js +51 -80
- package/es/core/CommonStyleAttribute.js +2 -5
- package/es/core/LayerPickService.js +21 -32
- package/es/core/TextureService.js +0 -13
- package/es/core/interface.js +17 -24
- package/es/core/shape/Path.js +13 -20
- package/es/core/shape/extrude.js +27 -39
- package/es/core/triangulation.js +99 -136
- package/es/earth/index.js +9 -33
- package/es/earth/models/atmosphere.js +30 -54
- package/es/earth/models/base.js +47 -85
- package/es/earth/models/bloomsphere.js +30 -54
- package/es/earth/utils.js +9 -13
- package/es/heatmap/index.js +10 -40
- package/es/heatmap/models/grid.js +28 -52
- package/es/heatmap/models/grid3d.js +28 -52
- package/es/heatmap/models/heatmap.js +92 -149
- package/es/heatmap/models/hexagon.js +28 -52
- package/es/heatmap/triangulation.js +0 -4
- package/es/image/index.js +9 -28
- package/es/image/models/image.js +66 -100
- package/es/index.js +9 -17
- package/es/line/index.js +9 -35
- package/es/line/models/arc.js +63 -112
- package/es/line/models/arc_3d.js +58 -102
- package/es/line/models/earthArc_3d.js +60 -105
- package/es/line/models/flow.js +36 -60
- package/es/line/models/great_circle.js +53 -94
- package/es/line/models/line.js +92 -144
- package/es/line/models/linearline.js +42 -74
- package/es/line/models/simpleLine.js +38 -67
- package/es/line/models/wall.js +52 -92
- package/es/line/shaders/dash/line_dash_vert.glsl +1 -2
- package/es/line/shaders/line_frag.glsl +1 -3
- package/es/line/shaders/line_vert.glsl +2 -0
- package/es/line/shaders/linear/line_linear_frag.glsl +1 -1
- package/es/mask/index.js +9 -28
- package/es/mask/models/fill.js +29 -54
- package/es/plugins/DataMappingPlugin.js +78 -114
- package/es/plugins/DataSourcePlugin.js +45 -68
- package/es/plugins/FeatureScalePlugin.js +67 -122
- package/es/plugins/LayerAnimateStylePlugin.js +0 -5
- package/es/plugins/LayerMaskPlugin.js +3 -11
- package/es/plugins/LayerModelPlugin.js +69 -118
- package/es/plugins/LayerStylePlugin.js +4 -9
- package/es/plugins/LightingPlugin.js +12 -18
- package/es/plugins/MultiPassRendererPlugin.js +11 -16
- package/es/plugins/PixelPickingPlugin.js +12 -21
- package/es/plugins/RegisterStyleAttributePlugin.js +5 -12
- package/es/plugins/ShaderUniformPlugin.js +13 -27
- package/es/plugins/UpdateModelPlugin.js +0 -5
- package/es/plugins/UpdateStyleAttributePlugin.js +5 -11
- package/es/point/index.js +26 -78
- package/es/point/models/earthExtrude.js +58 -95
- package/es/point/models/earthFill.js +52 -80
- package/es/point/models/extrude.js +57 -94
- package/es/point/models/fill.js +56 -81
- package/es/point/models/fillmage.js +60 -100
- package/es/point/models/image.js +47 -83
- package/es/point/models/index.js +2 -2
- package/es/point/models/normal.js +30 -54
- package/es/point/models/radar.js +38 -63
- package/es/point/models/simplePoint.js +38 -62
- package/es/point/models/text.js +199 -296
- package/es/point/shape/extrude.js +4 -13
- package/es/polygon/index.js +11 -41
- package/es/polygon/models/extrude.js +87 -135
- package/es/polygon/models/fill.js +50 -79
- package/es/polygon/models/index.js +3 -2
- package/es/polygon/models/ocean.js +42 -76
- package/es/polygon/models/water.js +37 -71
- package/es/raster/buffers/triangulation.js +2 -4
- package/es/raster/index.js +9 -32
- package/es/raster/models/raster.js +80 -116
- package/es/raster/models/rasterRgb.js +84 -127
- package/es/raster/models/rasterTerrainRgb.js +56 -84
- package/es/tile/interaction/getRasterData.js +14 -20
- package/es/tile/interaction/utils.js +7 -9
- package/es/tile/manager/base.js +63 -96
- package/es/tile/service/TileLayerService.js +33 -55
- package/es/tile/service/TilePickService.js +26 -40
- package/es/tile/service/TileSourceService.js +3 -7
- package/es/tile/tileFactory/DebugTile.js +29 -46
- package/es/tile/tileFactory/ImageTile.js +20 -38
- package/es/tile/tileFactory/MaskTile.js +22 -43
- package/es/tile/tileFactory/RasterRGBTile.js +22 -42
- package/es/tile/tileFactory/RasterTerrainRGBTile.js +20 -38
- package/es/tile/tileFactory/RasterTile.js +30 -53
- package/es/tile/tileFactory/Tile.js +63 -97
- package/es/tile/tileFactory/VectorTile.js +41 -68
- package/es/tile/tileFactory/index.js +0 -11
- package/es/tile/tileFactory/layers/TileDebugLayer.js +6 -27
- package/es/tile/tileFactory/util.js +0 -3
- package/es/tile/tileLayer/BaseLayer.js +105 -146
- package/es/tile/utils.js +1 -1
- package/es/utils/blend.js +0 -2
- package/es/utils/collision-index.js +9 -16
- package/es/utils/extrude_polyline.js +101 -149
- package/es/utils/grid-index.js +2 -27
- package/es/utils/identityScale.js +0 -8
- package/es/utils/layerData.js +30 -44
- package/es/utils/multiPassRender.js +11 -13
- package/es/utils/polylineNormal.js +31 -37
- package/es/utils/simpleLine.js +2 -16
- package/es/utils/stencil.js +2 -3
- package/es/utils/symbol-layout.js +27 -53
- package/es/wind/index.js +9 -29
- package/es/wind/models/utils.js +26 -51
- package/es/wind/models/wind.js +101 -147
- package/es/wind/models/windRender.js +53 -66
- package/lib/Geometry/index.js +9 -38
- package/lib/Geometry/models/billboard.js +51 -97
- package/lib/Geometry/models/index.js +0 -5
- package/lib/Geometry/models/plane.js +79 -151
- package/lib/Geometry/models/sprite.js +60 -127
- package/lib/canvas/index.js +10 -40
- package/lib/canvas/models/canvas.js +41 -101
- package/lib/canvas/models/index.js +0 -3
- package/lib/citybuliding/building.js +8 -35
- package/lib/citybuliding/models/build.js +57 -92
- package/lib/core/BaseLayer.js +325 -474
- package/lib/core/BaseModel.js +51 -90
- package/lib/core/CommonStyleAttribute.js +2 -7
- package/lib/core/LayerPickService.js +21 -37
- package/lib/core/TextureService.js +0 -16
- package/lib/core/interface.js +21 -31
- package/lib/core/schema.js +0 -1
- package/lib/core/shape/Path.js +14 -31
- package/lib/core/shape/extrude.js +27 -62
- package/lib/core/triangulation.js +98 -177
- package/lib/earth/index.js +9 -43
- package/lib/earth/models/atmosphere.js +30 -63
- package/lib/earth/models/base.js +47 -90
- package/lib/earth/models/bloomsphere.js +30 -63
- package/lib/earth/utils.js +7 -31
- package/lib/heatmap/index.js +10 -48
- package/lib/heatmap/models/grid.js +28 -60
- package/lib/heatmap/models/grid3d.js +28 -60
- package/lib/heatmap/models/heatmap.js +92 -166
- package/lib/heatmap/models/hexagon.js +28 -60
- package/lib/heatmap/models/index.js +0 -6
- package/lib/heatmap/triangulation.js +0 -5
- package/lib/image/index.js +9 -36
- package/lib/image/models/image.js +66 -109
- package/lib/image/models/index.js +0 -3
- package/lib/index.js +7 -61
- package/lib/line/index.js +9 -40
- package/lib/line/models/arc.js +61 -122
- package/lib/line/models/arc_3d.js +56 -113
- package/lib/line/models/earthArc_3d.js +58 -115
- package/lib/line/models/flow.js +36 -70
- package/lib/line/models/great_circle.js +53 -104
- package/lib/line/models/index.js +0 -11
- package/lib/line/models/line.js +90 -152
- package/lib/line/models/linearline.js +42 -86
- package/lib/line/models/simpleLine.js +38 -77
- package/lib/line/models/wall.js +52 -103
- package/lib/line/shaders/dash/line_dash_vert.glsl +1 -2
- package/lib/line/shaders/line_frag.glsl +1 -3
- package/lib/line/shaders/line_vert.glsl +2 -0
- package/lib/line/shaders/linear/line_linear_frag.glsl +1 -1
- package/lib/mask/index.js +9 -36
- package/lib/mask/models/fill.js +29 -63
- package/lib/mask/models/index.js +0 -3
- package/lib/plugins/DataMappingPlugin.js +78 -125
- package/lib/plugins/DataSourcePlugin.js +45 -76
- package/lib/plugins/FeatureScalePlugin.js +67 -138
- package/lib/plugins/LayerAnimateStylePlugin.js +0 -10
- package/lib/plugins/LayerMaskPlugin.js +4 -17
- package/lib/plugins/LayerModelPlugin.js +70 -127
- package/lib/plugins/LayerStylePlugin.js +5 -14
- package/lib/plugins/LightingPlugin.js +12 -25
- package/lib/plugins/MultiPassRendererPlugin.js +11 -22
- package/lib/plugins/PixelPickingPlugin.js +12 -27
- package/lib/plugins/RegisterStyleAttributePlugin.js +5 -19
- package/lib/plugins/ShaderUniformPlugin.js +13 -34
- package/lib/plugins/UpdateModelPlugin.js +1 -10
- package/lib/plugins/UpdateStyleAttributePlugin.js +5 -16
- package/lib/point/index.js +26 -83
- package/lib/point/models/earthExtrude.js +58 -106
- package/lib/point/models/earthFill.js +52 -110
- package/lib/point/models/extrude.js +57 -103
- package/lib/point/models/fill.js +54 -90
- package/lib/point/models/fillmage.js +58 -107
- package/lib/point/models/image.js +47 -92
- package/lib/point/models/index.js +1 -12
- package/lib/point/models/normal.js +30 -64
- package/lib/point/models/radar.js +38 -72
- package/lib/point/models/simplePoint.js +38 -72
- package/lib/point/models/text.js +199 -305
- package/lib/point/shape/extrude.js +4 -20
- package/lib/polygon/index.js +11 -48
- package/lib/polygon/models/extrude.js +87 -146
- package/lib/polygon/models/fill.js +50 -89
- package/lib/polygon/models/index.js +2 -14
- package/lib/polygon/models/ocean.js +42 -88
- package/lib/polygon/models/water.js +37 -82
- package/lib/raster/buffers/triangulation.js +3 -7
- package/lib/raster/index.js +9 -40
- package/lib/raster/models/index.js +0 -5
- package/lib/raster/models/raster.js +80 -125
- package/lib/raster/models/rasterRgb.js +84 -139
- package/lib/raster/models/rasterTerrainRgb.js +56 -93
- package/lib/tile/interaction/getRasterData.js +14 -25
- package/lib/tile/interaction/utils.js +7 -19
- package/lib/tile/manager/base.js +63 -104
- package/lib/tile/service/TileLayerService.js +33 -60
- package/lib/tile/service/TilePickService.js +26 -48
- package/lib/tile/service/TileSourceService.js +2 -16
- package/lib/tile/style/utils.js +0 -3
- package/lib/tile/tileFactory/DebugTile.js +29 -54
- package/lib/tile/tileFactory/ImageTile.js +20 -46
- package/lib/tile/tileFactory/MaskTile.js +22 -51
- package/lib/tile/tileFactory/RasterRGBTile.js +22 -50
- package/lib/tile/tileFactory/RasterTerrainRGBTile.js +20 -46
- package/lib/tile/tileFactory/RasterTile.js +30 -63
- package/lib/tile/tileFactory/Tile.js +63 -102
- package/lib/tile/tileFactory/VectorTile.js +41 -76
- package/lib/tile/tileFactory/index.js +0 -25
- package/lib/tile/tileFactory/layers/TileDebugLayer.js +6 -32
- package/lib/tile/tileFactory/util.js +0 -9
- package/lib/tile/tileLayer/BaseLayer.js +105 -153
- package/lib/tile/utils.js +1 -5
- package/lib/utils/blend.js +0 -5
- package/lib/utils/collision-index.js +9 -25
- package/lib/utils/extrude_polyline.js +101 -181
- package/lib/utils/grid-index.js +2 -28
- package/lib/utils/identityScale.js +0 -9
- package/lib/utils/layerData.js +30 -49
- package/lib/utils/multiPassRender.js +11 -16
- package/lib/utils/polylineNormal.js +31 -66
- package/lib/utils/simpleLine.js +2 -21
- package/lib/utils/stencil.js +0 -4
- package/lib/utils/symbol-layout.js +27 -55
- package/lib/wind/index.js +9 -37
- package/lib/wind/models/index.js +0 -3
- package/lib/wind/models/utils.js +26 -62
- package/lib/wind/models/wind.js +101 -157
- package/lib/wind/models/windRender.js +53 -71
- package/lib/wind/models/windShader.js +0 -1
- package/package.json +7 -7
|
@@ -6,9 +6,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
6
6
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
7
|
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
|
|
8
8
|
import _initializerWarningHelper from "@babel/runtime/helpers/esm/initializerWarningHelper";
|
|
9
|
-
|
|
10
9
|
var _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2;
|
|
11
|
-
|
|
12
10
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
13
11
|
import { IDebugLog, ILayerStage, TYPES } from '@antv/l7-core';
|
|
14
12
|
import { Version } from '@antv/l7-maps';
|
|
@@ -19,35 +17,27 @@ import 'reflect-metadata';
|
|
|
19
17
|
var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService), _dec3 = inject(TYPES.IFontService), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
20
18
|
function DataMappingPlugin() {
|
|
21
19
|
_classCallCheck(this, DataMappingPlugin);
|
|
22
|
-
|
|
23
20
|
_initializerDefineProperty(this, "mapService", _descriptor, this);
|
|
24
|
-
|
|
25
21
|
_initializerDefineProperty(this, "fontService", _descriptor2, this);
|
|
26
22
|
}
|
|
27
|
-
|
|
28
23
|
_createClass(DataMappingPlugin, [{
|
|
29
24
|
key: "apply",
|
|
30
25
|
value: function apply(layer, _ref) {
|
|
31
26
|
var _this = this;
|
|
32
|
-
|
|
33
27
|
var styleAttributeService = _ref.styleAttributeService;
|
|
34
28
|
layer.hooks.init.tapPromise('DataMappingPlugin', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
35
29
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
36
|
-
while (1) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
case 3:
|
|
48
|
-
case "end":
|
|
49
|
-
return _context.stop();
|
|
50
|
-
}
|
|
30
|
+
while (1) switch (_context.prev = _context.next) {
|
|
31
|
+
case 0:
|
|
32
|
+
layer.log(IDebugLog.MappingStart, ILayerStage.INIT);
|
|
33
|
+
// 初始化重新生成 map
|
|
34
|
+
_this.generateMaping(layer, {
|
|
35
|
+
styleAttributeService: styleAttributeService
|
|
36
|
+
});
|
|
37
|
+
layer.log(IDebugLog.MappingEnd, ILayerStage.INIT);
|
|
38
|
+
case 3:
|
|
39
|
+
case "end":
|
|
40
|
+
return _context.stop();
|
|
51
41
|
}
|
|
52
42
|
}, _callee);
|
|
53
43
|
})));
|
|
@@ -55,106 +45,95 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
55
45
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(flag) {
|
|
56
46
|
var mappingResult;
|
|
57
47
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
58
|
-
while (1) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
case 7:
|
|
78
|
-
case "end":
|
|
79
|
-
return _context2.stop();
|
|
80
|
-
}
|
|
48
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
49
|
+
case 0:
|
|
50
|
+
if (flag) {
|
|
51
|
+
_context2.next = 2;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
return _context2.abrupt("return", flag);
|
|
55
|
+
case 2:
|
|
56
|
+
layer.dataState.dataMappingNeedUpdate = false;
|
|
57
|
+
layer.log(IDebugLog.MappingStart, ILayerStage.UPDATE);
|
|
58
|
+
mappingResult = _this.generateMaping(layer, {
|
|
59
|
+
styleAttributeService: styleAttributeService
|
|
60
|
+
});
|
|
61
|
+
layer.log(IDebugLog.MappingEnd, ILayerStage.UPDATE);
|
|
62
|
+
return _context2.abrupt("return", mappingResult);
|
|
63
|
+
case 7:
|
|
64
|
+
case "end":
|
|
65
|
+
return _context2.stop();
|
|
81
66
|
}
|
|
82
67
|
}, _callee2);
|
|
83
68
|
}));
|
|
84
|
-
|
|
85
69
|
return function (_x) {
|
|
86
70
|
return _ref3.apply(this, arguments);
|
|
87
71
|
};
|
|
88
|
-
}());
|
|
72
|
+
}());
|
|
89
73
|
|
|
74
|
+
// remapping before render
|
|
90
75
|
layer.hooks.beforeRender.tap('DataMappingPlugin', function () {
|
|
91
76
|
var source = layer.getSource();
|
|
92
|
-
|
|
93
77
|
if (layer.layerModelNeedUpdate || !source || !source.inited) {
|
|
94
78
|
return;
|
|
95
79
|
}
|
|
96
|
-
|
|
97
80
|
var attributes = styleAttributeService.getLayerStyleAttributes() || [];
|
|
98
81
|
var filter = styleAttributeService.getLayerStyleAttribute('filter');
|
|
99
|
-
var dataArray = source.data.dataArray;
|
|
100
|
-
|
|
82
|
+
var dataArray = source.data.dataArray;
|
|
83
|
+
// TODO 数据为空的情况
|
|
101
84
|
if (Array.isArray(dataArray) && dataArray.length === 0) {
|
|
102
85
|
return;
|
|
103
86
|
}
|
|
104
|
-
|
|
105
87
|
var attributesToRemapping = attributes.filter(function (attribute) {
|
|
106
88
|
return attribute.needRemapping;
|
|
107
89
|
} // 如果filter变化
|
|
108
90
|
);
|
|
109
|
-
var filterData = dataArray; // 数据过滤完 再执行数据映射
|
|
110
91
|
|
|
92
|
+
var filterData = dataArray;
|
|
93
|
+
// 数据过滤完 再执行数据映射
|
|
111
94
|
if (filter !== null && filter !== void 0 && filter.needRemapping && filter !== null && filter !== void 0 && filter.scale) {
|
|
112
95
|
filterData = dataArray.filter(function (record) {
|
|
113
96
|
return _this.applyAttributeMapping(filter, record)[0];
|
|
114
97
|
});
|
|
115
98
|
}
|
|
116
|
-
|
|
117
99
|
if (attributesToRemapping.length) {
|
|
118
100
|
// 过滤数据
|
|
119
101
|
var encodeData = _this.mapping(layer, attributesToRemapping, filterData, layer.getEncodedData() // TODO 优化
|
|
120
102
|
);
|
|
121
103
|
|
|
122
104
|
layer.setEncodedData(encodeData);
|
|
123
|
-
}
|
|
124
|
-
// layer.emit('remapping', null);
|
|
105
|
+
}
|
|
125
106
|
|
|
107
|
+
// 处理文本更新,更新文字形状
|
|
108
|
+
// layer.emit('remapping', null);
|
|
126
109
|
});
|
|
127
110
|
}
|
|
128
111
|
}, {
|
|
129
112
|
key: "generateMaping",
|
|
130
113
|
value: function generateMaping(layer, _ref4) {
|
|
131
114
|
var _this2 = this;
|
|
132
|
-
|
|
133
115
|
var styleAttributeService = _ref4.styleAttributeService;
|
|
134
116
|
var attributes = styleAttributeService.getLayerStyleAttributes() || [];
|
|
135
117
|
var filter = styleAttributeService.getLayerStyleAttribute('filter');
|
|
136
118
|
var dataArray = layer.getSource().data.dataArray;
|
|
137
|
-
var filterData = dataArray;
|
|
138
|
-
|
|
119
|
+
var filterData = dataArray;
|
|
120
|
+
// 数据过滤完 再执行数据映射
|
|
139
121
|
if (filter !== null && filter !== void 0 && filter.scale) {
|
|
140
122
|
filterData = dataArray.filter(function (record) {
|
|
141
123
|
return _this2.applyAttributeMapping(filter, record)[0];
|
|
142
124
|
});
|
|
143
|
-
}
|
|
125
|
+
}
|
|
126
|
+
// Tip: layer 对数据做处理
|
|
144
127
|
// 数据处理 在数据进行 mapping 生成 encodeData 之前对数据进行处理
|
|
145
128
|
// 在各个 layer 中继承
|
|
146
129
|
|
|
147
|
-
|
|
148
130
|
filterData = layer.processData(filterData); // 目前只有简单线需要处理
|
|
149
|
-
|
|
150
131
|
var encodeData = this.mapping(layer, attributes, filterData, undefined);
|
|
151
132
|
layer.setEncodedData(encodeData);
|
|
152
|
-
|
|
153
133
|
if (dataArray.length === 0 && layer.encodeDataLength === 0) {
|
|
154
134
|
return false;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
135
|
+
}
|
|
136
|
+
// 对外暴露事件
|
|
158
137
|
layer.emit('dataUpdate', null);
|
|
159
138
|
return true;
|
|
160
139
|
}
|
|
@@ -162,13 +141,11 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
162
141
|
key: "mapping",
|
|
163
142
|
value: function mapping(layer, attributes, data, predata) {
|
|
164
143
|
var _this3 = this;
|
|
165
|
-
|
|
166
144
|
var _ref5 = layer.getLayerConfig(),
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
145
|
+
_ref5$arrow = _ref5.arrow,
|
|
146
|
+
arrow = _ref5$arrow === void 0 ? {
|
|
147
|
+
enable: false
|
|
148
|
+
} : _ref5$arrow;
|
|
172
149
|
var usedAttributes = attributes.filter(function (attribute) {
|
|
173
150
|
return attribute.scale !== undefined;
|
|
174
151
|
}).filter(function (attribute) {
|
|
@@ -176,52 +153,47 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
176
153
|
});
|
|
177
154
|
var mappedData = data.map(function (record, i) {
|
|
178
155
|
var preRecord = predata ? predata[i] : {};
|
|
179
|
-
|
|
180
156
|
var encodeRecord = _objectSpread({
|
|
181
157
|
id: record._id,
|
|
182
158
|
coordinates: record.coordinates
|
|
183
159
|
}, preRecord);
|
|
184
|
-
|
|
185
160
|
usedAttributes.forEach(function (attribute) {
|
|
186
|
-
var values = _this3.applyAttributeMapping(attribute, record);
|
|
187
|
-
|
|
188
|
-
|
|
161
|
+
var values = _this3.applyAttributeMapping(attribute, record);
|
|
162
|
+
// TODO: 支持每个属性配置 postprocess}
|
|
189
163
|
if (attribute.name === 'color' || attribute.name === 'stroke') {
|
|
190
164
|
values = values.map(function (c) {
|
|
191
165
|
return rgb2arr(c);
|
|
192
166
|
});
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values; // 增加对 layer/text/iconfont unicode 映射的解析
|
|
167
|
+
}
|
|
168
|
+
// @ts-ignore
|
|
169
|
+
encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values;
|
|
197
170
|
|
|
171
|
+
// 增加对 layer/text/iconfont unicode 映射的解析
|
|
198
172
|
if (attribute.name === 'shape') {
|
|
199
173
|
encodeRecord.shape = _this3.fontService.getIconFontKey(encodeRecord[attribute.name]);
|
|
200
174
|
}
|
|
201
175
|
});
|
|
202
|
-
|
|
203
176
|
if (arrow.enable && encodeRecord.shape === 'line') {
|
|
204
177
|
// 只有在线图层且支持配置箭头的时候进行插入顶点的处理
|
|
205
|
-
var coords = encodeRecord.coordinates;
|
|
206
|
-
|
|
178
|
+
var coords = encodeRecord.coordinates;
|
|
179
|
+
// @ts-ignore
|
|
207
180
|
if (layer.arrowInsertCount < layer.encodeDataLength) {
|
|
208
181
|
// Tip: arrowInsert 的判断用于确保每一条线数据 arrow 的属性点只会被植入一次
|
|
209
182
|
var arrowPoint = _this3.getArrowPoints(coords[0], coords[1]);
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
183
|
+
encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
|
|
184
|
+
// @ts-ignore
|
|
213
185
|
layer.arrowInsertCount++;
|
|
214
186
|
}
|
|
215
187
|
}
|
|
216
|
-
|
|
217
188
|
return encodeRecord;
|
|
218
189
|
});
|
|
219
190
|
attributes.forEach(function (attribute) {
|
|
220
191
|
attribute.needRemapping = false;
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
this.adjustData2Amap2Coordinates(mappedData, layer);
|
|
192
|
+
});
|
|
193
|
+
// 调整数据兼容 Amap2.0
|
|
194
|
+
this.adjustData2Amap2Coordinates(mappedData, layer);
|
|
224
195
|
|
|
196
|
+
// 调整数据兼容 SimpleCoordinates
|
|
225
197
|
this.adjustData2SimpleCoordinates(mappedData);
|
|
226
198
|
return mappedData;
|
|
227
199
|
}
|
|
@@ -229,22 +201,21 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
229
201
|
key: "adjustData2Amap2Coordinates",
|
|
230
202
|
value: function adjustData2Amap2Coordinates(mappedData, layer) {
|
|
231
203
|
var _this4 = this;
|
|
232
|
-
|
|
233
204
|
// 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移
|
|
234
205
|
if (mappedData.length > 0 && this.mapService.version === Version['GAODE2.x']) {
|
|
235
|
-
var layerCenter = layer.coordCenter || layer.getSource().center;
|
|
206
|
+
var layerCenter = layer.coordCenter || layer.getSource().center;
|
|
207
|
+
// 单个的点数据
|
|
236
208
|
// @ts-ignore
|
|
237
|
-
|
|
238
|
-
|
|
209
|
+
mappedData
|
|
210
|
+
// TODO: 避免经纬度被重复计算导致坐标位置偏移
|
|
239
211
|
.filter(function (d) {
|
|
240
212
|
return !d.originCoordinates;
|
|
241
213
|
}).map(function (d) {
|
|
242
|
-
d.version = Version['GAODE2.x'];
|
|
243
|
-
|
|
214
|
+
d.version = Version['GAODE2.x'];
|
|
215
|
+
// @ts-ignore
|
|
244
216
|
d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
|
|
245
217
|
// @ts-ignore
|
|
246
218
|
// d.coordinates = this.mapService.lngLatToCoord(d.coordinates);
|
|
247
|
-
|
|
248
219
|
d.coordinates = _this4.mapService.coordToAMap2RelativeCoordinates(d.coordinates, layerCenter);
|
|
249
220
|
});
|
|
250
221
|
}
|
|
@@ -253,7 +224,6 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
253
224
|
key: "adjustData2SimpleCoordinates",
|
|
254
225
|
value: function adjustData2SimpleCoordinates(mappedData) {
|
|
255
226
|
var _this5 = this;
|
|
256
|
-
|
|
257
227
|
if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {
|
|
258
228
|
mappedData.map(function (d) {
|
|
259
229
|
if (!d.simpleCoordinate) {
|
|
@@ -267,11 +237,9 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
267
237
|
key: "unProjectCoordinates",
|
|
268
238
|
value: function unProjectCoordinates(coordinates) {
|
|
269
239
|
var _this6 = this;
|
|
270
|
-
|
|
271
240
|
if (typeof coordinates[0] === 'number') {
|
|
272
241
|
return this.mapService.simpleMapCoord.unproject(coordinates);
|
|
273
242
|
}
|
|
274
|
-
|
|
275
243
|
if (coordinates[0] && coordinates[0][0] instanceof Array) {
|
|
276
244
|
// @ts-ignore
|
|
277
245
|
var coords = [];
|
|
@@ -280,20 +248,20 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
280
248
|
var c1 = [];
|
|
281
249
|
coord.map(function (co) {
|
|
282
250
|
c1.push(_this6.mapService.simpleMapCoord.unproject(co));
|
|
283
|
-
});
|
|
284
|
-
|
|
251
|
+
});
|
|
252
|
+
// @ts-ignore
|
|
285
253
|
coords.push(c1);
|
|
286
|
-
});
|
|
287
|
-
|
|
254
|
+
});
|
|
255
|
+
// @ts-ignore
|
|
288
256
|
return coords;
|
|
289
257
|
} else {
|
|
290
258
|
// @ts-ignore
|
|
291
|
-
var _coords = [];
|
|
292
|
-
|
|
259
|
+
var _coords = [];
|
|
260
|
+
// @ts-ignore
|
|
293
261
|
coordinates.map(function (coord) {
|
|
294
262
|
_coords.push(_this6.mapService.simpleMapCoord.unproject(coord));
|
|
295
|
-
});
|
|
296
|
-
|
|
263
|
+
});
|
|
264
|
+
// @ts-ignore
|
|
297
265
|
return _coords;
|
|
298
266
|
}
|
|
299
267
|
}
|
|
@@ -301,25 +269,22 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
301
269
|
key: "applyAttributeMapping",
|
|
302
270
|
value: function applyAttributeMapping(attribute, record) {
|
|
303
271
|
var _attribute$scale;
|
|
304
|
-
|
|
305
272
|
if (!attribute.scale) {
|
|
306
273
|
return [];
|
|
307
274
|
}
|
|
308
|
-
|
|
309
275
|
var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
|
|
310
276
|
var params = [];
|
|
311
277
|
scalers.forEach(function (_ref6) {
|
|
312
278
|
var _attribute$scale2;
|
|
313
|
-
|
|
314
279
|
var field = _ref6.field;
|
|
315
|
-
|
|
316
280
|
if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
|
|
317
281
|
// TODO:多字段,常量
|
|
318
282
|
params.push(record[field]);
|
|
319
283
|
}
|
|
320
284
|
});
|
|
321
285
|
var mappingResult = attribute.mapping ? attribute.mapping(params) : [];
|
|
322
|
-
return mappingResult;
|
|
286
|
+
return mappingResult;
|
|
287
|
+
// return attribute.mapping ? attribute.mapping(params) : [];
|
|
323
288
|
}
|
|
324
289
|
}, {
|
|
325
290
|
key: "getArrowPoints",
|
|
@@ -330,7 +295,6 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
330
295
|
return arrowPoint;
|
|
331
296
|
}
|
|
332
297
|
}]);
|
|
333
|
-
|
|
334
298
|
return DataMappingPlugin;
|
|
335
299
|
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "mapService", [_dec2], {
|
|
336
300
|
configurable: true,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
|
|
5
4
|
var _dec, _class;
|
|
6
|
-
|
|
7
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
6
|
import { IDebugLog, ILayerStage, TYPES } from '@antv/l7-core';
|
|
9
7
|
import Source from '@antv/l7-source';
|
|
@@ -13,79 +11,64 @@ var DataSourcePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function
|
|
|
13
11
|
function DataSourcePlugin() {
|
|
14
12
|
_classCallCheck(this, DataSourcePlugin);
|
|
15
13
|
}
|
|
16
|
-
|
|
17
14
|
_createClass(DataSourcePlugin, [{
|
|
18
15
|
key: "apply",
|
|
19
16
|
value: function apply(layer) {
|
|
20
17
|
var _this = this;
|
|
21
|
-
|
|
22
18
|
this.mapService = layer.getContainer().get(TYPES.IMapService);
|
|
23
19
|
layer.hooks.init.tapPromise('DataSourcePlugin', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
24
20
|
var source, _ref2, data, options;
|
|
25
|
-
|
|
26
21
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
27
|
-
while (1) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (!source.inited) {
|
|
41
|
-
_context.next = 8;
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
_this.updateClusterData(layer);
|
|
46
|
-
|
|
47
|
-
layer.log(IDebugLog.SourceInitEnd, ILayerStage.INIT);
|
|
48
|
-
_context.next = 10;
|
|
22
|
+
while (1) switch (_context.prev = _context.next) {
|
|
23
|
+
case 0:
|
|
24
|
+
layer.log(IDebugLog.SourceInitStart, ILayerStage.INIT);
|
|
25
|
+
source = layer.getSource();
|
|
26
|
+
if (!source) {
|
|
27
|
+
// Tip: 用户没有传入 source 的时候使用图层的默认数据
|
|
28
|
+
_ref2 = layer.sourceOption || layer.defaultSourceConfig, data = _ref2.data, options = _ref2.options;
|
|
29
|
+
source = new Source(data, options);
|
|
30
|
+
layer.setSource(source);
|
|
31
|
+
}
|
|
32
|
+
if (!source.inited) {
|
|
33
|
+
_context.next = 8;
|
|
49
34
|
break;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
35
|
+
}
|
|
36
|
+
_this.updateClusterData(layer);
|
|
37
|
+
layer.log(IDebugLog.SourceInitEnd, ILayerStage.INIT);
|
|
38
|
+
_context.next = 10;
|
|
39
|
+
break;
|
|
40
|
+
case 8:
|
|
41
|
+
_context.next = 10;
|
|
42
|
+
return new Promise(function (resolve) {
|
|
43
|
+
source.on('update', function (e) {
|
|
44
|
+
if (e.type === 'inited') {
|
|
45
|
+
_this.updateClusterData(layer);
|
|
46
|
+
layer.log(IDebugLog.SourceInitEnd, ILayerStage.INIT);
|
|
47
|
+
}
|
|
48
|
+
resolve(null);
|
|
63
49
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
50
|
+
});
|
|
51
|
+
case 10:
|
|
52
|
+
case "end":
|
|
53
|
+
return _context.stop();
|
|
69
54
|
}
|
|
70
55
|
}, _callee);
|
|
71
|
-
})));
|
|
56
|
+
})));
|
|
72
57
|
|
|
58
|
+
// 检测数据是否需要更新
|
|
73
59
|
layer.hooks.beforeRenderData.tapPromise('DataSourcePlugin', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
74
60
|
var neeUpdateCluster, dataSourceNeedUpdate, needScale;
|
|
75
61
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
76
|
-
while (1) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
case "end":
|
|
87
|
-
return _context2.stop();
|
|
88
|
-
}
|
|
62
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
63
|
+
case 0:
|
|
64
|
+
neeUpdateCluster = _this.updateClusterData(layer);
|
|
65
|
+
dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
|
|
66
|
+
layer.dataState.dataSourceNeedUpdate = false;
|
|
67
|
+
needScale = neeUpdateCluster || dataSourceNeedUpdate;
|
|
68
|
+
return _context2.abrupt("return", needScale);
|
|
69
|
+
case 5:
|
|
70
|
+
case "end":
|
|
71
|
+
return _context2.stop();
|
|
89
72
|
}
|
|
90
73
|
}, _callee2);
|
|
91
74
|
})));
|
|
@@ -97,33 +80,27 @@ var DataSourcePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function
|
|
|
97
80
|
if (layer.isTileLayer || layer.tileLayer || !layer.getSource()) {
|
|
98
81
|
return false;
|
|
99
82
|
}
|
|
100
|
-
|
|
101
83
|
var source = layer.getSource();
|
|
102
84
|
var cluster = source.cluster;
|
|
103
85
|
var _source$clusterOption = source.clusterOptions.zoom,
|
|
104
|
-
|
|
86
|
+
zoom = _source$clusterOption === void 0 ? 0 : _source$clusterOption;
|
|
105
87
|
var newZoom = this.mapService.getZoom() - 1;
|
|
106
88
|
var dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
|
|
107
|
-
|
|
108
89
|
if (cluster && dataSourceNeedUpdate) {
|
|
109
90
|
// 数据发生更新
|
|
110
91
|
source.updateClusterData(Math.floor(newZoom));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
92
|
+
}
|
|
93
|
+
// 如果 dataSource 有更新,跳过 zoom 的判断,直接更新一次
|
|
114
94
|
if (cluster && Math.abs(layer.clusterZoom - newZoom) >= 1) {
|
|
115
95
|
if (zoom !== Math.floor(newZoom)) {
|
|
116
96
|
source.updateClusterData(Math.floor(newZoom));
|
|
117
97
|
}
|
|
118
|
-
|
|
119
98
|
layer.clusterZoom = newZoom;
|
|
120
99
|
return true;
|
|
121
100
|
}
|
|
122
|
-
|
|
123
101
|
return false;
|
|
124
102
|
}
|
|
125
103
|
}]);
|
|
126
|
-
|
|
127
104
|
return DataSourcePlugin;
|
|
128
105
|
}()) || _class);
|
|
129
106
|
export { DataSourcePlugin as default };
|