@antv/l7-layers 2.8.32 → 2.8.33

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 (36) hide show
  1. package/es/Geometry/models/plane.d.ts +13 -11
  2. package/es/Geometry/models/plane.js +134 -110
  3. package/es/Geometry/models/plane.js.map +1 -1
  4. package/es/canvas/models/canvas.js +5 -3
  5. package/es/canvas/models/canvas.js.map +1 -1
  6. package/es/core/BaseLayer.d.ts +5 -1
  7. package/es/core/BaseLayer.js +47 -0
  8. package/es/core/BaseLayer.js.map +1 -1
  9. package/es/line/models/line.js +1 -0
  10. package/es/line/models/line.js.map +1 -1
  11. package/es/point/models/fill.js +1 -0
  12. package/es/point/models/fill.js.map +1 -1
  13. package/es/point/models/simplePoint.js +1 -0
  14. package/es/point/models/simplePoint.js.map +1 -1
  15. package/es/polygon/models/fill.js +1 -0
  16. package/es/polygon/models/fill.js.map +1 -1
  17. package/es/utils/layerData.d.ts +2 -0
  18. package/es/utils/layerData.js +152 -0
  19. package/es/utils/layerData.js.map +1 -0
  20. package/lib/Geometry/models/plane.js +133 -108
  21. package/lib/Geometry/models/plane.js.map +1 -1
  22. package/lib/canvas/models/canvas.js +5 -3
  23. package/lib/canvas/models/canvas.js.map +1 -1
  24. package/lib/core/BaseLayer.js +47 -0
  25. package/lib/core/BaseLayer.js.map +1 -1
  26. package/lib/line/models/line.js +1 -0
  27. package/lib/line/models/line.js.map +1 -1
  28. package/lib/point/models/fill.js +1 -0
  29. package/lib/point/models/fill.js.map +1 -1
  30. package/lib/point/models/simplePoint.js +1 -0
  31. package/lib/point/models/simplePoint.js.map +1 -1
  32. package/lib/polygon/models/fill.js +1 -0
  33. package/lib/polygon/models/fill.js.map +1 -1
  34. package/lib/utils/layerData.js +163 -0
  35. package/lib/utils/layerData.js.map +1 -0
  36. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/point/models/simplePoint.ts"],"names":["AttributeType","BlendType","gl","getMask","BaseModel","PointTriangulation","feature","coordinates","vertices","indices","size","length","SimplePointModel","blend","layer","getLayerConfig","opacity","offsets","strokeOpacity","strokeWidth","stroke","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_additive","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_offsets","isOffsetStatic","u_stroke_opacity","u_stroke_width","u_stroke_color","getStrokeColor","buildModels","mask","maskInside","buildLayerModel","moduleName","vertexShader","simplePointVert","fragmentShader","simplePointFrag","triangulation","depth","enable","primitive","POINTS","getBlend","stencil","destroy","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","update","featureIdx","vertex","attributeIdx","Array","isArray","additive"],"mappings":";;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,SAFF,EAGEC,EAHF,QAOO,eAPP;AASA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;;;AAMA,OAAO,SAASC,kBAAT,CAA4BC,OAA5B,EAAqD;AAC1D,MAAMC,WAAW,GAAGD,OAAO,CAACC,WAA5B;AACA,SAAO;AACLC,IAAAA,QAAQ,qBAAMD,WAAN,CADH;AAELE,IAAAA,OAAO,EAAE,CAAC,CAAD,CAFJ;AAGLC,IAAAA,IAAI,EAAEH,WAAW,CAACI;AAHb,GAAP;AAKD;;IAEoBC,gB;;;;;;;;;;;;;WACnB,2BAA2D;AACzD,aAAO;AACLC,QAAAA,KAAK,EAAE;AADF,OAAP;AAGD;;;WACD,wBAAqC;AACnC,iBAOI,KAAKC,KAAL,CAAWC,cAAX,EAPJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,8BAEEC,OAFF;AAAA,UAEEA,OAFF,6BAEY,CAAC,CAAD,EAAI,CAAJ,CAFZ;AAAA,UAG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AAAA,KAAK,EAAE,KAAKoD,QAAL,EAPkB;AAQzBC,QAAAA,OAAO,EAAE/D,OAAO,CAACiD,IAAD,EAAOC,UAAP;AARS,OAA3B,CADK,CAAP;AAYD;;;WAED,uBAAqB;AAAA;;AACnB,gCAAKpB,WAAL,wEAAkBkC,OAAlB;AACD;;;WAED,qCAAsC;AAEpC,WAAKC,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,MAD0C;AAEhDhC,QAAAA,IAAI,EAAEtC,aAAa,CAACuE,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVF,UAAAA,IAAI,EAAE,QADI;AAEVG,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAExE,EAAE,CAACyE,YAFJ;AAGN9C,YAAAA,IAAI,EAAE,EAHA;AAINS,YAAAA,IAAI,EAAEpC,EAAE,CAACqC;AAJH,WAFE;AAQV7B,UAAAA,IAAI,EAAE,CARI;AASVkE,UAAAA,MAAM,EAAE,gBACNtE,OADM,EAENuE,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gCAAqBzE,OAArB,CAAQI,IAAR;AAAA,gBAAQA,IAAR,8BAAe,CAAf;AACA,mBAAOsE,KAAK,CAACC,OAAN,CAAcvE,IAAd,IAAsB,CAACA,IAAI,CAAC,CAAD,CAAL,CAAtB,GAAkC,CAACA,IAAD,CAAzC;AACD;AAjBS;AAHoC,OAAlD;AAuBD;;;WAED,+BAAgE;AAC9D,aAAO;AACLG,QAAAA,KAAK,EAAEZ,SAAS,CAACiF;AADZ,OAAP;AAGD;;;;EAhI2C9E,S;;SAAzBQ,gB","sourcesContent":["import {\n AttributeType,\n BlendType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\n\nimport { getMask } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\n\nimport simplePointFrag from '../shaders/simplePoint_frag.glsl';\nimport simplePointVert from '../shaders/simplePoint_vert.glsl';\n\nexport function PointTriangulation(feature: IEncodeFeature) {\n const coordinates = feature.coordinates as number[];\n return {\n vertices: [...coordinates],\n indices: [0],\n size: coordinates.length,\n };\n}\n\nexport default class SimplePointModel extends BaseModel {\n public getDefaultStyle(): Partial<IPointLayerStyleOptions> {\n return {\n blend: 'additive',\n };\n }\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n offsets = [0, 0],\n blend,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = '#fff',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n offsets,\n });\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_additive: blend === 'additive' ? 1.0 : 0.0,\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n u_stroke_opacity: isNumber(strokeOpacity) ? strokeOpacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 0.0,\n u_stroke_color: this.getStrokeColor(stroke),\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'simplepoint',\n vertexShader: simplePointVert,\n fragmentShader: simplePointFrag,\n triangulation: PointTriangulation,\n depth: { enable: false },\n primitive: gl.POINTS,\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n }\n\n private defaultStyleOptions(): Partial<IPointLayerStyleOptions> {\n return {\n blend: BlendType.additive,\n };\n }\n}\n"],"file":"simplePoint.js"}
1
+ {"version":3,"sources":["../../../src/point/models/simplePoint.ts"],"names":["AttributeType","BlendType","gl","getMask","BaseModel","PointTriangulation","feature","coordinates","vertices","indices","size","length","SimplePointModel","blend","layer","getLayerConfig","opacity","offsets","strokeOpacity","strokeWidth","stroke","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_additive","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_offsets","isOffsetStatic","u_stroke_opacity","u_stroke_width","u_stroke_color","getStrokeColor","buildModels","mask","maskInside","triangulation","buildLayerModel","moduleName","vertexShader","simplePointVert","fragmentShader","simplePointFrag","depth","enable","primitive","POINTS","getBlend","stencil","destroy","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","update","featureIdx","vertex","attributeIdx","Array","isArray","additive"],"mappings":";;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,SAFF,EAGEC,EAHF,QAOO,eAPP;AASA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;;;AAMA,OAAO,SAASC,kBAAT,CAA4BC,OAA5B,EAAqD;AAC1D,MAAMC,WAAW,GAAGD,OAAO,CAACC,WAA5B;AACA,SAAO;AACLC,IAAAA,QAAQ,qBAAMD,WAAN,CADH;AAELE,IAAAA,OAAO,EAAE,CAAC,CAAD,CAFJ;AAGLC,IAAAA,IAAI,EAAEH,WAAW,CAACI;AAHb,GAAP;AAKD;;IAEoBC,gB;;;;;;;;;;;;;WACnB,2BAA2D;AACzD,aAAO;AACLC,QAAAA,KAAK,EAAE;AADF,OAAP;AAGD;;;WACD,wBAAqC;AACnC,iBAOI,KAAKC,KAAL,CAAWC,cAAX,EAPJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,8BAEEC,OAFF;AAAA,UAEEA,OAFF,6BAEY,CAAC,CAAD,EAAI,CAAJ,CAFZ;AAAA,UAGEJ,KAHF,QAGEA,KAHF;AAAA,oCAIEK,aAJF;AAAA,UAIEA,aAJF,mCAIkB,CAJlB;AAAA,kCAKEC,WALF;AAAA,UAKEA,WALF,iCAKgB,CALhB;AAAA,6BAMEC,MANF;AAAA,UAMEA,MANF,4BAMW,MANX;;AASA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBN,QAAAA,OAAO,EAAPA,OADyB;AAEzBC,QAAAA,OAAO,EAAPA;AAFyB,OAA3B,CAFF,EAME;AAEA,aAAKM,oBAAL,CAA0B;AACxBP,UAAAA,OAAO,EAAPA,OADwB;AAExBC,UAAAA,OAAO,EAAPA;AAFwB,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U,EAAE;AACVF,UAAAA,IAAI,EAAE,QADI;AAEVG,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAExE,EAAE,CAACyE,YAFJ;AAGN9C,YAAAA,IAAI,EAAE,EAHA;AAINS,YAAAA,IAAI,EAAEpC,EAAE,CAACqC;AAJH,WAFE;AAQV7B,UAAAA,IAAI,EAAE,CARI;AASVkE,UAAAA,MAAM,EAAE,gBACNtE,OADM,EAENuE,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gCAAqBzE,OAArB,CAAQI,IAAR;AAAA,gBAAQA,IAAR,8BAAe,CAAf;AACA,mBAAOsE,KAAK,CAACC,OAAN,CAAcvE,IAAd,IAAsB,CAACA,IAAI,CAAC,CAAD,CAAL,CAAtB,GAAkC,CAACA,IAAD,CAAzC;AACD;AAjBS;AAHoC,OAAlD;AAuBD;;;WAED,+BAAgE;AAC9D,aAAO;AACLG,QAAAA,KAAK,EAAEZ,SAAS,CAACiF;AADZ,OAAP;AAGD;;;;EAjI2C9E,S;;SAAzBQ,gB","sourcesContent":["import {\n AttributeType,\n BlendType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\n\nimport { getMask } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\n\nimport simplePointFrag from '../shaders/simplePoint_frag.glsl';\nimport simplePointVert from '../shaders/simplePoint_vert.glsl';\n\nexport function PointTriangulation(feature: IEncodeFeature) {\n const coordinates = feature.coordinates as number[];\n return {\n vertices: [...coordinates],\n indices: [0],\n size: coordinates.length,\n };\n}\n\nexport default class SimplePointModel extends BaseModel {\n public getDefaultStyle(): Partial<IPointLayerStyleOptions> {\n return {\n blend: 'additive',\n };\n }\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n offsets = [0, 0],\n blend,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = '#fff',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n offsets,\n });\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_additive: blend === 'additive' ? 1.0 : 0.0,\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n u_stroke_opacity: isNumber(strokeOpacity) ? strokeOpacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 0.0,\n u_stroke_color: this.getStrokeColor(stroke),\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n this.layer.triangulation = PointTriangulation;\n return [\n this.layer.buildLayerModel({\n moduleName: 'simplepoint',\n vertexShader: simplePointVert,\n fragmentShader: simplePointFrag,\n triangulation: PointTriangulation,\n depth: { enable: false },\n primitive: gl.POINTS,\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n }\n\n private defaultStyleOptions(): Partial<IPointLayerStyleOptions> {\n return {\n blend: BlendType.additive,\n };\n }\n}\n"],"file":"simplePoint.js"}
@@ -102,6 +102,7 @@ var FillModel = function (_BaseModel) {
102
102
  _ref2$maskInside = _ref2.maskInside,
103
103
  maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
104
104
 
105
+ this.layer.triangulation = opacityLinear.enable ? polygonTriangulationWithCenter : polygonTriangulation;
105
106
  return [this.layer.buildLayerModel({
106
107
  moduleName: 'polygon',
107
108
  vertexShader: opacityLinear.enable ? polygon_linear_vert : polygon_vert,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/polygon/models/fill.ts"],"names":["AttributeType","gl","getMask","BaseModel","polygonTriangulation","polygonTriangulationWithCenter","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","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","blend","getBlend","depth","cull","face","BACK","stencil","destroy","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","STATI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VC,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;;;;EA7HoCvE,S;;SAAlBG,S","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":["AttributeType","gl","getMask","BaseModel","polygonTriangulation","polygonTriangulationWithCenter","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","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_raisingHeight","Number","u_opacity","u_opacitylinear","u_dir","buildModels","mask","maskInside","triangulation","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","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","normal"],"mappings":";;;;;;;;;;;AAAA,SAASA,aAAT,EAAwBC,EAAxB,QAA0D,eAA1D;AACA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SACEC,oBADF,EAEEC,8BAFF,QAGO,0BAHP;;;;;;IAQqBC,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,iCAAgC,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AA,sCACEG,aADF;AAAA,UACEA,aADF,oCACkB;AACdC,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,GAAG,EAAE;AAFS,OADlB;;AAMA,UAAIF,aAAa,CAACC,MAAlB,EAA0B;AACxB,aAAKkD,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,UAAAA,IAAI,EAAE,QAD0C;AAEhDhC,UAAAA,IAAI,EAAEhC,aAAa,CAACiE,SAF4B;AAGhDC,UAAAA,UAAU,EAAE;AACVF,YAAAA,IAAI,EAAE,UADI;AAEVG,YAAAA,MAAM,EAAE;AAENC,cAAAA,KAAK,EAAEnE,EAAE,CAACoE,WAFJ;AAGN/C,cAAAA,IAAI,EAAE,EAHA;AAINU,cAAAA,IAAI,EAAE/B,EAAE,CAACgC;AAJH,aAFE;AAQVqC,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;;;;EAhIoCvE,S;;SAAlBG,S","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,2 @@
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[];
@@ -0,0 +1,152 @@
1
+ import { Version } from '@antv/l7-maps';
2
+ import Source from '@antv/l7-source';
3
+ import { isColor, normalize, rgb2arr } from '@antv/l7-utils';
4
+
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
+
12
+ function adjustData2Amap2Coordinates(mappedData, mapService) {
13
+ var _this = this;
14
+
15
+ if (mappedData.length > 0 && mapService.version === Version['GAODE2.x']) {
16
+ if (typeof mappedData[0].coordinates[0] === 'number') {
17
+ mappedData.filter(function (d) {
18
+ return !d.originCoordinates;
19
+ }).map(function (d) {
20
+ d.version = Version['GAODE2.x'];
21
+ d.originCoordinates = cloneDeep(d.coordinates);
22
+ d.coordinates = _this.mapService.lngLatToCoord(d.coordinates);
23
+ });
24
+ } else {
25
+ mappedData.filter(function (d) {
26
+ return !d.originCoordinates;
27
+ }).map(function (d) {
28
+ d.version = Version['GAODE2.x'];
29
+ d.originCoordinates = cloneDeep(d.coordinates);
30
+ d.coordinates = _this.mapService.lngLatToCoords(d.coordinates);
31
+ });
32
+ }
33
+ }
34
+ }
35
+
36
+ function adjustData2SimpleCoordinates(mappedData, mapService) {
37
+ if (mappedData.length > 0 && mapService.version === Version.SIMPLE) {
38
+ mappedData.map(function (d) {
39
+ if (!d.simpleCoordinate) {
40
+ d.coordinates = unProjectCoordinates(d.coordinates, mapService);
41
+ d.simpleCoordinate = true;
42
+ }
43
+ });
44
+ }
45
+ }
46
+
47
+ function unProjectCoordinates(coordinates, mapService) {
48
+ if (typeof coordinates[0] === 'number') {
49
+ return mapService.simpleMapCoord.unproject(coordinates);
50
+ }
51
+
52
+ if (coordinates[0] && coordinates[0][0] instanceof Array) {
53
+ var coords = [];
54
+ coordinates.map(function (coord) {
55
+ var c1 = [];
56
+ coord.map(function (co) {
57
+ c1.push(mapService.simpleMapCoord.unproject(co));
58
+ });
59
+ coords.push(c1);
60
+ });
61
+ return coords;
62
+ } else {
63
+ var _coords = [];
64
+ coordinates.map(function (coord) {
65
+ _coords.push(mapService.simpleMapCoord.unproject(coord));
66
+ });
67
+ return _coords;
68
+ }
69
+ }
70
+
71
+ function applyAttributeMapping(attribute, record, minimumColor) {
72
+ var _attribute$scale;
73
+
74
+ if (!attribute.scale) {
75
+ return [];
76
+ }
77
+
78
+ var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
79
+ var params = [];
80
+ scalers.forEach(function (_ref) {
81
+ var _attribute$scale2;
82
+
83
+ var field = _ref.field;
84
+
85
+ if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
86
+ params.push(record[field]);
87
+ }
88
+ });
89
+ var mappingResult = attribute.mapping ? attribute.mapping(params) : [];
90
+
91
+ if (attribute.name === 'color' && !isColor(mappingResult[0])) {
92
+ return [minimumColor];
93
+ }
94
+
95
+ return mappingResult;
96
+ }
97
+
98
+ function mapping(attributes, data, fontService, mapService, minimumColor, layer) {
99
+ var _ref2 = layer === null || layer === void 0 ? void 0 : layer.getLayerConfig(),
100
+ _ref2$arrow = _ref2.arrow,
101
+ arrow = _ref2$arrow === void 0 ? {
102
+ enable: false
103
+ } : _ref2$arrow;
104
+
105
+ var mappedData = data.map(function (record) {
106
+ var encodeRecord = {
107
+ id: record._id,
108
+ coordinates: record.coordinates
109
+ };
110
+ attributes.filter(function (attribute) {
111
+ return attribute.scale !== undefined;
112
+ }).forEach(function (attribute) {
113
+ var values = applyAttributeMapping(attribute, record, minimumColor);
114
+ attribute.needRemapping = false;
115
+
116
+ if (attribute.name === 'color') {
117
+ values = values.map(function (c) {
118
+ return rgb2arr(c);
119
+ });
120
+ }
121
+
122
+ encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values;
123
+
124
+ if (attribute.name === 'shape') {
125
+ encodeRecord.shape = fontService.getIconFontKey(encodeRecord[attribute.name]);
126
+ }
127
+ });
128
+
129
+ if (encodeRecord.shape === 'line' && arrow.enable) {
130
+ var coords = encodeRecord.coordinates;
131
+ var arrowPoint = getArrowPoints(coords[0], coords[1]);
132
+ encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
133
+ }
134
+
135
+ return encodeRecord;
136
+ });
137
+ adjustData2Amap2Coordinates(mappedData, mapService);
138
+ adjustData2SimpleCoordinates(mappedData, mapService);
139
+ return mappedData;
140
+ }
141
+
142
+ export function calculateData(layer, fontService, mapService, styleAttributeService, data, options) {
143
+ var source = new Source(data, options);
144
+ var bottomColor = layer.getBottomColor();
145
+ var attributes = styleAttributeService.getLayerStyleAttributes() || [];
146
+ var dataArray = source.data.dataArray;
147
+ var filterData = dataArray;
148
+ var mappedEncodeData = mapping(attributes, filterData, fontService, mapService, bottomColor, layer);
149
+ source.destroy();
150
+ return mappedEncodeData;
151
+ }
152
+ //# sourceMappingURL=layerData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/layerData.ts"],"names":["Version","Source","isColor","normalize","rgb2arr","getArrowPoints","p1","p2","dir","normalizeDir","arrowPoint","adjustData2Amap2Coordinates","mappedData","mapService","length","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","bottomColor","getBottomColor","getLayerStyleAttributes","dataArray","filterData","mappedEncodeData","destroy"],"mappings":"AAWA,SAASA,OAAT,QAAwB,eAAxB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,SAASC,OAAT,EAAkBC,SAAlB,EAA6BC,OAA7B,QAA4C,gBAA5C;;AAGA,SAASC,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,GAAGN,SAAS,CAACK,GAAD,CAA9B;AACA,MAAME,UAAU,GAAG,CACjBJ,EAAE,CAAC,CAAD,CAAF,GAAQG,YAAY,CAAC,CAAD,CAAZ,GAAkB,MADT,EAEjBH,EAAE,C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,CAAlB,CAAjC;AACA0B,MAAAA,YAAY,CAACzC,WAAb,CAAyBmD,MAAzB,CAAgC,CAAhC,EAAmC,CAAnC,EAAsCzD,UAAtC,EAAkDA,UAAlD;AACD;;AACD,WAAO+C,YAAP;AACD,GAtCkB,CAAnB;AAwCA9C,EAAAA,2BAA2B,CAACC,UAAD,EAAaC,UAAb,CAA3B;AAGAW,EAAAA,4BAA4B,CAACZ,UAAD,EAAaC,UAAb,CAA5B;AAEA,SAAOD,UAAP;AACD;;AAED,OAAO,SAASwD,aAAT,CACLf,KADK,EAELD,WAFK,EAGLvC,UAHK,EAILwD,qBAJK,EAKLlB,IALK,EAMLmB,OANK,EAOa;AAClB,MAAMC,MAAM,GAAG,IAAItE,MAAJ,CAAWkD,IAAX,EAAiBmB,OAAjB,CAAf;AACA,MAAME,WAAW,GAAGnB,KAAK,CAACoB,cAAN,EAApB;AACA,MAAMvB,UAAU,GAAGmB,qBAAqB,CAACK,uBAAtB,MAAmD,EAAtE;AACA,MAAQC,SAAR,GAAsBJ,MAAM,CAACpB,IAA7B,CAAQwB,SAAR;AACA,MAAMC,UAAU,GAAGD,SAAnB;AAEA,MAAME,gBAAgB,GAAG7B,OAAO,CAC9BE,UAD8B,EAE9B0B,UAF8B,EAG9BxB,WAH8B,EAI9BvC,UAJ8B,EAK9B2D,WAL8B,EAM9BnB,KAN8B,CAAhC;AAQAkB,EAAAA,MAAM,CAACO,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"}
@@ -56,9 +56,9 @@ var PlaneModel = function (_BaseModel) {
56
56
 
57
57
  _this = _super.call.apply(_super, [this].concat(args));
58
58
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "texture", void 0);
59
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "terrainImage", void 0);
60
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "terrainImageLoaded", false);
59
61
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "mapTexture", void 0);
60
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "positions", void 0);
61
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "indices", void 0);
62
62
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "planeGeometryTriangulation", function () {
63
63
  var _this2;
64
64
 
@@ -79,11 +79,8 @@ var PlaneModel = function (_BaseModel) {
79
79
  indices = _this$initPlane.indices,
80
80
  positions = _this$initPlane.positions;
81
81
 
82
- _this.positions = positions;
83
- _this.indices = indices;
84
-
85
82
  if (terrainTexture) {
86
- _this.loadTerrainTexture();
83
+ _this.loadTerrainTexture(positions, indices);
87
84
  }
88
85
 
89
86
  return {
@@ -92,13 +89,6 @@ var PlaneModel = function (_BaseModel) {
92
89
  size: 5
93
90
  };
94
91
  });
95
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "planeGeometryUpdateTriangulation", function () {
96
- return {
97
- vertices: _this.positions,
98
- indices: _this.indices,
99
- size: 5
100
- };
101
- });
102
92
  return _this;
103
93
  }
104
94
 
@@ -132,9 +122,9 @@ var PlaneModel = function (_BaseModel) {
132
122
  var _ref2 = this.mapService.lngLatToCoord([x + lng, -y + lat]),
133
123
  _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
134
124
  a = _ref3[0],
135
- b = _ref3[1];
125
+ _b = _ref3[1];
136
126
 
137
- positions.push(a, b, 0);
127
+ positions.push(a, _b, 0);
138
128
  } else {
139
129
  positions.push(x + lng, -y + lat, 0);
140
130
  }
@@ -148,12 +138,12 @@ var PlaneModel = function (_BaseModel) {
148
138
  for (var _ix = 0; _ix < gridX; _ix++) {
149
139
  var _a = _ix + gridX1 * _iy;
150
140
 
151
- var _b = _ix + gridX1 * (_iy + 1);
141
+ var _b2 = _ix + gridX1 * (_iy + 1);
152
142
 
153
143
  var c = _ix + 1 + gridX1 * (_iy + 1);
154
144
  var d = _ix + 1 + gridX1 * _iy;
155
- indices.push(_a, _b, d);
156
- indices.push(_b, c, d);
145
+ indices.push(_a, _b2, d);
146
+ indices.push(_b2, c, d);
157
147
  }
158
148
  }
159
149
 
@@ -192,6 +182,7 @@ var PlaneModel = function (_BaseModel) {
192
182
  value: function clearModels() {
193
183
  var _this$texture2;
194
184
 
185
+ this.terrainImage = null;
195
186
  (_this$texture2 = this.texture) === null || _this$texture2 === void 0 ? void 0 : _this$texture2.destroy();
196
187
  }
197
188
  }, {
@@ -228,101 +219,42 @@ var PlaneModel = function (_BaseModel) {
228
219
  }
229
220
  })];
230
221
  }
231
- }, {
232
- key: "getImageData",
233
- value: function getImageData(img) {
234
- var canvas = document.createElement('canvas');
235
- var ctx = canvas.getContext('2d');
236
- var width = img.width,
237
- height = img.height;
238
- canvas.width = width;
239
- canvas.height = height;
240
- ctx.drawImage(img, 0, 0, width, height);
241
- var imageData = ctx.getImageData(0, 0, width, height);
242
- return imageData;
243
- }
244
- }, {
245
- key: "loadTerrainTexture",
246
- value: function loadTerrainTexture() {
247
- var _this3 = this;
248
-
249
- var _ref6 = this.layer.getLayerConfig(),
250
- _ref6$mask = _ref6.mask,
251
- mask = _ref6$mask === void 0 ? false : _ref6$mask,
252
- _ref6$maskInside = _ref6.maskInside,
253
- maskInside = _ref6$maskInside === void 0 ? true : _ref6$maskInside,
254
- _ref6$widthSegments = _ref6.widthSegments,
255
- widthSegments = _ref6$widthSegments === void 0 ? 1 : _ref6$widthSegments,
256
- _ref6$heightSegments = _ref6.heightSegments,
257
- heightSegments = _ref6$heightSegments === void 0 ? 1 : _ref6$heightSegments,
258
- terrainTexture = _ref6.terrainTexture,
259
- _ref6$rgb2height = _ref6.rgb2height,
260
- rgb2height = _ref6$rgb2height === void 0 ? function (r, g, b) {
261
- return r + g + b;
262
- } : _ref6$rgb2height;
263
-
264
- var terrainImage = new Image();
265
- terrainImage.crossOrigin = 'anonymous';
266
-
267
- terrainImage.onload = function () {
268
- var imgWidth = terrainImage.width;
269
- var imgHeight = terrainImage.height;
270
-
271
- var imageData = _this3.getImageData(terrainImage).data;
272
-
273
- var gridX = Math.floor(widthSegments);
274
- var gridY = Math.floor(heightSegments);
275
- var gridX1 = gridX + 1;
276
- var gridY1 = gridY + 1;
277
- var widthStep = imgWidth / gridX;
278
- var heihgtStep = imgHeight / gridY;
279
-
280
- for (var iy = 0; iy < gridY1; iy++) {
281
- var imgIndexY = Math.floor(iy * heihgtStep);
282
- var imgLen = imgIndexY * imgWidth;
283
-
284
- for (var ix = 0; ix < gridX1; ix++) {
285
- var imgIndexX = Math.floor(ix * widthStep);
286
- var imgDataIndex = (imgLen + imgIndexX) * 4;
287
- var r = imageData[imgDataIndex];
288
- var g = imageData[imgDataIndex + 1];
289
- var b = imageData[imgDataIndex + 2];
290
- var z = (iy * gridX1 + ix) * 5 + 2;
291
- _this3.positions[z] = rgb2height(r, g, b);
292
- }
293
- }
294
-
295
- _this3.layer.models = [_this3.layer.buildLayerModel({
296
- moduleName: 'geometry_plane',
297
- vertexShader: planeVert,
298
- fragmentShader: planeFrag,
299
- triangulation: _this3.planeGeometryUpdateTriangulation,
300
- primitive: _l7Core.gl.TRIANGLES,
301
- depth: {
302
- enable: true
303
- },
304
- blend: _this3.getBlend(),
305
- stencil: (0, _l7Utils.getMask)(mask, maskInside),
306
- cull: {
307
- enable: true,
308
- face: _l7Core.gl.BACK
309
- }
310
- })];
311
-
312
- _this3.layerService.renderLayers();
313
- };
314
-
315
- terrainImage.src = terrainTexture;
316
- }
317
222
  }, {
318
223
  key: "buildModels",
319
224
  value: function buildModels() {
320
225
  return this.initModels();
321
226
  }
227
+ }, {
228
+ key: "createModelData",
229
+ value: function createModelData(options) {
230
+ if (options) {
231
+ var _ref6 = this.layer.getLayerConfig(),
232
+ oldwidthSegments = _ref6.widthSegments,
233
+ oldheightSegments = _ref6.heightSegments,
234
+ oldwidth = _ref6.width,
235
+ oldheight = _ref6.height;
236
+
237
+ var _ref7 = options,
238
+ widthSegments = _ref7.widthSegments,
239
+ heightSegments = _ref7.heightSegments,
240
+ width = _ref7.width,
241
+ height = _ref7.height;
242
+ this.layer.style({
243
+ widthSegments: widthSegments !== undefined ? widthSegments : oldwidthSegments,
244
+ heightSegments: heightSegments !== undefined ? heightSegments : oldheightSegments,
245
+ width: width !== undefined ? width : oldwidth,
246
+ height: height !== undefined ? height : oldheight
247
+ });
248
+ }
249
+
250
+ var oldFeatures = this.layer.getEncodedData();
251
+ var res = this.styleAttributeService.createAttributesAndIndices(oldFeatures, this.planeGeometryTriangulation);
252
+ return res;
253
+ }
322
254
  }, {
323
255
  key: "updateTexture",
324
256
  value: function updateTexture(mapTexture) {
325
- var _this4 = this;
257
+ var _this3 = this;
326
258
 
327
259
  var createTexture2D = this.rendererService.createTexture2D;
328
260
 
@@ -331,7 +263,7 @@ var PlaneModel = function (_BaseModel) {
331
263
  img.crossOrigin = 'anonymous';
332
264
 
333
265
  img.onload = function () {
334
- _this4.texture = createTexture2D({
266
+ _this3.texture = createTexture2D({
335
267
  data: img,
336
268
  width: img.width,
337
269
  height: img.height,
@@ -339,9 +271,9 @@ var PlaneModel = function (_BaseModel) {
339
271
  wrapT: _l7Core.gl.CLAMP_TO_EDGE
340
272
  });
341
273
 
342
- _this4.layerService.updateLayerRenderList();
274
+ _this3.layerService.updateLayerRenderList();
343
275
 
344
- _this4.layerService.renderLayers();
276
+ _this3.layerService.renderLayers();
345
277
  };
346
278
 
347
279
  img.src = mapTexture;
@@ -352,6 +284,99 @@ var PlaneModel = function (_BaseModel) {
352
284
  });
353
285
  }
354
286
  }
287
+ }, {
288
+ key: "getImageData",
289
+ value: function getImageData(img) {
290
+ var canvas = document.createElement('canvas');
291
+ var ctx = canvas.getContext('2d');
292
+ var width = img.width,
293
+ height = img.height;
294
+ canvas.width = width;
295
+ canvas.height = height;
296
+ ctx.drawImage(img, 0, 0, width, height);
297
+ var imageData = ctx.getImageData(0, 0, width, height);
298
+ return imageData;
299
+ }
300
+ }, {
301
+ key: "translateVertex",
302
+ value: function translateVertex(positions, indices, image, widthSegments, heightSegments, rgb2height) {
303
+ var imgWidth = image.width;
304
+ var imgHeight = image.height;
305
+ var imageData = this.getImageData(image).data;
306
+ var gridX = Math.floor(widthSegments);
307
+ var gridY = Math.floor(heightSegments);
308
+ var gridX1 = gridX + 1;
309
+ var gridY1 = gridY + 1;
310
+ var widthStep = imgWidth / gridX;
311
+ var heihgtStep = imgHeight / gridY;
312
+
313
+ for (var iy = 0; iy < gridY1; iy++) {
314
+ var imgIndexY = Math.floor(iy * heihgtStep);
315
+ var imgLen = imgIndexY * imgWidth;
316
+
317
+ for (var ix = 0; ix < gridX1; ix++) {
318
+ var imgIndexX = Math.floor(ix * widthStep);
319
+ var imgDataIndex = (imgLen + imgIndexX) * 4;
320
+ var _r = imageData[imgDataIndex];
321
+ var _g = imageData[imgDataIndex + 1];
322
+ var _b3 = imageData[imgDataIndex + 2];
323
+ var z = (iy * gridX1 + ix) * 5 + 2;
324
+ positions[z] = rgb2height(_r, _g, _b3);
325
+ }
326
+ }
327
+
328
+ var oldFeatures = this.layer.getEncodedData();
329
+ var modelData = this.styleAttributeService.createAttributesAndIndices(oldFeatures, function () {
330
+ return {
331
+ vertices: positions,
332
+ indices: indices,
333
+ size: 5
334
+ };
335
+ });
336
+ this.layer.updateModelData(modelData);
337
+ this.layerService.renderLayers();
338
+ }
339
+ }, {
340
+ key: "loadTerrainTexture",
341
+ value: function loadTerrainTexture(positions, indices) {
342
+ var _this4 = this;
343
+
344
+ var _ref8 = this.layer.getLayerConfig(),
345
+ _ref8$widthSegments = _ref8.widthSegments,
346
+ widthSegments = _ref8$widthSegments === void 0 ? 1 : _ref8$widthSegments,
347
+ _ref8$heightSegments = _ref8.heightSegments,
348
+ heightSegments = _ref8$heightSegments === void 0 ? 1 : _ref8$heightSegments,
349
+ terrainTexture = _ref8.terrainTexture,
350
+ _ref8$rgb2height = _ref8.rgb2height,
351
+ rgb2height = _ref8$rgb2height === void 0 ? function (r, g, b) {
352
+ return r + g + b;
353
+ } : _ref8$rgb2height;
354
+
355
+ if (this.terrainImage) {
356
+ if (this.terrainImageLoaded) {
357
+ this.translateVertex(positions, indices, this.terrainImage, widthSegments, heightSegments, rgb2height);
358
+ } else {
359
+ this.terrainImage.onload = function () {
360
+ _this4.translateVertex(positions, indices, _this4.terrainImage, widthSegments, heightSegments, rgb2height);
361
+ };
362
+ }
363
+ } else {
364
+ var terrainImage = new Image();
365
+ this.terrainImage = terrainImage;
366
+ terrainImage.crossOrigin = 'anonymous';
367
+
368
+ terrainImage.onload = function () {
369
+ _this4.terrainImageLoaded = true;
370
+ setTimeout(function () {
371
+ return _this4.layer.emit('terrainImageLoaded', null);
372
+ });
373
+
374
+ _this4.translateVertex(positions, indices, terrainImage, widthSegments, heightSegments, rgb2height);
375
+ };
376
+
377
+ terrainImage.src = terrainTexture;
378
+ }
379
+ }
355
380
  }, {
356
381
  key: "getConfigSchema",
357
382
  value: function getConfigSchema() {