@antv/l7-layers 2.19.9 → 2.19.11
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/core/BaseLayer.d.ts +0 -2
- package/es/core/BaseLayer.js +19 -38
- package/es/core/BaseModel.js +4 -19
- package/es/core/CommonStyleAttribute.js +20 -0
- package/es/core/constant.d.ts +6 -0
- package/es/core/constant.js +19 -0
- package/es/core/interface.d.ts +15 -9
- package/es/core/line_trangluation.d.ts +19 -0
- package/es/core/line_trangluation.js +91 -0
- package/es/core/shape/arrow.d.ts +25 -0
- package/es/core/shape/arrow.js +160 -0
- package/es/core/triangulation.d.ts +2 -8
- package/es/core/triangulation.js +6 -34
- package/es/geometry/models/plane.js +1 -2
- package/es/geometry/models/sprite.js +1 -2
- package/es/line/index.js +3 -2
- package/es/line/models/arc.js +13 -14
- package/es/line/models/arc_3d.js +5 -3
- package/es/line/models/earthArc_3d.js +5 -3
- package/es/line/models/flow.js +4 -5
- package/es/line/models/great_circle.js +6 -7
- package/es/line/models/line.js +9 -24
- package/es/line/models/linearline.js +5 -4
- package/es/line/models/simpleLine.js +6 -5
- package/es/line/models/wall.js +4 -5
- package/es/line/shaders/dash/arc_dash_frag.glsl +0 -4
- package/es/line/shaders/dash/arc_dash_vert.glsl +3 -8
- package/es/line/shaders/dash/line_dash_frag.glsl +0 -1
- package/es/line/shaders/flow/flow_line_vert.glsl +36 -6
- package/es/line/shaders/line_arc_3d_frag.glsl +2 -4
- package/es/line/shaders/line_arc_3d_vert.glsl +2 -1
- package/es/line/shaders/line_arc_frag.glsl +1 -4
- package/es/line/shaders/line_arc_great_circle_frag.glsl +4 -5
- package/es/line/shaders/line_arc_great_circle_vert.glsl +1 -2
- package/es/line/shaders/line_arc_vert.glsl +3 -5
- package/es/line/shaders/line_frag.glsl +12 -12
- package/es/line/shaders/line_vert.glsl +2 -0
- package/es/line/shaders/linear/arc_linear_vert.glsl +3 -5
- package/es/line/shaders/linear/line_linear_frag.glsl +0 -1
- package/es/line/shaders/linearLine/line_linear_vert.glsl +1 -2
- package/es/line/shaders/simple/simpleline_linear_frag.glsl +2 -2
- package/es/line/shaders/simple/simpleline_vert.glsl +1 -2
- package/es/plugins/DataMappingPlugin.js +5 -23
- package/es/polygon/models/ocean.js +1 -2
- package/es/polygon/models/water.js +1 -2
- package/es/tile/tile/Tile.d.ts +0 -1
- package/lib/core/BaseLayer.js +19 -38
- package/lib/core/BaseModel.js +4 -19
- package/lib/core/CommonStyleAttribute.js +20 -0
- package/lib/core/constant.js +27 -0
- package/lib/core/line_trangluation.js +99 -0
- package/lib/core/shape/arrow.js +174 -0
- package/lib/core/triangulation.js +6 -35
- package/lib/geometry/models/plane.js +1 -2
- package/lib/geometry/models/sprite.js +1 -2
- package/lib/line/index.js +3 -2
- package/lib/line/models/arc.js +13 -14
- package/lib/line/models/arc_3d.js +5 -3
- package/lib/line/models/earthArc_3d.js +5 -3
- package/lib/line/models/flow.js +4 -5
- package/lib/line/models/great_circle.js +6 -7
- package/lib/line/models/line.js +9 -24
- package/lib/line/models/linearline.js +5 -4
- package/lib/line/models/simpleLine.js +6 -5
- package/lib/line/models/wall.js +4 -5
- package/lib/line/shaders/dash/arc_dash_frag.glsl +0 -4
- package/lib/line/shaders/dash/arc_dash_vert.glsl +3 -8
- package/lib/line/shaders/dash/line_dash_frag.glsl +0 -1
- package/lib/line/shaders/flow/flow_line_vert.glsl +36 -6
- package/lib/line/shaders/line_arc_3d_frag.glsl +2 -4
- package/lib/line/shaders/line_arc_3d_vert.glsl +2 -1
- package/lib/line/shaders/line_arc_frag.glsl +1 -4
- package/lib/line/shaders/line_arc_great_circle_frag.glsl +4 -5
- package/lib/line/shaders/line_arc_great_circle_vert.glsl +1 -2
- package/lib/line/shaders/line_arc_vert.glsl +3 -5
- package/lib/line/shaders/line_frag.glsl +12 -12
- package/lib/line/shaders/line_vert.glsl +2 -0
- package/lib/line/shaders/linear/arc_linear_vert.glsl +3 -5
- package/lib/line/shaders/linear/line_linear_frag.glsl +0 -1
- package/lib/line/shaders/linearLine/line_linear_vert.glsl +1 -2
- package/lib/line/shaders/simple/simpleline_linear_frag.glsl +2 -2
- package/lib/line/shaders/simple/simpleline_vert.glsl +1 -2
- package/lib/plugins/DataMappingPlugin.js +5 -23
- package/lib/polygon/models/ocean.js +1 -2
- package/lib/polygon/models/water.js +1 -2
- package/package.json +7 -7
- package/es/utils/layerData.d.ts +0 -2
- package/es/utils/layerData.js +0 -159
- package/lib/utils/layerData.js +0 -166
package/lib/utils/layerData.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.calculateData = calculateData;
|
|
8
|
-
var _l7Maps = require("@antv/l7-maps");
|
|
9
|
-
var _l7Source = _interopRequireDefault(require("@antv/l7-source"));
|
|
10
|
-
var _l7Utils = require("@antv/l7-utils");
|
|
11
|
-
var cloneDeep = _l7Utils.lodashUtil.cloneDeep;
|
|
12
|
-
function getArrowPoints(p1, p2) {
|
|
13
|
-
var dir = [p2[0] - p1[0], p2[1] - p1[1]];
|
|
14
|
-
var normalizeDir = (0, _l7Utils.normalize)(dir);
|
|
15
|
-
var arrowPoint = [p1[0] + normalizeDir[0] * 0.0001, p1[1] + normalizeDir[1] * 0.0001];
|
|
16
|
-
return arrowPoint;
|
|
17
|
-
}
|
|
18
|
-
function adjustData2Amap2Coordinates(mappedData, mapService, layer) {
|
|
19
|
-
// 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移
|
|
20
|
-
if (mappedData.length > 0 && mapService.version === _l7Maps.Version['GAODE2.x']) {
|
|
21
|
-
var layerCenter = layer.coordCenter;
|
|
22
|
-
if (typeof mappedData[0].coordinates[0] === 'number') {
|
|
23
|
-
// 单个的点数据
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
mappedData
|
|
26
|
-
// 避免经纬度被重复计算导致坐标位置偏移
|
|
27
|
-
.filter(function (d) {
|
|
28
|
-
return !d.originCoordinates;
|
|
29
|
-
}).map(function (d) {
|
|
30
|
-
d.version = _l7Maps.Version['GAODE2.x'];
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
// d.coordinates = mapService.lngLatToCoord(d.coordinates);
|
|
35
|
-
d.coordinates = mapService.coordToAMap2RelativeCoordinates(d.coordinates, layerCenter);
|
|
36
|
-
});
|
|
37
|
-
} else {
|
|
38
|
-
// 连续的线、面数据
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
mappedData
|
|
41
|
-
// 避免经纬度被重复计算导致坐标位置偏移
|
|
42
|
-
.filter(function (d) {
|
|
43
|
-
return !d.originCoordinates;
|
|
44
|
-
}).map(function (d) {
|
|
45
|
-
d.version = _l7Maps.Version['GAODE2.x'];
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
// d.coordinates = mapService.lngLatToCoords(d.coordinates);
|
|
50
|
-
d.coordinates = mapService.coordToAMap2RelativeCoordinates(d.coordinates, layerCenter);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function adjustData2SimpleCoordinates(mappedData, mapService) {
|
|
56
|
-
if (mappedData.length > 0 && mapService.version === _l7Maps.Version.SIMPLE) {
|
|
57
|
-
mappedData.map(function (d) {
|
|
58
|
-
if (!d.simpleCoordinate) {
|
|
59
|
-
d.coordinates = unProjectCoordinates(d.coordinates, mapService);
|
|
60
|
-
d.simpleCoordinate = true;
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function unProjectCoordinates(coordinates, mapService) {
|
|
66
|
-
if (typeof coordinates[0] === 'number') {
|
|
67
|
-
return mapService.simpleMapCoord.unproject(coordinates);
|
|
68
|
-
}
|
|
69
|
-
if (coordinates[0] && coordinates[0][0] instanceof Array) {
|
|
70
|
-
// @ts-ignore
|
|
71
|
-
var coords = [];
|
|
72
|
-
coordinates.map(function (coord) {
|
|
73
|
-
// @ts-ignore
|
|
74
|
-
var c1 = [];
|
|
75
|
-
coord.map(function (co) {
|
|
76
|
-
c1.push(mapService.simpleMapCoord.unproject(co));
|
|
77
|
-
});
|
|
78
|
-
// @ts-ignore
|
|
79
|
-
coords.push(c1);
|
|
80
|
-
});
|
|
81
|
-
// @ts-ignore
|
|
82
|
-
return coords;
|
|
83
|
-
} else {
|
|
84
|
-
// @ts-ignore
|
|
85
|
-
var _coords = [];
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
coordinates.map(function (coord) {
|
|
88
|
-
_coords.push(mapService.simpleMapCoord.unproject(coord));
|
|
89
|
-
});
|
|
90
|
-
// @ts-ignore
|
|
91
|
-
return _coords;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function applyAttributeMapping(attribute, record) {
|
|
95
|
-
var _attribute$scale;
|
|
96
|
-
if (!attribute.scale) {
|
|
97
|
-
return [];
|
|
98
|
-
}
|
|
99
|
-
var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
|
|
100
|
-
var params = [];
|
|
101
|
-
scalers.forEach(function (_ref) {
|
|
102
|
-
var _attribute$scale2;
|
|
103
|
-
var field = _ref.field;
|
|
104
|
-
if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
|
|
105
|
-
// TODO:多字段,常量
|
|
106
|
-
params.push(record[field]);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
var mappingResult = attribute.mapping ? attribute.mapping(params) : [];
|
|
110
|
-
return mappingResult;
|
|
111
|
-
}
|
|
112
|
-
function mapping(attributes, data, fontService, mapService, layer) {
|
|
113
|
-
var _ref2 = layer === null || layer === void 0 ? void 0 : layer.getLayerConfig(),
|
|
114
|
-
_ref2$arrow = _ref2.arrow,
|
|
115
|
-
arrow = _ref2$arrow === void 0 ? {
|
|
116
|
-
enable: false
|
|
117
|
-
} : _ref2$arrow;
|
|
118
|
-
var mappedData = data.map(function (record) {
|
|
119
|
-
var encodeRecord = {
|
|
120
|
-
id: record._id,
|
|
121
|
-
coordinates: record.coordinates
|
|
122
|
-
};
|
|
123
|
-
attributes.filter(function (attribute) {
|
|
124
|
-
return attribute.scale !== undefined;
|
|
125
|
-
}).forEach(function (attribute) {
|
|
126
|
-
var values = applyAttributeMapping(attribute, record);
|
|
127
|
-
attribute.needRemapping = false;
|
|
128
|
-
|
|
129
|
-
// TODO: 支持每个属性配置 postprocess
|
|
130
|
-
if (attribute.name === 'color') {
|
|
131
|
-
values = values.map(function (c) {
|
|
132
|
-
return (0, _l7Utils.rgb2arr)(c);
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
// @ts-ignore
|
|
136
|
-
encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values;
|
|
137
|
-
|
|
138
|
-
// 增加对 layer/text/iconfont unicode 映射的解析
|
|
139
|
-
if (attribute.name === 'shape') {
|
|
140
|
-
encodeRecord.shape = fontService.getIconFontKey(encodeRecord[attribute.name]);
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
if (encodeRecord.shape === 'line' && arrow.enable) {
|
|
144
|
-
// 只有在线图层且支持配置箭头的时候进行插入顶点的处理
|
|
145
|
-
var coords = encodeRecord.coordinates;
|
|
146
|
-
var arrowPoint = getArrowPoints(coords[0], coords[1]);
|
|
147
|
-
encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
|
|
148
|
-
}
|
|
149
|
-
return encodeRecord;
|
|
150
|
-
});
|
|
151
|
-
// 调整数据兼容 Amap2.0
|
|
152
|
-
adjustData2Amap2Coordinates(mappedData, mapService, layer);
|
|
153
|
-
|
|
154
|
-
// 调整数据兼容 SimpleCoordinates
|
|
155
|
-
adjustData2SimpleCoordinates(mappedData, mapService);
|
|
156
|
-
return mappedData;
|
|
157
|
-
}
|
|
158
|
-
function calculateData(layer, fontService, mapService, styleAttributeService, data, options) {
|
|
159
|
-
var source = new _l7Source.default(data, options);
|
|
160
|
-
var attributes = styleAttributeService.getLayerStyleAttributes() || [];
|
|
161
|
-
var dataArray = source.data.dataArray;
|
|
162
|
-
var filterData = dataArray;
|
|
163
|
-
var mappedEncodeData = mapping(attributes, filterData, fontService, mapService, layer);
|
|
164
|
-
source.destroy();
|
|
165
|
-
return mappedEncodeData;
|
|
166
|
-
}
|