@antv/l7-layers 2.9.23 → 2.9.25
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/models/plane.d.ts +1 -0
- package/es/citybuliding/building.js +1 -1
- package/es/core/BaseLayer.js +10 -3
- package/es/core/interface.d.ts +26 -48
- package/es/core/interface.js +3 -0
- package/es/core/schema.d.ts +3 -3
- package/es/core/triangulation.d.ts +4 -3
- package/es/core/triangulation.js +54 -39
- package/es/heatmap/models/heatmap.js +1 -1
- package/es/image/models/image.js +7 -1
- package/es/line/index.js +4 -1
- package/es/line/models/arc.js +1 -1
- package/es/line/models/simpleLine.js +1 -1
- package/es/line/shaders/line_arc_vert.glsl +5 -3
- package/es/line/shaders/simple/simpleline_vert.glsl +1 -0
- package/es/plugins/FeatureScalePlugin.js +0 -1
- package/es/point/index.js +3 -1
- package/es/point/models/fill.js +5 -2
- package/es/point/models/fillmage.js +9 -3
- package/es/point/models/image.js +8 -2
- package/es/point/models/radar.js +2 -3
- package/es/point/models/tile.js +1 -1
- package/es/point/shaders/fill_vert.glsl +13 -6
- package/es/point/shaders/image/fillImage_vert.glsl +13 -5
- package/es/point/shaders/image_vert.glsl +17 -8
- package/es/polygon/index.js +4 -1
- package/es/raster/index.js +3 -1
- package/es/tile/manager/tileLayerManager.d.ts +3 -2
- package/es/tile/manager/tileLayerManager.js +5 -2
- package/es/tile/models/tileModel.js +4 -3
- package/es/tile/tileFactory/base.d.ts +1 -1
- package/es/tile/tileFactory/base.js +32 -5
- package/es/tile/tileFactory/vectorLayer.d.ts +3 -1
- package/es/tile/tileFactory/vectorLayer.js +22 -1
- package/es/tile/tileLayer/baseTileLayer.d.ts +1 -1
- package/es/tile/tileLayer/baseTileLayer.js +3 -2
- package/es/tile/utils.d.ts +2 -0
- package/es/tile/utils.js +5 -1
- package/lib/Geometry/index.js +114 -77
- package/lib/Geometry/models/billboard.js +232 -181
- package/lib/Geometry/models/index.js +18 -34
- package/lib/Geometry/models/plane.js +407 -278
- package/lib/Geometry/models/sprite.js +291 -189
- package/lib/canvas/index.js +101 -66
- package/lib/canvas/models/canvas.js +207 -140
- package/lib/canvas/models/index.js +12 -30
- package/lib/citybuliding/building.js +98 -63
- package/lib/citybuliding/models/build.js +192 -146
- package/lib/core/BaseLayer.js +1331 -809
- package/lib/core/BaseModel.js +457 -279
- package/lib/core/interface.js +40 -53
- package/lib/core/schema.js +21 -39
- package/lib/core/shape/Path.js +67 -79
- package/lib/core/shape/extrude.js +132 -91
- package/lib/core/triangulation.js +412 -213
- package/lib/earth/index.js +100 -62
- package/lib/earth/models/atmosphere.js +146 -112
- package/lib/earth/models/base.js +210 -150
- package/lib/earth/models/bloomsphere.js +146 -112
- package/lib/earth/utils.js +111 -91
- package/lib/heatmap/index.js +149 -92
- package/lib/heatmap/models/grid.js +118 -91
- package/lib/heatmap/models/grid3d.js +155 -123
- package/lib/heatmap/models/heatmap.js +475 -338
- package/lib/heatmap/models/hexagon.js +121 -92
- package/lib/heatmap/models/index.js +22 -37
- package/lib/heatmap/triangulation.js +31 -47
- package/lib/image/index.js +111 -74
- package/lib/image/models/dataImage.js +232 -174
- package/lib/image/models/image.js +175 -123
- package/lib/image/models/index.js +15 -32
- package/lib/index.js +263 -97
- package/lib/line/index.js +131 -83
- package/lib/line/models/arc.js +352 -237
- package/lib/line/models/arc_3d.js +334 -228
- package/lib/line/models/earthArc_3d.js +336 -228
- package/lib/line/models/great_circle.js +291 -200
- package/lib/line/models/half.js +286 -201
- package/lib/line/models/index.js +42 -50
- package/lib/line/models/line.js +428 -299
- package/lib/line/models/linearline.js +277 -203
- package/lib/line/models/simpleLine.js +239 -175
- package/lib/line/models/tile.js +348 -237
- package/lib/line/models/wall.js +327 -235
- package/lib/line/shaders/line_arc_vert.glsl +5 -3
- package/lib/line/shaders/simple/simpleline_vert.glsl +1 -0
- package/lib/mask/index.js +92 -59
- package/lib/mask/models/fill.js +134 -82
- package/lib/mask/models/index.js +12 -30
- package/lib/plugins/DataMappingPlugin.js +342 -224
- package/lib/plugins/DataSourcePlugin.js +102 -87
- package/lib/plugins/FeatureScalePlugin.js +330 -241
- package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
- package/lib/plugins/LayerModelPlugin.js +80 -73
- package/lib/plugins/LayerStylePlugin.js +48 -51
- package/lib/plugins/LightingPlugin.js +80 -68
- package/lib/plugins/MultiPassRendererPlugin.js +91 -65
- package/lib/plugins/PixelPickingPlugin.js +150 -109
- package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
- package/lib/plugins/ShaderUniformPlugin.js +118 -99
- package/lib/plugins/UpdateModelPlugin.js +40 -47
- package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
- package/lib/point/index.js +226 -148
- package/lib/point/models/earthExtrude.js +279 -201
- package/lib/point/models/earthFill.js +287 -202
- package/lib/point/models/extrude.js +299 -203
- package/lib/point/models/fill.js +406 -273
- package/lib/point/models/fillmage.js +365 -252
- package/lib/point/models/image.js +241 -164
- package/lib/point/models/index.js +46 -52
- package/lib/point/models/normal.js +183 -134
- package/lib/point/models/radar.js +304 -212
- package/lib/point/models/simplePoint.js +194 -142
- package/lib/point/models/text.js +608 -385
- package/lib/point/models/tile.js +314 -223
- package/lib/point/shaders/fill_vert.glsl +13 -6
- package/lib/point/shaders/image/fillImage_vert.glsl +13 -5
- package/lib/point/shaders/image_vert.glsl +17 -8
- package/lib/point/shape/extrude.js +56 -52
- package/lib/polygon/index.js +154 -100
- package/lib/polygon/models/extrude.js +311 -223
- package/lib/polygon/models/fill.js +215 -153
- package/lib/polygon/models/index.js +46 -52
- package/lib/polygon/models/ocean.js +244 -173
- package/lib/polygon/models/tile.js +144 -100
- package/lib/polygon/models/water.js +222 -153
- package/lib/raster/buffers/triangulation.js +27 -40
- package/lib/raster/index.js +115 -74
- package/lib/raster/models/index.js +16 -33
- package/lib/raster/models/raster.js +178 -135
- package/lib/raster/raster.js +187 -132
- package/lib/tile/interface.js +4 -16
- package/lib/tile/manager/tileConfigManager.js +125 -86
- package/lib/tile/manager/tileLayerManager.js +314 -227
- package/lib/tile/manager/tilePickerManager.js +192 -123
- package/lib/tile/models/tileModel.js +71 -51
- package/lib/tile/tileFactory/base.js +433 -292
- package/lib/tile/tileFactory/index.js +51 -49
- package/lib/tile/tileFactory/line.js +65 -50
- package/lib/tile/tileFactory/point.js +65 -50
- package/lib/tile/tileFactory/polygon.js +65 -50
- package/lib/tile/tileFactory/raster.js +66 -54
- package/lib/tile/tileFactory/rasterData.js +88 -76
- package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
- package/lib/tile/tileFactory/vectorLayer.js +169 -95
- package/lib/tile/tileLayer/baseTileLayer.js +420 -220
- package/lib/tile/tmsTileLayer.js +110 -67
- package/lib/tile/utils.js +113 -87
- package/lib/utils/blend.js +59 -79
- package/lib/utils/collision-index.js +107 -64
- package/lib/utils/dataMappingStyle.js +105 -60
- package/lib/utils/extrude_polyline.js +600 -398
- package/lib/utils/grid-index.js +163 -111
- package/lib/utils/layerData.js +130 -99
- package/lib/utils/multiPassRender.js +49 -41
- package/lib/utils/polylineNormal.js +148 -96
- package/lib/utils/simpleLine.js +100 -85
- package/lib/utils/symbol-layout.js +219 -116
- package/lib/utils/updateShape.js +15 -41
- package/lib/wind/index.js +109 -71
- package/lib/wind/models/index.js +12 -30
- package/lib/wind/models/utils.js +144 -105
- package/lib/wind/models/wind.js +333 -224
- package/lib/wind/models/windRender.js +329 -218
- package/lib/wind/models/windShader.js +23 -181
- package/package.json +7 -6
|
@@ -1,242 +1,360 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
19
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
20
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
21
|
-
if (decorator = decorators[i])
|
|
22
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
23
|
-
if (kind && result)
|
|
24
|
-
__defProp(target, key, result);
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// src/plugins/DataMappingPlugin.ts
|
|
29
|
-
var DataMappingPlugin_exports = {};
|
|
30
|
-
__export(DataMappingPlugin_exports, {
|
|
31
|
-
default: () => DataMappingPlugin
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
32
7
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const bottomColor = layer.getBottomColor();
|
|
72
|
-
const attributes = styleAttributeService.getLayerStyleAttributes() || [];
|
|
73
|
-
const filter = styleAttributeService.getLayerStyleAttribute("filter");
|
|
74
|
-
const { dataArray } = source.data;
|
|
75
|
-
const attributesToRemapping = attributes.filter((attribute) => attribute.needRemapping);
|
|
76
|
-
let filterData = dataArray;
|
|
77
|
-
if ((filter == null ? void 0 : filter.needRemapping) && (filter == null ? void 0 : filter.scale)) {
|
|
78
|
-
filterData = dataArray.filter((record) => {
|
|
79
|
-
return this.applyAttributeMapping(filter, record, bottomColor)[0];
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
if (attributesToRemapping.length) {
|
|
83
|
-
if (filter == null ? void 0 : filter.needRemapping) {
|
|
84
|
-
layer.setEncodedData(this.mapping(layer, attributes, filterData, void 0, bottomColor));
|
|
85
|
-
filter.needRemapping = false;
|
|
86
|
-
} else {
|
|
87
|
-
layer.setEncodedData(this.mapping(layer, attributesToRemapping, filterData, layer.getEncodedData(), bottomColor));
|
|
88
|
-
}
|
|
89
|
-
layer.emit("remapping", null);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
|
|
12
|
+
var _initializerDefineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/initializerDefineProperty"));
|
|
13
|
+
|
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
18
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
+
|
|
20
|
+
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime/helpers/applyDecoratedDescriptor"));
|
|
21
|
+
|
|
22
|
+
var _initializerWarningHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/initializerWarningHelper"));
|
|
23
|
+
|
|
24
|
+
var _l7Core = require("@antv/l7-core");
|
|
25
|
+
|
|
26
|
+
var _l7Maps = require("@antv/l7-maps");
|
|
27
|
+
|
|
28
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
29
|
+
|
|
30
|
+
var _inversify = require("inversify");
|
|
31
|
+
|
|
32
|
+
var _lodash = require("lodash");
|
|
33
|
+
|
|
34
|
+
require("reflect-metadata");
|
|
35
|
+
|
|
36
|
+
var _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2, _descriptor3;
|
|
37
|
+
|
|
38
|
+
var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inversify.inject)(_l7Core.TYPES.IGlobalConfigService), _dec3 = (0, _inversify.inject)(_l7Core.TYPES.IMapService), _dec4 = (0, _inversify.inject)(_l7Core.TYPES.IFontService), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
39
|
+
function DataMappingPlugin() {
|
|
40
|
+
(0, _classCallCheck2.default)(this, DataMappingPlugin);
|
|
41
|
+
(0, _initializerDefineProperty2.default)(this, "configService", _descriptor, this);
|
|
42
|
+
(0, _initializerDefineProperty2.default)(this, "mapService", _descriptor2, this);
|
|
43
|
+
(0, _initializerDefineProperty2.default)(this, "fontService", _descriptor3, this);
|
|
92
44
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
45
|
+
|
|
46
|
+
(0, _createClass2.default)(DataMappingPlugin, [{
|
|
47
|
+
key: "apply",
|
|
48
|
+
value: function apply(layer, _ref) {
|
|
49
|
+
var _this = this;
|
|
50
|
+
|
|
51
|
+
var styleAttributeService = _ref.styleAttributeService;
|
|
52
|
+
layer.hooks.init.tap('DataMappingPlugin', function () {
|
|
53
|
+
// 初始化重新生成 map
|
|
54
|
+
var source = layer.getSource();
|
|
55
|
+
|
|
56
|
+
if (source.inited) {
|
|
57
|
+
_this.generateMaping(layer, {
|
|
58
|
+
styleAttributeService: styleAttributeService
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
source.once('sourceUpdate', function () {
|
|
62
|
+
_this.generateMaping(layer, {
|
|
63
|
+
styleAttributeService: styleAttributeService
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
} // this.generateMaping(layer, { styleAttributeService });
|
|
67
|
+
|
|
104
68
|
});
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
69
|
+
layer.hooks.beforeRenderData.tap('DataMappingPlugin', function () {
|
|
70
|
+
layer.dataState.dataMappingNeedUpdate = false;
|
|
71
|
+
var source = layer.getSource();
|
|
72
|
+
|
|
73
|
+
if (source.inited) {
|
|
74
|
+
_this.generateMaping(layer, {
|
|
75
|
+
styleAttributeService: styleAttributeService
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
source.once('sourceUpdate', function () {
|
|
79
|
+
_this.generateMaping(layer, {
|
|
80
|
+
styleAttributeService: styleAttributeService
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
} // this.generateMaping(layer, { styleAttributeService });
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
return true;
|
|
87
|
+
}); // remapping before render
|
|
88
|
+
|
|
89
|
+
layer.hooks.beforeRender.tap('DataMappingPlugin', function () {
|
|
90
|
+
var source = layer.getSource();
|
|
91
|
+
|
|
92
|
+
if (layer.layerModelNeedUpdate || !source || !source.inited) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var bottomColor = layer.getBottomColor();
|
|
97
|
+
var attributes = styleAttributeService.getLayerStyleAttributes() || [];
|
|
98
|
+
var filter = styleAttributeService.getLayerStyleAttribute('filter');
|
|
99
|
+
var dataArray = source.data.dataArray;
|
|
100
|
+
var attributesToRemapping = attributes.filter(function (attribute) {
|
|
101
|
+
return attribute.needRemapping;
|
|
102
|
+
} // 如果filter变化
|
|
103
|
+
);
|
|
104
|
+
var filterData = dataArray; // 数据过滤完 再执行数据映射
|
|
105
|
+
|
|
106
|
+
if (filter !== null && filter !== void 0 && filter.needRemapping && filter !== null && filter !== void 0 && filter.scale) {
|
|
107
|
+
filterData = dataArray.filter(function (record) {
|
|
108
|
+
return _this.applyAttributeMapping(filter, record, bottomColor)[0];
|
|
137
109
|
});
|
|
138
110
|
}
|
|
139
|
-
|
|
140
|
-
if (
|
|
141
|
-
|
|
111
|
+
|
|
112
|
+
if (attributesToRemapping.length) {
|
|
113
|
+
// 过滤数据
|
|
114
|
+
if (filter !== null && filter !== void 0 && filter.needRemapping) {
|
|
115
|
+
layer.setEncodedData(_this.mapping(layer, attributes, filterData, undefined, bottomColor));
|
|
116
|
+
filter.needRemapping = false;
|
|
117
|
+
} else {
|
|
118
|
+
layer.setEncodedData(_this.mapping(layer, attributesToRemapping, filterData, layer.getEncodedData(), bottomColor));
|
|
119
|
+
} // 处理文本更新
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
layer.emit('remapping', null);
|
|
142
123
|
}
|
|
143
124
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
d.version = import_l7_maps.Version["GAODE2.x"];
|
|
161
|
-
d.originCoordinates = (0, import_lodash.cloneDeep)(d.coordinates);
|
|
162
|
-
d.coordinates = this.mapService.lngLatToCoordByLayer(d.coordinates, layerCenter);
|
|
163
|
-
});
|
|
164
|
-
} else {
|
|
165
|
-
mappedData.filter((d) => !d.originCoordinates).map((d) => {
|
|
166
|
-
d.version = import_l7_maps.Version["GAODE2.x"];
|
|
167
|
-
d.originCoordinates = (0, import_lodash.cloneDeep)(d.coordinates);
|
|
168
|
-
d.coordinates = this.mapService.lngLatToCoordsByLayer(d.coordinates, layerCenter);
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "generateMaping",
|
|
128
|
+
value: function generateMaping(layer, _ref2) {
|
|
129
|
+
var _this2 = this;
|
|
130
|
+
|
|
131
|
+
var styleAttributeService = _ref2.styleAttributeService;
|
|
132
|
+
var bottomColor = layer.getBottomColor();
|
|
133
|
+
var attributes = styleAttributeService.getLayerStyleAttributes() || [];
|
|
134
|
+
var filter = styleAttributeService.getLayerStyleAttribute('filter');
|
|
135
|
+
var dataArray = layer.getSource().data.dataArray;
|
|
136
|
+
var filterData = dataArray; // 数据过滤完 再执行数据映射
|
|
137
|
+
|
|
138
|
+
if (filter !== null && filter !== void 0 && filter.scale) {
|
|
139
|
+
filterData = dataArray.filter(function (record) {
|
|
140
|
+
return _this2.applyAttributeMapping(filter, record, bottomColor)[0];
|
|
169
141
|
});
|
|
170
142
|
}
|
|
143
|
+
|
|
144
|
+
layer.setEncodedData(this.mapping(layer, attributes, filterData, undefined, bottomColor)); // 对外暴露事件
|
|
145
|
+
|
|
146
|
+
layer.emit('dataUpdate', null);
|
|
171
147
|
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
148
|
+
}, {
|
|
149
|
+
key: "getArrowPoints",
|
|
150
|
+
value: function getArrowPoints(p1, p2) {
|
|
151
|
+
var dir = [p2[0] - p1[0], p2[1] - p1[1]];
|
|
152
|
+
var normalizeDir = (0, _l7Utils.normalize)(dir);
|
|
153
|
+
var arrowPoint = [p1[0] + normalizeDir[0] * 0.0001, p1[1] + normalizeDir[1] * 0.0001];
|
|
154
|
+
return arrowPoint;
|
|
155
|
+
}
|
|
156
|
+
}, {
|
|
157
|
+
key: "mapping",
|
|
158
|
+
value: function mapping(layer, attributes, data, predata, minimumColor) {
|
|
159
|
+
var _this3 = this;
|
|
160
|
+
|
|
161
|
+
var _ref3 = layer.getLayerConfig(),
|
|
162
|
+
_ref3$arrow = _ref3.arrow,
|
|
163
|
+
arrow = _ref3$arrow === void 0 ? {
|
|
164
|
+
enable: false
|
|
165
|
+
} : _ref3$arrow;
|
|
166
|
+
|
|
167
|
+
var mappedData = data.map(function (record, i) {
|
|
168
|
+
var preRecord = predata ? predata[i] : {};
|
|
169
|
+
var encodeRecord = (0, _objectSpread2.default)({
|
|
170
|
+
id: record._id,
|
|
171
|
+
coordinates: record.coordinates
|
|
172
|
+
}, preRecord);
|
|
173
|
+
attributes.filter(function (attribute) {
|
|
174
|
+
return attribute.scale !== undefined;
|
|
175
|
+
}).forEach(function (attribute) {
|
|
176
|
+
// console.log('record', record)
|
|
177
|
+
var values = _this3.applyAttributeMapping(attribute, record, minimumColor); // console.log('values', values)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
attribute.needRemapping = false; // TODO: 支持每个属性配置 postprocess
|
|
181
|
+
|
|
182
|
+
if (attribute.name === 'color') {
|
|
183
|
+
// console.log('attribute', attribute)
|
|
184
|
+
values = values.map(function (c) {
|
|
185
|
+
return (0, _l7Utils.rgb2arr)(c);
|
|
186
|
+
});
|
|
187
|
+
} // @ts-ignore
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values; // 增加对 layer/text/iconfont unicode 映射的解析
|
|
191
|
+
|
|
192
|
+
if (attribute.name === 'shape') {
|
|
193
|
+
encodeRecord.shape = _this3.fontService.getIconFontKey(encodeRecord[attribute.name]);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
if (arrow.enable && (encodeRecord.shape === 'line' || encodeRecord.shape === 'halfLine')) {
|
|
198
|
+
// 只有在线图层且支持配置箭头的时候进行插入顶点的处理
|
|
199
|
+
var coords = encodeRecord.coordinates;
|
|
200
|
+
|
|
201
|
+
var arrowPoint = _this3.getArrowPoints(coords[0], coords[1]);
|
|
202
|
+
|
|
203
|
+
encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
|
|
183
204
|
}
|
|
184
|
-
|
|
205
|
+
|
|
206
|
+
return encodeRecord;
|
|
207
|
+
}); // console.log('mappedData', mappedData)
|
|
208
|
+
// 调整数据兼容 Amap2.0
|
|
209
|
+
|
|
210
|
+
this.adjustData2Amap2Coordinates(mappedData, layer); // 调整数据兼容 SimpleCoordinates
|
|
211
|
+
|
|
212
|
+
this.adjustData2SimpleCoordinates(mappedData);
|
|
213
|
+
return mappedData;
|
|
185
214
|
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
215
|
+
}, {
|
|
216
|
+
key: "adjustData2Amap2Coordinates",
|
|
217
|
+
value: function adjustData2Amap2Coordinates(mappedData, layer) {
|
|
218
|
+
var _this4 = this;
|
|
219
|
+
|
|
220
|
+
// 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移
|
|
221
|
+
if (mappedData.length > 0 && this.mapService.version === _l7Maps.Version['GAODE2.x']) {
|
|
222
|
+
var layerCenter = this.getLayerCenter(layer);
|
|
223
|
+
|
|
224
|
+
if (typeof mappedData[0].coordinates[0] === 'number') {
|
|
225
|
+
// 单个的点数据
|
|
226
|
+
// @ts-ignore
|
|
227
|
+
mappedData // TODO: 避免经纬度被重复计算导致坐标位置偏移
|
|
228
|
+
.filter(function (d) {
|
|
229
|
+
return !d.originCoordinates;
|
|
230
|
+
}).map(function (d) {
|
|
231
|
+
d.version = _l7Maps.Version['GAODE2.x']; // @ts-ignore
|
|
232
|
+
|
|
233
|
+
d.originCoordinates = (0, _lodash.cloneDeep)(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
|
|
234
|
+
// @ts-ignore
|
|
235
|
+
// d.coordinates = this.mapService.lngLatToCoord(d.coordinates);
|
|
236
|
+
|
|
237
|
+
d.coordinates = _this4.mapService.lngLatToCoordByLayer(d.coordinates, layerCenter);
|
|
238
|
+
});
|
|
239
|
+
} else {
|
|
240
|
+
// 连续的线、面数据
|
|
241
|
+
// @ts-ignore
|
|
242
|
+
mappedData // TODO: 避免经纬度被重复计算导致坐标位置偏移
|
|
243
|
+
.filter(function (d) {
|
|
244
|
+
return !d.originCoordinates;
|
|
245
|
+
}).map(function (d) {
|
|
246
|
+
d.version = _l7Maps.Version['GAODE2.x']; // @ts-ignore
|
|
247
|
+
|
|
248
|
+
d.originCoordinates = (0, _lodash.cloneDeep)(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
|
|
249
|
+
// @ts-ignore
|
|
250
|
+
// d.coordinates = this.mapService.lngLatToCoords(d.coordinates);
|
|
251
|
+
|
|
252
|
+
d.coordinates = _this4.mapService.lngLatToCoordsByLayer(d.coordinates, layerCenter);
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}, {
|
|
258
|
+
key: "getLayerCenter",
|
|
259
|
+
value: function getLayerCenter(layer) {
|
|
260
|
+
var source = layer.getSource();
|
|
261
|
+
return source.center;
|
|
190
262
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
263
|
+
}, {
|
|
264
|
+
key: "adjustData2SimpleCoordinates",
|
|
265
|
+
value: function adjustData2SimpleCoordinates(mappedData) {
|
|
266
|
+
var _this5 = this;
|
|
267
|
+
|
|
268
|
+
if (mappedData.length > 0 && this.mapService.version === _l7Maps.Version.SIMPLE) {
|
|
269
|
+
mappedData.map(function (d) {
|
|
270
|
+
if (!d.simpleCoordinate) {
|
|
271
|
+
d.coordinates = _this5.unProjectCoordinates(d.coordinates);
|
|
272
|
+
d.simpleCoordinate = true;
|
|
273
|
+
}
|
|
197
274
|
});
|
|
198
|
-
|
|
199
|
-
});
|
|
200
|
-
return coords;
|
|
201
|
-
} else {
|
|
202
|
-
const coords = [];
|
|
203
|
-
coordinates.map((coord) => {
|
|
204
|
-
coords.push(this.mapService.simpleMapCoord.unproject(coord));
|
|
205
|
-
});
|
|
206
|
-
return coords;
|
|
275
|
+
}
|
|
207
276
|
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
277
|
+
}, {
|
|
278
|
+
key: "unProjectCoordinates",
|
|
279
|
+
value: function unProjectCoordinates(coordinates) {
|
|
280
|
+
var _this6 = this;
|
|
281
|
+
|
|
282
|
+
if (typeof coordinates[0] === 'number') {
|
|
283
|
+
return this.mapService.simpleMapCoord.unproject(coordinates);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (coordinates[0] && coordinates[0][0] instanceof Array) {
|
|
287
|
+
// @ts-ignore
|
|
288
|
+
var coords = [];
|
|
289
|
+
coordinates.map(function (coord) {
|
|
290
|
+
// @ts-ignore
|
|
291
|
+
var c1 = [];
|
|
292
|
+
coord.map(function (co) {
|
|
293
|
+
c1.push(_this6.mapService.simpleMapCoord.unproject(co));
|
|
294
|
+
}); // @ts-ignore
|
|
295
|
+
|
|
296
|
+
coords.push(c1);
|
|
297
|
+
}); // @ts-ignore
|
|
298
|
+
|
|
299
|
+
return coords;
|
|
300
|
+
} else {
|
|
301
|
+
// @ts-ignore
|
|
302
|
+
var _coords = []; // @ts-ignore
|
|
303
|
+
|
|
304
|
+
coordinates.map(function (coord) {
|
|
305
|
+
_coords.push(_this6.mapService.simpleMapCoord.unproject(coord));
|
|
306
|
+
}); // @ts-ignore
|
|
307
|
+
|
|
308
|
+
return _coords;
|
|
309
|
+
}
|
|
213
310
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
var
|
|
218
|
-
|
|
219
|
-
|
|
311
|
+
}, {
|
|
312
|
+
key: "applyAttributeMapping",
|
|
313
|
+
value: function applyAttributeMapping(attribute, record, minimumColor) {
|
|
314
|
+
var _attribute$scale;
|
|
315
|
+
|
|
316
|
+
if (!attribute.scale) {
|
|
317
|
+
return [];
|
|
220
318
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
319
|
+
|
|
320
|
+
var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
|
|
321
|
+
var params = [];
|
|
322
|
+
scalers.forEach(function (_ref4) {
|
|
323
|
+
var _attribute$scale2;
|
|
324
|
+
|
|
325
|
+
var field = _ref4.field;
|
|
326
|
+
|
|
327
|
+
if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
|
|
328
|
+
// TODO:多字段,常量
|
|
329
|
+
params.push(record[field]);
|
|
330
|
+
}
|
|
331
|
+
}); // console.log('params', params)
|
|
332
|
+
// console.log('attribute', attribute)
|
|
333
|
+
|
|
334
|
+
var mappingResult = attribute.mapping ? attribute.mapping(params) : [];
|
|
335
|
+
|
|
336
|
+
if (attribute.name === 'color' && !(0, _l7Utils.isColor)(mappingResult[0])) {
|
|
337
|
+
return [minimumColor];
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return mappingResult; // return attribute.mapping ? attribute.mapping(params) : [];
|
|
225
341
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
342
|
+
}]);
|
|
343
|
+
return DataMappingPlugin;
|
|
344
|
+
}(), (_descriptor = (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "configService", [_dec2], {
|
|
345
|
+
configurable: true,
|
|
346
|
+
enumerable: true,
|
|
347
|
+
writable: true,
|
|
348
|
+
initializer: null
|
|
349
|
+
}), _descriptor2 = (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "mapService", [_dec3], {
|
|
350
|
+
configurable: true,
|
|
351
|
+
enumerable: true,
|
|
352
|
+
writable: true,
|
|
353
|
+
initializer: null
|
|
354
|
+
}), _descriptor3 = (0, _applyDecoratedDescriptor2.default)(_class2.prototype, "fontService", [_dec4], {
|
|
355
|
+
configurable: true,
|
|
356
|
+
enumerable: true,
|
|
357
|
+
writable: true,
|
|
358
|
+
initializer: null
|
|
359
|
+
})), _class2)) || _class);
|
|
360
|
+
exports.default = DataMappingPlugin;
|