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