@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/es/core/BaseLayer.d.ts
CHANGED
|
@@ -127,9 +127,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
|
|
|
127
127
|
init(): Promise<void>;
|
|
128
128
|
log(logType: string, step?: string): void;
|
|
129
129
|
updateModelData(data: IAttributeAndElements): void;
|
|
130
|
-
createModelData(data: any, option?: ISourceCFG): any;
|
|
131
130
|
setLayerPickService(layerPickService: ILayerPickService): void;
|
|
132
|
-
calculateEncodeData(data: any, option?: ISourceCFG): IEncodeFeature[] | null;
|
|
133
131
|
/**
|
|
134
132
|
* Model初始化前需要更新Model样式
|
|
135
133
|
*/
|
package/es/core/BaseLayer.js
CHANGED
|
@@ -13,7 +13,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
13
13
|
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
|
|
14
14
|
import _initializerWarningHelper from "@babel/runtime/helpers/esm/initializerWarningHelper";
|
|
15
15
|
var _excluded = ["passes"],
|
|
16
|
-
_excluded2 = ["moduleName", "vertexShader", "fragmentShader", "inject", "triangulation", "
|
|
16
|
+
_excluded2 = ["moduleName", "vertexShader", "fragmentShader", "inject", "triangulation", "styleOption"];
|
|
17
17
|
var _dec, _class, _descriptor;
|
|
18
18
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
19
19
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
@@ -28,7 +28,6 @@ import Source from '@antv/l7-source';
|
|
|
28
28
|
import { encodePickingColor, lodashUtil } from '@antv/l7-utils';
|
|
29
29
|
import { EventEmitter } from 'eventemitter3';
|
|
30
30
|
import { BlendTypes } from "../utils/blend";
|
|
31
|
-
import { calculateData } from "../utils/layerData";
|
|
32
31
|
import { createMultiPassRenderer, normalizePasses } from "../utils/multiPassRender";
|
|
33
32
|
import LayerPickService from "./LayerPickService";
|
|
34
33
|
import TextureService from "./TextureService";
|
|
@@ -389,40 +388,11 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
389
388
|
console.warn('data error');
|
|
390
389
|
}
|
|
391
390
|
}
|
|
392
|
-
}, {
|
|
393
|
-
key: "createModelData",
|
|
394
|
-
value: function createModelData(data, option) {
|
|
395
|
-
var _this$layerModel;
|
|
396
|
-
if ((_this$layerModel = this.layerModel) !== null && _this$layerModel !== void 0 && _this$layerModel.createModelData) {
|
|
397
|
-
// 在某些特殊图层中单独构建 attribute & elements
|
|
398
|
-
return this.layerModel.createModelData(option);
|
|
399
|
-
}
|
|
400
|
-
var calEncodeData = this.calculateEncodeData(data, option);
|
|
401
|
-
var triangulation = this.triangulation;
|
|
402
|
-
if (calEncodeData && triangulation) {
|
|
403
|
-
return this.styleAttributeService.createAttributesAndIndices(calEncodeData, triangulation);
|
|
404
|
-
} else {
|
|
405
|
-
return {
|
|
406
|
-
attributes: undefined,
|
|
407
|
-
elements: undefined
|
|
408
|
-
};
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
391
|
}, {
|
|
412
392
|
key: "setLayerPickService",
|
|
413
393
|
value: function setLayerPickService(layerPickService) {
|
|
414
394
|
this.layerPickService = layerPickService;
|
|
415
395
|
}
|
|
416
|
-
}, {
|
|
417
|
-
key: "calculateEncodeData",
|
|
418
|
-
value: function calculateEncodeData(data, option) {
|
|
419
|
-
if (this.inited) {
|
|
420
|
-
return calculateData(this, this.fontService, this.mapService, this.styleAttributeService, data, option);
|
|
421
|
-
} else {
|
|
422
|
-
console.warn('layer not inited!');
|
|
423
|
-
return null;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
396
|
/**
|
|
427
397
|
* Model初始化前需要更新Model样式
|
|
428
398
|
*/
|
|
@@ -568,6 +538,17 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
568
538
|
}
|
|
569
539
|
});
|
|
570
540
|
}
|
|
541
|
+
// 兼容 borderColor borderWidth
|
|
542
|
+
// @ts-ignore
|
|
543
|
+
if (rest.borderColor) {
|
|
544
|
+
// @ts-ignore
|
|
545
|
+
rest.stroke = rest.borderColor;
|
|
546
|
+
}
|
|
547
|
+
// @ts-ignore
|
|
548
|
+
if (rest.borderWidth) {
|
|
549
|
+
// @ts-ignore
|
|
550
|
+
rest.strokeWidth = rest.borderWidth;
|
|
551
|
+
}
|
|
571
552
|
|
|
572
553
|
// 兼容老版本的写法 ['field, 'value']
|
|
573
554
|
var newOption = rest;
|
|
@@ -965,7 +946,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
965
946
|
}, {
|
|
966
947
|
key: "destroy",
|
|
967
948
|
value: function destroy() {
|
|
968
|
-
var _this$multiPassRender, _this$
|
|
949
|
+
var _this$multiPassRender, _this$layerModel, _this$tileLayer, _this$debugService2;
|
|
969
950
|
var refresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
970
951
|
if (this.isDestroyed) {
|
|
971
952
|
return;
|
|
@@ -998,7 +979,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
998
979
|
|
|
999
980
|
this.hooks.afterDestroy.call();
|
|
1000
981
|
// Tip: 清除各个图层自定义的 models 资源
|
|
1001
|
-
(_this$
|
|
982
|
+
(_this$layerModel = this.layerModel) === null || _this$layerModel === void 0 ? void 0 : _this$layerModel.clearModels(refresh);
|
|
1002
983
|
(_this$tileLayer = this.tileLayer) === null || _this$tileLayer === void 0 ? void 0 : _this$tileLayer.destroy();
|
|
1003
984
|
this.models = [];
|
|
1004
985
|
// 清除图层日志(如果有的话:非瓦片相关)
|
|
@@ -1025,11 +1006,11 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
1025
1006
|
}, {
|
|
1026
1007
|
key: "clearModels",
|
|
1027
1008
|
value: function clearModels() {
|
|
1028
|
-
var _this$
|
|
1009
|
+
var _this$layerModel2;
|
|
1029
1010
|
this.models.forEach(function (model) {
|
|
1030
1011
|
return model.destroy();
|
|
1031
1012
|
});
|
|
1032
|
-
(_this$
|
|
1013
|
+
(_this$layerModel2 = this.layerModel) === null || _this$layerModel2 === void 0 ? void 0 : _this$layerModel2.clearModels();
|
|
1033
1014
|
this.models = [];
|
|
1034
1015
|
}
|
|
1035
1016
|
}, {
|
|
@@ -1176,11 +1157,11 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
1176
1157
|
value: function () {
|
|
1177
1158
|
var _buildLayerModel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(options) {
|
|
1178
1159
|
var _this10 = this;
|
|
1179
|
-
var moduleName, vertexShader, fragmentShader, inject, triangulation,
|
|
1160
|
+
var moduleName, vertexShader, fragmentShader, inject, triangulation, styleOption, rest, _this$shaderModuleSer, vs, fs, uniforms, createModel;
|
|
1180
1161
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
1181
1162
|
while (1) switch (_context3.prev = _context3.next) {
|
|
1182
1163
|
case 0:
|
|
1183
|
-
moduleName = options.moduleName, vertexShader = options.vertexShader, fragmentShader = options.fragmentShader, inject = options.inject, triangulation = options.triangulation,
|
|
1164
|
+
moduleName = options.moduleName, vertexShader = options.vertexShader, fragmentShader = options.fragmentShader, inject = options.inject, triangulation = options.triangulation, styleOption = options.styleOption, rest = _objectWithoutProperties(options, _excluded2);
|
|
1184
1165
|
this.shaderModuleService.registerModule(moduleName, {
|
|
1185
1166
|
vs: vertexShader,
|
|
1186
1167
|
fs: fragmentShader,
|
|
@@ -1190,7 +1171,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
1190
1171
|
createModel = this.rendererService.createModel;
|
|
1191
1172
|
return _context3.abrupt("return", new Promise(function (resolve) {
|
|
1192
1173
|
// console.log(this.encodedData)
|
|
1193
|
-
var _this10$styleAttribut = _this10.styleAttributeService.createAttributesAndIndices(_this10.encodedData, triangulation,
|
|
1174
|
+
var _this10$styleAttribut = _this10.styleAttributeService.createAttributesAndIndices(_this10.encodedData, triangulation, styleOption),
|
|
1194
1175
|
attributes = _this10$styleAttribut.attributes,
|
|
1195
1176
|
elements = _this10$styleAttribut.elements,
|
|
1196
1177
|
count = _this10$styleAttribut.count;
|
package/es/core/BaseModel.js
CHANGED
|
@@ -13,6 +13,7 @@ import { rgb2arr } from '@antv/l7-utils';
|
|
|
13
13
|
import { BlendTypes } from "../utils/blend";
|
|
14
14
|
import { getStencil as _getStencil, getStencilMask } from "../utils/stencil";
|
|
15
15
|
import { getCommonStyleAttributeOptions } from "./CommonStyleAttribute";
|
|
16
|
+
import { DefaultUniformStyleType, DefaultUniformStyleValue } from "./constant";
|
|
16
17
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
18
|
var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__PURE__*/function () {
|
|
18
19
|
// @lazyInject(TYPES.IIconService)
|
|
@@ -207,23 +208,15 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
207
208
|
value: function getInject() {
|
|
208
209
|
var encodeStyleAttribute = this.layer.encodeStyleAttribute;
|
|
209
210
|
var str = '';
|
|
210
|
-
var attrType = {
|
|
211
|
-
opacity: 'float',
|
|
212
|
-
stroke: 'vec4',
|
|
213
|
-
offsets: 'vec2',
|
|
214
|
-
textOffset: 'vec2',
|
|
215
|
-
rotation: 'float',
|
|
216
|
-
extrusionBase: 'float'
|
|
217
|
-
};
|
|
218
211
|
this.layer.enableShaderEncodeStyles.forEach(function (key) {
|
|
219
212
|
if (encodeStyleAttribute[key]) {
|
|
220
213
|
str += "#define USE_ATTRIBUTE_".concat(key.toUpperCase(), " 0.0; \n\n");
|
|
221
214
|
}
|
|
222
|
-
str += "\n #ifdef USE_ATTRIBUTE_".concat(key.toUpperCase(), "\n attribute ").concat(
|
|
215
|
+
str += "\n #ifdef USE_ATTRIBUTE_".concat(key.toUpperCase(), "\n attribute ").concat(DefaultUniformStyleType[key], " a_").concat(key.charAt(0).toUpperCase() + key.slice(1), ";\n #else\n uniform ").concat(DefaultUniformStyleType[key], " u_").concat(key, ";\n #endif\n\n ");
|
|
223
216
|
});
|
|
224
217
|
var innerStr = '';
|
|
225
218
|
this.layer.enableShaderEncodeStyles.forEach(function (key) {
|
|
226
|
-
innerStr += "\n\n#ifdef USE_ATTRIBUTE_".concat(key.toUpperCase(), "\n ").concat(
|
|
219
|
+
innerStr += "\n\n#ifdef USE_ATTRIBUTE_".concat(key.toUpperCase(), "\n ").concat(DefaultUniformStyleType[key], " ").concat(key, " = a_").concat(key.charAt(0).toUpperCase() + key.slice(1), ";\n#else\n ").concat(DefaultUniformStyleType[key], " ").concat(key, " = u_").concat(key, ";\n#endif\n\n");
|
|
227
220
|
});
|
|
228
221
|
return {
|
|
229
222
|
'vs:#decl': str,
|
|
@@ -238,20 +231,12 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
238
231
|
var _this = this;
|
|
239
232
|
var options = {};
|
|
240
233
|
// TODO: 优化
|
|
241
|
-
|
|
242
|
-
var defualtValue = {
|
|
243
|
-
opacity: 1,
|
|
244
|
-
stroke: [1, 0, 0, 1],
|
|
245
|
-
offsets: [0, 0],
|
|
246
|
-
rotation: 0,
|
|
247
|
-
extrusionBase: 0
|
|
248
|
-
};
|
|
249
234
|
this.layer.enableShaderEncodeStyles.forEach(function (key) {
|
|
250
235
|
if (!_this.layer.encodeStyleAttribute[key]) {
|
|
251
236
|
// 没有设置样式映射
|
|
252
237
|
// @ts-ignore
|
|
253
238
|
var keyValue = _this.layer.getLayerConfig()[key];
|
|
254
|
-
var value = typeof keyValue === 'undefined' ?
|
|
239
|
+
var value = typeof keyValue === 'undefined' ? DefaultUniformStyleValue[key] : keyValue;
|
|
255
240
|
if (key === 'stroke') {
|
|
256
241
|
value = rgb2arr(value);
|
|
257
242
|
}
|
|
@@ -100,6 +100,26 @@ export function getCommonStyleAttributeOptions(name) {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
+
case 'thetaOffset':
|
|
104
|
+
return {
|
|
105
|
+
name: 'thetaOffset',
|
|
106
|
+
type: AttributeType.Attribute,
|
|
107
|
+
descriptor: {
|
|
108
|
+
name: 'a_ThetaOffset',
|
|
109
|
+
buffer: {
|
|
110
|
+
// give the WebGL driver a hint that this buffer may change
|
|
111
|
+
usage: gl.STATIC_DRAW,
|
|
112
|
+
data: [],
|
|
113
|
+
type: gl.FLOAT
|
|
114
|
+
},
|
|
115
|
+
size: 1,
|
|
116
|
+
update: function update(feature) {
|
|
117
|
+
var _feature$thetaOffset = feature.thetaOffset,
|
|
118
|
+
op = _feature$thetaOffset === void 0 ? 1 : _feature$thetaOffset;
|
|
119
|
+
return [op];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
103
123
|
default:
|
|
104
124
|
return undefined;
|
|
105
125
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export var DefaultUniformStyleValue = {
|
|
2
|
+
opacity: 1,
|
|
3
|
+
stroke: [1, 0, 0, 1],
|
|
4
|
+
offsets: [0, 0],
|
|
5
|
+
rotation: 0,
|
|
6
|
+
extrusionBase: 0,
|
|
7
|
+
strokeOpacity: 1,
|
|
8
|
+
thetaOffset: 0.314
|
|
9
|
+
};
|
|
10
|
+
export var DefaultUniformStyleType = {
|
|
11
|
+
opacity: 'float',
|
|
12
|
+
stroke: 'vec4',
|
|
13
|
+
offsets: 'vec2',
|
|
14
|
+
textOffset: 'vec2',
|
|
15
|
+
rotation: 'float',
|
|
16
|
+
extrusionBase: 'float',
|
|
17
|
+
strokeOpacity: 'float',
|
|
18
|
+
thetaOffset: 'float'
|
|
19
|
+
};
|
package/es/core/interface.d.ts
CHANGED
|
@@ -5,12 +5,6 @@ export declare enum lineStyleType {
|
|
|
5
5
|
'solid' = 0,
|
|
6
6
|
'dash' = 1
|
|
7
7
|
}
|
|
8
|
-
interface ILineArrow {
|
|
9
|
-
enable: boolean;
|
|
10
|
-
arrowWidth: number;
|
|
11
|
-
arrowHeight: number;
|
|
12
|
-
tailWidth: number;
|
|
13
|
-
}
|
|
14
8
|
export declare enum LinearDir {
|
|
15
9
|
VERTICAL = "vertical",
|
|
16
10
|
HORIZONTAL = "horizontal"
|
|
@@ -31,7 +25,6 @@ export interface IBaseLayerStyleOptions {
|
|
|
31
25
|
zIndex?: number;
|
|
32
26
|
mask?: boolean;
|
|
33
27
|
maskInside?: boolean;
|
|
34
|
-
usage?: string;
|
|
35
28
|
color?: string;
|
|
36
29
|
size?: number;
|
|
37
30
|
}
|
|
@@ -54,8 +47,10 @@ export interface ILineLayerStyleOptions extends IBaseLayerStyleOptions {
|
|
|
54
47
|
vertexHeightScale?: number;
|
|
55
48
|
borderWidth?: number;
|
|
56
49
|
borderColor?: string;
|
|
50
|
+
strokeWidth?: number;
|
|
51
|
+
storke?: string;
|
|
57
52
|
blur?: [number, number, number];
|
|
58
|
-
|
|
53
|
+
symbol?: ILineSymbol;
|
|
59
54
|
rampColors?: IColorRamp;
|
|
60
55
|
featureId?: string;
|
|
61
56
|
sourceLayer?: string;
|
|
@@ -231,15 +226,26 @@ export interface IRasterTerrainLayerStyleOptions extends IBaseRasterLayerStyleOp
|
|
|
231
226
|
bScaler?: number;
|
|
232
227
|
offset?: number;
|
|
233
228
|
}
|
|
229
|
+
export type ArrowType = 'circle' | 'triangle' | 'rect' | 'diamond' | 'classic' | 'halfTriangle' | 'none';
|
|
230
|
+
export interface IArrowOptions {
|
|
231
|
+
type: ArrowType;
|
|
232
|
+
width?: number;
|
|
233
|
+
height?: number;
|
|
234
|
+
radius?: number;
|
|
235
|
+
}
|
|
236
|
+
export interface ILineSymbol {
|
|
237
|
+
source: ArrowType | IArrowOptions;
|
|
238
|
+
target: ArrowType | IArrowOptions;
|
|
239
|
+
}
|
|
234
240
|
export interface IFlowLineStyleOptions extends IBaseLayerStyleOptions {
|
|
235
241
|
gapWidth?: number;
|
|
236
242
|
offsets?: [number, number];
|
|
237
243
|
stroke?: string;
|
|
238
244
|
strokeOpacity?: number;
|
|
239
245
|
strokeWidth?: number;
|
|
246
|
+
symbol?: ILineSymbol;
|
|
240
247
|
}
|
|
241
248
|
export interface IStyleEncodeAttributeOptions {
|
|
242
249
|
field: StyleAttributeField;
|
|
243
250
|
values?: StyleAttributeOption;
|
|
244
251
|
}
|
|
245
|
-
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IEncodeFeature } from '@antv/l7-core';
|
|
2
|
+
export declare function FlowHalfArrowFillTriangulation(feature: IEncodeFeature): {
|
|
3
|
+
vertices: number[];
|
|
4
|
+
normals: number[];
|
|
5
|
+
indices: number[];
|
|
6
|
+
size: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function FlowLineTriangulation(feature: IEncodeFeature, symbolOption?: unknown): {
|
|
9
|
+
vertices: number[];
|
|
10
|
+
normals: number[];
|
|
11
|
+
indices: number[];
|
|
12
|
+
size: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function ArrowLineTriangulation(feature: IEncodeFeature, symbolOption?: unknown): {
|
|
15
|
+
vertices: number[];
|
|
16
|
+
indices: number[];
|
|
17
|
+
normals: number[];
|
|
18
|
+
size: number;
|
|
19
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
import { getSymbol, lineArrowPath } from "./shape/arrow";
|
|
4
|
+
|
|
5
|
+
// list all arrow shape
|
|
6
|
+
|
|
7
|
+
// Half Edge
|
|
8
|
+
export function FlowHalfArrowFillTriangulation(feature) {
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
var coord = feature.coordinates.flat();
|
|
11
|
+
var tin = 1;
|
|
12
|
+
var tout = 1.0;
|
|
13
|
+
return {
|
|
14
|
+
vertices: [1, 0, 0].concat(_toConsumableArray(coord), [
|
|
15
|
+
// 0
|
|
16
|
+
1, 2, -3], _toConsumableArray(coord), [
|
|
17
|
+
// 1
|
|
18
|
+
1, 1, -3], _toConsumableArray(coord), [
|
|
19
|
+
// 2
|
|
20
|
+
0, 1, 0], _toConsumableArray(coord), [
|
|
21
|
+
// 3
|
|
22
|
+
0, 0, 0], _toConsumableArray(coord), [
|
|
23
|
+
// 4
|
|
24
|
+
1, 0, 0], _toConsumableArray(coord), [
|
|
25
|
+
// 0
|
|
26
|
+
1, 2, -3], _toConsumableArray(coord), [
|
|
27
|
+
// 1
|
|
28
|
+
1, 1, -3], _toConsumableArray(coord), [
|
|
29
|
+
// 2
|
|
30
|
+
0, 1, 0], _toConsumableArray(coord), [
|
|
31
|
+
// 3
|
|
32
|
+
0, 0, 0], _toConsumableArray(coord)),
|
|
33
|
+
normals: [-tin, 2 * tout, 1,
|
|
34
|
+
// 0
|
|
35
|
+
2 * tout, -tout, 1,
|
|
36
|
+
// 1
|
|
37
|
+
tout, -tout, 1,
|
|
38
|
+
// 2
|
|
39
|
+
tout, -tout, 1,
|
|
40
|
+
// 3
|
|
41
|
+
-tin, -tout, 1,
|
|
42
|
+
// 4
|
|
43
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
44
|
+
indices: [0, 1, 2, 0, 2, 3, 0, 3, 4, 5, 6, 7, 5, 7, 8, 5, 8, 9],
|
|
45
|
+
size: 7
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function FlowLineTriangulation(feature, symbolOption) {
|
|
49
|
+
return symbolOption ? ArrowLineTriangulation(feature, symbolOption) : FlowHalfArrowFillTriangulation(feature);
|
|
50
|
+
}
|
|
51
|
+
export function ArrowLineTriangulation(feature, symbolOption) {
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
var coord = feature.coordinates.flat();
|
|
54
|
+
var _ref = symbolOption,
|
|
55
|
+
_ref$target = _ref.target,
|
|
56
|
+
target = _ref$target === void 0 ? 'classic' : _ref$target,
|
|
57
|
+
_ref$source = _ref.source,
|
|
58
|
+
source = _ref$source === void 0 ? 'circle' : _ref$source;
|
|
59
|
+
var startSymbol = shape2Vertices(getSymbol(source, 'source'), coord, 0, 0);
|
|
60
|
+
var linePath = lineArrowPath(coord, startSymbol.vertices.length / 7, symbolOption);
|
|
61
|
+
var endSymbol = shape2Vertices(getSymbol(target, 'target'), coord, 1, startSymbol.vertices.length / 7 + linePath.vertices.length / 7);
|
|
62
|
+
var data = {
|
|
63
|
+
vertices: [].concat(_toConsumableArray(startSymbol.vertices), _toConsumableArray(linePath.vertices), _toConsumableArray(endSymbol.vertices)),
|
|
64
|
+
indices: [].concat(_toConsumableArray(startSymbol.outLineIndices), _toConsumableArray(linePath.outLineIndices), _toConsumableArray(endSymbol.outLineIndices), _toConsumableArray(startSymbol.indices), _toConsumableArray(linePath.indices), _toConsumableArray(endSymbol.indices)),
|
|
65
|
+
normals: [].concat(_toConsumableArray(startSymbol.normals), _toConsumableArray(linePath.normals), _toConsumableArray(endSymbol.normals)),
|
|
66
|
+
size: 7
|
|
67
|
+
};
|
|
68
|
+
return data;
|
|
69
|
+
}
|
|
70
|
+
// start 0,end 1;
|
|
71
|
+
function shape2Vertices(shape, coord) {
|
|
72
|
+
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
73
|
+
var indexOffset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
74
|
+
var shapeVertices = [];
|
|
75
|
+
var vertices = shape.vertices,
|
|
76
|
+
indices = shape.indices,
|
|
77
|
+
dimensions = shape.dimensions,
|
|
78
|
+
outLineIndices = shape.outLineIndices;
|
|
79
|
+
for (var i = 0; i < vertices.length; i += dimensions) {
|
|
80
|
+
shapeVertices.push.apply(shapeVertices, [type, vertices[i + 1], vertices[i]].concat(_toConsumableArray(coord)));
|
|
81
|
+
}
|
|
82
|
+
return _objectSpread(_objectSpread({}, shape), {}, {
|
|
83
|
+
vertices: shapeVertices,
|
|
84
|
+
indices: indices.map(function (i) {
|
|
85
|
+
return i + indexOffset;
|
|
86
|
+
}),
|
|
87
|
+
outLineIndices: outLineIndices.map(function (i) {
|
|
88
|
+
return i + indexOffset;
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ArrowType, IArrowOptions, ILineSymbol } from '../interface';
|
|
2
|
+
export interface IArrowData {
|
|
3
|
+
vertices: number[];
|
|
4
|
+
indices: number[];
|
|
5
|
+
outLineIndices: number[];
|
|
6
|
+
dimensions: number;
|
|
7
|
+
offset?: number[];
|
|
8
|
+
normals: number[];
|
|
9
|
+
}
|
|
10
|
+
export type arrowPosition = -1 | 1;
|
|
11
|
+
export declare function halfTriangleArrow(dir: arrowPosition, options: IArrowOptions): IArrowData;
|
|
12
|
+
export declare function triangleArrow(dir: arrowPosition, options: IArrowOptions): IArrowData;
|
|
13
|
+
export declare function rectArrow(dir: arrowPosition, options: IArrowOptions): IArrowData;
|
|
14
|
+
export declare function diamondArrow(dir: arrowPosition, options: IArrowOptions): IArrowData;
|
|
15
|
+
export declare function classicArrow(dir: arrowPosition, options: IArrowOptions): IArrowData;
|
|
16
|
+
export declare function circleArraw(dir: arrowPosition, options: IArrowOptions): IArrowData;
|
|
17
|
+
export declare function lineArrowPath(coord: number[], indexOffset: number | undefined, symbol: ILineSymbol): IArrowData;
|
|
18
|
+
export declare function getSymbol(type: ArrowType | IArrowOptions, position: 'source' | 'target'): IArrowData | {
|
|
19
|
+
vertices: never[];
|
|
20
|
+
indices: never[];
|
|
21
|
+
normals: never[];
|
|
22
|
+
dimensions: number;
|
|
23
|
+
outLineIndices: never[];
|
|
24
|
+
outLineNormals: never[];
|
|
25
|
+
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
import { circle } from "./Path";
|
|
4
|
+
import earcut from 'earcut';
|
|
5
|
+
var maxArrowWidthMap = {
|
|
6
|
+
circle: 2,
|
|
7
|
+
triangle: 2,
|
|
8
|
+
diamond: 4,
|
|
9
|
+
rect: 2,
|
|
10
|
+
classic: 3,
|
|
11
|
+
halfTriangle: 2,
|
|
12
|
+
'none': 0
|
|
13
|
+
};
|
|
14
|
+
var PathHeight = 1 / 2;
|
|
15
|
+
export function halfTriangleArrow(dir, options) {
|
|
16
|
+
var _options$width = options.width,
|
|
17
|
+
width = _options$width === void 0 ? 2 : _options$width,
|
|
18
|
+
_options$height = options.height,
|
|
19
|
+
height = _options$height === void 0 ? 1 : _options$height;
|
|
20
|
+
return {
|
|
21
|
+
vertices: [0, PathHeight * dir, 1 * dir * width, -(height + PathHeight) * dir, 1 * dir * width, (height - PathHeight) * dir, 0, PathHeight * dir, 1 * dir * width, -(height + PathHeight) * dir, 1 * dir * width, (height - PathHeight) * dir],
|
|
22
|
+
indices: [3, 4, 5],
|
|
23
|
+
outLineIndices: [0, 1, 2],
|
|
24
|
+
normals: [1 * dir, -2 * dir, 1,
|
|
25
|
+
// y,x
|
|
26
|
+
-2 * dir, 1.5 * dir, 1, 1 * dir, 1.5 * dir, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
27
|
+
dimensions: 2
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function triangleArrow(dir, options) {
|
|
31
|
+
var _options$width2 = options.width,
|
|
32
|
+
width = _options$width2 === void 0 ? 2 : _options$width2,
|
|
33
|
+
_options$height2 = options.height,
|
|
34
|
+
height = _options$height2 === void 0 ? 3 : _options$height2;
|
|
35
|
+
return {
|
|
36
|
+
vertices: [0, 0, 1 * dir * width, 1 * height, 1 * dir * width, -1 * height, 0, 0, 1 * dir * width, 1 * height, 1 * dir * width, -1 * height],
|
|
37
|
+
outLineIndices: [0, 1, 2],
|
|
38
|
+
indices: [3, 4, 5],
|
|
39
|
+
normals: [0, -1.5 * dir, 1, 2, 1 * dir, 1, -2, 1 * dir, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
40
|
+
dimensions: 2
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export function rectArrow(dir, options) {
|
|
44
|
+
var _options$width3 = options.width,
|
|
45
|
+
width = _options$width3 === void 0 ? 2 : _options$width3,
|
|
46
|
+
_options$height3 = options.height,
|
|
47
|
+
height = _options$height3 === void 0 ? 2 : _options$height3;
|
|
48
|
+
return {
|
|
49
|
+
vertices: [0, height / 2, dir * width * 1, height / 2, dir * width * 1, -height / 2, 0, -height / 2, 0, height / 2, dir * width * 1, height / 2, dir * width * 1, -height / 2, 0, -height / 2],
|
|
50
|
+
dimensions: 2,
|
|
51
|
+
indices: [4, 5, 6, 4, 6, 7],
|
|
52
|
+
outLineIndices: [0, 1, 2, 0, 2, 3],
|
|
53
|
+
normals: [0, -dir, 1, 1, 0, 1, 0, -dir, 1, -1, -0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export function diamondArrow(dir, options) {
|
|
57
|
+
var _options$width4 = options.width,
|
|
58
|
+
width = _options$width4 === void 0 ? 2 : _options$width4,
|
|
59
|
+
_options$height4 = options.height,
|
|
60
|
+
height = _options$height4 === void 0 ? 3 : _options$height4;
|
|
61
|
+
return {
|
|
62
|
+
vertices: [0, 0, 1 * width * dir, 0.5 * height, 2 * width * dir, 0, 1 * width * dir, -0.5 * height, 0, 0, 1 * width * dir, 0.5 * height, 2 * width * dir, 0, 1 * width * dir, -0.5 * height],
|
|
63
|
+
dimensions: 2,
|
|
64
|
+
indices: [4, 5, 6, 4, 6, 7],
|
|
65
|
+
outLineIndices: [0, 1, 2, 0, 2, 3],
|
|
66
|
+
normals: [0, -dir, 1, 1, 0, 1, 0, -dir, 1, -1, -0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export function classicArrow(dir, options) {
|
|
70
|
+
var _options$width5 = options.width,
|
|
71
|
+
width = _options$width5 === void 0 ? 2 : _options$width5,
|
|
72
|
+
_options$height5 = options.height,
|
|
73
|
+
height = _options$height5 === void 0 ? 3 : _options$height5;
|
|
74
|
+
return {
|
|
75
|
+
vertices: [0, 0, 2 * dir * width, 1 * height, 1.5 * dir * width, 0, 2 * dir * width, -1 * height, 0, 0, 2 * dir * width, 1 * height, 1.5 * dir * width, 0, 2 * dir * width, -1 * height],
|
|
76
|
+
dimensions: 2,
|
|
77
|
+
indices: [4, 5, 6, 4, 6, 7],
|
|
78
|
+
outLineIndices: [0, 1, 2, 0, 2, 3],
|
|
79
|
+
normals: [0, -dir, 1, 1, 0, 1, 0, -dir, 1, -1, -0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export function circleArraw(dir, options) {
|
|
83
|
+
var _options$width6 = options.width,
|
|
84
|
+
width = _options$width6 === void 0 ? 2 : _options$width6,
|
|
85
|
+
_options$height6 = options.height,
|
|
86
|
+
height = _options$height6 === void 0 ? 2 : _options$height6;
|
|
87
|
+
var path = circle();
|
|
88
|
+
var flattengeo = earcut.flatten([path]);
|
|
89
|
+
var triangles = earcut(flattengeo.vertices, flattengeo.holes, flattengeo.dimensions);
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
var vertice = path.map(function (t) {
|
|
92
|
+
return [t[0] * width * dir, t[1] * height];
|
|
93
|
+
}).flat();
|
|
94
|
+
return {
|
|
95
|
+
vertices: [].concat(_toConsumableArray(vertice), _toConsumableArray(vertice)),
|
|
96
|
+
dimensions: 2,
|
|
97
|
+
indices: triangles.map(function (v) {
|
|
98
|
+
return v + path.length;
|
|
99
|
+
}),
|
|
100
|
+
outLineIndices: triangles,
|
|
101
|
+
normals: [].concat(_toConsumableArray(path.map(function (t) {
|
|
102
|
+
return [t[1] * height, t[0] * width * dir, 1];
|
|
103
|
+
}).flat()), _toConsumableArray(new Array(path.length * 3).fill(0)))
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export function lineArrowPath(coord) {
|
|
107
|
+
var indexOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
108
|
+
var symbol = arguments.length > 2 ? arguments[2] : undefined;
|
|
109
|
+
var sourceType = _typeof(symbol['source']) === 'object' ? symbol['source'].type : symbol['source'];
|
|
110
|
+
var targetType = _typeof(symbol['target']) === 'object' ? symbol['target'].type : symbol['target'];
|
|
111
|
+
var _ref = _typeof(symbol['source']) === 'object' ? symbol['source'] : {},
|
|
112
|
+
_ref$width = _ref.width,
|
|
113
|
+
sourceWidth = _ref$width === void 0 ? sourceType ? maxArrowWidthMap[sourceType] : 0 : _ref$width,
|
|
114
|
+
_ref$height = _ref.height,
|
|
115
|
+
sourceHeight = _ref$height === void 0 ? 2 : _ref$height;
|
|
116
|
+
var _ref2 = _typeof(symbol['target']) === 'object' ? symbol['target'] : {},
|
|
117
|
+
_ref2$width = _ref2.width,
|
|
118
|
+
targetWidth = _ref2$width === void 0 ? targetType ? maxArrowWidthMap[targetType] : 0 : _ref2$width,
|
|
119
|
+
_ref2$height = _ref2.height,
|
|
120
|
+
targetHeight = _ref2$height === void 0 ? 2 : _ref2$height;
|
|
121
|
+
return {
|
|
122
|
+
vertices: [0, PathHeight, 1 * sourceWidth].concat(_toConsumableArray(coord), [1, PathHeight, -1 * targetWidth], _toConsumableArray(coord), [1, -PathHeight, -1 * targetWidth], _toConsumableArray(coord), [0, -PathHeight, 1 * sourceWidth], _toConsumableArray(coord), [0, PathHeight, 1 * sourceWidth], _toConsumableArray(coord), [1, PathHeight, -1 * targetWidth], _toConsumableArray(coord), [1, -PathHeight, -1 * targetWidth], _toConsumableArray(coord), [0, -PathHeight, 1 * sourceWidth], _toConsumableArray(coord)),
|
|
123
|
+
outLineIndices: [0, 1, 2, 0, 2, 3].map(function (t) {
|
|
124
|
+
return t + indexOffset;
|
|
125
|
+
}),
|
|
126
|
+
indices: [4, 5, 6, 4, 6, 7].map(function (t) {
|
|
127
|
+
return t + indexOffset;
|
|
128
|
+
}),
|
|
129
|
+
normals: [1, -1, 1, 1, 1, 1, -1, 0, 1, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
130
|
+
dimensions: 2
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export function getSymbol(type, position) {
|
|
134
|
+
var shape = _typeof(type) === 'object' ? type.type : type;
|
|
135
|
+
var dir = position === 'source' ? 1 : -1;
|
|
136
|
+
var option = _typeof(type) === 'object' ? type : {};
|
|
137
|
+
switch (shape) {
|
|
138
|
+
case 'circle':
|
|
139
|
+
return circleArraw(dir, option);
|
|
140
|
+
case 'triangle':
|
|
141
|
+
return triangleArrow(dir, option);
|
|
142
|
+
case 'diamond':
|
|
143
|
+
return diamondArrow(dir, option);
|
|
144
|
+
case 'rect':
|
|
145
|
+
return rectArrow(dir, option);
|
|
146
|
+
case 'classic':
|
|
147
|
+
return classicArrow(dir, option);
|
|
148
|
+
case 'halfTriangle':
|
|
149
|
+
return halfTriangleArrow(dir, option);
|
|
150
|
+
default:
|
|
151
|
+
return {
|
|
152
|
+
vertices: [],
|
|
153
|
+
indices: [],
|
|
154
|
+
normals: [],
|
|
155
|
+
dimensions: 2,
|
|
156
|
+
outLineIndices: [],
|
|
157
|
+
outLineNormals: []
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -48,13 +48,7 @@ export declare function LineTriangulation(feature: IEncodeFeature): {
|
|
|
48
48
|
size: number;
|
|
49
49
|
};
|
|
50
50
|
export declare function FlowLineFillTriangulation(feature: IEncodeFeature): {
|
|
51
|
-
vertices:
|
|
52
|
-
normals: number[];
|
|
53
|
-
indices: number[];
|
|
54
|
-
size: number;
|
|
55
|
-
};
|
|
56
|
-
export declare function FlowLineStrokeTriangulation(feature: IEncodeFeature): {
|
|
57
|
-
vertices: any[];
|
|
51
|
+
vertices: number[];
|
|
58
52
|
normals: number[];
|
|
59
53
|
indices: number[];
|
|
60
54
|
size: number;
|
|
@@ -107,7 +101,7 @@ export declare function RasterImageTriangulation(feature: IEncodeFeature): {
|
|
|
107
101
|
* @param feature 映射数据
|
|
108
102
|
* @param segNum 弧线线段数
|
|
109
103
|
*/
|
|
110
|
-
export declare function LineArcTriangulation(feature: IEncodeFeature,
|
|
104
|
+
export declare function LineArcTriangulation(feature: IEncodeFeature, styleOption?: unknown): {
|
|
111
105
|
vertices: number[];
|
|
112
106
|
indices: number[];
|
|
113
107
|
size: number;
|