@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.
Files changed (89) hide show
  1. package/es/core/BaseLayer.d.ts +0 -2
  2. package/es/core/BaseLayer.js +19 -38
  3. package/es/core/BaseModel.js +4 -19
  4. package/es/core/CommonStyleAttribute.js +20 -0
  5. package/es/core/constant.d.ts +6 -0
  6. package/es/core/constant.js +19 -0
  7. package/es/core/interface.d.ts +15 -9
  8. package/es/core/line_trangluation.d.ts +19 -0
  9. package/es/core/line_trangluation.js +91 -0
  10. package/es/core/shape/arrow.d.ts +25 -0
  11. package/es/core/shape/arrow.js +160 -0
  12. package/es/core/triangulation.d.ts +2 -8
  13. package/es/core/triangulation.js +6 -34
  14. package/es/geometry/models/plane.js +1 -2
  15. package/es/geometry/models/sprite.js +1 -2
  16. package/es/line/index.js +3 -2
  17. package/es/line/models/arc.js +13 -14
  18. package/es/line/models/arc_3d.js +5 -3
  19. package/es/line/models/earthArc_3d.js +5 -3
  20. package/es/line/models/flow.js +4 -5
  21. package/es/line/models/great_circle.js +6 -7
  22. package/es/line/models/line.js +9 -24
  23. package/es/line/models/linearline.js +5 -4
  24. package/es/line/models/simpleLine.js +6 -5
  25. package/es/line/models/wall.js +4 -5
  26. package/es/line/shaders/dash/arc_dash_frag.glsl +0 -4
  27. package/es/line/shaders/dash/arc_dash_vert.glsl +3 -8
  28. package/es/line/shaders/dash/line_dash_frag.glsl +0 -1
  29. package/es/line/shaders/flow/flow_line_vert.glsl +36 -6
  30. package/es/line/shaders/line_arc_3d_frag.glsl +2 -4
  31. package/es/line/shaders/line_arc_3d_vert.glsl +2 -1
  32. package/es/line/shaders/line_arc_frag.glsl +1 -4
  33. package/es/line/shaders/line_arc_great_circle_frag.glsl +4 -5
  34. package/es/line/shaders/line_arc_great_circle_vert.glsl +1 -2
  35. package/es/line/shaders/line_arc_vert.glsl +3 -5
  36. package/es/line/shaders/line_frag.glsl +12 -12
  37. package/es/line/shaders/line_vert.glsl +2 -0
  38. package/es/line/shaders/linear/arc_linear_vert.glsl +3 -5
  39. package/es/line/shaders/linear/line_linear_frag.glsl +0 -1
  40. package/es/line/shaders/linearLine/line_linear_vert.glsl +1 -2
  41. package/es/line/shaders/simple/simpleline_linear_frag.glsl +2 -2
  42. package/es/line/shaders/simple/simpleline_vert.glsl +1 -2
  43. package/es/plugins/DataMappingPlugin.js +5 -23
  44. package/es/polygon/models/ocean.js +1 -2
  45. package/es/polygon/models/water.js +1 -2
  46. package/es/tile/tile/Tile.d.ts +0 -1
  47. package/lib/core/BaseLayer.js +19 -38
  48. package/lib/core/BaseModel.js +4 -19
  49. package/lib/core/CommonStyleAttribute.js +20 -0
  50. package/lib/core/constant.js +27 -0
  51. package/lib/core/line_trangluation.js +99 -0
  52. package/lib/core/shape/arrow.js +174 -0
  53. package/lib/core/triangulation.js +6 -35
  54. package/lib/geometry/models/plane.js +1 -2
  55. package/lib/geometry/models/sprite.js +1 -2
  56. package/lib/line/index.js +3 -2
  57. package/lib/line/models/arc.js +13 -14
  58. package/lib/line/models/arc_3d.js +5 -3
  59. package/lib/line/models/earthArc_3d.js +5 -3
  60. package/lib/line/models/flow.js +4 -5
  61. package/lib/line/models/great_circle.js +6 -7
  62. package/lib/line/models/line.js +9 -24
  63. package/lib/line/models/linearline.js +5 -4
  64. package/lib/line/models/simpleLine.js +6 -5
  65. package/lib/line/models/wall.js +4 -5
  66. package/lib/line/shaders/dash/arc_dash_frag.glsl +0 -4
  67. package/lib/line/shaders/dash/arc_dash_vert.glsl +3 -8
  68. package/lib/line/shaders/dash/line_dash_frag.glsl +0 -1
  69. package/lib/line/shaders/flow/flow_line_vert.glsl +36 -6
  70. package/lib/line/shaders/line_arc_3d_frag.glsl +2 -4
  71. package/lib/line/shaders/line_arc_3d_vert.glsl +2 -1
  72. package/lib/line/shaders/line_arc_frag.glsl +1 -4
  73. package/lib/line/shaders/line_arc_great_circle_frag.glsl +4 -5
  74. package/lib/line/shaders/line_arc_great_circle_vert.glsl +1 -2
  75. package/lib/line/shaders/line_arc_vert.glsl +3 -5
  76. package/lib/line/shaders/line_frag.glsl +12 -12
  77. package/lib/line/shaders/line_vert.glsl +2 -0
  78. package/lib/line/shaders/linear/arc_linear_vert.glsl +3 -5
  79. package/lib/line/shaders/linear/line_linear_frag.glsl +0 -1
  80. package/lib/line/shaders/linearLine/line_linear_vert.glsl +1 -2
  81. package/lib/line/shaders/simple/simpleline_linear_frag.glsl +2 -2
  82. package/lib/line/shaders/simple/simpleline_vert.glsl +1 -2
  83. package/lib/plugins/DataMappingPlugin.js +5 -23
  84. package/lib/polygon/models/ocean.js +1 -2
  85. package/lib/polygon/models/water.js +1 -2
  86. package/package.json +7 -7
  87. package/es/utils/layerData.d.ts +0 -2
  88. package/es/utils/layerData.js +0 -159
  89. package/lib/utils/layerData.js +0 -166
@@ -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
- }