@antv/l7-layers 2.15.1 → 2.15.3
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 +320 -484
- package/es/core/BaseModel.js +97 -126
- 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 +10 -31
- package/es/core/triangulation.js +54 -114
- 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 +91 -146
- 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 -34
- package/es/line/models/arc.js +66 -118
- package/es/line/models/arc_3d.js +60 -108
- package/es/line/models/earthArc_3d.js +63 -111
- package/es/line/models/great_circle.js +56 -100
- package/es/line/models/half.js +46 -77
- package/es/line/models/line.js +94 -148
- package/es/line/models/linearline.js +45 -80
- package/es/line/models/simpleLine.js +41 -74
- package/es/line/models/wall.js +52 -92
- package/es/mask/index.js +9 -28
- package/es/mask/models/fill.js +29 -54
- package/es/plugins/DataMappingPlugin.js +80 -117
- 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 +67 -104
- package/es/plugins/LayerStylePlugin.js +3 -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 -77
- package/es/point/models/earthExtrude.js +61 -102
- package/es/point/models/earthFill.js +57 -87
- package/es/point/models/extrude.js +60 -101
- package/es/point/models/fill.js +70 -100
- package/es/point/models/fillmage.js +63 -107
- package/es/point/models/image.js +48 -88
- package/es/point/models/index.js +2 -2
- package/es/point/models/normal.js +30 -54
- package/es/point/models/radar.js +40 -64
- package/es/point/models/simplePoint.js +41 -69
- package/es/point/models/text.d.ts +2 -0
- package/es/point/models/text.js +214 -295
- package/es/point/shape/extrude.js +4 -13
- package/es/polygon/index.js +11 -40
- package/es/polygon/models/extrude.js +48 -92
- package/es/polygon/models/fill.js +54 -88
- 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 +30 -52
- package/es/tile/service/TilePickService.js +26 -40
- package/es/tile/service/TileSourceService.js +3 -7
- package/es/tile/tileFactory/DebugTile.js +28 -45
- 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/dataMappingStyle.js +8 -18
- 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 +320 -478
- package/lib/core/BaseModel.js +97 -139
- 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 +10 -54
- package/lib/core/triangulation.js +53 -153
- 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 +91 -162
- 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 +64 -128
- package/lib/line/models/arc_3d.js +58 -119
- package/lib/line/models/earthArc_3d.js +61 -122
- package/lib/line/models/great_circle.js +56 -111
- package/lib/line/models/half.js +46 -87
- package/lib/line/models/index.js +0 -11
- package/lib/line/models/line.js +92 -156
- package/lib/line/models/linearline.js +45 -92
- package/lib/line/models/simpleLine.js +41 -84
- package/lib/line/models/wall.js +52 -103
- 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 +80 -128
- 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 +68 -113
- package/lib/plugins/LayerStylePlugin.js +4 -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 +61 -113
- package/lib/point/models/earthFill.js +57 -117
- package/lib/point/models/extrude.js +60 -111
- package/lib/point/models/fill.js +68 -109
- package/lib/point/models/fillmage.js +61 -115
- package/lib/point/models/image.js +48 -98
- package/lib/point/models/index.js +1 -12
- package/lib/point/models/normal.js +30 -64
- package/lib/point/models/radar.js +40 -74
- package/lib/point/models/simplePoint.js +41 -79
- package/lib/point/models/text.js +214 -303
- package/lib/point/shape/extrude.js +4 -20
- package/lib/polygon/index.js +11 -48
- package/lib/polygon/models/extrude.js +48 -103
- package/lib/polygon/models/fill.js +54 -98
- 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 +30 -57
- 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 +28 -53
- 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/dataMappingStyle.js +8 -19
- 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,104 +45,93 @@ 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());
|
|
120
|
-
|
|
121
102
|
layer.setEncodedData(encodeData);
|
|
122
|
-
}
|
|
123
|
-
// layer.emit('remapping', null);
|
|
103
|
+
}
|
|
124
104
|
|
|
105
|
+
// 处理文本更新,更新文字形状
|
|
106
|
+
// layer.emit('remapping', null);
|
|
125
107
|
});
|
|
126
108
|
}
|
|
127
109
|
}, {
|
|
128
110
|
key: "generateMaping",
|
|
129
111
|
value: function generateMaping(layer, _ref4) {
|
|
130
112
|
var _this2 = this;
|
|
131
|
-
|
|
132
113
|
var styleAttributeService = _ref4.styleAttributeService;
|
|
133
114
|
var attributes = styleAttributeService.getLayerStyleAttributes() || [];
|
|
134
115
|
var filter = styleAttributeService.getLayerStyleAttribute('filter');
|
|
135
116
|
var dataArray = layer.getSource().data.dataArray;
|
|
136
|
-
var filterData = dataArray;
|
|
137
|
-
|
|
117
|
+
var filterData = dataArray;
|
|
118
|
+
// 数据过滤完 再执行数据映射
|
|
138
119
|
if (filter !== null && filter !== void 0 && filter.scale) {
|
|
139
120
|
filterData = dataArray.filter(function (record) {
|
|
140
121
|
return _this2.applyAttributeMapping(filter, record)[0];
|
|
141
122
|
});
|
|
142
|
-
}
|
|
123
|
+
}
|
|
124
|
+
// Tip: layer 对数据做处理
|
|
143
125
|
// 数据处理 在数据进行 mapping 生成 encodeData 之前对数据进行处理
|
|
144
126
|
// 在各个 layer 中继承
|
|
145
127
|
|
|
146
|
-
|
|
147
128
|
filterData = layer.processData(filterData);
|
|
148
129
|
var encodeData = this.mapping(layer, attributes, filterData, undefined);
|
|
149
130
|
layer.setEncodedData(encodeData);
|
|
150
|
-
|
|
151
131
|
if (dataArray.length === 0 && layer.encodeDataLength === 0) {
|
|
152
132
|
return false;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
133
|
+
}
|
|
134
|
+
// 对外暴露事件
|
|
156
135
|
layer.emit('dataUpdate', null);
|
|
157
136
|
return true;
|
|
158
137
|
}
|
|
@@ -160,13 +139,11 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
160
139
|
key: "mapping",
|
|
161
140
|
value: function mapping(layer, attributes, data, predata) {
|
|
162
141
|
var _this3 = this;
|
|
163
|
-
|
|
164
142
|
var _ref5 = layer.getLayerConfig(),
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
143
|
+
_ref5$arrow = _ref5.arrow,
|
|
144
|
+
arrow = _ref5$arrow === void 0 ? {
|
|
145
|
+
enable: false
|
|
146
|
+
} : _ref5$arrow;
|
|
170
147
|
var usedAttributes = attributes.filter(function (attribute) {
|
|
171
148
|
return attribute.scale !== undefined;
|
|
172
149
|
}).filter(function (attribute) {
|
|
@@ -174,52 +151,47 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
174
151
|
});
|
|
175
152
|
var mappedData = data.map(function (record, i) {
|
|
176
153
|
var preRecord = predata ? predata[i] : {};
|
|
177
|
-
|
|
178
154
|
var encodeRecord = _objectSpread({
|
|
179
155
|
id: record._id,
|
|
180
156
|
coordinates: record.coordinates
|
|
181
157
|
}, preRecord);
|
|
182
|
-
|
|
183
158
|
usedAttributes.forEach(function (attribute) {
|
|
184
|
-
var values = _this3.applyAttributeMapping(attribute, record);
|
|
185
|
-
|
|
186
|
-
|
|
159
|
+
var values = _this3.applyAttributeMapping(attribute, record);
|
|
160
|
+
// TODO: 支持每个属性配置 postprocess
|
|
187
161
|
if (attribute.name === 'color') {
|
|
188
162
|
values = values.map(function (c) {
|
|
189
163
|
return rgb2arr(c);
|
|
190
164
|
});
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values; // 增加对 layer/text/iconfont unicode 映射的解析
|
|
165
|
+
}
|
|
166
|
+
// @ts-ignore
|
|
167
|
+
encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values;
|
|
195
168
|
|
|
169
|
+
// 增加对 layer/text/iconfont unicode 映射的解析
|
|
196
170
|
if (attribute.name === 'shape') {
|
|
197
171
|
encodeRecord.shape = _this3.fontService.getIconFontKey(encodeRecord[attribute.name]);
|
|
198
172
|
}
|
|
199
173
|
});
|
|
200
|
-
|
|
201
174
|
if (arrow.enable && (encodeRecord.shape === 'line' || encodeRecord.shape === 'halfLine')) {
|
|
202
175
|
// 只有在线图层且支持配置箭头的时候进行插入顶点的处理
|
|
203
|
-
var coords = encodeRecord.coordinates;
|
|
204
|
-
|
|
176
|
+
var coords = encodeRecord.coordinates;
|
|
177
|
+
// @ts-ignore
|
|
205
178
|
if (layer.arrowInsertCount < layer.encodeDataLength) {
|
|
206
179
|
// Tip: arrowInsert 的判断用于确保每一条线数据 arrow 的属性点只会被植入一次
|
|
207
180
|
var arrowPoint = _this3.getArrowPoints(coords[0], coords[1]);
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
181
|
+
encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
|
|
182
|
+
// @ts-ignore
|
|
211
183
|
layer.arrowInsertCount++;
|
|
212
184
|
}
|
|
213
185
|
}
|
|
214
|
-
|
|
215
186
|
return encodeRecord;
|
|
216
187
|
});
|
|
217
188
|
attributes.forEach(function (attribute) {
|
|
218
189
|
attribute.needRemapping = false;
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
this.adjustData2Amap2Coordinates(mappedData, layer);
|
|
190
|
+
});
|
|
191
|
+
// 调整数据兼容 Amap2.0
|
|
192
|
+
this.adjustData2Amap2Coordinates(mappedData, layer);
|
|
222
193
|
|
|
194
|
+
// 调整数据兼容 SimpleCoordinates
|
|
223
195
|
this.adjustData2SimpleCoordinates(mappedData);
|
|
224
196
|
return mappedData;
|
|
225
197
|
}
|
|
@@ -227,38 +199,36 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
227
199
|
key: "adjustData2Amap2Coordinates",
|
|
228
200
|
value: function adjustData2Amap2Coordinates(mappedData, layer) {
|
|
229
201
|
var _this4 = this;
|
|
230
|
-
|
|
231
202
|
// 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移
|
|
232
203
|
if (mappedData.length > 0 && this.mapService.version === Version['GAODE2.x']) {
|
|
233
204
|
var layerCenter = layer.coordCenter || layer.getSource().center;
|
|
234
|
-
|
|
235
205
|
if (typeof mappedData[0].coordinates[0] === 'number') {
|
|
236
206
|
// 单个的点数据
|
|
237
207
|
// @ts-ignore
|
|
238
|
-
mappedData
|
|
208
|
+
mappedData
|
|
209
|
+
// TODO: 避免经纬度被重复计算导致坐标位置偏移
|
|
239
210
|
.filter(function (d) {
|
|
240
211
|
return !d.originCoordinates;
|
|
241
212
|
}).map(function (d) {
|
|
242
|
-
d.version = Version['GAODE2.x'];
|
|
243
|
-
|
|
213
|
+
d.version = Version['GAODE2.x'];
|
|
214
|
+
// @ts-ignore
|
|
244
215
|
d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
|
|
245
216
|
// @ts-ignore
|
|
246
217
|
// d.coordinates = this.mapService.lngLatToCoord(d.coordinates);
|
|
247
|
-
|
|
248
218
|
d.coordinates = _this4.mapService.lngLatToCoordByLayer(d.coordinates, layerCenter);
|
|
249
219
|
});
|
|
250
220
|
} else {
|
|
251
221
|
// 连续的线、面数据
|
|
252
|
-
mappedData
|
|
222
|
+
mappedData
|
|
223
|
+
// TODO: 避免经纬度被重复计算导致坐标位置偏移
|
|
253
224
|
.filter(function (d) {
|
|
254
225
|
return !d.originCoordinates;
|
|
255
226
|
}).map(function (d) {
|
|
256
|
-
d.version = Version['GAODE2.x'];
|
|
257
|
-
|
|
227
|
+
d.version = Version['GAODE2.x'];
|
|
228
|
+
// @ts-ignore
|
|
258
229
|
d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
|
|
259
230
|
// @ts-ignore
|
|
260
231
|
// d.coordinates = this.mapService.lngLatToCoords(d.coordinates);
|
|
261
|
-
|
|
262
232
|
d.coordinates = _this4.mapService.lngLatToCoordsByLayer(d.coordinates, layerCenter);
|
|
263
233
|
});
|
|
264
234
|
}
|
|
@@ -268,7 +238,6 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
268
238
|
key: "adjustData2SimpleCoordinates",
|
|
269
239
|
value: function adjustData2SimpleCoordinates(mappedData) {
|
|
270
240
|
var _this5 = this;
|
|
271
|
-
|
|
272
241
|
if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {
|
|
273
242
|
mappedData.map(function (d) {
|
|
274
243
|
if (!d.simpleCoordinate) {
|
|
@@ -282,11 +251,9 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
282
251
|
key: "unProjectCoordinates",
|
|
283
252
|
value: function unProjectCoordinates(coordinates) {
|
|
284
253
|
var _this6 = this;
|
|
285
|
-
|
|
286
254
|
if (typeof coordinates[0] === 'number') {
|
|
287
255
|
return this.mapService.simpleMapCoord.unproject(coordinates);
|
|
288
256
|
}
|
|
289
|
-
|
|
290
257
|
if (coordinates[0] && coordinates[0][0] instanceof Array) {
|
|
291
258
|
// @ts-ignore
|
|
292
259
|
var coords = [];
|
|
@@ -295,20 +262,20 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
295
262
|
var c1 = [];
|
|
296
263
|
coord.map(function (co) {
|
|
297
264
|
c1.push(_this6.mapService.simpleMapCoord.unproject(co));
|
|
298
|
-
});
|
|
299
|
-
|
|
265
|
+
});
|
|
266
|
+
// @ts-ignore
|
|
300
267
|
coords.push(c1);
|
|
301
|
-
});
|
|
302
|
-
|
|
268
|
+
});
|
|
269
|
+
// @ts-ignore
|
|
303
270
|
return coords;
|
|
304
271
|
} else {
|
|
305
272
|
// @ts-ignore
|
|
306
|
-
var _coords = [];
|
|
307
|
-
|
|
273
|
+
var _coords = [];
|
|
274
|
+
// @ts-ignore
|
|
308
275
|
coordinates.map(function (coord) {
|
|
309
276
|
_coords.push(_this6.mapService.simpleMapCoord.unproject(coord));
|
|
310
|
-
});
|
|
311
|
-
|
|
277
|
+
});
|
|
278
|
+
// @ts-ignore
|
|
312
279
|
return _coords;
|
|
313
280
|
}
|
|
314
281
|
}
|
|
@@ -316,25 +283,22 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
316
283
|
key: "applyAttributeMapping",
|
|
317
284
|
value: function applyAttributeMapping(attribute, record) {
|
|
318
285
|
var _attribute$scale;
|
|
319
|
-
|
|
320
286
|
if (!attribute.scale) {
|
|
321
287
|
return [];
|
|
322
288
|
}
|
|
323
|
-
|
|
324
289
|
var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
|
|
325
290
|
var params = [];
|
|
326
291
|
scalers.forEach(function (_ref6) {
|
|
327
292
|
var _attribute$scale2;
|
|
328
|
-
|
|
329
293
|
var field = _ref6.field;
|
|
330
|
-
|
|
331
294
|
if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
|
|
332
295
|
// TODO:多字段,常量
|
|
333
296
|
params.push(record[field]);
|
|
334
297
|
}
|
|
335
298
|
});
|
|
336
299
|
var mappingResult = attribute.mapping ? attribute.mapping(params) : [];
|
|
337
|
-
return mappingResult;
|
|
300
|
+
return mappingResult;
|
|
301
|
+
// return attribute.mapping ? attribute.mapping(params) : [];
|
|
338
302
|
}
|
|
339
303
|
}, {
|
|
340
304
|
key: "getArrowPoints",
|
|
@@ -345,7 +309,6 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
|
|
|
345
309
|
return arrowPoint;
|
|
346
310
|
}
|
|
347
311
|
}]);
|
|
348
|
-
|
|
349
312
|
return DataMappingPlugin;
|
|
350
313
|
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "mapService", [_dec2], {
|
|
351
314
|
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 };
|