@antv/l7-layers 2.17.3 → 2.17.4
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 +478 -313
- package/es/core/BaseModel.js +80 -51
- package/es/core/CommonStyleAttribute.js +5 -2
- 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 +39 -27
- package/es/core/triangulation.js +136 -99
- 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 +149 -92
- 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 +35 -9
- package/es/line/models/arc.js +112 -63
- package/es/line/models/arc_3d.js +102 -58
- package/es/line/models/earthArc_3d.js +105 -60
- package/es/line/models/flow.js +60 -36
- package/es/line/models/great_circle.js +94 -53
- package/es/line/models/line.js +136 -85
- package/es/line/models/linearline.js +74 -42
- package/es/line/models/simpleLine.js +67 -38
- 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 +114 -78
- 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 +108 -69
- 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 +78 -26
- package/es/point/models/earthExtrude.js +95 -58
- package/es/point/models/earthFill.js +80 -52
- package/es/point/models/extrude.js +94 -57
- package/es/point/models/fill.js +81 -56
- package/es/point/models/fillmage.js +100 -60
- package/es/point/models/image.js +83 -47
- package/es/point/models/index.js +2 -2
- package/es/point/models/normal.js +54 -30
- package/es/point/models/radar.js +63 -38
- package/es/point/models/simplePoint.js +62 -38
- package/es/point/models/text.js +296 -199
- package/es/point/shape/extrude.js +13 -4
- package/es/polygon/index.js +41 -11
- package/es/polygon/models/extrude.js +135 -87
- package/es/polygon/models/fill.js +79 -50
- 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/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 +469 -313
- package/lib/core/BaseModel.js +90 -51
- package/lib/core/CommonStyleAttribute.js +7 -2
- 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 +62 -27
- package/lib/core/triangulation.js +177 -98
- 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 +166 -92
- 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 +122 -61
- package/lib/line/models/arc_3d.js +113 -56
- package/lib/line/models/earthArc_3d.js +115 -58
- package/lib/line/models/flow.js +70 -36
- package/lib/line/models/great_circle.js +104 -53
- package/lib/line/models/index.js +11 -0
- package/lib/line/models/line.js +144 -83
- package/lib/line/models/linearline.js +86 -42
- package/lib/line/models/simpleLine.js +77 -38
- 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 +125 -78
- 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 +117 -70
- 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 +106 -58
- package/lib/point/models/earthFill.js +110 -52
- package/lib/point/models/extrude.js +103 -57
- package/lib/point/models/fill.js +90 -54
- package/lib/point/models/fillmage.js +107 -58
- package/lib/point/models/image.js +92 -47
- package/lib/point/models/index.js +12 -1
- package/lib/point/models/normal.js +64 -30
- package/lib/point/models/radar.js +72 -38
- package/lib/point/models/simplePoint.js +72 -38
- package/lib/point/models/text.js +305 -199
- package/lib/point/shape/extrude.js +20 -4
- package/lib/polygon/index.js +48 -11
- package/lib/polygon/models/extrude.js +146 -87
- package/lib/polygon/models/fill.js +89 -50
- 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/extrude_polyline.js +181 -101
- package/lib/utils/grid-index.js +28 -2
- package/lib/utils/identityScale.js +9 -0
- package/lib/utils/layerData.js +49 -30
- package/lib/utils/multiPassRender.js +16 -11
- package/lib/utils/polylineNormal.js +66 -31
- package/lib/utils/simpleLine.js +21 -2
- package/lib/utils/stencil.js +4 -0
- package/lib/utils/symbol-layout.js +55 -27
- package/lib/wind/index.js +37 -9
- package/lib/wind/models/index.js +3 -0
- package/lib/wind/models/utils.js +62 -26
- package/lib/wind/models/wind.js +157 -101
- package/lib/wind/models/windRender.js +71 -53
- package/lib/wind/models/windShader.js +1 -0
- package/package.json +7 -7
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
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
|
+
|
|
4
5
|
var _dec, _class;
|
|
6
|
+
|
|
5
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
8
|
import { IDebugLog, ILayerStage, TYPES } from '@antv/l7-core';
|
|
7
9
|
import Source from '@antv/l7-source';
|
|
@@ -11,64 +13,79 @@ var DataSourcePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function
|
|
|
11
13
|
function DataSourcePlugin() {
|
|
12
14
|
_classCallCheck(this, DataSourcePlugin);
|
|
13
15
|
}
|
|
16
|
+
|
|
14
17
|
_createClass(DataSourcePlugin, [{
|
|
15
18
|
key: "apply",
|
|
16
19
|
value: function apply(layer) {
|
|
17
20
|
var _this = this;
|
|
21
|
+
|
|
18
22
|
this.mapService = layer.getContainer().get(TYPES.IMapService);
|
|
19
23
|
layer.hooks.init.tapPromise('DataSourcePlugin', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
20
24
|
var source, _ref2, data, options;
|
|
25
|
+
|
|
21
26
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
22
|
-
while (1)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
while (1) {
|
|
28
|
+
switch (_context.prev = _context.next) {
|
|
29
|
+
case 0:
|
|
30
|
+
layer.log(IDebugLog.SourceInitStart, ILayerStage.INIT);
|
|
31
|
+
source = layer.getSource();
|
|
32
|
+
|
|
33
|
+
if (!source) {
|
|
34
|
+
// Tip: 用户没有传入 source 的时候使用图层的默认数据
|
|
35
|
+
_ref2 = layer.sourceOption || layer.defaultSourceConfig, data = _ref2.data, options = _ref2.options;
|
|
36
|
+
source = new Source(data, options);
|
|
37
|
+
layer.setSource(source);
|
|
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;
|
|
34
49
|
break;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
resolve(null);
|
|
50
|
+
|
|
51
|
+
case 8:
|
|
52
|
+
_context.next = 10;
|
|
53
|
+
return new Promise(function (resolve) {
|
|
54
|
+
source.on('update', function (e) {
|
|
55
|
+
if (e.type === 'inited') {
|
|
56
|
+
_this.updateClusterData(layer);
|
|
57
|
+
|
|
58
|
+
layer.log(IDebugLog.SourceInitEnd, ILayerStage.INIT);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
resolve(null);
|
|
62
|
+
});
|
|
49
63
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
64
|
+
|
|
65
|
+
case 10:
|
|
66
|
+
case "end":
|
|
67
|
+
return _context.stop();
|
|
68
|
+
}
|
|
54
69
|
}
|
|
55
70
|
}, _callee);
|
|
56
|
-
})));
|
|
71
|
+
}))); // 检测数据是否需要更新
|
|
57
72
|
|
|
58
|
-
// 检测数据是否需要更新
|
|
59
73
|
layer.hooks.beforeRenderData.tapPromise('DataSourcePlugin', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
60
74
|
var neeUpdateCluster, dataSourceNeedUpdate, needScale;
|
|
61
75
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
62
|
-
while (1)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
76
|
+
while (1) {
|
|
77
|
+
switch (_context2.prev = _context2.next) {
|
|
78
|
+
case 0:
|
|
79
|
+
neeUpdateCluster = _this.updateClusterData(layer);
|
|
80
|
+
dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
|
|
81
|
+
layer.dataState.dataSourceNeedUpdate = false;
|
|
82
|
+
needScale = neeUpdateCluster || dataSourceNeedUpdate;
|
|
83
|
+
return _context2.abrupt("return", needScale);
|
|
84
|
+
|
|
85
|
+
case 5:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context2.stop();
|
|
88
|
+
}
|
|
72
89
|
}
|
|
73
90
|
}, _callee2);
|
|
74
91
|
})));
|
|
@@ -80,27 +97,33 @@ var DataSourcePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function
|
|
|
80
97
|
if (layer.isTileLayer || layer.tileLayer || !layer.getSource()) {
|
|
81
98
|
return false;
|
|
82
99
|
}
|
|
100
|
+
|
|
83
101
|
var source = layer.getSource();
|
|
84
102
|
var cluster = source.cluster;
|
|
85
103
|
var _source$clusterOption = source.clusterOptions.zoom,
|
|
86
|
-
|
|
104
|
+
zoom = _source$clusterOption === void 0 ? 0 : _source$clusterOption;
|
|
87
105
|
var newZoom = this.mapService.getZoom() - 1;
|
|
88
106
|
var dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
|
|
107
|
+
|
|
89
108
|
if (cluster && dataSourceNeedUpdate) {
|
|
90
109
|
// 数据发生更新
|
|
91
110
|
source.updateClusterData(Math.floor(newZoom));
|
|
92
|
-
}
|
|
93
|
-
|
|
111
|
+
} // 如果 dataSource 有更新,跳过 zoom 的判断,直接更新一次
|
|
112
|
+
|
|
113
|
+
|
|
94
114
|
if (cluster && Math.abs(layer.clusterZoom - newZoom) >= 1) {
|
|
95
115
|
if (zoom !== Math.floor(newZoom)) {
|
|
96
116
|
source.updateClusterData(Math.floor(newZoom));
|
|
97
117
|
}
|
|
118
|
+
|
|
98
119
|
layer.clusterZoom = newZoom;
|
|
99
120
|
return true;
|
|
100
121
|
}
|
|
122
|
+
|
|
101
123
|
return false;
|
|
102
124
|
}
|
|
103
125
|
}]);
|
|
126
|
+
|
|
104
127
|
return DataSourcePlugin;
|
|
105
128
|
}()) || _class);
|
|
106
129
|
export { DataSourcePlugin as default };
|
|
@@ -3,7 +3,9 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
3
3
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
4
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
5
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
|
+
|
|
6
7
|
var _scaleMap, _dec, _class;
|
|
8
|
+
|
|
7
9
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
10
|
import { IDebugLog, ILayerStage, ScaleTypes, StyleScaleType } from '@antv/l7-core';
|
|
9
11
|
import { extent } from 'd3-array';
|
|
@@ -18,75 +20,96 @@ var scaleMap = (_scaleMap = {}, _defineProperty(_scaleMap, ScaleTypes.LINEAR, d3
|
|
|
18
20
|
/**
|
|
19
21
|
* 根据 Source 原始数据为指定字段创建 Scale,保存在 StyleAttribute 上,供下游插件使用
|
|
20
22
|
*/
|
|
23
|
+
|
|
21
24
|
var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function () {
|
|
22
25
|
function FeatureScalePlugin() {
|
|
23
26
|
_classCallCheck(this, FeatureScalePlugin);
|
|
27
|
+
|
|
24
28
|
_defineProperty(this, "scaleOptions", {});
|
|
25
29
|
}
|
|
30
|
+
|
|
26
31
|
_createClass(FeatureScalePlugin, [{
|
|
27
32
|
key: "apply",
|
|
28
33
|
value: function apply(layer, _ref) {
|
|
29
34
|
var _this = this;
|
|
35
|
+
|
|
30
36
|
var styleAttributeService = _ref.styleAttributeService;
|
|
31
37
|
layer.hooks.init.tapPromise('FeatureScalePlugin', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
32
38
|
var _layer$getSource;
|
|
39
|
+
|
|
33
40
|
var attributes, dataArray;
|
|
34
41
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
35
|
-
while (1)
|
|
36
|
-
|
|
37
|
-
layer.log(IDebugLog.ScaleInitStart, ILayerStage.INIT);
|
|
38
|
-
_this.scaleOptions = layer.getScaleOptions();
|
|
39
|
-
attributes = styleAttributeService.getLayerStyleAttributes();
|
|
40
|
-
dataArray = (_layer$getSource = layer.getSource()) === null || _layer$getSource === void 0 ? void 0 : _layer$getSource.data.dataArray;
|
|
41
|
-
if (!(Array.isArray(dataArray) && dataArray.length === 0)) {
|
|
42
|
-
_context.next = 8;
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
return _context.abrupt("return");
|
|
46
|
-
case 8:
|
|
47
|
-
_this.caculateScalesForAttributes(attributes || [], dataArray);
|
|
48
|
-
case 9:
|
|
49
|
-
layer.log(IDebugLog.ScaleInitEnd, ILayerStage.INIT);
|
|
50
|
-
case 10:
|
|
51
|
-
case "end":
|
|
52
|
-
return _context.stop();
|
|
53
|
-
}
|
|
54
|
-
}, _callee);
|
|
55
|
-
})));
|
|
56
|
-
|
|
57
|
-
// 检测数据是否需要更新
|
|
58
|
-
layer.hooks.beforeRenderData.tapPromise('FeatureScalePlugin', /*#__PURE__*/function () {
|
|
59
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(flag) {
|
|
60
|
-
var attributes, dataArray;
|
|
61
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
62
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
42
|
+
while (1) {
|
|
43
|
+
switch (_context.prev = _context.next) {
|
|
63
44
|
case 0:
|
|
64
|
-
|
|
65
|
-
_context2.next = 2;
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
return _context2.abrupt("return", flag);
|
|
69
|
-
case 2:
|
|
70
|
-
layer.log(IDebugLog.ScaleInitStart, ILayerStage.UPDATE);
|
|
45
|
+
layer.log(IDebugLog.ScaleInitStart, ILayerStage.INIT);
|
|
71
46
|
_this.scaleOptions = layer.getScaleOptions();
|
|
72
47
|
attributes = styleAttributeService.getLayerStyleAttributes();
|
|
73
|
-
dataArray = layer.getSource().data.dataArray;
|
|
48
|
+
dataArray = (_layer$getSource = layer.getSource()) === null || _layer$getSource === void 0 ? void 0 : _layer$getSource.data.dataArray;
|
|
49
|
+
|
|
74
50
|
if (!(Array.isArray(dataArray) && dataArray.length === 0)) {
|
|
75
|
-
|
|
51
|
+
_context.next = 8;
|
|
76
52
|
break;
|
|
77
53
|
}
|
|
78
|
-
|
|
54
|
+
|
|
55
|
+
return _context.abrupt("return");
|
|
56
|
+
|
|
79
57
|
case 8:
|
|
80
58
|
_this.caculateScalesForAttributes(attributes || [], dataArray);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
59
|
+
|
|
60
|
+
case 9:
|
|
61
|
+
layer.log(IDebugLog.ScaleInitEnd, ILayerStage.INIT);
|
|
62
|
+
|
|
63
|
+
case 10:
|
|
85
64
|
case "end":
|
|
86
|
-
return
|
|
65
|
+
return _context.stop();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}, _callee);
|
|
69
|
+
}))); // 检测数据是否需要更新
|
|
70
|
+
|
|
71
|
+
layer.hooks.beforeRenderData.tapPromise('FeatureScalePlugin', /*#__PURE__*/function () {
|
|
72
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(flag) {
|
|
73
|
+
var attributes, dataArray;
|
|
74
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
75
|
+
while (1) {
|
|
76
|
+
switch (_context2.prev = _context2.next) {
|
|
77
|
+
case 0:
|
|
78
|
+
if (flag) {
|
|
79
|
+
_context2.next = 2;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return _context2.abrupt("return", flag);
|
|
84
|
+
|
|
85
|
+
case 2:
|
|
86
|
+
layer.log(IDebugLog.ScaleInitStart, ILayerStage.UPDATE);
|
|
87
|
+
_this.scaleOptions = layer.getScaleOptions();
|
|
88
|
+
attributes = styleAttributeService.getLayerStyleAttributes();
|
|
89
|
+
dataArray = layer.getSource().data.dataArray;
|
|
90
|
+
|
|
91
|
+
if (!(Array.isArray(dataArray) && dataArray.length === 0)) {
|
|
92
|
+
_context2.next = 8;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return _context2.abrupt("return", true);
|
|
97
|
+
|
|
98
|
+
case 8:
|
|
99
|
+
_this.caculateScalesForAttributes(attributes || [], dataArray);
|
|
100
|
+
|
|
101
|
+
layer.log(IDebugLog.ScaleInitEnd, ILayerStage.UPDATE);
|
|
102
|
+
layer.layerModelNeedUpdate = true;
|
|
103
|
+
return _context2.abrupt("return", true);
|
|
104
|
+
|
|
105
|
+
case 12:
|
|
106
|
+
case "end":
|
|
107
|
+
return _context2.stop();
|
|
108
|
+
}
|
|
87
109
|
}
|
|
88
110
|
}, _callee2);
|
|
89
111
|
}));
|
|
112
|
+
|
|
90
113
|
return function (_x) {
|
|
91
114
|
return _ref3.apply(this, arguments);
|
|
92
115
|
};
|
|
@@ -95,16 +118,20 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
|
|
|
95
118
|
if (layer.layerModelNeedUpdate) {
|
|
96
119
|
return;
|
|
97
120
|
}
|
|
121
|
+
|
|
98
122
|
_this.scaleOptions = layer.getScaleOptions();
|
|
99
123
|
var attributes = styleAttributeService.getLayerStyleAttributes();
|
|
100
124
|
var dataArray = layer.getSource().data.dataArray;
|
|
125
|
+
|
|
101
126
|
if (Array.isArray(dataArray) && dataArray.length === 0) {
|
|
102
127
|
return;
|
|
103
128
|
}
|
|
129
|
+
|
|
104
130
|
if (attributes) {
|
|
105
131
|
var attributesToRescale = attributes.filter(function (attribute) {
|
|
106
132
|
return attribute.needRescale;
|
|
107
133
|
});
|
|
134
|
+
|
|
108
135
|
if (attributesToRescale.length) {
|
|
109
136
|
_this.caculateScalesForAttributes(attributesToRescale, dataArray);
|
|
110
137
|
}
|
|
@@ -120,28 +147,30 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
|
|
|
120
147
|
key: "caculateScalesForAttributes",
|
|
121
148
|
value: function caculateScalesForAttributes(attributes, dataArray) {
|
|
122
149
|
var _this2 = this;
|
|
150
|
+
|
|
123
151
|
attributes.forEach(function (attribute) {
|
|
124
152
|
if (attribute.scale) {
|
|
125
153
|
// 创建Scale
|
|
126
|
-
var attributeScale = attribute.scale;
|
|
127
|
-
|
|
154
|
+
var attributeScale = attribute.scale; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
155
|
+
|
|
128
156
|
attributeScale.names = _this2.parseFields(attribute.scale.field || []);
|
|
129
|
-
var scales = [];
|
|
130
|
-
|
|
157
|
+
var scales = []; // 为每个字段创建 Scale
|
|
158
|
+
|
|
131
159
|
attributeScale.names.forEach(function (field) {
|
|
132
160
|
var _attribute$scale;
|
|
161
|
+
|
|
133
162
|
scales.push(_this2.createScale(field, attribute.name, (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.values, dataArray));
|
|
134
|
-
});
|
|
163
|
+
}); // 为scales 设置值区间 Range
|
|
135
164
|
|
|
136
|
-
// 为scales 设置值区间 Range
|
|
137
165
|
if (scales.some(function (scale) {
|
|
138
166
|
return scale.type === StyleScaleType.VARIABLE;
|
|
139
167
|
})) {
|
|
140
168
|
attributeScale.type = StyleScaleType.VARIABLE;
|
|
141
169
|
scales.forEach(function (scale) {
|
|
170
|
+
var _scale$option;
|
|
171
|
+
|
|
142
172
|
// 如果设置了回调, 这不需要设置range
|
|
143
173
|
if (!attributeScale.callback && attributeScale.values !== 'text') {
|
|
144
|
-
var _scale$option;
|
|
145
174
|
switch ((_scale$option = scale.option) === null || _scale$option === void 0 ? void 0 : _scale$option.type) {
|
|
146
175
|
case ScaleTypes.LOG:
|
|
147
176
|
case ScaleTypes.LINEAR:
|
|
@@ -150,29 +179,36 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
|
|
|
150
179
|
var tick = scale.scale.ticks(attributeScale.values.length);
|
|
151
180
|
scale.scale.domain(tick);
|
|
152
181
|
}
|
|
182
|
+
|
|
153
183
|
attributeScale.values ? scale.scale.range(attributeScale.values) : scale.scale.range(scale.option.domain);
|
|
154
184
|
break;
|
|
185
|
+
|
|
155
186
|
case ScaleTypes.QUANTILE:
|
|
156
187
|
case ScaleTypes.QUANTIZE:
|
|
157
188
|
case ScaleTypes.THRESHOLD:
|
|
158
189
|
scale.scale.range(attributeScale.values); //
|
|
190
|
+
|
|
159
191
|
break;
|
|
192
|
+
|
|
160
193
|
case ScaleTypes.IDENTITY:
|
|
161
194
|
// 不做处理xe
|
|
162
195
|
break;
|
|
196
|
+
|
|
163
197
|
case ScaleTypes.CAT:
|
|
164
198
|
attributeScale.values ? scale.scale.range(attributeScale.values) : scale.scale.range(scale.option.domain);
|
|
165
199
|
break;
|
|
200
|
+
|
|
166
201
|
case ScaleTypes.DIVERGING:
|
|
167
202
|
case ScaleTypes.SEQUENTIAL:
|
|
168
|
-
scale.scale.interpolator(
|
|
169
|
-
// @ts-ignore
|
|
203
|
+
scale.scale.interpolator( // @ts-ignore
|
|
170
204
|
d3interpolate.interpolateRgbBasis(attributeScale.values));
|
|
171
205
|
break;
|
|
172
206
|
}
|
|
173
207
|
}
|
|
208
|
+
|
|
174
209
|
if (attributeScale.values === 'text') {
|
|
175
210
|
var _scale$option2;
|
|
211
|
+
|
|
176
212
|
scale.scale.range((_scale$option2 = scale.option) === null || _scale$option2 === void 0 ? void 0 : _scale$option2.domain);
|
|
177
213
|
}
|
|
178
214
|
});
|
|
@@ -183,6 +219,7 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
|
|
|
183
219
|
return scale.scale(attributeScale.names[index]);
|
|
184
220
|
});
|
|
185
221
|
}
|
|
222
|
+
|
|
186
223
|
attributeScale.scalers = scales.map(function (scale) {
|
|
187
224
|
return {
|
|
188
225
|
field: scale.field,
|
|
@@ -194,27 +231,30 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
|
|
|
194
231
|
}
|
|
195
232
|
});
|
|
196
233
|
}
|
|
197
|
-
|
|
198
234
|
/**
|
|
199
235
|
* @example
|
|
200
236
|
* 'w*h' => ['w', 'h']
|
|
201
237
|
* 'w' => ['w']
|
|
202
238
|
*/
|
|
239
|
+
|
|
203
240
|
}, {
|
|
204
241
|
key: "parseFields",
|
|
205
242
|
value: function parseFields(field) {
|
|
206
243
|
if (Array.isArray(field)) {
|
|
207
244
|
return field;
|
|
208
245
|
}
|
|
246
|
+
|
|
209
247
|
if (isString(field)) {
|
|
210
248
|
return field.split('*');
|
|
211
249
|
}
|
|
250
|
+
|
|
212
251
|
return [field];
|
|
213
252
|
}
|
|
214
253
|
}, {
|
|
215
254
|
key: "createScale",
|
|
216
255
|
value: function createScale(field, name, values, data) {
|
|
217
256
|
var _this$scaleOptions$na, _find;
|
|
257
|
+
|
|
218
258
|
// scale 支持根据视觉通道和字段
|
|
219
259
|
var scaleOption = this.scaleOptions[name] && ((_this$scaleOptions$na = this.scaleOptions[name]) === null || _this$scaleOptions$na === void 0 ? void 0 : _this$scaleOptions$na.field) === field ? this.scaleOptions[name] // TODO zi
|
|
220
260
|
: this.scaleOptions[field];
|
|
@@ -224,6 +264,7 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
|
|
|
224
264
|
type: StyleScaleType.VARIABLE,
|
|
225
265
|
option: scaleOption
|
|
226
266
|
};
|
|
267
|
+
|
|
227
268
|
if (!data || !data.length) {
|
|
228
269
|
if (scaleOption && scaleOption.type) {
|
|
229
270
|
styleScale.scale = this.createDefaultScale(scaleOption);
|
|
@@ -231,39 +272,46 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
|
|
|
231
272
|
styleScale.scale = d3.scaleOrdinal([field]);
|
|
232
273
|
styleScale.type = StyleScaleType.CONSTANT;
|
|
233
274
|
}
|
|
275
|
+
|
|
234
276
|
return styleScale;
|
|
235
|
-
}
|
|
236
|
-
|
|
277
|
+
} // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
278
|
+
|
|
279
|
+
|
|
237
280
|
var firstValue = (_find = data.find(function (d) {
|
|
238
281
|
return !isNil(d[field]);
|
|
239
|
-
})) === null || _find === void 0 ? void 0 : _find[field];
|
|
240
|
-
|
|
282
|
+
})) === null || _find === void 0 ? void 0 : _find[field]; // 常量 Scale
|
|
283
|
+
|
|
241
284
|
if (this.isNumber(field) || isNil(firstValue) && !scaleOption) {
|
|
242
285
|
styleScale.scale = d3.scaleOrdinal([field]);
|
|
243
286
|
styleScale.type = StyleScaleType.CONSTANT;
|
|
244
287
|
} else {
|
|
245
288
|
// 根据数据类型判断 默认等分位,时间,和枚举类型
|
|
246
289
|
var type = scaleOption && scaleOption.type || this.getDefaultType(firstValue);
|
|
290
|
+
|
|
247
291
|
if (values === 'text') {
|
|
248
292
|
// text 为内置变 如果是文本则为cat
|
|
249
293
|
type = ScaleTypes.CAT;
|
|
250
294
|
}
|
|
295
|
+
|
|
251
296
|
var cfg = this.createScaleConfig(type, field, scaleOption, data);
|
|
252
297
|
styleScale.scale = this.createDefaultScale(cfg);
|
|
253
298
|
styleScale.option = cfg;
|
|
254
299
|
}
|
|
300
|
+
|
|
255
301
|
return styleScale;
|
|
256
302
|
}
|
|
257
303
|
}, {
|
|
258
304
|
key: "getDefaultType",
|
|
259
305
|
value: function getDefaultType(firstValue) {
|
|
260
306
|
var type = ScaleTypes.LINEAR;
|
|
307
|
+
|
|
261
308
|
if (typeof firstValue === 'string') {
|
|
262
309
|
type = dateRegex.test(firstValue) ? ScaleTypes.TIME : ScaleTypes.CAT;
|
|
263
310
|
}
|
|
311
|
+
|
|
264
312
|
return type;
|
|
265
|
-
}
|
|
266
|
-
|
|
313
|
+
} // 生成Scale 默认配置
|
|
314
|
+
|
|
267
315
|
}, {
|
|
268
316
|
key: "createScaleConfig",
|
|
269
317
|
value: function createScaleConfig(type, field, scaleOption, data) {
|
|
@@ -273,6 +321,7 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
|
|
|
273
321
|
var values = (data === null || data === void 0 ? void 0 : data.map(function (item) {
|
|
274
322
|
return item[field];
|
|
275
323
|
})) || [];
|
|
324
|
+
|
|
276
325
|
if (scaleOption !== null && scaleOption !== void 0 && scaleOption.domain) {
|
|
277
326
|
cfg.domain = scaleOption === null || scaleOption === void 0 ? void 0 : scaleOption.domain;
|
|
278
327
|
} else if (type === ScaleTypes.CAT || type === ScaleTypes.IDENTITY) {
|
|
@@ -287,36 +336,42 @@ var FeatureScalePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/functi
|
|
|
287
336
|
// linear/Power/log
|
|
288
337
|
cfg.domain = extent(values);
|
|
289
338
|
}
|
|
339
|
+
|
|
290
340
|
return _objectSpread(_objectSpread({}, cfg), scaleOption);
|
|
291
|
-
}
|
|
341
|
+
} // 创建Scale 实例
|
|
292
342
|
|
|
293
|
-
// 创建Scale 实例
|
|
294
343
|
}, {
|
|
295
344
|
key: "createDefaultScale",
|
|
296
345
|
value: function createDefaultScale(_ref4) {
|
|
297
346
|
var type = _ref4.type,
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
347
|
+
domain = _ref4.domain,
|
|
348
|
+
unknown = _ref4.unknown,
|
|
349
|
+
clamp = _ref4.clamp,
|
|
350
|
+
nice = _ref4.nice;
|
|
302
351
|
// @ts-ignore
|
|
303
352
|
var scale = scaleMap[type]();
|
|
353
|
+
|
|
304
354
|
if (domain && scale.domain) {
|
|
305
355
|
scale.domain(domain);
|
|
306
356
|
}
|
|
357
|
+
|
|
307
358
|
if (unknown) {
|
|
308
359
|
scale.unknown(unknown);
|
|
309
360
|
}
|
|
361
|
+
|
|
310
362
|
if (clamp !== undefined && scale.clamp) {
|
|
311
363
|
scale.clamp(clamp);
|
|
312
364
|
}
|
|
365
|
+
|
|
313
366
|
if (nice !== undefined && scale.nice) {
|
|
314
367
|
scale.nice(nice);
|
|
315
|
-
}
|
|
316
|
-
|
|
368
|
+
} // TODO 其他属性支持
|
|
369
|
+
|
|
370
|
+
|
|
317
371
|
return scale;
|
|
318
372
|
}
|
|
319
373
|
}]);
|
|
374
|
+
|
|
320
375
|
return FeatureScalePlugin;
|
|
321
376
|
}()) || _class);
|
|
322
377
|
export { FeatureScalePlugin as default };
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
|
|
4
5
|
var _dec, _class;
|
|
6
|
+
|
|
5
7
|
import { injectable } from 'inversify';
|
|
6
8
|
import 'reflect-metadata';
|
|
7
9
|
var LayerAnimateStylePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function () {
|
|
8
10
|
function LayerAnimateStylePlugin() {
|
|
9
11
|
_classCallCheck(this, LayerAnimateStylePlugin);
|
|
10
12
|
}
|
|
13
|
+
|
|
11
14
|
_createClass(LayerAnimateStylePlugin, [{
|
|
12
15
|
key: "apply",
|
|
13
16
|
value: function apply(layer) {
|
|
14
17
|
layer.hooks.beforeRender.tap('LayerAnimateStylePlugin', function () {
|
|
15
18
|
// @ts-ignore
|
|
16
19
|
var animateStatus = layer.animateStatus;
|
|
20
|
+
|
|
17
21
|
if (animateStatus) {
|
|
18
22
|
layer.models.forEach(function (model) {
|
|
19
23
|
model.addUniforms(_objectSpread({}, layer.layerModel.getAnimateUniforms()));
|
|
@@ -22,6 +26,7 @@ var LayerAnimateStylePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/f
|
|
|
22
26
|
});
|
|
23
27
|
}
|
|
24
28
|
}]);
|
|
29
|
+
|
|
25
30
|
return LayerAnimateStylePlugin;
|
|
26
31
|
}()) || _class);
|
|
27
32
|
export { LayerAnimateStylePlugin as default };
|
|
@@ -1,27 +1,34 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
|
|
4
5
|
var _dec, _class;
|
|
6
|
+
|
|
5
7
|
import { injectable } from 'inversify';
|
|
6
8
|
import 'reflect-metadata';
|
|
7
9
|
/**
|
|
8
10
|
* 更新图层样式,初始图层相关配置
|
|
9
11
|
*/
|
|
12
|
+
|
|
10
13
|
var LayerStylePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function () {
|
|
11
14
|
function LayerStylePlugin() {
|
|
12
15
|
_classCallCheck(this, LayerStylePlugin);
|
|
13
16
|
}
|
|
17
|
+
|
|
14
18
|
_createClass(LayerStylePlugin, [{
|
|
15
19
|
key: "apply",
|
|
16
20
|
value: function apply(layer) {
|
|
17
21
|
layer.hooks.afterInit.tap('LayerMaskPlugin', function () {
|
|
18
22
|
var _layer$getLayerConfig = layer.getLayerConfig(),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
maskLayers = _layer$getLayerConfig.maskLayers,
|
|
24
|
+
enableMask = _layer$getLayerConfig.enableMask; // mask 初始化
|
|
25
|
+
|
|
26
|
+
|
|
22
27
|
if (!layer.tileLayer && maskLayers && maskLayers.length > 0) {
|
|
23
28
|
var _layer$masks;
|
|
29
|
+
|
|
24
30
|
(_layer$masks = layer.masks).push.apply(_layer$masks, _toConsumableArray(maskLayers));
|
|
31
|
+
|
|
25
32
|
layer.updateLayerConfig({
|
|
26
33
|
mask: true && enableMask
|
|
27
34
|
});
|
|
@@ -29,6 +36,7 @@ var LayerStylePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function
|
|
|
29
36
|
});
|
|
30
37
|
}
|
|
31
38
|
}]);
|
|
39
|
+
|
|
32
40
|
return LayerStylePlugin;
|
|
33
41
|
}()) || _class);
|
|
34
42
|
export { LayerStylePlugin as default };
|