@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,50 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.default = void 0;
|
|
9
|
+
|
|
8
10
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
9
12
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
13
|
+
|
|
10
14
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
+
|
|
11
16
|
var _initializerDefineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/initializerDefineProperty"));
|
|
17
|
+
|
|
12
18
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
19
|
+
|
|
13
20
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
21
|
+
|
|
14
22
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
+
|
|
15
24
|
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime/helpers/applyDecoratedDescriptor"));
|
|
25
|
+
|
|
16
26
|
var _initializerWarningHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/initializerWarningHelper"));
|
|
27
|
+
|
|
17
28
|
var _l7Core = require("@antv/l7-core");
|
|
29
|
+
|
|
18
30
|
var _l7Maps = require("@antv/l7-maps");
|
|
31
|
+
|
|
19
32
|
var _l7Utils = require("@antv/l7-utils");
|
|
33
|
+
|
|
20
34
|
var _inversify = require("inversify");
|
|
35
|
+
|
|
21
36
|
var _lodash = require("lodash");
|
|
37
|
+
|
|
22
38
|
require("reflect-metadata");
|
|
39
|
+
|
|
23
40
|
var _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2;
|
|
41
|
+
|
|
24
42
|
var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inversify.inject)(_l7Core.TYPES.IMapService), _dec3 = (0, _inversify.inject)(_l7Core.TYPES.IFontService), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
25
43
|
function DataMappingPlugin() {
|
|
26
44
|
(0, _classCallCheck2.default)(this, DataMappingPlugin);
|
|
27
45
|
(0, _initializerDefineProperty2.default)(this, "mapService", _descriptor, this);
|
|
28
46
|
(0, _initializerDefineProperty2.default)(this, "fontService", _descriptor2, this);
|
|
29
47
|
}
|
|
48
|
+
|
|
30
49
|
(0, _createClass2.default)(DataMappingPlugin, [{
|
|
31
50
|
key: "apply",
|
|
32
51
|
value: function apply(layer, _ref) {
|
|
33
52
|
var _this = this;
|
|
53
|
+
|
|
34
54
|
var styleAttributeService = _ref.styleAttributeService;
|
|
35
55
|
layer.hooks.init.tapPromise('DataMappingPlugin', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
36
56
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
37
|
-
while (1)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
57
|
+
while (1) {
|
|
58
|
+
switch (_context.prev = _context.next) {
|
|
59
|
+
case 0:
|
|
60
|
+
layer.log(_l7Core.IDebugLog.MappingStart, _l7Core.ILayerStage.INIT); // 初始化重新生成 map
|
|
61
|
+
|
|
62
|
+
_this.generateMaping(layer, {
|
|
63
|
+
styleAttributeService: styleAttributeService
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
layer.log(_l7Core.IDebugLog.MappingEnd, _l7Core.ILayerStage.INIT);
|
|
67
|
+
|
|
68
|
+
case 3:
|
|
69
|
+
case "end":
|
|
70
|
+
return _context.stop();
|
|
71
|
+
}
|
|
48
72
|
}
|
|
49
73
|
}, _callee);
|
|
50
74
|
})));
|
|
@@ -52,93 +76,104 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
|
|
|
52
76
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(flag) {
|
|
53
77
|
var mappingResult;
|
|
54
78
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
55
|
-
while (1)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
while (1) {
|
|
80
|
+
switch (_context2.prev = _context2.next) {
|
|
81
|
+
case 0:
|
|
82
|
+
if (flag) {
|
|
83
|
+
_context2.next = 2;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return _context2.abrupt("return", flag);
|
|
88
|
+
|
|
89
|
+
case 2:
|
|
90
|
+
layer.dataState.dataMappingNeedUpdate = false;
|
|
91
|
+
layer.log(_l7Core.IDebugLog.MappingStart, _l7Core.ILayerStage.UPDATE);
|
|
92
|
+
mappingResult = _this.generateMaping(layer, {
|
|
93
|
+
styleAttributeService: styleAttributeService
|
|
94
|
+
});
|
|
95
|
+
layer.log(_l7Core.IDebugLog.MappingEnd, _l7Core.ILayerStage.UPDATE);
|
|
96
|
+
return _context2.abrupt("return", mappingResult);
|
|
97
|
+
|
|
98
|
+
case 7:
|
|
99
|
+
case "end":
|
|
100
|
+
return _context2.stop();
|
|
101
|
+
}
|
|
73
102
|
}
|
|
74
103
|
}, _callee2);
|
|
75
104
|
}));
|
|
105
|
+
|
|
76
106
|
return function (_x) {
|
|
77
107
|
return _ref3.apply(this, arguments);
|
|
78
108
|
};
|
|
79
|
-
}());
|
|
109
|
+
}()); // remapping before render
|
|
80
110
|
|
|
81
|
-
// remapping before render
|
|
82
111
|
layer.hooks.beforeRender.tap('DataMappingPlugin', function () {
|
|
83
112
|
var source = layer.getSource();
|
|
113
|
+
|
|
84
114
|
if (layer.layerModelNeedUpdate || !source || !source.inited) {
|
|
85
115
|
return;
|
|
86
116
|
}
|
|
117
|
+
|
|
87
118
|
var attributes = styleAttributeService.getLayerStyleAttributes() || [];
|
|
88
119
|
var filter = styleAttributeService.getLayerStyleAttribute('filter');
|
|
89
|
-
var dataArray = source.data.dataArray;
|
|
90
|
-
|
|
120
|
+
var dataArray = source.data.dataArray; // TODO 数据为空的情况
|
|
121
|
+
|
|
91
122
|
if (Array.isArray(dataArray) && dataArray.length === 0) {
|
|
92
123
|
return;
|
|
93
124
|
}
|
|
125
|
+
|
|
94
126
|
var attributesToRemapping = attributes.filter(function (attribute) {
|
|
95
127
|
return attribute.needRemapping;
|
|
96
128
|
} // 如果filter变化
|
|
97
129
|
);
|
|
130
|
+
var filterData = dataArray; // 数据过滤完 再执行数据映射
|
|
98
131
|
|
|
99
|
-
var filterData = dataArray;
|
|
100
|
-
// 数据过滤完 再执行数据映射
|
|
101
132
|
if (filter !== null && filter !== void 0 && filter.needRemapping && filter !== null && filter !== void 0 && filter.scale) {
|
|
102
133
|
filterData = dataArray.filter(function (record) {
|
|
103
134
|
return _this.applyAttributeMapping(filter, record)[0];
|
|
104
135
|
});
|
|
105
136
|
}
|
|
137
|
+
|
|
106
138
|
if (attributesToRemapping.length) {
|
|
107
139
|
// 过滤数据
|
|
108
140
|
var encodeData = _this.mapping(layer, attributesToRemapping, filterData, layer.getEncodedData());
|
|
109
|
-
layer.setEncodedData(encodeData);
|
|
110
|
-
}
|
|
111
141
|
|
|
112
|
-
|
|
142
|
+
layer.setEncodedData(encodeData);
|
|
143
|
+
} // 处理文本更新,更新文字形状
|
|
113
144
|
// layer.emit('remapping', null);
|
|
145
|
+
|
|
114
146
|
});
|
|
115
147
|
}
|
|
116
148
|
}, {
|
|
117
149
|
key: "generateMaping",
|
|
118
150
|
value: function generateMaping(layer, _ref4) {
|
|
119
151
|
var _this2 = this;
|
|
152
|
+
|
|
120
153
|
var styleAttributeService = _ref4.styleAttributeService;
|
|
121
154
|
var attributes = styleAttributeService.getLayerStyleAttributes() || [];
|
|
122
155
|
var filter = styleAttributeService.getLayerStyleAttribute('filter');
|
|
123
156
|
var dataArray = layer.getSource().data.dataArray;
|
|
124
|
-
var filterData = dataArray;
|
|
125
|
-
|
|
157
|
+
var filterData = dataArray; // 数据过滤完 再执行数据映射
|
|
158
|
+
|
|
126
159
|
if (filter !== null && filter !== void 0 && filter.scale) {
|
|
127
160
|
filterData = dataArray.filter(function (record) {
|
|
128
161
|
return _this2.applyAttributeMapping(filter, record)[0];
|
|
129
162
|
});
|
|
130
|
-
}
|
|
131
|
-
// Tip: layer 对数据做处理
|
|
163
|
+
} // Tip: layer 对数据做处理
|
|
132
164
|
// 数据处理 在数据进行 mapping 生成 encodeData 之前对数据进行处理
|
|
133
165
|
// 在各个 layer 中继承
|
|
134
166
|
|
|
167
|
+
|
|
135
168
|
filterData = layer.processData(filterData);
|
|
136
169
|
var encodeData = this.mapping(layer, attributes, filterData, undefined);
|
|
137
170
|
layer.setEncodedData(encodeData);
|
|
171
|
+
|
|
138
172
|
if (dataArray.length === 0 && layer.encodeDataLength === 0) {
|
|
139
173
|
return false;
|
|
140
|
-
}
|
|
141
|
-
|
|
174
|
+
} // 对外暴露事件
|
|
175
|
+
|
|
176
|
+
|
|
142
177
|
layer.emit('dataUpdate', null);
|
|
143
178
|
return true;
|
|
144
179
|
}
|
|
@@ -146,11 +181,13 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
|
|
|
146
181
|
key: "mapping",
|
|
147
182
|
value: function mapping(layer, attributes, data, predata) {
|
|
148
183
|
var _this3 = this;
|
|
184
|
+
|
|
149
185
|
var _ref5 = layer.getLayerConfig(),
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
186
|
+
_ref5$arrow = _ref5.arrow,
|
|
187
|
+
arrow = _ref5$arrow === void 0 ? {
|
|
188
|
+
enable: false
|
|
189
|
+
} : _ref5$arrow;
|
|
190
|
+
|
|
154
191
|
var usedAttributes = attributes.filter(function (attribute) {
|
|
155
192
|
return attribute.scale !== undefined;
|
|
156
193
|
}).filter(function (attribute) {
|
|
@@ -163,42 +200,45 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
|
|
|
163
200
|
coordinates: record.coordinates
|
|
164
201
|
}, preRecord);
|
|
165
202
|
usedAttributes.forEach(function (attribute) {
|
|
166
|
-
var values = _this3.applyAttributeMapping(attribute, record);
|
|
167
|
-
|
|
203
|
+
var values = _this3.applyAttributeMapping(attribute, record); // TODO: 支持每个属性配置 postprocess
|
|
204
|
+
|
|
205
|
+
|
|
168
206
|
if (attribute.name === 'color') {
|
|
169
207
|
values = values.map(function (c) {
|
|
170
208
|
return (0, _l7Utils.rgb2arr)(c);
|
|
171
209
|
});
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
210
|
+
} // @ts-ignore
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values; // 增加对 layer/text/iconfont unicode 映射的解析
|
|
175
214
|
|
|
176
|
-
// 增加对 layer/text/iconfont unicode 映射的解析
|
|
177
215
|
if (attribute.name === 'shape') {
|
|
178
216
|
encodeRecord.shape = _this3.fontService.getIconFontKey(encodeRecord[attribute.name]);
|
|
179
217
|
}
|
|
180
218
|
});
|
|
219
|
+
|
|
181
220
|
if (arrow.enable && (encodeRecord.shape === 'line' || encodeRecord.shape === 'halfLine')) {
|
|
182
221
|
// 只有在线图层且支持配置箭头的时候进行插入顶点的处理
|
|
183
|
-
var coords = encodeRecord.coordinates;
|
|
184
|
-
|
|
222
|
+
var coords = encodeRecord.coordinates; // @ts-ignore
|
|
223
|
+
|
|
185
224
|
if (layer.arrowInsertCount < layer.encodeDataLength) {
|
|
186
225
|
// Tip: arrowInsert 的判断用于确保每一条线数据 arrow 的属性点只会被植入一次
|
|
187
226
|
var arrowPoint = _this3.getArrowPoints(coords[0], coords[1]);
|
|
188
|
-
|
|
189
|
-
// @ts-ignore
|
|
227
|
+
|
|
228
|
+
encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint); // @ts-ignore
|
|
229
|
+
|
|
190
230
|
layer.arrowInsertCount++;
|
|
191
231
|
}
|
|
192
232
|
}
|
|
233
|
+
|
|
193
234
|
return encodeRecord;
|
|
194
235
|
});
|
|
195
236
|
attributes.forEach(function (attribute) {
|
|
196
237
|
attribute.needRemapping = false;
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
this.adjustData2Amap2Coordinates(mappedData, layer);
|
|
238
|
+
}); // 调整数据兼容 Amap2.0
|
|
239
|
+
|
|
240
|
+
this.adjustData2Amap2Coordinates(mappedData, layer); // 调整数据兼容 SimpleCoordinates
|
|
200
241
|
|
|
201
|
-
// 调整数据兼容 SimpleCoordinates
|
|
202
242
|
this.adjustData2SimpleCoordinates(mappedData);
|
|
203
243
|
return mappedData;
|
|
204
244
|
}
|
|
@@ -206,36 +246,38 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
|
|
|
206
246
|
key: "adjustData2Amap2Coordinates",
|
|
207
247
|
value: function adjustData2Amap2Coordinates(mappedData, layer) {
|
|
208
248
|
var _this4 = this;
|
|
249
|
+
|
|
209
250
|
// 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移
|
|
210
251
|
if (mappedData.length > 0 && this.mapService.version === _l7Maps.Version['GAODE2.x']) {
|
|
211
252
|
var layerCenter = layer.coordCenter || layer.getSource().center;
|
|
253
|
+
|
|
212
254
|
if (typeof mappedData[0].coordinates[0] === 'number') {
|
|
213
255
|
// 单个的点数据
|
|
214
256
|
// @ts-ignore
|
|
215
|
-
mappedData
|
|
216
|
-
// TODO: 避免经纬度被重复计算导致坐标位置偏移
|
|
257
|
+
mappedData // TODO: 避免经纬度被重复计算导致坐标位置偏移
|
|
217
258
|
.filter(function (d) {
|
|
218
259
|
return !d.originCoordinates;
|
|
219
260
|
}).map(function (d) {
|
|
220
|
-
d.version = _l7Maps.Version['GAODE2.x'];
|
|
221
|
-
|
|
261
|
+
d.version = _l7Maps.Version['GAODE2.x']; // @ts-ignore
|
|
262
|
+
|
|
222
263
|
d.originCoordinates = (0, _lodash.cloneDeep)(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
|
|
223
264
|
// @ts-ignore
|
|
224
265
|
// d.coordinates = this.mapService.lngLatToCoord(d.coordinates);
|
|
266
|
+
|
|
225
267
|
d.coordinates = _this4.mapService.lngLatToCoordByLayer(d.coordinates, layerCenter);
|
|
226
268
|
});
|
|
227
269
|
} else {
|
|
228
270
|
// 连续的线、面数据
|
|
229
|
-
mappedData
|
|
230
|
-
// TODO: 避免经纬度被重复计算导致坐标位置偏移
|
|
271
|
+
mappedData // TODO: 避免经纬度被重复计算导致坐标位置偏移
|
|
231
272
|
.filter(function (d) {
|
|
232
273
|
return !d.originCoordinates;
|
|
233
274
|
}).map(function (d) {
|
|
234
|
-
d.version = _l7Maps.Version['GAODE2.x'];
|
|
235
|
-
|
|
275
|
+
d.version = _l7Maps.Version['GAODE2.x']; // @ts-ignore
|
|
276
|
+
|
|
236
277
|
d.originCoordinates = (0, _lodash.cloneDeep)(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
|
|
237
278
|
// @ts-ignore
|
|
238
279
|
// d.coordinates = this.mapService.lngLatToCoords(d.coordinates);
|
|
280
|
+
|
|
239
281
|
d.coordinates = _this4.mapService.lngLatToCoordsByLayer(d.coordinates, layerCenter);
|
|
240
282
|
});
|
|
241
283
|
}
|
|
@@ -245,6 +287,7 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
|
|
|
245
287
|
key: "adjustData2SimpleCoordinates",
|
|
246
288
|
value: function adjustData2SimpleCoordinates(mappedData) {
|
|
247
289
|
var _this5 = this;
|
|
290
|
+
|
|
248
291
|
if (mappedData.length > 0 && this.mapService.version === _l7Maps.Version.SIMPLE) {
|
|
249
292
|
mappedData.map(function (d) {
|
|
250
293
|
if (!d.simpleCoordinate) {
|
|
@@ -258,9 +301,11 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
|
|
|
258
301
|
key: "unProjectCoordinates",
|
|
259
302
|
value: function unProjectCoordinates(coordinates) {
|
|
260
303
|
var _this6 = this;
|
|
304
|
+
|
|
261
305
|
if (typeof coordinates[0] === 'number') {
|
|
262
306
|
return this.mapService.simpleMapCoord.unproject(coordinates);
|
|
263
307
|
}
|
|
308
|
+
|
|
264
309
|
if (coordinates[0] && coordinates[0][0] instanceof Array) {
|
|
265
310
|
// @ts-ignore
|
|
266
311
|
var coords = [];
|
|
@@ -269,20 +314,20 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
|
|
|
269
314
|
var c1 = [];
|
|
270
315
|
coord.map(function (co) {
|
|
271
316
|
c1.push(_this6.mapService.simpleMapCoord.unproject(co));
|
|
272
|
-
});
|
|
273
|
-
|
|
317
|
+
}); // @ts-ignore
|
|
318
|
+
|
|
274
319
|
coords.push(c1);
|
|
275
|
-
});
|
|
276
|
-
|
|
320
|
+
}); // @ts-ignore
|
|
321
|
+
|
|
277
322
|
return coords;
|
|
278
323
|
} else {
|
|
279
324
|
// @ts-ignore
|
|
280
|
-
var _coords = [];
|
|
281
|
-
|
|
325
|
+
var _coords = []; // @ts-ignore
|
|
326
|
+
|
|
282
327
|
coordinates.map(function (coord) {
|
|
283
328
|
_coords.push(_this6.mapService.simpleMapCoord.unproject(coord));
|
|
284
|
-
});
|
|
285
|
-
|
|
329
|
+
}); // @ts-ignore
|
|
330
|
+
|
|
286
331
|
return _coords;
|
|
287
332
|
}
|
|
288
333
|
}
|
|
@@ -290,22 +335,25 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
|
|
|
290
335
|
key: "applyAttributeMapping",
|
|
291
336
|
value: function applyAttributeMapping(attribute, record) {
|
|
292
337
|
var _attribute$scale;
|
|
338
|
+
|
|
293
339
|
if (!attribute.scale) {
|
|
294
340
|
return [];
|
|
295
341
|
}
|
|
342
|
+
|
|
296
343
|
var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
|
|
297
344
|
var params = [];
|
|
298
345
|
scalers.forEach(function (_ref6) {
|
|
299
346
|
var _attribute$scale2;
|
|
347
|
+
|
|
300
348
|
var field = _ref6.field;
|
|
349
|
+
|
|
301
350
|
if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
|
|
302
351
|
// TODO:多字段,常量
|
|
303
352
|
params.push(record[field]);
|
|
304
353
|
}
|
|
305
354
|
});
|
|
306
355
|
var mappingResult = attribute.mapping ? attribute.mapping(params) : [];
|
|
307
|
-
return mappingResult;
|
|
308
|
-
// return attribute.mapping ? attribute.mapping(params) : [];
|
|
356
|
+
return mappingResult; // return attribute.mapping ? attribute.mapping(params) : [];
|
|
309
357
|
}
|
|
310
358
|
}, {
|
|
311
359
|
key: "getArrowPoints",
|
|
@@ -1,81 +1,107 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.default = void 0;
|
|
9
|
+
|
|
8
10
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
9
12
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
|
|
10
14
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
|
|
11
16
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
12
18
|
var _l7Core = require("@antv/l7-core");
|
|
19
|
+
|
|
13
20
|
var _l7Source = _interopRequireDefault(require("@antv/l7-source"));
|
|
21
|
+
|
|
14
22
|
var _inversify = require("inversify");
|
|
23
|
+
|
|
15
24
|
require("reflect-metadata");
|
|
25
|
+
|
|
16
26
|
var _dec, _class;
|
|
27
|
+
|
|
17
28
|
var DataSourcePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__PURE__*/function () {
|
|
18
29
|
function DataSourcePlugin() {
|
|
19
30
|
(0, _classCallCheck2.default)(this, DataSourcePlugin);
|
|
20
31
|
}
|
|
32
|
+
|
|
21
33
|
(0, _createClass2.default)(DataSourcePlugin, [{
|
|
22
34
|
key: "apply",
|
|
23
35
|
value: function apply(layer) {
|
|
24
36
|
var _this = this;
|
|
37
|
+
|
|
25
38
|
this.mapService = layer.getContainer().get(_l7Core.TYPES.IMapService);
|
|
26
39
|
layer.hooks.init.tapPromise('DataSourcePlugin', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
27
40
|
var source, _ref2, data, options;
|
|
41
|
+
|
|
28
42
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
29
|
-
while (1)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
while (1) {
|
|
44
|
+
switch (_context.prev = _context.next) {
|
|
45
|
+
case 0:
|
|
46
|
+
layer.log(_l7Core.IDebugLog.SourceInitStart, _l7Core.ILayerStage.INIT);
|
|
47
|
+
source = layer.getSource();
|
|
48
|
+
|
|
49
|
+
if (!source) {
|
|
50
|
+
// Tip: 用户没有传入 source 的时候使用图层的默认数据
|
|
51
|
+
_ref2 = layer.sourceOption || layer.defaultSourceConfig, data = _ref2.data, options = _ref2.options;
|
|
52
|
+
source = new _l7Source.default(data, options);
|
|
53
|
+
layer.setSource(source);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!source.inited) {
|
|
57
|
+
_context.next = 8;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
_this.updateClusterData(layer);
|
|
62
|
+
|
|
63
|
+
layer.log(_l7Core.IDebugLog.SourceInitEnd, _l7Core.ILayerStage.INIT);
|
|
64
|
+
_context.next = 10;
|
|
41
65
|
break;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
resolve(null);
|
|
66
|
+
|
|
67
|
+
case 8:
|
|
68
|
+
_context.next = 10;
|
|
69
|
+
return new Promise(function (resolve) {
|
|
70
|
+
source.on('update', function (e) {
|
|
71
|
+
if (e.type === 'inited') {
|
|
72
|
+
_this.updateClusterData(layer);
|
|
73
|
+
|
|
74
|
+
layer.log(_l7Core.IDebugLog.SourceInitEnd, _l7Core.ILayerStage.INIT);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
resolve(null);
|
|
78
|
+
});
|
|
56
79
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
80
|
+
|
|
81
|
+
case 10:
|
|
82
|
+
case "end":
|
|
83
|
+
return _context.stop();
|
|
84
|
+
}
|
|
61
85
|
}
|
|
62
86
|
}, _callee);
|
|
63
|
-
})));
|
|
87
|
+
}))); // 检测数据是否需要更新
|
|
64
88
|
|
|
65
|
-
// 检测数据是否需要更新
|
|
66
89
|
layer.hooks.beforeRenderData.tapPromise('DataSourcePlugin', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
67
90
|
var neeUpdateCluster, dataSourceNeedUpdate, needScale;
|
|
68
91
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
69
|
-
while (1)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
92
|
+
while (1) {
|
|
93
|
+
switch (_context2.prev = _context2.next) {
|
|
94
|
+
case 0:
|
|
95
|
+
neeUpdateCluster = _this.updateClusterData(layer);
|
|
96
|
+
dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
|
|
97
|
+
layer.dataState.dataSourceNeedUpdate = false;
|
|
98
|
+
needScale = neeUpdateCluster || dataSourceNeedUpdate;
|
|
99
|
+
return _context2.abrupt("return", needScale);
|
|
100
|
+
|
|
101
|
+
case 5:
|
|
102
|
+
case "end":
|
|
103
|
+
return _context2.stop();
|
|
104
|
+
}
|
|
79
105
|
}
|
|
80
106
|
}, _callee2);
|
|
81
107
|
})));
|
|
@@ -87,24 +113,29 @@ var DataSourcePlugin = (_dec = (0, _inversify.injectable)(), _dec(_class = /*#__
|
|
|
87
113
|
if (layer.isTileLayer || layer.tileLayer || !layer.getSource()) {
|
|
88
114
|
return false;
|
|
89
115
|
}
|
|
116
|
+
|
|
90
117
|
var source = layer.getSource();
|
|
91
118
|
var cluster = source.cluster;
|
|
92
119
|
var _source$clusterOption = source.clusterOptions.zoom,
|
|
93
|
-
|
|
120
|
+
zoom = _source$clusterOption === void 0 ? 0 : _source$clusterOption;
|
|
94
121
|
var newZoom = this.mapService.getZoom() - 1;
|
|
95
122
|
var dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
|
|
123
|
+
|
|
96
124
|
if (cluster && dataSourceNeedUpdate) {
|
|
97
125
|
// 数据发生更新
|
|
98
126
|
source.updateClusterData(Math.floor(newZoom));
|
|
99
|
-
}
|
|
100
|
-
|
|
127
|
+
} // 如果 dataSource 有更新,跳过 zoom 的判断,直接更新一次
|
|
128
|
+
|
|
129
|
+
|
|
101
130
|
if (cluster && Math.abs(layer.clusterZoom - newZoom) >= 1) {
|
|
102
131
|
if (zoom !== Math.floor(newZoom)) {
|
|
103
132
|
source.updateClusterData(Math.floor(newZoom));
|
|
104
133
|
}
|
|
134
|
+
|
|
105
135
|
layer.clusterZoom = newZoom;
|
|
106
136
|
return true;
|
|
107
137
|
}
|
|
138
|
+
|
|
108
139
|
return false;
|
|
109
140
|
}
|
|
110
141
|
}]);
|