@antv/l7-layers 2.19.9 → 2.19.10

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 (75) hide show
  1. package/es/core/BaseLayer.d.ts +0 -2
  2. package/es/core/BaseLayer.js +15 -34
  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 +2 -0
  8. package/es/geometry/models/plane.js +1 -2
  9. package/es/geometry/models/sprite.js +1 -2
  10. package/es/line/index.js +1 -1
  11. package/es/line/models/arc.js +10 -13
  12. package/es/line/models/arc_3d.js +2 -2
  13. package/es/line/models/earthArc_3d.js +2 -2
  14. package/es/line/models/great_circle.js +6 -7
  15. package/es/line/models/line.js +7 -10
  16. package/es/line/models/linearline.js +5 -4
  17. package/es/line/models/simpleLine.js +6 -5
  18. package/es/line/models/wall.js +4 -5
  19. package/es/line/shaders/dash/arc_dash_frag.glsl +0 -4
  20. package/es/line/shaders/dash/arc_dash_vert.glsl +1 -3
  21. package/es/line/shaders/dash/line_dash_frag.glsl +0 -1
  22. package/es/line/shaders/line_arc_3d_frag.glsl +2 -4
  23. package/es/line/shaders/line_arc_3d_vert.glsl +2 -1
  24. package/es/line/shaders/line_arc_frag.glsl +1 -4
  25. package/es/line/shaders/line_arc_great_circle_frag.glsl +4 -5
  26. package/es/line/shaders/line_arc_great_circle_vert.glsl +1 -2
  27. package/es/line/shaders/line_arc_vert.glsl +3 -5
  28. package/es/line/shaders/line_frag.glsl +12 -12
  29. package/es/line/shaders/line_vert.glsl +2 -0
  30. package/es/line/shaders/linear/arc_linear_vert.glsl +1 -2
  31. package/es/line/shaders/linear/line_linear_frag.glsl +0 -1
  32. package/es/line/shaders/linearLine/line_linear_vert.glsl +1 -2
  33. package/es/line/shaders/simple/simpleline_linear_frag.glsl +2 -2
  34. package/es/line/shaders/simple/simpleline_vert.glsl +1 -2
  35. package/es/plugins/DataMappingPlugin.js +3 -4
  36. package/es/polygon/models/ocean.js +1 -2
  37. package/es/polygon/models/water.js +1 -2
  38. package/lib/core/BaseLayer.js +15 -34
  39. package/lib/core/BaseModel.js +4 -19
  40. package/lib/core/CommonStyleAttribute.js +20 -0
  41. package/lib/core/constant.js +27 -0
  42. package/lib/geometry/models/plane.js +1 -2
  43. package/lib/geometry/models/sprite.js +1 -2
  44. package/lib/line/index.js +1 -1
  45. package/lib/line/models/arc.js +10 -13
  46. package/lib/line/models/arc_3d.js +2 -2
  47. package/lib/line/models/earthArc_3d.js +2 -2
  48. package/lib/line/models/great_circle.js +6 -7
  49. package/lib/line/models/line.js +7 -10
  50. package/lib/line/models/linearline.js +5 -4
  51. package/lib/line/models/simpleLine.js +6 -5
  52. package/lib/line/models/wall.js +4 -5
  53. package/lib/line/shaders/dash/arc_dash_frag.glsl +0 -4
  54. package/lib/line/shaders/dash/arc_dash_vert.glsl +1 -3
  55. package/lib/line/shaders/dash/line_dash_frag.glsl +0 -1
  56. package/lib/line/shaders/line_arc_3d_frag.glsl +2 -4
  57. package/lib/line/shaders/line_arc_3d_vert.glsl +2 -1
  58. package/lib/line/shaders/line_arc_frag.glsl +1 -4
  59. package/lib/line/shaders/line_arc_great_circle_frag.glsl +4 -5
  60. package/lib/line/shaders/line_arc_great_circle_vert.glsl +1 -2
  61. package/lib/line/shaders/line_arc_vert.glsl +3 -5
  62. package/lib/line/shaders/line_frag.glsl +12 -12
  63. package/lib/line/shaders/line_vert.glsl +2 -0
  64. package/lib/line/shaders/linear/arc_linear_vert.glsl +1 -2
  65. package/lib/line/shaders/linear/line_linear_frag.glsl +0 -1
  66. package/lib/line/shaders/linearLine/line_linear_vert.glsl +1 -2
  67. package/lib/line/shaders/simple/simpleline_linear_frag.glsl +2 -2
  68. package/lib/line/shaders/simple/simpleline_vert.glsl +1 -2
  69. package/lib/plugins/DataMappingPlugin.js +3 -4
  70. package/lib/polygon/models/ocean.js +1 -2
  71. package/lib/polygon/models/water.js +1 -2
  72. package/package.json +7 -7
  73. package/es/utils/layerData.d.ts +0 -2
  74. package/es/utils/layerData.js +0 -159
  75. package/lib/utils/layerData.js +0 -166
@@ -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,7 +10,6 @@ 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
14
  uniform float u_thetaOffset: 0.314;
16
15
  uniform vec4 u_sourceColor;
@@ -92,7 +91,7 @@ void main() {
92
91
  float d_segmentIndex = a_Position.x + 1.0; // 当前顶点在弧线中所处的分段位置
93
92
 
94
93
  v_color = mix(u_sourceColor, u_targetColor, d_segmentIndex/segmentNumber);
95
- v_color.a *= u_opacity;
94
+ v_color.a *= opacity;
96
95
 
97
96
  gl_Position = project_common_position_to_clipspace_v2(vec4(curr.xy + offset, 0, 1.0));
98
97
 
@@ -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");
@@ -209,7 +208,7 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
209
208
  value: function adjustData2Amap2Coordinates(mappedData, layer) {
210
209
  var _this4 = this;
211
210
  // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移
212
- if (mappedData.length > 0 && this.mapService.version === _l7Maps.Version['GAODE2.x']) {
211
+ if (mappedData.length > 0 && this.mapService.version === 'GAODE2.x') {
213
212
  var layerCenter = layer.coordCenter || layer.getSource().center;
214
213
  // 单个的点数据
215
214
  // @ts-ignore
@@ -218,7 +217,7 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
218
217
  .filter(function (d) {
219
218
  return !d.originCoordinates;
220
219
  }).map(function (d) {
221
- d.version = _l7Maps.Version['GAODE2.x'];
220
+ d.version = 'GAODE2.x';
222
221
  // @ts-ignore
223
222
  d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
224
223
  // @ts-ignore
@@ -231,7 +230,7 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
231
230
  key: "adjustData2SimpleCoordinates",
232
231
  value: function adjustData2SimpleCoordinates(mappedData) {
233
232
  var _this5 = this;
234
- if (mappedData.length > 0 && this.mapService.version === _l7Maps.Version.SIMPLE) {
233
+ if (mappedData.length > 0 && this.mapService.version === 'SIMPLE') {
235
234
  mappedData.map(function (d) {
236
235
  if (!d.simpleCoordinate) {
237
236
  d.coordinates = _this5.unProjectCoordinates(d.coordinates);
@@ -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.10",
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.10",
31
+ "@antv/l7-maps": "2.19.10",
32
+ "@antv/l7-source": "2.19.10",
33
+ "@antv/l7-utils": "2.19.10",
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.10",
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": "150d3dc74f975ad10d48868612b6f978e4bbce85",
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
- }
@@ -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
- }