@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,8 +1,6 @@
1
1
 
2
2
  #define Animate 0.0
3
3
  #define LineTexture 1.0
4
-
5
- uniform float u_opacity;
6
4
  uniform float u_textureBlend;
7
5
  uniform float u_blur : 0.9;
8
6
  uniform float u_line_type: 0.0;
@@ -28,7 +26,6 @@ void main() {
28
26
  float animateSpeed = 0.0; // 运动速度
29
27
  gl_FragColor = v_color;
30
28
 
31
- gl_FragColor.a *= u_opacity;
32
29
 
33
30
  if(u_animate.x == Animate && u_line_texture != LineTexture) {
34
31
  animateSpeed = u_time / u_animate.y;
@@ -71,7 +68,7 @@ void main() {
71
68
  pattern.a = 0.0;
72
69
  gl_FragColor = filterColor(gl_FragColor + pattern);
73
70
  } else { // replace
74
- pattern.a *= u_opacity;
71
+ pattern.a *= v_color.a;
75
72
  if(gl_FragColor.a <= 0.0) {
76
73
  pattern.a = 0.0;
77
74
  }
@@ -3,7 +3,6 @@
3
3
  #define Animate 0.0
4
4
  #define LineTexture 1.0
5
5
 
6
- uniform float u_opacity;
7
6
  uniform float u_textureBlend;
8
7
  uniform float u_blur : 0.9;
9
8
  uniform float u_line_type: 0.0;
@@ -32,20 +31,20 @@ varying vec4 v_line_data;
32
31
  #pragma include "projection"
33
32
 
34
33
  void main() {
35
- float opacity = u_opacity;
34
+
36
35
  float animateSpeed = 0.0;
37
36
  float d_segmentIndex = v_line_data.g;
38
37
 
39
38
  // 设置弧线的底色
40
39
  if(u_linearColor == 1.0) { // 使用渐变颜色
41
40
  gl_FragColor = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);
41
+ gl_FragColor.a *= v_color.a;
42
42
  } else { // 使用 color 方法传入的颜色
43
43
  gl_FragColor = v_color;
44
44
  }
45
45
 
46
46
  // float blur = 1.- smoothstep(u_blur, 1., length(v_normal.xy));
47
47
  // float blur = smoothstep(1.0, u_blur, length(v_normal.xy));
48
- gl_FragColor.a *= opacity;
49
48
  if(u_line_type == LineTypeDash) {
50
49
  float dashLength = mod(v_distance_ratio, v_dash_array.x + v_dash_array.y + v_dash_array.z + v_dash_array.w);
51
50
  if(dashLength < v_dash_array.x || (dashLength > (v_dash_array.x + v_dash_array.y) && dashLength < v_dash_array.x + v_dash_array.y + v_dash_array.z)) {
@@ -73,7 +72,7 @@ void main() {
73
72
  float u = fract(arcRadio * count - animateSpeed * count);
74
73
  // float u = fract(arcRadio * count - animateSpeed);
75
74
  if(u_animate.x == Animate) {
76
- u = gl_FragColor.a/opacity;
75
+ u = gl_FragColor.a/v_color.a;
77
76
  }
78
77
 
79
78
  float v = v_line_data.a; // 线图层贴图部分的 v 坐标值
@@ -86,7 +85,7 @@ void main() {
86
85
  pattern.a = 0.0;
87
86
  gl_FragColor = filterColor(gl_FragColor + pattern);
88
87
  } else { // replace
89
- pattern.a *= opacity;
88
+ pattern.a *= v_color.a;
90
89
  if(gl_FragColor.a <= 0.0) {
91
90
  pattern.a = 0.0;
92
91
  }
@@ -119,9 +119,8 @@ vec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {
119
119
  }
120
120
 
121
121
  void main() {
122
-
123
-
124
122
  v_color = a_Color;
123
+ v_color.a = v_color.a * opacity;
125
124
  vec2 source = radians(a_Instance.rg);
126
125
  vec2 target = radians(a_Instance.ba);
127
126
  float angularDist = getAngularDist(source, target);
@@ -13,7 +13,6 @@ varying vec4 v_color;
13
13
 
14
14
  uniform float u_lineDir: 1.0;
15
15
 
16
- uniform float u_thetaOffset: 0.314;
17
16
  uniform float u_icon_step: 100;
18
17
  uniform float u_line_texture: 0.0;
19
18
  attribute vec2 a_iconMapUV;
@@ -21,8 +20,6 @@ varying vec2 v_iconMapUV;
21
20
  varying vec4 v_lineData;
22
21
  varying vec2 v_distance_ratio;
23
22
 
24
- uniform float u_opacity: 1.0;
25
-
26
23
 
27
24
  #pragma include "projection"
28
25
  #pragma include "project"
@@ -80,6 +77,7 @@ vec2 getNormal(vec2 line_clipspace, float offset_direction) {
80
77
 
81
78
  void main() {
82
79
  v_color = a_Color;
80
+ v_color.a = v_color.a * opacity;
83
81
 
84
82
  vec2 source = a_Instance.rg; // 起始点
85
83
  vec2 target = a_Instance.ba; // 终点
@@ -99,8 +97,8 @@ void main() {
99
97
 
100
98
  v_lineData.b = d_distance_ratio;
101
99
 
102
- vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, u_thetaOffset), 0.0, 1.0));
103
- vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, u_thetaOffset), 0.0, 1.0));
100
+ vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, thetaOffset), 0.0, 1.0));
101
+ vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, thetaOffset), 0.0, 1.0));
104
102
 
105
103
 
106
104
  vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));
@@ -3,11 +3,11 @@
3
3
  #define LineTexture 1.0
4
4
  uniform float u_textureBlend;
5
5
 
6
- uniform float u_borderWidth: 0.0;
6
+ uniform float u_strokeWidth: 0.0;
7
7
 
8
8
  uniform vec3 u_blur;
9
- uniform vec4 u_borderColor;
10
9
  varying vec4 v_color;
10
+ varying vec4 v_stroke;
11
11
 
12
12
  // line texture
13
13
  uniform float u_line_texture;
@@ -59,20 +59,20 @@ void main() {
59
59
  }
60
60
 
61
61
  float v = v_texture_data.a;
62
- float borderWidth = min(0.5, u_borderWidth);
62
+ float strokeWidth = min(0.5, u_strokeWidth);
63
63
  // 绘制 border
64
- if(borderWidth > 0.01) {
65
- float borderOuterWidth = borderWidth / 2.0;
64
+ if(strokeWidth > 0.01) {
65
+ float borderOuterWidth = strokeWidth / 2.0;
66
66
 
67
67
 
68
- if(v >= 1.0 - borderWidth || v <= borderWidth) {
69
- if(v > borderWidth) { // 外侧
70
- float linear = smoothstep(0.0, 1.0, (v - (1.0 - borderWidth))/borderWidth);
68
+ if(v >= 1.0 - strokeWidth || v <= strokeWidth) {
69
+ if(v > strokeWidth) { // 外侧
70
+ float linear = smoothstep(0.0, 1.0, (v - (1.0 - strokeWidth))/strokeWidth);
71
71
  // float linear = step(0.0, (v - (1.0 - borderWidth))/borderWidth);
72
- gl_FragColor.rgb = mix(gl_FragColor.rgb, u_borderColor.rgb, linear);
73
- } else if(v <= borderWidth) {
74
- float linear = smoothstep(0.0, 1.0, v/borderWidth);
75
- gl_FragColor.rgb = mix(u_borderColor.rgb, gl_FragColor.rgb, linear);
72
+ gl_FragColor.rgb = mix(gl_FragColor.rgb, v_stroke.rgb, linear);
73
+ } else if(v <= strokeWidth) {
74
+ float linear = smoothstep(0.0, 1.0, v/strokeWidth);
75
+ gl_FragColor.rgb = mix(v_stroke.rgb, gl_FragColor.rgb, linear);
76
76
  }
77
77
  }
78
78
 
@@ -26,6 +26,7 @@ uniform float u_raisingHeight: 0.0;
26
26
  #pragma include "picking"
27
27
 
28
28
  varying vec4 v_color;
29
+ varying vec4 v_stroke;
29
30
 
30
31
  // texV 线图层 - 贴图部分的 v 坐标(线的宽度方向)
31
32
  varying vec2 v_iconMapUV;
@@ -95,6 +96,7 @@ void main() {
95
96
 
96
97
  v_color = a_Color;
97
98
  v_color.a *= opacity;
99
+ v_stroke = stroke;
98
100
 
99
101
  vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);
100
102
 
@@ -10,9 +10,7 @@ varying vec4 v_color;
10
10
  varying float v_segmentIndex;
11
11
 
12
12
  uniform float u_lineDir: 1.0;
13
- uniform float u_opacity: 1.0;
14
13
 
15
- uniform float u_thetaOffset: 0.314;
16
14
  uniform vec4 u_sourceColor;
17
15
  uniform vec4 u_targetColor;
18
16
 
@@ -81,8 +79,8 @@ void main() {
81
79
  float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));
82
80
  float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);
83
81
  float d_distance_ratio;
84
- vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, u_thetaOffset), 0.0, 1.0));
85
- vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, u_thetaOffset), 0.0, 1.0));
82
+ vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, thetaOffset), 0.0, 1.0));
83
+ vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, thetaOffset), 0.0, 1.0));
86
84
  // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);
87
85
  //unProjCustomCoord
88
86
 
@@ -92,7 +90,7 @@ void main() {
92
90
  float d_segmentIndex = a_Position.x + 1.0; // 当前顶点在弧线中所处的分段位置
93
91
 
94
92
  v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);
95
- v_color.a *= u_opacity;
93
+ v_color.a *= opacity;
96
94
 
97
95
  gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));
98
96
 
@@ -4,7 +4,6 @@ uniform float u_linearDir: 1.0;
4
4
  uniform float u_linearColor: 0;
5
5
  uniform vec4 u_sourceColor;
6
6
  uniform vec4 u_targetColor;
7
- uniform float u_opacity: 1.0;
8
7
 
9
8
  #pragma include "picking"
10
9
 
@@ -14,7 +14,6 @@ uniform mat4 u_ModelMatrix;
14
14
  uniform float u_heightfixed: 0.0;
15
15
  uniform float u_vertexScale: 1.0;
16
16
  uniform float u_raisingHeight: 0.0;
17
- uniform float u_opacity : 1.0;
18
17
  uniform sampler2D u_texture;
19
18
  uniform float u_linearDir: 1.0;
20
19
  varying vec4 v_Color;
@@ -46,7 +45,7 @@ void main() {
46
45
 
47
46
  v_Color = texture2D(u_texture, vec2(linearRadio, 0.5));
48
47
 
49
- v_Color.a *= u_opacity; // 全局透明度
48
+ v_Color.a *= opacity; // 全局透明度
50
49
 
51
50
 
52
51
 
@@ -1,8 +1,8 @@
1
1
  uniform vec4 u_sourceColor;
2
2
  uniform vec4 u_targetColor;
3
3
  varying float v_distanceScale;
4
- uniform float u_opacity: 1.0;
4
+ varying vec4 v_color;
5
5
  void main() {
6
6
  gl_FragColor = mix(u_sourceColor, u_targetColor, v_distanceScale);
7
- gl_FragColor.a *= u_opacity; // 全局透明度
7
+ gl_FragColor.a *= v_color.a; // 全局透明度
8
8
  }
@@ -8,7 +8,6 @@ attribute float a_Distance;
8
8
  uniform mat4 u_ModelMatrix;
9
9
 
10
10
 
11
- uniform float u_opacity: 1.0;
12
11
  uniform float u_vertexScale: 1.0;
13
12
  uniform vec4 u_sourceColor;
14
13
  uniform vec4 u_targetColor;
@@ -24,7 +23,7 @@ void main() {
24
23
 
25
24
  v_color = a_Color;
26
25
  v_distanceScale = a_Distance / a_Total_Distance;
27
- v_color = vec4(a_Color.xyz, a_Color.w * u_opacity);
26
+ v_color.a = v_color.a * opacity;
28
27
  vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
29
28
 
30
29
  float h = float(a_Position.z) * u_vertexScale; // 线顶点的高度 - 兼容不存在第三个数值的情况
@@ -15,7 +15,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
15
15
  var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime/helpers/applyDecoratedDescriptor"));
16
16
  var _initializerWarningHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/initializerWarningHelper"));
17
17
  var _l7Core = require("@antv/l7-core");
18
- var _l7Maps = require("@antv/l7-maps");
19
18
  var _l7Utils = require("@antv/l7-utils");
20
19
  var _inversify = require("inversify");
21
20
  require("reflect-metadata");
@@ -148,11 +147,6 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
148
147
  key: "mapping",
149
148
  value: function mapping(layer, attributes, data, predata) {
150
149
  var _this3 = this;
151
- var _ref5 = layer.getLayerConfig(),
152
- _ref5$arrow = _ref5.arrow,
153
- arrow = _ref5$arrow === void 0 ? {
154
- enable: false
155
- } : _ref5$arrow;
156
150
  var usedAttributes = attributes.filter(function (attribute) {
157
151
  return attribute.scale !== undefined;
158
152
  }).filter(function (attribute) {
@@ -180,18 +174,6 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
180
174
  encodeRecord.shape = _this3.fontService.getIconFontKey(encodeRecord[attribute.name]);
181
175
  }
182
176
  });
183
- if (arrow.enable && encodeRecord.shape === 'line') {
184
- // 只有在线图层且支持配置箭头的时候进行插入顶点的处理
185
- var coords = encodeRecord.coordinates;
186
- // @ts-ignore
187
- if (layer.arrowInsertCount < layer.encodeDataLength) {
188
- // Tip: arrowInsert 的判断用于确保每一条线数据 arrow 的属性点只会被植入一次
189
- var arrowPoint = _this3.getArrowPoints(coords[0], coords[1]);
190
- encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
191
- // @ts-ignore
192
- layer.arrowInsertCount++;
193
- }
194
- }
195
177
  return encodeRecord;
196
178
  });
197
179
  attributes.forEach(function (attribute) {
@@ -209,7 +191,7 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
209
191
  value: function adjustData2Amap2Coordinates(mappedData, layer) {
210
192
  var _this4 = this;
211
193
  // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移
212
- if (mappedData.length > 0 && this.mapService.version === _l7Maps.Version['GAODE2.x']) {
194
+ if (mappedData.length > 0 && this.mapService.version === 'GAODE2.x') {
213
195
  var layerCenter = layer.coordCenter || layer.getSource().center;
214
196
  // 单个的点数据
215
197
  // @ts-ignore
@@ -218,7 +200,7 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
218
200
  .filter(function (d) {
219
201
  return !d.originCoordinates;
220
202
  }).map(function (d) {
221
- d.version = _l7Maps.Version['GAODE2.x'];
203
+ d.version = 'GAODE2.x';
222
204
  // @ts-ignore
223
205
  d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
224
206
  // @ts-ignore
@@ -231,7 +213,7 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
231
213
  key: "adjustData2SimpleCoordinates",
232
214
  value: function adjustData2SimpleCoordinates(mappedData) {
233
215
  var _this5 = this;
234
- if (mappedData.length > 0 && this.mapService.version === _l7Maps.Version.SIMPLE) {
216
+ if (mappedData.length > 0 && this.mapService.version === 'SIMPLE') {
235
217
  mappedData.map(function (d) {
236
218
  if (!d.simpleCoordinate) {
237
219
  d.coordinates = _this5.unProjectCoordinates(d.coordinates);
@@ -281,9 +263,9 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
281
263
  }
282
264
  var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
283
265
  var params = [];
284
- scalers.forEach(function (_ref6) {
266
+ scalers.forEach(function (_ref5) {
285
267
  var _attribute$scale2;
286
- var field = _ref6.field;
268
+ var field = _ref5.field;
287
269
  if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
288
270
  // TODO:多字段,常量
289
271
  params.push(record[field]);
@@ -14,7 +14,6 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
14
14
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
15
15
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
16
16
  var _l7Core = require("@antv/l7-core");
17
- var _l7Maps = require("@antv/l7-maps");
18
17
  var _l7Utils = require("@antv/l7-utils");
19
18
  var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
20
19
  var _triangulation = require("../../core/triangulation");
@@ -143,7 +142,7 @@ var OceanModel = /*#__PURE__*/function (_BaseModel) {
143
142
  },
144
143
  size: 2,
145
144
  update: function update(feature, featureIdx, vertex, attributeIdx) {
146
- var v = feature.version === _l7Maps.Version['GAODE2.x'] ? feature.originCoordinates[0][attributeIdx] : vertex;
145
+ var v = feature.version === 'GAODE2.x' ? feature.originCoordinates[0][attributeIdx] : vertex;
147
146
  var _v = (0, _slicedToArray2.default)(v, 2),
148
147
  lng = _v[0],
149
148
  lat = _v[1];
@@ -14,7 +14,6 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
14
14
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
15
15
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
16
16
  var _l7Core = require("@antv/l7-core");
17
- var _l7Maps = require("@antv/l7-maps");
18
17
  var _l7Utils = require("@antv/l7-utils");
19
18
  var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
20
19
  var _triangulation = require("../../core/triangulation");
@@ -136,7 +135,7 @@ var WaterModel = /*#__PURE__*/function (_BaseModel) {
136
135
  },
137
136
  size: 2,
138
137
  update: function update(feature, featureIdx, vertex, attributeIdx) {
139
- var v = feature.version === _l7Maps.Version['GAODE2.x'] ? feature.originCoordinates[0][attributeIdx] : vertex;
138
+ var v = feature.version === 'GAODE2.x' ? feature.originCoordinates[0][attributeIdx] : vertex;
140
139
  var _v = (0, _slicedToArray2.default)(v, 2),
141
140
  lng = _v[0],
142
141
  lat = _v[1];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-layers",
3
- "version": "2.19.9",
3
+ "version": "2.19.11",
4
4
  "description": "L7's collection of built-in layers",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -27,10 +27,10 @@
27
27
  "license": "ISC",
28
28
  "dependencies": {
29
29
  "@antv/async-hook": "^2.2.9",
30
- "@antv/l7-core": "2.19.9",
31
- "@antv/l7-maps": "2.19.9",
32
- "@antv/l7-source": "2.19.9",
33
- "@antv/l7-utils": "2.19.9",
30
+ "@antv/l7-core": "2.19.11",
31
+ "@antv/l7-maps": "2.19.11",
32
+ "@antv/l7-source": "2.19.11",
33
+ "@antv/l7-utils": "2.19.11",
34
34
  "@babel/runtime": "^7.7.7",
35
35
  "@mapbox/martini": "^0.2.0",
36
36
  "@turf/clone": "^6.5.0",
@@ -52,7 +52,7 @@
52
52
  "reflect-metadata": "^0.1.13"
53
53
  },
54
54
  "devDependencies": {
55
- "@antv/l7-test-utils": "2.19.9",
55
+ "@antv/l7-test-utils": "2.19.11",
56
56
  "@types/d3-array": "^2.0.0",
57
57
  "@types/d3-color": "^1.2.2",
58
58
  "@types/d3-interpolate": "1.1.6",
@@ -61,7 +61,7 @@
61
61
  "@types/gl-matrix": "^2.4.5",
62
62
  "@types/lodash": "^4.14.138"
63
63
  },
64
- "gitHead": "52744e944c7c136f2fcc4d369661040223100c0c",
64
+ "gitHead": "a16cafc9907fb3a118ee97df82832c88e114446d",
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  }
@@ -1,2 +0,0 @@
1
- import { IEncodeFeature, IFontService, ILayer, IMapService, ISourceCFG, IStyleAttributeService } from '@antv/l7-core';
2
- export declare function calculateData(layer: ILayer, fontService: IFontService, mapService: IMapService, styleAttributeService: IStyleAttributeService, data: any, options: ISourceCFG | undefined): IEncodeFeature[];
@@ -1,159 +0,0 @@
1
- import { Version } from '@antv/l7-maps';
2
- import Source from '@antv/l7-source';
3
- import { lodashUtil, normalize, rgb2arr } from '@antv/l7-utils';
4
- var cloneDeep = lodashUtil.cloneDeep;
5
- function getArrowPoints(p1, p2) {
6
- var dir = [p2[0] - p1[0], p2[1] - p1[1]];
7
- var normalizeDir = normalize(dir);
8
- var arrowPoint = [p1[0] + normalizeDir[0] * 0.0001, p1[1] + normalizeDir[1] * 0.0001];
9
- return arrowPoint;
10
- }
11
- function adjustData2Amap2Coordinates(mappedData, mapService, layer) {
12
- // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移
13
- if (mappedData.length > 0 && mapService.version === Version['GAODE2.x']) {
14
- var layerCenter = layer.coordCenter;
15
- if (typeof mappedData[0].coordinates[0] === 'number') {
16
- // 单个的点数据
17
- // @ts-ignore
18
- mappedData
19
- // 避免经纬度被重复计算导致坐标位置偏移
20
- .filter(function (d) {
21
- return !d.originCoordinates;
22
- }).map(function (d) {
23
- d.version = Version['GAODE2.x'];
24
- // @ts-ignore
25
- d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
26
- // @ts-ignore
27
- // d.coordinates = mapService.lngLatToCoord(d.coordinates);
28
- d.coordinates = mapService.coordToAMap2RelativeCoordinates(d.coordinates, layerCenter);
29
- });
30
- } else {
31
- // 连续的线、面数据
32
- // @ts-ignore
33
- mappedData
34
- // 避免经纬度被重复计算导致坐标位置偏移
35
- .filter(function (d) {
36
- return !d.originCoordinates;
37
- }).map(function (d) {
38
- d.version = Version['GAODE2.x'];
39
- // @ts-ignore
40
- d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
41
- // @ts-ignore
42
- // d.coordinates = mapService.lngLatToCoords(d.coordinates);
43
- d.coordinates = mapService.coordToAMap2RelativeCoordinates(d.coordinates, layerCenter);
44
- });
45
- }
46
- }
47
- }
48
- function adjustData2SimpleCoordinates(mappedData, mapService) {
49
- if (mappedData.length > 0 && mapService.version === Version.SIMPLE) {
50
- mappedData.map(function (d) {
51
- if (!d.simpleCoordinate) {
52
- d.coordinates = unProjectCoordinates(d.coordinates, mapService);
53
- d.simpleCoordinate = true;
54
- }
55
- });
56
- }
57
- }
58
- function unProjectCoordinates(coordinates, mapService) {
59
- if (typeof coordinates[0] === 'number') {
60
- return mapService.simpleMapCoord.unproject(coordinates);
61
- }
62
- if (coordinates[0] && coordinates[0][0] instanceof Array) {
63
- // @ts-ignore
64
- var coords = [];
65
- coordinates.map(function (coord) {
66
- // @ts-ignore
67
- var c1 = [];
68
- coord.map(function (co) {
69
- c1.push(mapService.simpleMapCoord.unproject(co));
70
- });
71
- // @ts-ignore
72
- coords.push(c1);
73
- });
74
- // @ts-ignore
75
- return coords;
76
- } else {
77
- // @ts-ignore
78
- var _coords = [];
79
- // @ts-ignore
80
- coordinates.map(function (coord) {
81
- _coords.push(mapService.simpleMapCoord.unproject(coord));
82
- });
83
- // @ts-ignore
84
- return _coords;
85
- }
86
- }
87
- function applyAttributeMapping(attribute, record) {
88
- var _attribute$scale;
89
- if (!attribute.scale) {
90
- return [];
91
- }
92
- var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
93
- var params = [];
94
- scalers.forEach(function (_ref) {
95
- var _attribute$scale2;
96
- var field = _ref.field;
97
- if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
98
- // TODO:多字段,常量
99
- params.push(record[field]);
100
- }
101
- });
102
- var mappingResult = attribute.mapping ? attribute.mapping(params) : [];
103
- return mappingResult;
104
- }
105
- function mapping(attributes, data, fontService, mapService, layer) {
106
- var _ref2 = layer === null || layer === void 0 ? void 0 : layer.getLayerConfig(),
107
- _ref2$arrow = _ref2.arrow,
108
- arrow = _ref2$arrow === void 0 ? {
109
- enable: false
110
- } : _ref2$arrow;
111
- var mappedData = data.map(function (record) {
112
- var encodeRecord = {
113
- id: record._id,
114
- coordinates: record.coordinates
115
- };
116
- attributes.filter(function (attribute) {
117
- return attribute.scale !== undefined;
118
- }).forEach(function (attribute) {
119
- var values = applyAttributeMapping(attribute, record);
120
- attribute.needRemapping = false;
121
-
122
- // TODO: 支持每个属性配置 postprocess
123
- if (attribute.name === 'color') {
124
- values = values.map(function (c) {
125
- return rgb2arr(c);
126
- });
127
- }
128
- // @ts-ignore
129
- encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values;
130
-
131
- // 增加对 layer/text/iconfont unicode 映射的解析
132
- if (attribute.name === 'shape') {
133
- encodeRecord.shape = fontService.getIconFontKey(encodeRecord[attribute.name]);
134
- }
135
- });
136
- if (encodeRecord.shape === 'line' && arrow.enable) {
137
- // 只有在线图层且支持配置箭头的时候进行插入顶点的处理
138
- var coords = encodeRecord.coordinates;
139
- var arrowPoint = getArrowPoints(coords[0], coords[1]);
140
- encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
141
- }
142
- return encodeRecord;
143
- });
144
- // 调整数据兼容 Amap2.0
145
- adjustData2Amap2Coordinates(mappedData, mapService, layer);
146
-
147
- // 调整数据兼容 SimpleCoordinates
148
- adjustData2SimpleCoordinates(mappedData, mapService);
149
- return mappedData;
150
- }
151
- export function calculateData(layer, fontService, mapService, styleAttributeService, data, options) {
152
- var source = new Source(data, options);
153
- var attributes = styleAttributeService.getLayerStyleAttributes() || [];
154
- var dataArray = source.data.dataArray;
155
- var filterData = dataArray;
156
- var mappedEncodeData = mapping(attributes, filterData, fontService, mapService, layer);
157
- source.destroy();
158
- return mappedEncodeData;
159
- }