@antv/l7-layers 2.8.32 → 2.8.35

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 (84) hide show
  1. package/es/Geometry/index.d.ts +1 -1
  2. package/es/Geometry/index.js +4 -1
  3. package/es/Geometry/index.js.map +1 -1
  4. package/es/Geometry/models/billboard.d.ts +29 -0
  5. package/es/Geometry/models/billboard.js +222 -0
  6. package/es/Geometry/models/billboard.js.map +1 -0
  7. package/es/Geometry/models/index.d.ts +1 -1
  8. package/es/Geometry/models/index.js +3 -1
  9. package/es/Geometry/models/index.js.map +1 -1
  10. package/es/Geometry/models/plane.d.ts +13 -11
  11. package/es/Geometry/models/plane.js +134 -110
  12. package/es/Geometry/models/plane.js.map +1 -1
  13. package/es/canvas/models/canvas.js +5 -3
  14. package/es/canvas/models/canvas.js.map +1 -1
  15. package/es/core/BaseLayer.d.ts +5 -1
  16. package/es/core/BaseLayer.js +47 -0
  17. package/es/core/BaseLayer.js.map +1 -1
  18. package/es/core/interface.d.ts +5 -0
  19. package/es/core/interface.js.map +1 -1
  20. package/es/heatmap/index.d.ts +2 -0
  21. package/es/heatmap/index.js +9 -0
  22. package/es/heatmap/index.js.map +1 -1
  23. package/es/heatmap/models/heatmap.js +1 -0
  24. package/es/heatmap/models/heatmap.js.map +1 -1
  25. package/es/index.js.map +1 -1
  26. package/es/line/index.d.ts +1 -1
  27. package/es/line/index.js +1 -0
  28. package/es/line/index.js.map +1 -1
  29. package/es/line/models/index.d.ts +1 -1
  30. package/es/line/models/index.js +3 -1
  31. package/es/line/models/index.js.map +1 -1
  32. package/es/line/models/line.js +1 -0
  33. package/es/line/models/line.js.map +1 -1
  34. package/es/line/models/linearline.d.ts +20 -0
  35. package/es/line/models/linearline.js +267 -0
  36. package/es/line/models/linearline.js.map +1 -0
  37. package/es/point/models/fill.js +1 -0
  38. package/es/point/models/fill.js.map +1 -1
  39. package/es/point/models/normal.js +1 -0
  40. package/es/point/models/normal.js.map +1 -1
  41. package/es/point/models/simplePoint.js +1 -0
  42. package/es/point/models/simplePoint.js.map +1 -1
  43. package/es/polygon/models/fill.js +1 -0
  44. package/es/polygon/models/fill.js.map +1 -1
  45. package/es/utils/layerData.d.ts +2 -0
  46. package/es/utils/layerData.js +152 -0
  47. package/es/utils/layerData.js.map +1 -0
  48. package/lib/Geometry/index.js +4 -1
  49. package/lib/Geometry/index.js.map +1 -1
  50. package/lib/Geometry/models/billboard.js +233 -0
  51. package/lib/Geometry/models/billboard.js.map +1 -0
  52. package/lib/Geometry/models/index.js +4 -1
  53. package/lib/Geometry/models/index.js.map +1 -1
  54. package/lib/Geometry/models/plane.js +133 -108
  55. package/lib/Geometry/models/plane.js.map +1 -1
  56. package/lib/canvas/models/canvas.js +5 -3
  57. package/lib/canvas/models/canvas.js.map +1 -1
  58. package/lib/core/BaseLayer.js +47 -0
  59. package/lib/core/BaseLayer.js.map +1 -1
  60. package/lib/core/interface.js.map +1 -1
  61. package/lib/heatmap/index.js +9 -0
  62. package/lib/heatmap/index.js.map +1 -1
  63. package/lib/heatmap/models/heatmap.js +1 -0
  64. package/lib/heatmap/models/heatmap.js.map +1 -1
  65. package/lib/index.js.map +1 -1
  66. package/lib/line/index.js +1 -0
  67. package/lib/line/index.js.map +1 -1
  68. package/lib/line/models/index.js +4 -1
  69. package/lib/line/models/index.js.map +1 -1
  70. package/lib/line/models/line.js +1 -0
  71. package/lib/line/models/line.js.map +1 -1
  72. package/lib/line/models/linearline.js +283 -0
  73. package/lib/line/models/linearline.js.map +1 -0
  74. package/lib/point/models/fill.js +1 -0
  75. package/lib/point/models/fill.js.map +1 -1
  76. package/lib/point/models/normal.js +1 -0
  77. package/lib/point/models/normal.js.map +1 -1
  78. package/lib/point/models/simplePoint.js +1 -0
  79. package/lib/point/models/simplePoint.js.map +1 -1
  80. package/lib/polygon/models/fill.js +1 -0
  81. package/lib/polygon/models/fill.js.map +1 -1
  82. package/lib/utils/layerData.js +163 -0
  83. package/lib/utils/layerData.js.map +1 -0
  84. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/polygon/models/fill.ts"],"names":["FillModel","layer","getLayerConfig","raisingHeight","opacity","opacityLinear","enable","dir","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_raisingHeight","Number","u_opacity","u_opacitylinear","u_dir","buildModels","mask","maskInside","buildLayerModel","moduleName","vertexShader","polygon_linear_vert","polygon_vert","fragmentShader","polygon_linear_frag","polygon_frag","triangulation","polygonTriangulationWithCenter","polygonTriangulation","blend","getBlend","depth","cull","face","BACK","stencil","destroy","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","normal","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AAEA;;;;;;;;;;;IAQqBA,S;;;;;;;;;;;;WACnB,wBAAsB;AACpB,iBAOI,KAAKC,KAAL,CAAWC,cAAX,EAPJ;AAAA,oCACEC,aADF;AAAA,UACEA,aADF,mCACkB,CADlB;AAAA,8BAEEC,OAFF;AAAA,UAEEA,OAFF,6BAEY,CAFZ;AAAA,oCAGEC,aAHF;AAAA,UAGEA,aAHF,mCAGkB;AACdC,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,GAAG,EAAE;AAFS,OAHlB;;AAQA,UAAI,KAAKC,eAAL,IAAwB,KAAKC,qBAAL,CAA2B;AAAEL,QAAAA,OAAO,EAAPA;AAAF,OAA3B,CAA5B,EAAqE;AACnE,aAAKM,oBAAL,CAA0B;AAAEN,UAAAA,OAAO,EAAPA;AAAF,SAA1B;AACA,YAAMO,UAAU,GAAG,KAAKV,KAAL,CAAWW,cAAX,EAAnB;;AACA,iC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CAACC,MAAlB,EAA0B;AACxB,aAAKqD,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,UAAAA,IAAI,EAAE,QAD0C;AAEhDlC,UAAAA,IAAI,EAAEmC,sBAAcC,SAF4B;AAGhDC,UAAAA,UAAU,EAAE;AACVH,YAAAA,IAAI,EAAE,UADI;AAEVI,YAAAA,MAAM,EAAE;AAENC,cAAAA,KAAK,EAAEzC,WAAG0C,WAFJ;AAGNnD,cAAAA,IAAI,EAAE,EAHA;AAINW,cAAAA,IAAI,EAAEF,WAAGG;AAJH,aAFE;AAQVwC,YAAAA,IAAI,EAAE,CARI;AASVC,YAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKNC,MALM,EAMH;AAEH,qBAAO,CAACF,MAAM,CAAC,CAAD,CAAP,EAAYA,MAAM,CAAC,CAAD,CAAlB,EAAuBA,MAAM,CAAC,CAAD,CAA7B,CAAP;AACD;AAlBS;AAHoC,SAAlD;AAwBD;AACF;;;EA7HoCG,mB","sourcesContent":["import { AttributeType, gl, IEncodeFeature, IModel } from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPolygonLayerStyleOptions } from '../../core/interface';\nimport {\n polygonTriangulation,\n polygonTriangulationWithCenter,\n} from '../../core/triangulation';\nimport polygon_frag from '../shaders/polygon_frag.glsl';\nimport polygon_linear_frag from '../shaders/polygon_linear_frag.glsl';\nimport polygon_linear_vert from '../shaders/polygon_linear_vert.glsl';\nimport polygon_vert from '../shaders/polygon_vert.glsl';\nexport default class FillModel extends BaseModel {\n public getUninforms() {\n const {\n raisingHeight = 0,\n opacity = 1,\n opacityLinear = {\n enable: false,\n dir: 'in',\n },\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity,\n\n u_raisingHeight: Number(raisingHeight),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n u_opacitylinear: Number(opacityLinear.enable),\n u_dir: opacityLinear.dir === 'in' ? 1.0 : 0.0,\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n opacityLinear = {\n enable: false,\n dir: 'in',\n },\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'polygon',\n vertexShader: opacityLinear.enable ? polygon_linear_vert : polygon_vert,\n fragmentShader: opacityLinear.enable\n ? polygon_linear_frag\n : polygon_frag,\n // triangulation: polygonTriangulation,\n triangulation: opacityLinear.enable\n ? polygonTriangulationWithCenter\n : polygonTriangulation,\n blend: this.getBlend(),\n depth: { enable: false },\n cull: {\n enable: true,\n face: gl.BACK, // gl.FRONT | gl.BACK;\n },\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n const {\n opacityLinear = {\n enable: false,\n dir: 'in',\n },\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n if (opacityLinear.enable) {\n this.styleAttributeService.registerStyleAttribute({\n name: 'linear',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_linear',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n // center[0] center[1] radius\n return [vertex[3], vertex[4], vertex[5]];\n },\n },\n });\n }\n }\n}\n"],"file":"fill.js"}
1
+ {"version":3,"sources":["../../../src/polygon/models/fill.ts"],"names":["FillModel","layer","getLayerConfig","raisingHeight","opacity","opacityLinear","enable","dir","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_raisingHeight","Number","u_opacity","u_opacitylinear","u_dir","buildModels","mask","maskInside","triangulation","polygonTriangulationWithCenter","polygonTriangulation","buildLayerModel","moduleName","vertexShader","polygon_linear_vert","polygon_vert","fragmentShader","polygon_linear_frag","polygon_frag","blend","getBlend","depth","cull","face","BACK","stencil","destroy","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","normal","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AAEA;;;;;;;;;;;IAQqBA,S;;;;;;;;;;;;WACnB,wBAAsB;AACpB,iBAOI,KAAKC,KAAL,CAAWC,cAAX,EAPJ;AAAA,oCACEC,aADF;AAAA,UACEA,aADF,mCACkB,CADlB;AAAA,8BAEEC,OAFF;AAAA,UAEEA,OAFF,6BAEY,CAFZ;AAAA,oCAGEC,aAHF;AAAA,UAGEA,aAHF,mCAGkB;AACdC,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,GAAG,EAAE;AAFS,OAHlB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,QAAAA,OAAO,EAAE,sBAAQnB,IAAR,EAAcC,UAAd;AAhBgB,OAA3B,CADK,CAAP;AAoBD;;;WAED,uBAAqB;AAAA;;AACnB,gCAAKnB,WAAL,wEAAkBsC,OAAlB;AACD;;;WAED,qCAAsC;AACpC,kBAKI,KAAKzD,KAAL,CAAWC,cAAX,EALJ;AAAA,sCACEG,aADF;AAAA,UACEA,aADF,oCACkB;AACdC,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,GAAG,EAAE;AAFS,OADlB;;AAMA,UAAIF,aAAa,CAACC,MAAlB,EAA0B;AACxB,aAAKqD,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,UAAAA,IAAI,EAAE,QAD0C;AAEhDlC,UAAAA,IAAI,EAAEmC,sBAAcC,SAF4B;AAGhDC,UAAAA,UAAU,EAAE;AACVH,YAAAA,IAAI,EAAE,UADI;AAEVI,YAAAA,MAAM,EAAE;AAENC,cAAAA,KAAK,EAAEzC,WAAG0C,WAFJ;AAGNnD,cAAAA,IAAI,EAAE,EAHA;AAINW,cAAAA,IAAI,EAAEF,WAAGG;AAJH,aAFE;AAQVwC,YAAAA,IAAI,EAAE,CARI;AASVC,YAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKNC,MALM,EAMH;AAEH,qBAAO,CAACF,MAAM,CAAC,CAAD,CAAP,EAAYA,MAAM,CAAC,CAAD,CAAlB,EAAuBA,MAAM,CAAC,CAAD,CAA7B,CAAP;AACD;AAlBS;AAHoC,SAAlD;AAwBD;AACF;;;EAhIoCG,mB","sourcesContent":["import { AttributeType, gl, IEncodeFeature, IModel } from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPolygonLayerStyleOptions } from '../../core/interface';\nimport {\n polygonTriangulation,\n polygonTriangulationWithCenter,\n} from '../../core/triangulation';\nimport polygon_frag from '../shaders/polygon_frag.glsl';\nimport polygon_linear_frag from '../shaders/polygon_linear_frag.glsl';\nimport polygon_linear_vert from '../shaders/polygon_linear_vert.glsl';\nimport polygon_vert from '../shaders/polygon_vert.glsl';\nexport default class FillModel extends BaseModel {\n public getUninforms() {\n const {\n raisingHeight = 0,\n opacity = 1,\n opacityLinear = {\n enable: false,\n dir: 'in',\n },\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity,\n\n u_raisingHeight: Number(raisingHeight),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n u_opacitylinear: Number(opacityLinear.enable),\n u_dir: opacityLinear.dir === 'in' ? 1.0 : 0.0,\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n opacityLinear = {\n enable: false,\n dir: 'in',\n },\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n this.layer.triangulation = opacityLinear.enable\n ? polygonTriangulationWithCenter\n : polygonTriangulation;\n return [\n this.layer.buildLayerModel({\n moduleName: 'polygon',\n vertexShader: opacityLinear.enable ? polygon_linear_vert : polygon_vert,\n fragmentShader: opacityLinear.enable\n ? polygon_linear_frag\n : polygon_frag,\n // triangulation: polygonTriangulation,\n triangulation: opacityLinear.enable\n ? polygonTriangulationWithCenter\n : polygonTriangulation,\n blend: this.getBlend(),\n depth: { enable: false },\n cull: {\n enable: true,\n face: gl.BACK, // gl.FRONT | gl.BACK;\n },\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n const {\n opacityLinear = {\n enable: false,\n dir: 'in',\n },\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n if (opacityLinear.enable) {\n this.styleAttributeService.registerStyleAttribute({\n name: 'linear',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_linear',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n // center[0] center[1] radius\n return [vertex[3], vertex[4], vertex[5]];\n },\n },\n });\n }\n }\n}\n"],"file":"fill.js"}
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.calculateData = calculateData;
9
+
10
+ var _l7Maps = require("@antv/l7-maps");
11
+
12
+ var _l7Source = _interopRequireDefault(require("@antv/l7-source"));
13
+
14
+ var _l7Utils = require("@antv/l7-utils");
15
+
16
+ function getArrowPoints(p1, p2) {
17
+ var dir = [p2[0] - p1[0], p2[1] - p1[1]];
18
+ var normalizeDir = (0, _l7Utils.normalize)(dir);
19
+ var arrowPoint = [p1[0] + normalizeDir[0] * 0.0001, p1[1] + normalizeDir[1] * 0.0001];
20
+ return arrowPoint;
21
+ }
22
+
23
+ function adjustData2Amap2Coordinates(mappedData, mapService) {
24
+ var _this = this;
25
+
26
+ if (mappedData.length > 0 && mapService.version === _l7Maps.Version['GAODE2.x']) {
27
+ if (typeof mappedData[0].coordinates[0] === 'number') {
28
+ mappedData.filter(function (d) {
29
+ return !d.originCoordinates;
30
+ }).map(function (d) {
31
+ d.version = _l7Maps.Version['GAODE2.x'];
32
+ d.originCoordinates = cloneDeep(d.coordinates);
33
+ d.coordinates = _this.mapService.lngLatToCoord(d.coordinates);
34
+ });
35
+ } else {
36
+ mappedData.filter(function (d) {
37
+ return !d.originCoordinates;
38
+ }).map(function (d) {
39
+ d.version = _l7Maps.Version['GAODE2.x'];
40
+ d.originCoordinates = cloneDeep(d.coordinates);
41
+ d.coordinates = _this.mapService.lngLatToCoords(d.coordinates);
42
+ });
43
+ }
44
+ }
45
+ }
46
+
47
+ function adjustData2SimpleCoordinates(mappedData, mapService) {
48
+ if (mappedData.length > 0 && mapService.version === _l7Maps.Version.SIMPLE) {
49
+ mappedData.map(function (d) {
50
+ if (!d.simpleCoordinate) {
51
+ d.coordinates = unProjectCoordinates(d.coordinates, mapService);
52
+ d.simpleCoordinate = true;
53
+ }
54
+ });
55
+ }
56
+ }
57
+
58
+ function unProjectCoordinates(coordinates, mapService) {
59
+ if (typeof coordinates[0] === 'number') {
60
+ return mapService.simpleMapCoord.unproject(coordinates);
61
+ }
62
+
63
+ if (coordinates[0] && coordinates[0][0] instanceof Array) {
64
+ var coords = [];
65
+ coordinates.map(function (coord) {
66
+ var c1 = [];
67
+ coord.map(function (co) {
68
+ c1.push(mapService.simpleMapCoord.unproject(co));
69
+ });
70
+ coords.push(c1);
71
+ });
72
+ return coords;
73
+ } else {
74
+ var _coords = [];
75
+ coordinates.map(function (coord) {
76
+ _coords.push(mapService.simpleMapCoord.unproject(coord));
77
+ });
78
+ return _coords;
79
+ }
80
+ }
81
+
82
+ function applyAttributeMapping(attribute, record, minimumColor) {
83
+ var _attribute$scale;
84
+
85
+ if (!attribute.scale) {
86
+ return [];
87
+ }
88
+
89
+ var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
90
+ var params = [];
91
+ scalers.forEach(function (_ref) {
92
+ var _attribute$scale2;
93
+
94
+ var field = _ref.field;
95
+
96
+ if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
97
+ params.push(record[field]);
98
+ }
99
+ });
100
+ var mappingResult = attribute.mapping ? attribute.mapping(params) : [];
101
+
102
+ if (attribute.name === 'color' && !(0, _l7Utils.isColor)(mappingResult[0])) {
103
+ return [minimumColor];
104
+ }
105
+
106
+ return mappingResult;
107
+ }
108
+
109
+ function mapping(attributes, data, fontService, mapService, minimumColor, layer) {
110
+ var _ref2 = layer === null || layer === void 0 ? void 0 : layer.getLayerConfig(),
111
+ _ref2$arrow = _ref2.arrow,
112
+ arrow = _ref2$arrow === void 0 ? {
113
+ enable: false
114
+ } : _ref2$arrow;
115
+
116
+ var mappedData = data.map(function (record) {
117
+ var encodeRecord = {
118
+ id: record._id,
119
+ coordinates: record.coordinates
120
+ };
121
+ attributes.filter(function (attribute) {
122
+ return attribute.scale !== undefined;
123
+ }).forEach(function (attribute) {
124
+ var values = applyAttributeMapping(attribute, record, minimumColor);
125
+ attribute.needRemapping = false;
126
+
127
+ if (attribute.name === 'color') {
128
+ values = values.map(function (c) {
129
+ return (0, _l7Utils.rgb2arr)(c);
130
+ });
131
+ }
132
+
133
+ encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values;
134
+
135
+ if (attribute.name === 'shape') {
136
+ encodeRecord.shape = fontService.getIconFontKey(encodeRecord[attribute.name]);
137
+ }
138
+ });
139
+
140
+ if (encodeRecord.shape === 'line' && arrow.enable) {
141
+ var coords = encodeRecord.coordinates;
142
+ var arrowPoint = getArrowPoints(coords[0], coords[1]);
143
+ encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
144
+ }
145
+
146
+ return encodeRecord;
147
+ });
148
+ adjustData2Amap2Coordinates(mappedData, mapService);
149
+ adjustData2SimpleCoordinates(mappedData, mapService);
150
+ return mappedData;
151
+ }
152
+
153
+ function calculateData(layer, fontService, mapService, styleAttributeService, data, options) {
154
+ var source = new _l7Source.default(data, options);
155
+ var bottomColor = layer.getBottomColor();
156
+ var attributes = styleAttributeService.getLayerStyleAttributes() || [];
157
+ var dataArray = source.data.dataArray;
158
+ var filterData = dataArray;
159
+ var mappedEncodeData = mapping(attributes, filterData, fontService, mapService, bottomColor, layer);
160
+ source.destroy();
161
+ return mappedEncodeData;
162
+ }
163
+ //# sourceMappingURL=layerData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/layerData.ts"],"names":["getArrowPoints","p1","p2","dir","normalizeDir","arrowPoint","adjustData2Amap2Coordinates","mappedData","mapService","length","version","Version","coordinates","filter","d","originCoordinates","map","cloneDeep","lngLatToCoord","lngLatToCoords","adjustData2SimpleCoordinates","SIMPLE","simpleCoordinate","unProjectCoordinates","simpleMapCoord","unproject","Array","coords","coord","c1","co","push","applyAttributeMapping","attribute","record","minimumColor","scale","scalers","params","forEach","field","hasOwnProperty","type","mappingResult","mapping","name","attributes","data","fontService","layer","getLayerConfig","arrow","enable","encodeRecord","id","_id","undefined","values","needRemapping","c","isArray","shape","getIconFontKey","splice","calculateData","styleAttributeService","options","source","Source","bottomColor","getBottomColor","getLayerStyleAttributes","dataArray","filterData","mappedEncodeData","destroy"],"mappings":";;;;;;;;;AAWA;;AACA;;AACA;;AAGA,SAASA,cAAT,CAAwBC,EAAxB,EAAsCC,EAAtC,EAAoD;AAClD,MAAMC,GAAG,GAAG,CAACD,EAAE,CAAC,CAAD,CAAF,GAAQD,EAAE,CAAC,CAAD,CAAX,EAAgBC,EAAE,CAAC,CAAD,CAAF,GAAQD,EAAE,CAAC,CAAD,CAA1B,CAAZ;AACA,MAAMG,YAAY,GAAG,wBAAUD,GAAV,CAArB;AACA,MAAME,U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AU,GAAGL,cAAc,CAAC2B,MAAM,CAAC,CAAD,CAAP,EAAYA,MAAM,CAAC,CAAD,CAAlB,CAAjC;AACA0B,MAAAA,YAAY,CAACzC,WAAb,CAAyBmD,MAAzB,CAAgC,CAAhC,EAAmC,CAAnC,EAAsC1D,UAAtC,EAAkDA,UAAlD;AACD;;AACD,WAAOgD,YAAP;AACD,GAtCkB,CAAnB;AAwCA/C,EAAAA,2BAA2B,CAACC,UAAD,EAAaC,UAAb,CAA3B;AAGAY,EAAAA,4BAA4B,CAACb,UAAD,EAAaC,UAAb,CAA5B;AAEA,SAAOD,UAAP;AACD;;AAEM,SAASyD,aAAT,CACLf,KADK,EAELD,WAFK,EAGLxC,UAHK,EAILyD,qBAJK,EAKLlB,IALK,EAMLmB,OANK,EAOa;AAClB,MAAMC,MAAM,GAAG,IAAIC,iBAAJ,CAAWrB,IAAX,EAAiBmB,OAAjB,CAAf;AACA,MAAMG,WAAW,GAAGpB,KAAK,CAACqB,cAAN,EAApB;AACA,MAAMxB,UAAU,GAAGmB,qBAAqB,CAACM,uBAAtB,MAAmD,EAAtE;AACA,MAAQC,SAAR,GAAsBL,MAAM,CAACpB,IAA7B,CAAQyB,SAAR;AACA,MAAMC,UAAU,GAAGD,SAAnB;AAEA,MAAME,gBAAgB,GAAG9B,OAAO,CAC9BE,UAD8B,EAE9B2B,UAF8B,EAG9BzB,WAH8B,EAI9BxC,UAJ8B,EAK9B6D,WAL8B,EAM9BpB,KAN8B,CAAhC;AAQAkB,EAAAA,MAAM,CAACQ,OAAP;AACA,SAAOD,gBAAP;AACD","sourcesContent":["import {\n IEncodeFeature,\n IFontService,\n ILayer,\n IMapService,\n IParseDataItem,\n ISourceCFG,\n IStyleAttribute,\n IStyleAttributeService,\n Position,\n} from '@antv/l7-core';\nimport { Version } from '@antv/l7-maps';\nimport Source from '@antv/l7-source';\nimport { isColor, normalize, rgb2arr } from '@antv/l7-utils';\nimport { ILineLayerStyleOptions } from '../core/interface';\n\nfunction getArrowPoints(p1: Position, p2: Position) {\n const dir = [p2[0] - p1[0], p2[1] - p1[1]];\n const normalizeDir = normalize(dir);\n const arrowPoint = [\n p1[0] + normalizeDir[0] * 0.0001,\n p1[1] + normalizeDir[1] * 0.0001,\n ];\n return arrowPoint;\n}\n\nfunction adjustData2Amap2Coordinates(\n mappedData: IEncodeFeature[],\n mapService: IMapService,\n) {\n // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移\n if (mappedData.length > 0 && mapService.version === Version['GAODE2.x']) {\n if (typeof mappedData[0].coordinates[0] === 'number') {\n // 单个的点数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n d.coordinates = this.mapService.lngLatToCoord(d.coordinates);\n });\n } else {\n // 连续的线、面数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.version = Version['GAODE2.x'];\n // @ts-ignore\n d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)\n // @ts-ignore\n d.coordinates = this.mapService.lngLatToCoords(d.coordinates);\n });\n }\n }\n}\n\nfunction adjustData2SimpleCoordinates(\n mappedData: IEncodeFeature[],\n mapService: IMapService,\n) {\n if (mappedData.length > 0 && mapService.version === Version.SIMPLE) {\n mappedData.map((d) => {\n if (!d.simpleCoordinate) {\n d.coordinates = unProjectCoordinates(d.coordinates, mapService);\n d.simpleCoordinate = true;\n }\n });\n }\n}\n\nfunction unProjectCoordinates(coordinates: any, mapService: IMapService) {\n if (typeof coordinates[0] === 'number') {\n return mapService.simpleMapCoord.unproject(coordinates as [number, number]);\n }\n\n if (coordinates[0] && coordinates[0][0] instanceof Array) {\n // @ts-ignore\n const coords = [];\n coordinates.map((coord: any) => {\n // @ts-ignore\n const c1 = [];\n coord.map((co: any) => {\n c1.push(mapService.simpleMapCoord.unproject(co as [number, number]));\n });\n // @ts-ignore\n coords.push(c1);\n });\n // @ts-ignore\n return coords;\n } else {\n // @ts-ignore\n const coords = [];\n // @ts-ignore\n coordinates.map((coord) => {\n coords.push(\n mapService.simpleMapCoord.unproject(coord as [number, number]),\n );\n });\n // @ts-ignore\n return coords;\n }\n}\n\nfunction applyAttributeMapping(\n attribute: IStyleAttribute,\n record: { [key: string]: unknown },\n minimumColor?: string,\n) {\n if (!attribute.scale) {\n return [];\n }\n const scalers = attribute?.scale?.scalers || [];\n const params: unknown[] = [];\n\n scalers.forEach(({ field }) => {\n if (record.hasOwnProperty(field) || attribute.scale?.type === 'variable') {\n // TODO:多字段,常量\n params.push(record[field]);\n }\n });\n\n const mappingResult = attribute.mapping ? attribute.mapping(params) : [];\n if (attribute.name === 'color' && !isColor(mappingResult[0])) {\n return [minimumColor];\n }\n return mappingResult;\n}\n\nfunction mapping(\n attributes: IStyleAttribute[],\n data: IParseDataItem[],\n fontService: IFontService,\n mapService: IMapService,\n minimumColor?: string,\n layer?: ILayer,\n): IEncodeFeature[] {\n const {\n arrow = {\n enable: false,\n },\n } = layer?.getLayerConfig() as ILineLayerStyleOptions;\n const mappedData = data.map((record: IParseDataItem) => {\n const encodeRecord: IEncodeFeature = {\n id: record._id,\n coordinates: record.coordinates,\n };\n\n attributes\n .filter((attribute) => attribute.scale !== undefined)\n .forEach((attribute: IStyleAttribute) => {\n let values = applyAttributeMapping(attribute, record, minimumColor);\n\n attribute.needRemapping = false;\n\n // TODO: 支持每个属性配置 postprocess\n if (attribute.name === 'color') {\n values = values.map((c: unknown) => {\n return rgb2arr(c as string);\n });\n }\n // @ts-ignore\n encodeRecord[attribute.name] =\n Array.isArray(values) && values.length === 1 ? values[0] : values;\n\n // 增加对 layer/text/iconfont unicode 映射的解析\n if (attribute.name === 'shape') {\n encodeRecord.shape = fontService.getIconFontKey(\n encodeRecord[attribute.name] as string,\n );\n }\n });\n\n if (encodeRecord.shape === 'line' && arrow.enable) {\n // 只有在线图层且支持配置箭头的时候进行插入顶点的处理\n const coords = encodeRecord.coordinates as Position[];\n const arrowPoint = getArrowPoints(coords[0], coords[1]);\n encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);\n }\n return encodeRecord;\n }) as IEncodeFeature[];\n // 调整数据兼容 Amap2.0\n adjustData2Amap2Coordinates(mappedData, mapService);\n\n // 调整数据兼容 SimpleCoordinates\n adjustData2SimpleCoordinates(mappedData, mapService);\n\n return mappedData;\n}\n\nexport function calculateData(\n layer: ILayer,\n fontService: IFontService,\n mapService: IMapService,\n styleAttributeService: IStyleAttributeService,\n data: any,\n options: ISourceCFG | undefined,\n): IEncodeFeature[] {\n const source = new Source(data, options);\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const { dataArray } = source.data;\n const filterData = dataArray;\n\n const mappedEncodeData = mapping(\n attributes,\n filterData,\n fontService,\n mapService,\n bottomColor,\n layer,\n );\n source.destroy();\n return mappedEncodeData;\n}\n"],"file":"layerData.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-layers",
3
- "version": "2.8.32",
3
+ "version": "2.8.35",
4
4
  "description": "L7's collection of built-in layers",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -24,9 +24,9 @@
24
24
  "license": "ISC",
25
25
  "dependencies": {
26
26
  "@antv/geo-coord": "^1.0.8",
27
- "@antv/l7-core": "^2.8.32",
28
- "@antv/l7-source": "^2.8.32",
29
- "@antv/l7-utils": "^2.8.32",
27
+ "@antv/l7-core": "^2.8.35",
28
+ "@antv/l7-source": "^2.8.35",
29
+ "@antv/l7-utils": "^2.8.35",
30
30
  "@babel/runtime": "^7.7.7",
31
31
  "@mapbox/martini": "^0.2.0",
32
32
  "@turf/meta": "^6.0.2",
@@ -52,7 +52,7 @@
52
52
  "@types/gl-matrix": "^2.4.5",
53
53
  "@types/lodash": "^4.14.138"
54
54
  },
55
- "gitHead": "346a79a5ff4642ee87fe7f89694748b88718dae1",
55
+ "gitHead": "c1e1bb8c13c67c68ead38f722871a47440b13b4e",
56
56
  "publishConfig": {
57
57
  "access": "public"
58
58
  }