@antv/l7-layers 2.19.10 → 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.
@@ -16,13 +16,13 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
16
16
  var _l7Core = require("@antv/l7-core");
17
17
  var _l7Utils = require("@antv/l7-utils");
18
18
  var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
19
- var _triangulation = require("../../core/triangulation");
19
+ var _line_trangluation = require("../../core/line_trangluation");
20
20
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
21
21
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
22
22
  /* babel-plugin-inline-import '../shaders/flow/flow_line_frag.glsl' */
23
23
  var flow_line_frag = "#extension GL_OES_standard_derivatives : enable\n\nvarying vec4 v_color;\n\n\n// line texture\n\n#pragma include \"picking\"\n\nvoid main() {\ngl_FragColor = v_color;\ngl_FragColor = filterColor(gl_FragColor);\n}\n"; // linear simple line shader
24
24
  /* babel-plugin-inline-import '../shaders/flow/flow_line_vert.glsl' */
25
- var flow_line_vert = "attribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec4 a_Instance;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\n\n\n#pragma include \"projection\"\n#pragma include \"picking\"\nvarying vec4 v_color;\nuniform float u_gap_width: 1.0;\nuniform float u_stroke_width: 1.0;\nuniform float u_stroke_opacity: 1.0;\n\n\nvoid main() {\n\n// \u900F\u660E\u5EA6\u8BA1\u7B97\n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n vec2 flowlineDir = normalize(target - source);\n vec2 perpendicularDir = vec2(-flowlineDir.y, flowlineDir.x);\n\n\n vec2 position = mix(source, target, a_Position.x);\n \n float lengthCommon = length(project_position(vec4(target,0,1)) - project_position(vec4(source,0,1))); // \n vec2 offsetDistances = a_Size.x * project_pixel(a_Position.yz);\n vec2 limitedOffsetDistances = clamp( \n offsetDistances,\n project_pixel(-lengthCommon*.8), project_pixel(lengthCommon*.8)\n );\n\n\n float startOffsetCommon = project_pixel(offsets[0]);\n float endOffsetCommon = project_pixel(offsets[1]);\n float endpointOffset = mix(\n clamp(startOffsetCommon, 0.0, lengthCommon*.2),\n -clamp(endOffsetCommon, 0.0, lengthCommon*.2),\n a_Position.x\n );\n\n vec2 normalsCommon = u_stroke_width * project_pixel(a_Normal.xy);\n\n float gapCommon = project_pixel(u_gap_width);\n vec3 offsetCommon = vec3(\n flowlineDir * (limitedOffsetDistances[1] + normalsCommon.y + endpointOffset * 1.05) -\n perpendicularDir * (limitedOffsetDistances[0] + gapCommon + normalsCommon.x),\n 0.0\n );\n\n\n vec4 project_pos = project_position(vec4(position.xy, 0, 1.0));\n\n vec4 fillColor = vec4(a_Color.rgb, a_Color.a * opacity);\n v_color = mix(fillColor, vec4(u_stroke.xyz, u_stroke.w * fillColor.w * u_stroke_opacity), a_Normal.z);\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offsetCommon.xy, 0., 1.0));\n\n\n\n setPickingColor(a_PickingColor);\n}\n";
25
+ var flow_line_vert = "attribute vec4 a_Color;\nattribute vec2 a_Size;\nattribute vec4 a_Instance;\nattribute vec3 a_Normal;\nattribute vec3 a_Position;\n\nuniform mat4 u_ModelMatrix;\n\n\n#pragma include \"projection\"\n#pragma include \"project\"\n#pragma include \"picking\"\nvarying vec4 v_color;\nuniform float u_gap_width: 1.0;\nuniform float u_stroke_width: 1.0;\nuniform float u_stroke_opacity: 1.0;\n\nvec2 project_pixel_offset(vec2 offsets) {\n\n vec2 data = project_pixel(offsets);\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return data;\n }\n\n return vec2(data.x, -data.y);;\n}\n\nvec2 line_dir(vec2 target, vec2 source) {\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return normalize(target - source);\n }\n return normalize(ProjectFlat(target) - ProjectFlat(source));\n}\n\nfloat flag_gap() {\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {\n // P20_2 \u5750\u6807\u7CFB\u4E0B\uFF0C\u4E3A\u4E86\u548C Web \u58A8\u5361\u6258\u5750\u6807\u7CFB\u7EDF\u4E00\uFF0Czoom \u9ED8\u8BA4\u51CF3\n return 1.;\n }\n return -1.;\n\n}\n\n\nvoid main() {\n\n// \u900F\u660E\u5EA6\u8BA1\u7B97\n vec2 source = a_Instance.rg; // \u8D77\u59CB\u70B9\n vec2 target = a_Instance.ba; // \u7EC8\u70B9\n vec2 flowlineDir = line_dir(target,source);\n vec2 perpendicularDir = vec2(flowlineDir.y, flowlineDir.x); // mapbox || \u9AD8\u5FB7\n\n\n vec2 position = mix(source, target, a_Position.x);\n \n float lengthCommon = length(project_position(vec4(target,0,1)) - project_position(vec4(source,0,1))); // \n vec2 offsetDistances = a_Size.x * project_pixel_offset(vec2(a_Position.y, a_Position.z)); // Mapbox || \u9AD8\u5FB7\n vec2 limitedOffsetDistances = clamp( \n offsetDistances,\n project_pixel(-lengthCommon*.2), project_pixel(lengthCommon*.2)\n );\n\n\n float startOffsetCommon = project_pixel(offsets[0]);\n float endOffsetCommon = project_pixel(offsets[1]);\n float endpointOffset = mix(\n clamp(startOffsetCommon, 0.0, lengthCommon*.2),\n -clamp(endOffsetCommon, 0.0, lengthCommon*.2),\n a_Position.x\n );\n\n vec2 normalsCommon = u_stroke_width * project_pixel_offset(vec2(a_Normal.x, a_Normal.y)); // mapbox || \u9AD8\u5FB7\n\n float gapCommon = flag_gap() * project_pixel(u_gap_width);\n vec3 offsetCommon = vec3(\n flowlineDir * (limitedOffsetDistances[1] + normalsCommon.y + endpointOffset * 1.05) -\n perpendicularDir * (limitedOffsetDistances[0] + gapCommon + normalsCommon.x),\n 0.0\n );\n\n\n vec4 project_pos = project_position(vec4(position.xy, 0, 1.0));\n\n vec4 fillColor = vec4(a_Color.rgb, a_Color.a * opacity);\n v_color = mix(fillColor, vec4(u_stroke.xyz, u_stroke.w * fillColor.w * u_stroke_opacity), a_Normal.z);\n\n gl_Position = project_common_position_to_clipspace_v2(vec4(project_pos.xy + offsetCommon.xy, 0., 1.0));\n\n\n\n setPickingColor(a_PickingColor);\n}\n";
26
26
  var FlowLineModel = /*#__PURE__*/function (_BaseModel) {
27
27
  (0, _inherits2.default)(FlowLineModel, _BaseModel);
28
28
  var _super = _createSuper(FlowLineModel);
@@ -43,8 +43,6 @@ var FlowLineModel = /*#__PURE__*/function (_BaseModel) {
43
43
  _ref$strokeOpacity = _ref.strokeOpacity,
44
44
  strokeOpacity = _ref$strokeOpacity === void 0 ? 1 : _ref$strokeOpacity;
45
45
  return (0, _objectSpread2.default)({
46
- // u_opacity: opacity,
47
- // u_offsets: offsets,
48
46
  u_gap_width: gapWidth,
49
47
  u_stroke_width: strokeWidth,
50
48
  u_stroke: (0, _l7Utils.rgb2arr)(stroke),
@@ -84,7 +82,8 @@ var FlowLineModel = /*#__PURE__*/function (_BaseModel) {
84
82
  vertexShader: flow_line_vert,
85
83
  fragmentShader: flow_line_frag,
86
84
  inject: this.getInject(),
87
- triangulation: _triangulation.FlowLineFillTriangulation,
85
+ triangulation: _line_trangluation.FlowLineTriangulation,
86
+ styleOption: this.layer.getLayerConfig().symbol,
88
87
  primitive: _l7Core.gl.TRIANGLES,
89
88
  depth: {
90
89
  enable: false
@@ -103,14 +103,7 @@ var LineModel = /*#__PURE__*/function (_BaseModel) {
103
103
  _ref$linearDir = _ref.linearDir,
104
104
  linearDir = _ref$linearDir === void 0 ? _interface.LinearDir.VERTICAL : _ref$linearDir,
105
105
  _ref$blur = _ref.blur,
106
- blur = _ref$blur === void 0 ? [1, 1, 1] : _ref$blur,
107
- _ref$arrow = _ref.arrow,
108
- arrow = _ref$arrow === void 0 ? {
109
- enable: false,
110
- arrowWidth: 2,
111
- arrowHeight: 3,
112
- tailWidth: 1
113
- } : _ref$arrow;
106
+ blur = _ref$blur === void 0 ? [1, 1, 1] : _ref$blur;
114
107
  if (dashArray.length === 2) {
115
108
  dashArray.push(0, 0);
116
109
  }
@@ -151,12 +144,7 @@ var LineModel = /*#__PURE__*/function (_BaseModel) {
151
144
  u_heightfixed: Number(heightfixed),
152
145
  // 顶点高度 scale
153
146
  u_vertexScale: vertexHeightScale,
154
- u_raisingHeight: Number(raisingHeight),
155
- // arrow
156
- u_arrow: Number(arrow.enable),
157
- u_arrowHeight: arrow.arrowHeight || 3,
158
- u_arrowWidth: arrow.arrowWidth || 2,
159
- u_tailWidth: arrow.tailWidth === undefined ? 1 : arrow.tailWidth
147
+ u_raisingHeight: Number(raisingHeight)
160
148
  }, this.getStyleAttribute());
161
149
  }
162
150
  }, {
@@ -13,9 +13,6 @@ uniform vec4 u_dash_array: [10.0, 5., 0, 0];
13
13
  uniform float u_lineDir: 1.0;
14
14
  varying vec4 v_dash_array;
15
15
  varying float v_distance_ratio;
16
-
17
- uniform float u_thetaOffset: 0.314;
18
-
19
16
  #pragma include "projection"
20
17
  #pragma include "project"
21
18
  #pragma include "picking"
@@ -92,8 +89,8 @@ void main() {
92
89
 
93
90
  v_distance_ratio = segmentIndex / segmentNumber;
94
91
 
95
- vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, u_thetaOffset), 0.0, 1.0));
96
- vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, u_thetaOffset), 0.0, 1.0));
92
+ vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, thetaOffset), 0.0, 1.0));
93
+ vec4 next = project_position(vec4(interpolate(source, target, nextSegmentRatio, thetaOffset), 0.0, 1.0));
97
94
 
98
95
 
99
96
  vec2 offset = project_pixel(getExtrusionOffset((next.xy - curr.xy) * indexDir, a_Position.y));
@@ -8,29 +8,59 @@ uniform mat4 u_ModelMatrix;
8
8
 
9
9
 
10
10
  #pragma include "projection"
11
+ #pragma include "project"
11
12
  #pragma include "picking"
12
13
  varying vec4 v_color;
13
14
  uniform float u_gap_width: 1.0;
14
15
  uniform float u_stroke_width: 1.0;
15
16
  uniform float u_stroke_opacity: 1.0;
16
17
 
18
+ vec2 project_pixel_offset(vec2 offsets) {
19
+
20
+ vec2 data = project_pixel(offsets);
21
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
22
+ // P20_2 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减3
23
+ return data;
24
+ }
25
+
26
+ return vec2(data.x, -data.y);;
27
+ }
28
+
29
+ vec2 line_dir(vec2 target, vec2 source) {
30
+
31
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
32
+ // P20_2 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减3
33
+ return normalize(target - source);
34
+ }
35
+ return normalize(ProjectFlat(target) - ProjectFlat(source));
36
+ }
37
+
38
+ float flag_gap() {
39
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
40
+ // P20_2 坐标系下,为了和 Web 墨卡托坐标系统一,zoom 默认减3
41
+ return 1.;
42
+ }
43
+ return -1.;
44
+
45
+ }
46
+
17
47
 
18
48
  void main() {
19
49
 
20
50
  // 透明度计算
21
51
  vec2 source = a_Instance.rg; // 起始点
22
52
  vec2 target = a_Instance.ba; // 终点
23
- vec2 flowlineDir = normalize(target - source);
24
- vec2 perpendicularDir = vec2(-flowlineDir.y, flowlineDir.x);
53
+ vec2 flowlineDir = line_dir(target,source);
54
+ vec2 perpendicularDir = vec2(flowlineDir.y, flowlineDir.x); // mapbox || 高德
25
55
 
26
56
 
27
57
  vec2 position = mix(source, target, a_Position.x);
28
58
 
29
59
  float lengthCommon = length(project_position(vec4(target,0,1)) - project_position(vec4(source,0,1))); //
30
- vec2 offsetDistances = a_Size.x * project_pixel(a_Position.yz);
60
+ vec2 offsetDistances = a_Size.x * project_pixel_offset(vec2(a_Position.y, a_Position.z)); // Mapbox || 高德
31
61
  vec2 limitedOffsetDistances = clamp(
32
62
  offsetDistances,
33
- project_pixel(-lengthCommon*.8), project_pixel(lengthCommon*.8)
63
+ project_pixel(-lengthCommon*.2), project_pixel(lengthCommon*.2)
34
64
  );
35
65
 
36
66
 
@@ -42,9 +72,9 @@ void main() {
42
72
  a_Position.x
43
73
  );
44
74
 
45
- vec2 normalsCommon = u_stroke_width * project_pixel(a_Normal.xy);
75
+ vec2 normalsCommon = u_stroke_width * project_pixel_offset(vec2(a_Normal.x, a_Normal.y)); // mapbox || 高德
46
76
 
47
- float gapCommon = project_pixel(u_gap_width);
77
+ float gapCommon = flag_gap() * project_pixel(u_gap_width);
48
78
  vec3 offsetCommon = vec3(
49
79
  flowlineDir * (limitedOffsetDistances[1] + normalsCommon.y + endpointOffset * 1.05) -
50
80
  perpendicularDir * (limitedOffsetDistances[0] + gapCommon + normalsCommon.x),
@@ -11,7 +11,6 @@ varying float v_segmentIndex;
11
11
 
12
12
  uniform float u_lineDir: 1.0;
13
13
 
14
- uniform float u_thetaOffset: 0.314;
15
14
  uniform vec4 u_sourceColor;
16
15
  uniform vec4 u_targetColor;
17
16
 
@@ -80,8 +79,8 @@ void main() {
80
79
  float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));
81
80
  float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);
82
81
  float d_distance_ratio;
83
- vec4 curr = project_position(vec4(interpolate(source, target, segmentRatio, u_thetaOffset), 0.0, 1.0));
84
- 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));
85
84
  // v_normal = getNormal((next.xy - curr.xy) * indexDir, a_Position.y);
86
85
  //unProjCustomCoord
87
86
 
@@ -147,11 +147,6 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
147
147
  key: "mapping",
148
148
  value: function mapping(layer, attributes, data, predata) {
149
149
  var _this3 = this;
150
- var _ref5 = layer.getLayerConfig(),
151
- _ref5$arrow = _ref5.arrow,
152
- arrow = _ref5$arrow === void 0 ? {
153
- enable: false
154
- } : _ref5$arrow;
155
150
  var usedAttributes = attributes.filter(function (attribute) {
156
151
  return attribute.scale !== undefined;
157
152
  }).filter(function (attribute) {
@@ -179,18 +174,6 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
179
174
  encodeRecord.shape = _this3.fontService.getIconFontKey(encodeRecord[attribute.name]);
180
175
  }
181
176
  });
182
- if (arrow.enable && encodeRecord.shape === 'line') {
183
- // 只有在线图层且支持配置箭头的时候进行插入顶点的处理
184
- var coords = encodeRecord.coordinates;
185
- // @ts-ignore
186
- if (layer.arrowInsertCount < layer.encodeDataLength) {
187
- // Tip: arrowInsert 的判断用于确保每一条线数据 arrow 的属性点只会被植入一次
188
- var arrowPoint = _this3.getArrowPoints(coords[0], coords[1]);
189
- encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
190
- // @ts-ignore
191
- layer.arrowInsertCount++;
192
- }
193
- }
194
177
  return encodeRecord;
195
178
  });
196
179
  attributes.forEach(function (attribute) {
@@ -280,9 +263,9 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
280
263
  }
281
264
  var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
282
265
  var params = [];
283
- scalers.forEach(function (_ref6) {
266
+ scalers.forEach(function (_ref5) {
284
267
  var _attribute$scale2;
285
- var field = _ref6.field;
268
+ var field = _ref5.field;
286
269
  if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
287
270
  // TODO:多字段,常量
288
271
  params.push(record[field]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-layers",
3
- "version": "2.19.10",
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.10",
31
- "@antv/l7-maps": "2.19.10",
32
- "@antv/l7-source": "2.19.10",
33
- "@antv/l7-utils": "2.19.10",
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.10",
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": "150d3dc74f975ad10d48868612b6f978e4bbce85",
64
+ "gitHead": "a16cafc9907fb3a118ee97df82832c88e114446d",
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  }