@antv/l7-layers 2.8.8 → 2.8.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/canvas/models/canvas.js +5 -5
- package/es/canvas/models/canvas.js.map +1 -1
- package/es/core/interface.d.ts +2 -4
- package/es/core/interface.js +1 -1
- package/es/core/interface.js.map +1 -1
- package/es/plugins/DataMappingPlugin.d.ts +3 -0
- package/es/plugins/DataMappingPlugin.js +52 -4
- package/es/plugins/DataMappingPlugin.js.map +1 -1
- package/es/point/models/extrude.js.map +1 -1
- package/es/point/models/fill.d.ts +2 -2
- package/es/point/models/fill.js.map +1 -1
- package/es/point/models/radar.d.ts +1 -1
- package/es/point/models/radar.js.map +1 -1
- package/lib/canvas/models/canvas.js +5 -5
- package/lib/canvas/models/canvas.js.map +1 -1
- package/lib/core/interface.js +1 -1
- package/lib/core/interface.js.map +1 -1
- package/lib/plugins/DataMappingPlugin.js +53 -4
- package/lib/plugins/DataMappingPlugin.js.map +1 -1
- package/lib/point/models/extrude.js.map +1 -1
- package/lib/point/models/fill.js.map +1 -1
- package/lib/point/models/radar.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/models/radar.ts"],"names":["AttributeType","gl","getMask","BaseModel","PointFillTriangulation","Version","RadarModel","layer","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","speed","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_isMeter","Number","isMeter","u_speed","u_additive","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_offsets","isOffsetStatic","animateOption","enable","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","styleAttributeService","createAttributesAndIndices","unit","version","mapService","L7MAP","GLOBEL","calMeter2Coord","buildModels","getSource","extent","minLng","minLat","maxLng","maxLat","center","MAPBOX","window","mapboxgl","MercatorCoordinate","coord","fromLngLat","lng","lat","offsetInMeters","offsetInMercatorCoordinateUnits","meterInMercatorCoordinateUnits","westCoord","x","y","z","westLnglat","toLngLat","meter2coord","m1","meterToCoord","m2","Boolean","mask","maskInside","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","depth","getBlend","stencil","pointFillFrag","pointFillVert","destroy","option","rings","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","extrude","extrudeIndex","Array","isArray","shape","shape2d","shapeIndex","indexOf"],"mappings":";;;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QASO,eATP;AAUA,SAASC,OAAT,QAAwB,gBAAxB;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,sBAAT,QAAuC,0BAAvC;;;AAOA,SAASC,OAAT,QAAwB,eAAxB;;IAEqBC,U;;;;;;;;;;;;;;;;kEACU,C;;8DACF,K;;;;;;;WAC3B,wBAAqC;AACnC,iBAQI,KAAKC,KAAL,CAAWC,cAAX,EARJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,oCAEEC,aAFF;AAAA,UAEEA,aAFF,mCAEkB,CAFlB;AAAA,kCAGEC,WAHF;AAAA,UAGEA,WAHF,iCAGgB,CAHhB;AAAA,6BAIEC,MAJF;AAAA,UAIEA,MAJF,4BAIW,eAJX;AAAA,8BAKEC,OALF;AAAA,UAKEA,OALF,6BAKY,CAAC,CAAD,EAAI,CAAJ,CALZ;AAAA,UAMEC,KANF,QAMEA,KANF;AAAA,4BAOEC,KAPF;AAAA,UAOEA,KAPF,2BAOU,CAPV;;AAUA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBR,QAAAA,OAAO,EAAPA,OADyB;AAEzBC,QAAAA,aAAa,EAAbA,aAFyB;AAGzB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AR;AAAA,gBAAQA,KAAR,+BAAgB,CAAhB;;AACA,gBAAMC,OAAO,GAAG,MAAI,CAACxH,KAAL,CAAWC,cAAX,GAA4BuH,OAA5C;;AACA,gBAAMC,UAAU,GAAGD,OAAO,CAACE,OAAR,CAAgBH,KAAhB,CAAnB;AACA,mBAAO,CAACE,UAAD,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;;EAzRqC7H,S;;SAAnBG,U","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IAttribute,\n IElements,\n IEncodeFeature,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointFillTriangulation } from '../../core/triangulation';\n\nimport pointFillFrag from '../shaders/radar/radar_frag.glsl';\nimport pointFillVert from '../shaders/radar/radar_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { Version } from '@antv/l7-maps';\n\nexport default class RadarModel extends BaseModel {\n public meter2coord: number = 1;\n private isMeter: boolean = false;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n speed = 1,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\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_isMeter: Number(this.isMeter),\n u_speed: speed,\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 };\n }\n public getAnimateUniforms(): IModelUniform {\n const {\n animateOption = { enable: false },\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n return {\n u_aimate: this.animateOption2Array(animateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n const {\n unit = 'l7size',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { version } = this.mapService;\n if (\n unit === 'meter' &&\n version !== Version.L7MAP &&\n version !== Version.GLOBEL\n ) {\n this.isMeter = true;\n this.calMeter2Coord();\n }\n\n return this.buildModels();\n }\n\n /**\n * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例\n * @returns\n */\n public calMeter2Coord() {\n // @ts-ignore\n const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;\n const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];\n\n const { version } = this.mapService;\n if (version === Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {\n const coord = window.mapboxgl.MercatorCoordinate.fromLngLat(\n { lng: center[0], lat: center[1] },\n 0,\n );\n const offsetInMeters = 1;\n const offsetInMercatorCoordinateUnits =\n offsetInMeters * coord.meterInMercatorCoordinateUnits();\n const westCoord = new window.mapboxgl.MercatorCoordinate(\n coord.x - offsetInMercatorCoordinateUnits,\n coord.y,\n coord.z,\n );\n const westLnglat = westCoord.toLngLat();\n\n this.meter2coord = center[0] - westLnglat.lng;\n return;\n }\n\n // @ts-ignore\n const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);\n // @ts-ignore\n const m2 = this.mapService.meterToCoord(center, [\n maxLng === minLng ? maxLng + 0.1 : maxLng,\n maxLat === minLat ? minLat + 0.1 : maxLat,\n ]);\n this.meter2coord = (m1 + m2) / 2;\n if (!Boolean(this.meter2coord)) {\n // Tip: 兼容单个数据导致的 m1、m2 为 NaN\n this.meter2coord = 7.70681090738883;\n }\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill_' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: PointFillTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据 animateOption 的值返回对应的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n return {\n frag: pointFillFrag,\n vert: pointFillVert,\n type: 'radar',\n };\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n // overwrite baseModel func\n protected animateOption2Array(option: IAnimateOption): number[] {\n return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\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: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n let extrude;\n extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\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 = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size)\n ? [size[0] * this.meter2coord]\n : [(size as number) * this.meter2coord];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'shape',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Shape',\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 { shape = 2 } = feature;\n const shape2d = this.layer.getLayerConfig().shape2d as string[];\n const shapeIndex = shape2d.indexOf(shape as string);\n return [shapeIndex];\n },\n },\n });\n }\n}\n"],"file":"radar.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/point/models/radar.ts"],"names":["AttributeType","gl","getMask","BaseModel","PointFillTriangulation","Version","RadarModel","layer","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","speed","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_isMeter","Number","isMeter","u_speed","u_additive","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_offsets","isOffsetStatic","animateOption","enable","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","styleAttributeService","createAttributesAndIndices","unit","version","mapService","L7MAP","GLOBEL","calMeter2Coord","buildModels","getSource","extent","minLng","minLat","maxLng","maxLat","center","MAPBOX","window","mapboxgl","MercatorCoordinate","coord","fromLngLat","lng","lat","offsetInMeters","offsetInMercatorCoordinateUnits","meterInMercatorCoordinateUnits","westCoord","x","y","z","westLnglat","toLngLat","meter2coord","m1","meterToCoord","m2","Boolean","mask","maskInside","getShaders","frag","vert","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","depth","getBlend","stencil","pointFillFrag","pointFillVert","destroy","option","rings","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","extrude","extrudeIndex","Array","isArray","shape","shape2d","shapeIndex","indexOf"],"mappings":";;;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAUO,eAVP;AAWA,SAASC,OAAT,QAAwB,gBAAxB;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,sBAAT,QAAuC,0BAAvC;;;AAOA,SAASC,OAAT,QAAwB,eAAxB;;IAEqBC,U;;;;;;;;;;;;;;;;kEACU,C;;8DACF,K;;;;;;;WAC3B,wBAAqC;AACnC,iBAQI,KAAKC,KAAL,CAAWC,cAAX,EARJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,oCAEEC,aAFF;AAAA,UAEEA,aAFF,mCAEkB,CAFlB;AAAA,kCAGEC,WAHF;AAAA,UAGEA,WAHF,iCAGgB,CAHhB;AAAA,6BAIEC,MAJF;AAAA,UAIEA,MAJF,4BAIW,eAJX;AAAA,8BAKEC,OALF;AAAA,UAKEA,OALF,6BAKY,CAAC,CAAD,EAAI,CA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AAA,IAAI,EAAE,EAHA;AAINU,YAAAA,IAAI,EAAEjC,EAAE,CAACkC;AAJH,WAFE;AAQViF,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,iCAAsBH,OAAtB,CAAQQ,KAAR;AAAA,gBAAQA,KAAR,+BAAgB,CAAhB;;AACA,gBAAMC,OAAO,GAAG,MAAI,CAACxH,KAAL,CAAWC,cAAX,GAA4BuH,OAA5C;;AACA,gBAAMC,UAAU,GAAGD,OAAO,CAACE,OAAR,CAAgBH,KAAhB,CAAnB;AACA,mBAAO,CAACE,UAAD,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;;EAzRqC7H,S;;SAAnBG,U","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IAttribute,\n IElements,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointFillTriangulation } from '../../core/triangulation';\n\nimport pointFillFrag from '../shaders/radar/radar_frag.glsl';\nimport pointFillVert from '../shaders/radar/radar_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { Version } from '@antv/l7-maps';\n\nexport default class RadarModel extends BaseModel {\n public meter2coord: number = 1;\n private isMeter: boolean = false;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n speed = 1,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\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_isMeter: Number(this.isMeter),\n u_speed: speed,\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 };\n }\n public getAnimateUniforms(): IModelUniform {\n const {\n animateOption = { enable: false },\n } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n const {\n unit = 'l7size',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { version } = this.mapService;\n if (\n unit === 'meter' &&\n version !== Version.L7MAP &&\n version !== Version.GLOBEL\n ) {\n this.isMeter = true;\n this.calMeter2Coord();\n }\n\n return this.buildModels();\n }\n\n /**\n * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例\n * @returns\n */\n public calMeter2Coord() {\n // @ts-ignore\n const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;\n const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];\n\n const { version } = this.mapService;\n if (version === Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {\n const coord = window.mapboxgl.MercatorCoordinate.fromLngLat(\n { lng: center[0], lat: center[1] },\n 0,\n );\n const offsetInMeters = 1;\n const offsetInMercatorCoordinateUnits =\n offsetInMeters * coord.meterInMercatorCoordinateUnits();\n const westCoord = new window.mapboxgl.MercatorCoordinate(\n coord.x - offsetInMercatorCoordinateUnits,\n coord.y,\n coord.z,\n );\n const westLnglat = westCoord.toLngLat();\n\n this.meter2coord = center[0] - westLnglat.lng;\n return;\n }\n\n // @ts-ignore\n const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);\n // @ts-ignore\n const m2 = this.mapService.meterToCoord(center, [\n maxLng === minLng ? maxLng + 0.1 : maxLng,\n maxLat === minLat ? minLat + 0.1 : maxLat,\n ]);\n this.meter2coord = (m1 + m2) / 2;\n if (!Boolean(this.meter2coord)) {\n // Tip: 兼容单个数据导致的 m1、m2 为 NaN\n this.meter2coord = 7.70681090738883;\n }\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { frag, vert, type } = this.getShaders();\n\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill_' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: PointFillTriangulation,\n depth: { enable: false },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据 animateOption 的值返回对应的 shader 代码\n * @returns\n */\n public getShaders(): { frag: string; vert: string; type: string } {\n return {\n frag: pointFillFrag,\n vert: pointFillVert,\n type: 'radar',\n };\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n // overwrite baseModel func\n protected animateOption2Array(option: Partial<IAnimateOption>): number[] {\n return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\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: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n let extrude;\n extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\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 = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size)\n ? [size[0] * this.meter2coord]\n : [(size as number) * this.meter2coord];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'shape',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Shape',\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 { shape = 2 } = feature;\n const shape2d = this.layer.getLayerConfig().shape2d as string[];\n const shapeIndex = shape2d.indexOf(shape as string);\n return [shapeIndex];\n },\n },\n });\n }\n}\n"],"file":"radar.js"}
|
|
@@ -46,7 +46,7 @@ var CanvaModel = function (_BaseModel) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
49
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateMode", _interface.CanvasUpdateType.
|
|
49
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateMode", _interface.CanvasUpdateType.ALWAYS);
|
|
50
50
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "canvas", void 0);
|
|
51
51
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "ctx", void 0);
|
|
52
52
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "prevSize", void 0);
|
|
@@ -55,7 +55,7 @@ var CanvaModel = function (_BaseModel) {
|
|
|
55
55
|
_ref$zIndex = _ref.zIndex,
|
|
56
56
|
zIndex = _ref$zIndex === void 0 ? 10 : _ref$zIndex,
|
|
57
57
|
_ref$update = _ref.update,
|
|
58
|
-
update = _ref$update === void 0 ? _interface.CanvasUpdateType.
|
|
58
|
+
update = _ref$update === void 0 ? _interface.CanvasUpdateType.ALWAYS : _ref$update,
|
|
59
59
|
_ref$animateOption = _ref.animateOption,
|
|
60
60
|
animateOption = _ref$animateOption === void 0 ? {
|
|
61
61
|
enable: false,
|
|
@@ -74,7 +74,7 @@ var CanvaModel = function (_BaseModel) {
|
|
|
74
74
|
_this.bindListener();
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
if (_this.updateMode === _interface.CanvasUpdateType.
|
|
77
|
+
if (_this.updateMode === _interface.CanvasUpdateType.ALWAYS && animateOption.enable) {
|
|
78
78
|
_this.renderCanvas();
|
|
79
79
|
}
|
|
80
80
|
});
|
|
@@ -90,7 +90,7 @@ var CanvaModel = function (_BaseModel) {
|
|
|
90
90
|
_this.mapService.off('moveend', _this.renderCanvas);
|
|
91
91
|
});
|
|
92
92
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "bindListener", function () {
|
|
93
|
-
if (_this.updateMode === _interface.CanvasUpdateType.
|
|
93
|
+
if (_this.updateMode === _interface.CanvasUpdateType.ALWAYS) {
|
|
94
94
|
_this.mapService.on('mapchange', _this.renderCanvas);
|
|
95
95
|
} else {
|
|
96
96
|
_this.mapService.on('zoomstart', _this.clearCanvas);
|
|
@@ -161,7 +161,7 @@ var CanvaModel = function (_BaseModel) {
|
|
|
161
161
|
value: function initModels() {
|
|
162
162
|
var _ref3 = this.layer.getLayerConfig(),
|
|
163
163
|
_ref3$update = _ref3.update,
|
|
164
|
-
update = _ref3$update === void 0 ? _interface.CanvasUpdateType.
|
|
164
|
+
update = _ref3$update === void 0 ? _interface.CanvasUpdateType.ALWAYS : _ref3$update;
|
|
165
165
|
|
|
166
166
|
this.updateMode = update;
|
|
167
167
|
this.initCanvas();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/canvas/models/canvas.ts"],"names":["CanvaModel","CanvasUpdateType","
|
|
1
|
+
{"version":3,"sources":["../../../src/canvas/models/canvas.ts"],"names":["CanvaModel","CanvasUpdateType","ALWAYS","layer","getLayerConfig","zIndex","update","animateOption","enable","duration","canvas","style","updateMode","unBindListener","bindListener","renderCanvas","mapService","off","clearCanvas","on","ctx","rendererService","getViewportSize","w","width","h","height","clearRect","viewWidth","viewHeight","prevSize","size","getSize","drawingOnCanvas","document","removeChild","initCanvas","getContainer","createElement","pointerEvents","position","top","left","appendChild","getContext","initModels","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;;;;;IAMqBA,U;;;;;;;;;;;;;;;6FACsBC,4BAAiBC,M;;;;+FAKpC,YAAM;AAC1B,iBAII,MAAKC,KAAL,CAAWC,cAAX,EAJJ;AAAA,6BACEC,MADF;AAAA,UACEA,MADF,4BACW,EADX;AAAA,6BAEEC,MAFF;AAAA,UAEEA,MAFF,4BAEWL,4BAAiBC,MAF5B;AAAA,oCAGEK,aAHF;AAAA,UAGEA,aAHF,m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6B,MAA7B;AACA7B,MAAAA,MAAM,CAACC,KAAP,CAAaa,KAAb,GAAqBA,KAAK,GAAG,IAA7B;AACAd,MAAAA,MAAM,CAACC,KAAP,CAAae,MAAb,GAAsBA,MAAM,GAAG,IAA/B;AACAhB,MAAAA,MAAM,CAACC,KAAP,CAAa6B,QAAb,GAAwB,UAAxB;AACA9B,MAAAA,MAAM,CAACC,KAAP,CAAa8B,GAAb,GAAmB,GAAnB;AACA/B,MAAAA,MAAM,CAACC,KAAP,CAAa+B,IAAb,GAAoB,GAApB;AACAhC,MAAAA,MAAM,CAACC,KAAP,CAAaN,MAAb,GAAsBA,MAAM,GAAG,EAA/B;AACA,oCAAKW,UAAL,CAAgBqB,YAAhB,kFAAgCM,WAAhC,CAA4CjC,MAA5C;AAEA,UAAMU,GAAG,GAAGV,MAAM,CAACkC,UAAP,CAAkB,IAAlB,CAAZ;AACA,WAAKxB,GAAL,GAAWA,GAAX;AACD;;;WAsCD,uBAAqB;AACnB,aAAO,KAAKyB,UAAL,EAAP;AACD;;;WAED,qCAAsC;AACpC;AACD;;;EA3IqCC,mB","sourcesContent":["import { ILayerConfig, IModelUniform } from '@antv/l7-core';\nimport BaseModel from '../../core/BaseModel';\nimport {\n CanvasUpdateType,\n ICanvasLayerStyleOptions,\n IDrawingOnCanvas,\n} from '../../core/interface';\n\nexport default class CanvaModel extends BaseModel {\n protected updateMode: CanvasUpdateType = CanvasUpdateType.ALWAYS;\n protected canvas: HTMLCanvasElement;\n protected ctx: CanvasRenderingContext2D;\n protected prevSize: [number, number];\n\n public renderUpdate = () => {\n const {\n zIndex = 10,\n update = CanvasUpdateType.ALWAYS,\n animateOption = { enable: false, duration: 20 },\n } = this.layer.getLayerConfig() as Partial<\n ICanvasLayerStyleOptions & ILayerConfig\n >;\n if (+this.canvas.style.zIndex === zIndex) {\n this.canvas.style.zIndex = zIndex + '';\n }\n if (this.updateMode !== update) {\n this.updateMode = update as CanvasUpdateType;\n this.unBindListener();\n this.bindListener();\n }\n if (this.updateMode === CanvasUpdateType.ALWAYS && animateOption.enable) {\n this.renderCanvas();\n }\n };\n\n public unBindListener = () => {\n this.mapService.off('mapchange', this.renderCanvas);\n this.mapService.off('zoomstart', this.clearCanvas);\n this.mapService.off('zoomend', this.renderCanvas);\n this.mapService.off('movestart', this.clearCanvas);\n this.mapService.off('moveend', this.renderCanvas);\n };\n\n public bindListener = () => {\n if (this.updateMode === CanvasUpdateType.ALWAYS) {\n this.mapService.on('mapchange', this.renderCanvas);\n } else {\n this.mapService.on('zoomstart', this.clearCanvas);\n this.mapService.on('zoomend', this.renderCanvas);\n this.mapService.on('movestart', this.clearCanvas);\n this.mapService.on('moveend', this.renderCanvas);\n }\n };\n\n public clearModels(): void {\n if (this.canvas) {\n document.removeChild(this.canvas);\n // @ts-ignore\n this.canvas = null;\n }\n this.unBindListener();\n }\n\n public initModels() {\n const {\n update = CanvasUpdateType.ALWAYS,\n } = this.layer.getLayerConfig() as ICanvasLayerStyleOptions;\n this.updateMode = update as CanvasUpdateType;\n this.initCanvas();\n\n this.renderCanvas();\n\n this.bindListener();\n\n this.mapService.getContainer();\n return [];\n }\n\n public initCanvas(): void {\n const { zIndex } = this.layer.getLayerConfig() as ICanvasLayerStyleOptions;\n const size = this.mapService.getSize();\n const [width, height] = size;\n const {\n width: viewWidth,\n height: viewHeight,\n } = this.rendererService.getViewportSize();\n this.prevSize = [viewWidth, viewHeight];\n\n const canvas = document.createElement('canvas');\n this.canvas = canvas;\n canvas.width = viewWidth;\n canvas.height = viewHeight;\n canvas.style.pointerEvents = 'none';\n canvas.style.width = width + 'px';\n canvas.style.height = height + 'px';\n canvas.style.position = 'absolute';\n canvas.style.top = '0';\n canvas.style.left = '0';\n canvas.style.zIndex = zIndex + '';\n this.mapService.getContainer()?.appendChild(canvas);\n\n const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;\n this.ctx = ctx;\n }\n\n public clearCanvas = () => {\n if (this.ctx) {\n const { width: w, height: h } = this.rendererService.getViewportSize();\n this.ctx.clearRect(0, 0, w, h);\n }\n };\n\n public renderCanvas = () => {\n const {\n width: viewWidth,\n height: viewHeight,\n } = this.rendererService.getViewportSize();\n if (this.prevSize[0] !== viewWidth || this.prevSize[1] !== viewHeight) {\n this.prevSize = [viewWidth, viewHeight];\n const size = this.mapService.getSize();\n const [width, height] = size;\n this.canvas.width = viewWidth;\n this.canvas.height = viewHeight;\n this.canvas.style.width = width + 'px';\n this.canvas.style.height = height + 'px';\n }\n\n const {\n drawingOnCanvas,\n } = this.layer.getLayerConfig() as ICanvasLayerStyleOptions;\n\n if (this.ctx) {\n drawingOnCanvas({\n canvas: this.canvas,\n ctx: this.ctx,\n mapService: this.mapService,\n size: [viewWidth, viewHeight],\n });\n }\n };\n\n public buildModels() {\n return this.initModels();\n }\n\n protected registerBuiltinAttributes() {\n return;\n }\n}\n"],"file":"canvas.js"}
|
package/lib/core/interface.js
CHANGED
|
@@ -16,7 +16,7 @@ var CanvasUpdateType;
|
|
|
16
16
|
exports.CanvasUpdateType = CanvasUpdateType;
|
|
17
17
|
|
|
18
18
|
(function (CanvasUpdateType) {
|
|
19
|
-
CanvasUpdateType["
|
|
19
|
+
CanvasUpdateType["ALWAYS"] = "always";
|
|
20
20
|
CanvasUpdateType["DRAGEND"] = "dragend";
|
|
21
21
|
})(CanvasUpdateType || (exports.CanvasUpdateType = CanvasUpdateType = {}));
|
|
22
22
|
//# sourceMappingURL=interface.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/interface.ts"],"names":["lineStyleType","CanvasUpdateType"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"sources":["../../src/core/interface.ts"],"names":["lineStyleType","CanvasUpdateType"],"mappings":";;;;;;IAIYA,a;;;WAAAA,a;AAAAA,EAAAA,a,CAAAA,a;AAAAA,EAAAA,a,CAAAA,a;GAAAA,a,6BAAAA,a;;IAkHAC,gB;;;WAAAA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;GAAAA,gB,gCAAAA,gB","sourcesContent":["import { IMapService } from '@antv/l7-core';\nimport { IColorRamp } from '@antv/l7-utils';\nimport { styleOffset, styleSingle } from '../core/BaseModel';\nimport { anchorType } from '../utils/symbol-layout';\nexport enum lineStyleType {\n 'solid' = 0.0,\n 'dash' = 1.0,\n}\n\nexport interface ILineLayerStyleOptions {\n opacity: styleSingle;\n lineType?: keyof typeof lineStyleType; // 可选参数、线类型(all - dash/solid)\n dashArray?: [number, number]; // 可选参数、虚线间隔\n segmentNumber?: number;\n\n forward?: boolean; // 可选参数、是否反向(arcLine)\n lineTexture?: boolean; // 可选参数、是否开启纹理贴图功能(all)\n iconStep?: number; // 可选参数、纹理贴图步长(all)\n iconStepCount?: number; // 可选参数、纹理贴图间隔\n textureBlend?: string; // 可选参数、供给纹理贴图使用(all)\n sourceColor?: string; // 可选参数、设置渐变色的起始颜色(all)\n targetColor?: string; // 可选参数、设置渐变色的终点颜色(all)\n thetaOffset?: number; // 可选参数、设置弧线的偏移量\n\n globalArcHeight?: number; // 可选参数、地球模式下 3D 弧线的高度\n vertexHeightScale?: number; // 可选参数、lineLayer vertex height scale\n\n borderWidth?: number; // 可选参数 线边框宽度\n borderColor?: string; // 可选参数 线边框颜色\n\n heightfixed?: boolean; // 可选参数 高度是否固定\n\n mask?: boolean; // 可选参数 时候允许蒙层\n maskInside?: boolean; // 可选参数 控制图层是否显示在蒙层的内部\n}\n\nexport interface IPointLayerStyleOptions {\n opacity: number;\n strokeOpacity: number;\n strokeWidth: number;\n stroke: string;\n\n textOffset?: [number, number];\n textAnchor?: anchorType;\n spacing?: number;\n padding?: [number, number];\n halo?: number;\n gamma?: number;\n fontWeight?: string;\n fontFamily?: string;\n textAllowOverlap?: boolean;\n\n // cylinder\n pickLight?: boolean;\n depth?: boolean;\n sourceColor?: string; // 可选参数、设置渐变色的起始颜色(all)\n targetColor?: string; // 可选参数、设置渐变色的终点颜色(all)\n opacityLinear?: {\n enable: boolean;\n dir: string;\n };\n lightEnable: boolean;\n heightfixed?: boolean; // 圆柱体高度是否固定(不随 zoom 发生变化)\n\n offsets?: styleOffset;\n blend?: string;\n unit?: string;\n mask?: boolean;\n maskInside?: boolean;\n\n rotation?: number; // angle\n speed?: number;\n}\n\nexport interface IPolygonLayerStyleOptions {\n opacity: styleSingle;\n\n opacityLinear: {\n enable: boolean;\n dir: string;\n };\n\n heightfixed?: boolean; // 挤出几何体高度是否固定(不随 zoom 发生变化)\n\n pickLight: boolean;\n mask?: boolean;\n maskInside?: boolean;\n\n // water\n waterTexture?: string;\n speed?: number;\n // ocean\n watercolor?: string;\n watercolor2?: string;\n}\n\nexport interface IImageLayerStyleOptions {\n opacity: number;\n mask?: boolean;\n maskInside?: boolean;\n}\n\nexport interface IGeometryLayerStyleOptions {\n opacity: number;\n mask?: boolean;\n maskInside?: boolean;\n\n mapTexture?: string;\n\n // planeGeometry\n center?: [number, number];\n width?: number;\n height?: number;\n\n widthSegments?: number;\n heightSegments?: number;\n}\n\nexport enum CanvasUpdateType {\n 'ALWAYS' = 'always',\n 'DRAGEND' = 'dragend',\n}\n\nexport interface IDrawingOnCanvas {\n canvas: HTMLCanvasElement;\n ctx: CanvasRenderingContext2D;\n mapService: IMapService;\n size: [number, number];\n}\nexport interface ICanvasLayerStyleOptions {\n zIndex: number;\n update: CanvasUpdateType | string;\n drawingOnCanvas: (option: IDrawingOnCanvas) => void;\n}\n\nexport interface IHeatMapLayerStyleOptions {\n opacity: number;\n intensity: number;\n radius: number;\n angle: number;\n rampColors: IColorRamp;\n mask?: boolean;\n maskInside?: boolean;\n\n coverage?: number;\n}\n\nexport interface IRasterLayerStyleOptions {\n opacity: number;\n domain: [number, number];\n noDataValue: number;\n clampLow: boolean;\n clampHigh: boolean;\n rampColors: IColorRamp;\n mask?: boolean;\n maskInside?: boolean;\n}\n"],"file":"interface.js"}
|
|
@@ -23,6 +23,8 @@ var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
|
23
23
|
|
|
24
24
|
var _l7Core = require("@antv/l7-core");
|
|
25
25
|
|
|
26
|
+
var _l7Maps = require("@antv/l7-maps");
|
|
27
|
+
|
|
26
28
|
var _l7Utils = require("@antv/l7-utils");
|
|
27
29
|
|
|
28
30
|
var _inversify = require("inversify");
|
|
@@ -149,15 +151,23 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
|
|
|
149
151
|
});
|
|
150
152
|
return encodeRecord;
|
|
151
153
|
});
|
|
154
|
+
this.adjustData2Amap2Coordinates(mappedData);
|
|
155
|
+
this.adjustData2SimpleCoordinates(mappedData);
|
|
156
|
+
return mappedData;
|
|
157
|
+
}
|
|
158
|
+
}, {
|
|
159
|
+
key: "adjustData2Amap2Coordinates",
|
|
160
|
+
value: function adjustData2Amap2Coordinates(mappedData) {
|
|
161
|
+
var _this4 = this;
|
|
152
162
|
|
|
153
|
-
if (mappedData.length > 0 && this.mapService.version === 'GAODE2.x') {
|
|
163
|
+
if (mappedData.length > 0 && this.mapService.version === _l7Maps.Version['GAODE2.x']) {
|
|
154
164
|
if (typeof mappedData[0].coordinates[0] === 'number') {
|
|
155
165
|
mappedData.filter(function (d) {
|
|
156
166
|
return !d.originCoordinates;
|
|
157
167
|
}).map(function (d) {
|
|
158
168
|
d.version = 'GAODE2.x';
|
|
159
169
|
d.originCoordinates = (0, _cloneDeep2.default)(d.coordinates);
|
|
160
|
-
d.coordinates =
|
|
170
|
+
d.coordinates = _this4.mapService.lngLatToCoord(d.coordinates);
|
|
161
171
|
});
|
|
162
172
|
} else {
|
|
163
173
|
mappedData.filter(function (d) {
|
|
@@ -165,12 +175,51 @@ var DataMappingPlugin = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inver
|
|
|
165
175
|
}).map(function (d) {
|
|
166
176
|
d.version = 'GAODE2.x';
|
|
167
177
|
d.originCoordinates = (0, _cloneDeep2.default)(d.coordinates);
|
|
168
|
-
d.coordinates =
|
|
178
|
+
d.coordinates = _this4.mapService.lngLatToCoords(d.coordinates);
|
|
169
179
|
});
|
|
170
180
|
}
|
|
171
181
|
}
|
|
182
|
+
}
|
|
183
|
+
}, {
|
|
184
|
+
key: "adjustData2SimpleCoordinates",
|
|
185
|
+
value: function adjustData2SimpleCoordinates(mappedData) {
|
|
186
|
+
var _this5 = this;
|
|
187
|
+
|
|
188
|
+
if (mappedData.length > 0 && this.mapService.version === _l7Maps.Version.SIMPLE) {
|
|
189
|
+
mappedData.map(function (d) {
|
|
190
|
+
if (!d.simpleCoordinate) {
|
|
191
|
+
d.coordinates = _this5.unProjectCoordinates(d.coordinates);
|
|
192
|
+
d.simpleCoordinate = true;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}, {
|
|
198
|
+
key: "unProjectCoordinates",
|
|
199
|
+
value: function unProjectCoordinates(coordinates) {
|
|
200
|
+
var _this6 = this;
|
|
172
201
|
|
|
173
|
-
|
|
202
|
+
if (typeof coordinates[0] === 'number') {
|
|
203
|
+
return this.mapService.simpleMapCoord.unproject(coordinates);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (coordinates[0] && coordinates[0][0] instanceof Array) {
|
|
207
|
+
var coords = [];
|
|
208
|
+
coordinates.map(function (coord) {
|
|
209
|
+
var c1 = [];
|
|
210
|
+
coord.map(function (co) {
|
|
211
|
+
c1.push(_this6.mapService.simpleMapCoord.unproject(co));
|
|
212
|
+
});
|
|
213
|
+
coords.push(c1);
|
|
214
|
+
});
|
|
215
|
+
return coords;
|
|
216
|
+
} else {
|
|
217
|
+
var _coords = [];
|
|
218
|
+
coordinates.map(function (coord) {
|
|
219
|
+
_coords.push(_this6.mapService.simpleMapCoord.unproject(coord));
|
|
220
|
+
});
|
|
221
|
+
return _coords;
|
|
222
|
+
}
|
|
174
223
|
}
|
|
175
224
|
}, {
|
|
176
225
|
key: "applyAttributeMapping",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins/DataMappingPlugin.ts"],"names":["DataMappingPlugin","TYPES","IGlobalConfigService","IMapService","IFontService","layer","styleAttributeService","hooks","init","tap","generateMaping","beforeRenderData","dataState","dataMappingNeedUpdate","beforeRender","layerModelNeedUpdate","bottomColor","getBottomColor","attributes","getLayerStyleAttributes","filter","getLayerStyleAttribute","dataArray","getSource","data","attributesToRemapping","attribute","needRemapping","filterData","scale","record","applyAttributeMapping","length","setEncodedData","mapping","undefined","getEncodedData","emit","predata","minimumColor","mappedData","map","i","preRecord","encodeRecord","id","_id","coordinates","forEach","values","name","c","Array","isArray","shape","fontService","getIconFontKey","mapService","version","d","originCoordinates","lngLatToCoord","lngLatToCoords","scalers","params","field","hasOwnProperty","type","push","mappingResult"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAaA;;AACA;;AAEA;;;;;;;;IAGqBA,iB,WADpB,4B,UAEE,uBAAOC,cAAMC,oBAAb,C,UAGA,uBAAOD,cAAME,WAAb,C,UAGA,uBAAOF,cAAMG,YAAb,C;;;;;;;;;;WAGD,eACEC,KADF,QAKE;AAAA;;AAAA,UAFEC,qBAEF,QAFEA,qBAEF;AACAD,MAAAA,KAAK,CAACE,KAAN,CAAYC,IAAZ,CAAiBC,GAAjB,CAAqB,mBAArB,EAA0C,YAAM;AAE9C,QAAA,KAAI,CAACC,cAAL,CAAoBL,KAApB,EAA2B;AAAEC,UAAAA,qBAAqB,EAArBA;AAAF,SAA3B;AACD,OAHD;AAKAD,MAAAA,KAAK,CAACE,KAAN,CAAYI,gBAAZ,CAA6BF,GAA7B,CAAiC,mBAAjC,EAAsD,YAAM;AAC1DJ,QAAAA,KAAK,CAACO,SAAN,CAAgBC,qBAAhB,GAAwC,KAAxC;;AACA,QAAA,KAAI,CAACH,cAAL,CAAoBL,KAApB,EAA2B;AAAEC,UAAAA,qBAAqB,EAArBA;AAAF,SAA3B;;AACA,eAAO,IAAP;AACD,OAJD;AAOAD,MAAAA,KAAK,CAACE,KAAN,CAAYO,YAAZ,CAAyBL,GAA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M,CAACI,IAAP,CAAYtC,MAAM,CAACmC,KAAD,CAAlB;AACD;AACF,OARD;AAYA,UAAMI,aAAa,GAAG3C,SAAS,CAACQ,OAAV,GAAoBR,SAAS,CAACQ,OAAV,CAAkB8B,MAAlB,CAApB,GAAgD,EAAtE;;AACA,UAAItC,SAAS,CAACwB,IAAV,KAAmB,OAAnB,IAA8B,CAAC,sBAAQmB,aAAa,CAAC,CAAD,CAArB,CAAnC,EAA8D;AAC5D,eAAO,CAAC9B,YAAD,CAAP;AACD;;AACD,aAAO8B,aAAP;AAED","sourcesContent":["import {\n IEncodeFeature,\n IFontService,\n IGlobalConfigService,\n ILayer,\n ILayerPlugin,\n ILngLat,\n IMapService,\n IParseDataItem,\n IStyleAttribute,\n IStyleAttributeService,\n TYPES,\n} from '@antv/l7-core';\nimport { isColor, rgb2arr, unProjectFlat } from '@antv/l7-utils';\nimport { inject, injectable } from 'inversify';\nimport { cloneDeep } from 'lodash';\nimport 'reflect-metadata';\n\n@injectable()\nexport default class DataMappingPlugin implements ILayerPlugin {\n @inject(TYPES.IGlobalConfigService)\n private readonly configService: IGlobalConfigService;\n\n @inject(TYPES.IMapService)\n private readonly mapService: IMapService;\n\n @inject(TYPES.IFontService)\n private readonly fontService: IFontService;\n\n public apply(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n layer.hooks.init.tap('DataMappingPlugin', () => {\n // 初始化重新生成 map\n this.generateMaping(layer, { styleAttributeService });\n });\n\n layer.hooks.beforeRenderData.tap('DataMappingPlugin', () => {\n layer.dataState.dataMappingNeedUpdate = false;\n this.generateMaping(layer, { styleAttributeService });\n return true;\n });\n\n // remapping before render\n layer.hooks.beforeRender.tap('DataMappingPlugin', () => {\n if (layer.layerModelNeedUpdate) {\n return;\n }\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n const attributesToRemapping = attributes.filter(\n (attribute) => attribute.needRemapping, // 如果filter变化\n );\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.needRemapping && filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n if (attributesToRemapping.length) {\n // 过滤数据\n if (filter?.needRemapping) {\n layer.setEncodedData(\n this.mapping(attributes, filterData, undefined, bottomColor),\n );\n filter.needRemapping = false;\n } else {\n layer.setEncodedData(\n this.mapping(\n attributesToRemapping,\n filterData,\n layer.getEncodedData(),\n bottomColor,\n ),\n );\n }\n // 处理文本更新\n layer.emit('remapping', null);\n }\n });\n }\n private generateMaping(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n layer.setEncodedData(\n this.mapping(attributes, filterData, undefined, bottomColor),\n );\n }\n\n private mapping(\n attributes: IStyleAttribute[],\n data: IParseDataItem[],\n predata?: IEncodeFeature[],\n minimumColor?: string,\n ): IEncodeFeature[] {\n // console.log('data', data)\n const mappedData = data.map((record: IParseDataItem, i) => {\n const preRecord = predata ? predata[i] : {};\n const encodeRecord: IEncodeFeature = {\n id: record._id,\n coordinates: record.coordinates,\n ...preRecord,\n };\n // console.log('attributes', attributes)\n attributes\n .filter((attribute) => attribute.scale !== undefined)\n .forEach((attribute: IStyleAttribute) => {\n // console.log('attribute', attribute)\n // console.log('record', record)\n let values = this.applyAttributeMapping(\n attribute,\n record,\n minimumColor,\n );\n // console.log('values', values)\n attribute.needRemapping = false;\n\n // TODO: 支持每个属性配置 postprocess\n if (attribute.name === 'color') {\n // console.log('attribute', attribute)\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 = this.fontService.getIconFontKey(\n encodeRecord[attribute.name] as string,\n );\n }\n });\n return encodeRecord;\n }) as IEncodeFeature[];\n // console.log('mappedData', mappedData)\n\n // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移\n if (mappedData.length > 0 && this.mapService.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 = '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 // d.coordinates = this.mapService.lngLatToCoord(unProjectFlat(d.coordinates));\n });\n } else {\n // 连续的线、面数据\n // @ts-ignore\n mappedData\n // TODO: 避免经纬度被重复计算导致坐标位置偏移\n .filter((d) => !d.originCoordinates)\n .map((d) => {\n d.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 // console.log('mappedData', mappedData)\n return mappedData;\n }\n\n private 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 (\n record.hasOwnProperty(field) ||\n attribute.scale?.type === 'variable'\n ) {\n // TODO:多字段,常量\n params.push(record[field]);\n }\n });\n // console.log('params', params)\n // console.log('attribute', attribute)\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 // return attribute.mapping ? attribute.mapping(params) : [];\n }\n}\n"],"file":"DataMappingPlugin.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/DataMappingPlugin.ts"],"names":["DataMappingPlugin","TYPES","IGlobalConfigService","IMapService","IFontService","layer","styleAttributeService","hooks","init","tap","generateMaping","beforeRenderData","dataState","dataMappingNeedUpdate","beforeRender","layerModelNeedUpdate","bottomColor","getBottomColor","attributes","getLayerStyleAttributes","filter","getLayerStyleAttribute","dataArray","getSource","data","attributesToRemapping","attribute","needRemapping","filterData","scale","record","applyAttributeMapping","length","setEncodedData","mapping","undefined","getEncodedData","emit","predata","minimumColor","mappedData","map","i","preRecord","encodeRecord","id","_id","coordinates","forEach","values","name","c","Array","isArray","shape","fontService","getIconFontKey","adjustData2Amap2Coordinates","adjustData2SimpleCoordinates","mapService","version","Version","d","originCoordinates","lngLatToCoord","lngLatToCoords","SIMPLE","simpleCoordinate","unProjectCoordinates","simpleMapCoord","unproject","coords","coord","c1","co","push","scalers","params","field","hasOwnProperty","type","mappingResult"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAaA;;AACA;;AACA;;AAEA;;;;;;;;IAGqBA,iB,WADpB,4B,UAEE,uBAAOC,cAAMC,oBAAb,C,UAGA,uBAAOD,cAAME,WAAb,C,UAGA,uBAAOF,cAAMG,YAAb,C;;;;;;;;;;WAGD,eACEC,KADF,QAKE;AAAA;;AAAA,UAFEC,qBAEF,QAFEA,qBAEF;AACAD,MAAAA,KAAK,CAACE,KAAN,CAAYC,IAAZ,CAAiBC,GAAjB,CA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AAEAxB,QAAAA,WAAW,CAACN,GAAZ,CAAgB,UAAC+B,KAAD,EAAW;AACzBD,UAAAA,OAAM,CAACI,IAAP,CACE,MAAI,CAAChB,UAAL,CAAgBU,cAAhB,CAA+BC,SAA/B,CAAyCE,KAAzC,CADF;AAGD,SAJD;AAMA,eAAOD,OAAP;AACD;AACF;;;WAED,+BACE7C,SADF,EAEEI,MAFF,EAGES,YAHF,EAIE;AAAA;;AACA,UAAI,CAACb,SAAS,CAACG,KAAf,EAAsB;AACpB,eAAO,EAAP;AACD;;AACD,UAAM+C,OAAO,GAAG,CAAAlD,SAAS,SAAT,IAAAA,SAAS,WAAT,gCAAAA,SAAS,CAAEG,KAAX,sEAAkB+C,OAAlB,KAA6B,EAA7C;AACA,UAAMC,MAAiB,GAAG,EAA1B;AAEAD,MAAAA,OAAO,CAAC5B,OAAR,CAAgB,iBAAe;AAAA;;AAAA,YAAZ8B,KAAY,SAAZA,KAAY;;AAC7B,YACEhD,MAAM,CAACiD,cAAP,CAAsBD,KAAtB,KACA,sBAAApD,SAAS,CAACG,KAAV,wEAAiBmD,IAAjB,MAA0B,UAF5B,EAGE;AAEAH,UAAAA,MAAM,CAACF,IAAP,CAAY7C,MAAM,CAACgD,KAAD,CAAlB;AACD;AACF,OARD;AAYA,UAAMG,aAAa,GAAGvD,SAAS,CAACQ,OAAV,GAAoBR,SAAS,CAACQ,OAAV,CAAkB2C,MAAlB,CAApB,GAAgD,EAAtE;;AACA,UAAInD,SAAS,CAACwB,IAAV,KAAmB,OAAnB,IAA8B,CAAC,sBAAQ+B,aAAa,CAAC,CAAD,CAArB,CAAnC,EAA8D;AAC5D,eAAO,CAAC1C,YAAD,CAAP;AACD;;AACD,aAAO0C,aAAP;AAED","sourcesContent":["import {\n IEncodeFeature,\n IFontService,\n IGlobalConfigService,\n ILayer,\n ILayerPlugin,\n ILngLat,\n IMapService,\n IParseDataItem,\n IStyleAttribute,\n IStyleAttributeService,\n TYPES,\n} from '@antv/l7-core';\nimport { Version } from '@antv/l7-maps';\nimport { isColor, rgb2arr, unProjectFlat } from '@antv/l7-utils';\nimport { inject, injectable } from 'inversify';\nimport { cloneDeep } from 'lodash';\nimport 'reflect-metadata';\n\n@injectable()\nexport default class DataMappingPlugin implements ILayerPlugin {\n @inject(TYPES.IGlobalConfigService)\n private readonly configService: IGlobalConfigService;\n\n @inject(TYPES.IMapService)\n private readonly mapService: IMapService;\n\n @inject(TYPES.IFontService)\n private readonly fontService: IFontService;\n\n public apply(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n layer.hooks.init.tap('DataMappingPlugin', () => {\n // 初始化重新生成 map\n this.generateMaping(layer, { styleAttributeService });\n });\n\n layer.hooks.beforeRenderData.tap('DataMappingPlugin', () => {\n layer.dataState.dataMappingNeedUpdate = false;\n this.generateMaping(layer, { styleAttributeService });\n return true;\n });\n\n // remapping before render\n layer.hooks.beforeRender.tap('DataMappingPlugin', () => {\n if (layer.layerModelNeedUpdate) {\n return;\n }\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n const attributesToRemapping = attributes.filter(\n (attribute) => attribute.needRemapping, // 如果filter变化\n );\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.needRemapping && filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n if (attributesToRemapping.length) {\n // 过滤数据\n if (filter?.needRemapping) {\n layer.setEncodedData(\n this.mapping(attributes, filterData, undefined, bottomColor),\n );\n filter.needRemapping = false;\n } else {\n layer.setEncodedData(\n this.mapping(\n attributesToRemapping,\n filterData,\n layer.getEncodedData(),\n bottomColor,\n ),\n );\n }\n // 处理文本更新\n layer.emit('remapping', null);\n }\n });\n }\n private generateMaping(\n layer: ILayer,\n {\n styleAttributeService,\n }: { styleAttributeService: IStyleAttributeService },\n ) {\n const bottomColor = layer.getBottomColor();\n const attributes = styleAttributeService.getLayerStyleAttributes() || [];\n const filter = styleAttributeService.getLayerStyleAttribute('filter');\n const { dataArray } = layer.getSource().data;\n let filterData = dataArray;\n // 数据过滤完 再执行数据映射\n if (filter?.scale) {\n filterData = dataArray.filter((record: IParseDataItem) => {\n return this.applyAttributeMapping(filter, record, bottomColor)[0];\n });\n }\n layer.setEncodedData(\n this.mapping(attributes, filterData, undefined, bottomColor),\n );\n }\n\n private mapping(\n attributes: IStyleAttribute[],\n data: IParseDataItem[],\n predata?: IEncodeFeature[],\n minimumColor?: string,\n ): IEncodeFeature[] {\n // console.log('data', data)\n const mappedData = data.map((record: IParseDataItem, i) => {\n const preRecord = predata ? predata[i] : {};\n const encodeRecord: IEncodeFeature = {\n id: record._id,\n coordinates: record.coordinates,\n ...preRecord,\n };\n // console.log('attributes', attributes)\n attributes\n .filter((attribute) => attribute.scale !== undefined)\n .forEach((attribute: IStyleAttribute) => {\n // console.log('attribute', attribute)\n // console.log('record', record)\n let values = this.applyAttributeMapping(\n attribute,\n record,\n minimumColor,\n );\n // console.log('values', values)\n attribute.needRemapping = false;\n\n // TODO: 支持每个属性配置 postprocess\n if (attribute.name === 'color') {\n // console.log('attribute', attribute)\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 = this.fontService.getIconFontKey(\n encodeRecord[attribute.name] as string,\n );\n }\n });\n return encodeRecord;\n }) as IEncodeFeature[];\n // console.log('mappedData', mappedData)\n\n // 调整数据兼容 Amap2.0\n this.adjustData2Amap2Coordinates(mappedData);\n\n // 调整数据兼容 SimpleCoordinates\n this.adjustData2SimpleCoordinates(mappedData);\n // console.log('mappedData', mappedData)\n return mappedData;\n }\n\n private adjustData2Amap2Coordinates(mappedData: IEncodeFeature[]) {\n // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移\n if (\n mappedData.length > 0 &&\n this.mapService.version === Version['GAODE2.x']\n ) {\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 = '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 = '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\n private adjustData2SimpleCoordinates(mappedData: IEncodeFeature[]) {\n if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {\n mappedData.map((d) => {\n if (!d.simpleCoordinate) {\n d.coordinates = this.unProjectCoordinates(d.coordinates);\n d.simpleCoordinate = true;\n }\n });\n }\n }\n\n private unProjectCoordinates(coordinates: any) {\n if (typeof coordinates[0] === 'number') {\n return this.mapService.simpleMapCoord.unproject(\n coordinates as [number, number],\n );\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(\n this.mapService.simpleMapCoord.unproject(co as [number, number]),\n );\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 this.mapService.simpleMapCoord.unproject(coord as [number, number]),\n );\n });\n // @ts-ignore\n return coords;\n }\n }\n\n private 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 (\n record.hasOwnProperty(field) ||\n attribute.scale?.type === 'variable'\n ) {\n // TODO:多字段,常量\n params.push(record[field]);\n }\n });\n // console.log('params', params)\n // console.log('attribute', attribute)\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 // return attribute.mapping ? attribute.mapping(params) : [];\n }\n}\n"],"file":"DataMappingPlugin.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/models/extrude.ts"],"names":["ExtrudeModel","layer","getLayerConfig","animateOption","enable","speed","repeat","opacity","sourceColor","targetColor","pickLight","heightfixed","opacityLinear","dir","lightEnable","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","useLinearColor","sourceColorArr","targetColorArr","raiseCount","raiserepeat","u_pickLight","Number","u_heightfixed","u_r","u_globel","mapService","version","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_linearColor","u_sourceColor","u_targetColor","u_opacitylinear","u_opacitylinear_dir","u_lightEnable","buildModels","depth","buildLayerModel","moduleName","vertexShader","pointExtrudeVert","fragmentShader","pointExtrudeFrag","triangulation","PointExtrudeTriangulation","blend","getBlend","cull","face","FRONT","BACK","destroy","isGlobel","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","buffersize","Array","isArray","STATIC_DRAW","normal","coordinates","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;;;;;;;;IAIqBA,Y;;;;;;;;;;;;;;;6FACU,C;8FACC,C;;;;;;WAC9B,wBAAsB;AACpB,iBAoBI,KAAKC,KAAL,CAAWC,cAAX,EApBJ;AAAA,oCACEC,aADF;AAAA,UACEA,aADF,mCACkB;AACdC,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,KAAK,EAAE,IAFO;AAGdC,QAAAA,MAAM,EAAE;AAHM,OADlB;AAAA,8BAMEC,OANF;AAAA,UAMEA,OANF,6BAMY,CANZ;AAAA,UAQEC,WARF,QAQEA,WARF;AAAA,UASEC,WATF,QASEA,WATF;AAAA,gCAWEC,SAXF;AAAA,UAWEA,SAXF,+BAWc,KAXd;AAAA,kCAYEC,WAZF;AAAA,UAYEA,WAZF,iCAYgB,KAZhB;AAAA,oCAcEC,aAdF;AAAA,UAcEA,aAdF,mCAckB;AACdR,QAAAA,MAAM,EAAE,KADM;AAEdS,QAAAA,GAAG,EAAE;AAFS,OAdlB;AAAA,kCAmBEC,WAnBF;AAAA,UAmBEA,WAnBF,iCAmBgB,IAnBhB;;AAqBA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBT,QAAAA,OAAO,EAAPA;AADyB,OAA3B,CAFF,EAKE;AACA,aAAKU,oBAAL,CAA0B;AACxBV,UAAAA,OAAO,EAAPA;AADwB,SAA1B;AAGA,YAAMW,UAAU,GAAG,KAAKjB,KAAL,CAAWkB,cAAX,EAAnB;;AACA,iCAAgC,KAAKC,YAAL,CAC9B,KAAKC,UADyB,EAE9BH,UAF8B,EAG9B,KAAKI,cAHyB,CAAhC;AAAA,YAAQC,IAAR,sBAAQA,IAAR;AAAA,YAAcC,KAAd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K,MALM,EAMH;AACH,mBAAOA,MAAP;AACD;AAjBS;AAHoC,OAAlD;AAuBA,WAAKnB,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,KAD0C;AAEhD5C,QAAAA,IAAI,EAAE6C,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,OADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEnD,WAAGoD,YAFJ;AAGN7D,YAAAA,IAAI,EAAE,EAHA;AAINW,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQVkD,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBAACC,OAAD,EAA0BC,UAA1B,EAAiD;AACvD,gBAAMQ,WAAW,GAAG,4BAAkBT,OAAO,CAACS,WAA1B,CAApB;;AACA,gBAAIrB,QAAJ,EAAc;AAEZ,qBAAO,qBAAS,CAACqB,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,CAAT,CAAP;AAKD,aAPD,MAOO;AACL,qBAAO,CAACA,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,EAAiC,CAAjC,CAAP;AACD;AACF;AArBS;AAHoC,OAAlD;AA2BD;;;EA/OuCC,mB","sourcesContent":["import { AttributeType, gl, IEncodeFeature, IModel } from '@antv/l7-core';\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointExtrudeTriangulation } from '../../core/triangulation';\nimport { lglt2xyz } from '../../earth/utils';\nimport { calculateCentroid } from '../../utils/geo';\nimport pointExtrudeFrag from '../shaders/extrude/extrude_frag.glsl';\nimport pointExtrudeVert from '../shaders/extrude/extrude_vert.glsl';\n\nexport default class ExtrudeModel extends BaseModel {\n private raiseCount: number = 0;\n private raiserepeat: number = 0;\n public getUninforms() {\n const {\n animateOption = {\n enable: false,\n speed: 0.01,\n repeat: false,\n },\n opacity = 1,\n\n sourceColor,\n targetColor,\n\n pickLight = false,\n heightfixed = false,\n\n opacityLinear = {\n enable: false,\n dir: 'up',\n },\n\n lightEnable = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\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\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.raiseCount < 1 && this.raiserepeat > 0) {\n if (animateOption.enable) {\n const { speed = 0.01, repeat = false } = animateOption;\n this.raiseCount += speed;\n if (this.raiseCount >= 1) {\n if (this.raiserepeat > 1) {\n this.raiseCount = 0;\n this.raiserepeat--;\n } else {\n this.raiseCount = 1;\n }\n }\n }\n }\n\n return {\n // 圆柱体的拾取高亮是否要计算光照\n u_pickLight: Number(pickLight),\n // 圆柱体是否固定高度\n u_heightfixed: Number(heightfixed),\n\n u_r: animateOption.enable && this.raiserepeat > 0 ? this.raiseCount : 1.0,\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,\n\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity || 1.0,\n // u_offsets: offsets || [0, 0],\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 透明度渐变\n u_opacitylinear: Number(opacityLinear.enable),\n u_opacitylinear_dir: opacityLinear.dir === 'up' ? 1.0 : 0.0,\n\n // 光照计算开关\n u_lightEnable: Number(lightEnable),\n };\n }\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n // GAODE1.x GAODE2.x MAPBOX\n const {\n depth = true,\n animateOption: { repeat = 1 },\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n this.raiserepeat = repeat;\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointExtrude2',\n vertexShader: pointExtrudeVert,\n fragmentShader: pointExtrudeFrag,\n triangulation: PointExtrudeTriangulation,\n blend: this.getBlend(),\n cull: {\n enable: true,\n face: this.mapService.version === 'MAPBOX' ? gl.FRONT : gl.BACK,\n },\n depth: {\n enable: depth,\n },\n // primitive: gl.POINTS,\n }),\n ];\n }\n public clearModels() {\n this.dataTexture?.destroy();\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\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: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size } = feature;\n if (size) {\n let buffersize: number[] = [];\n if (Array.isArray(size)) {\n buffersize =\n size.length === 2 ? [size[0], size[0], size[1]] : size;\n }\n if (!Array.isArray(size)) {\n buffersize = [size, size, size];\n }\n return buffersize;\n } else {\n return [2, 2, 2];\n }\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\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 return normal;\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'pos',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Pos',\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: 3,\n update: (feature: IEncodeFeature, featureIdx: number) => {\n const coordinates = calculateCentroid(feature.coordinates);\n if (isGlobel) {\n // TODO: 在地球模式下需要将传入 shader 的经纬度转化成对应的 xyz 坐标\n return lglt2xyz([coordinates[0], coordinates[1]]) as [\n number,\n number,\n number,\n ];\n } else {\n return [coordinates[0], coordinates[1], 0];\n }\n },\n },\n });\n }\n}\n"],"file":"extrude.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/point/models/extrude.ts"],"names":["ExtrudeModel","layer","getLayerConfig","animateOption","enable","speed","repeat","opacity","sourceColor","targetColor","pickLight","heightfixed","opacityLinear","dir","lightEnable","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","useLinearColor","sourceColorArr","targetColorArr","raiseCount","raiserepeat","u_pickLight","Number","u_heightfixed","u_r","u_globel","mapService","version","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_linearColor","u_sourceColor","u_targetColor","u_opacitylinear","u_opacitylinear_dir","u_lightEnable","buildModels","depth","buildLayerModel","moduleName","vertexShader","pointExtrudeVert","fragmentShader","pointExtrudeFrag","triangulation","PointExtrudeTriangulation","blend","getBlend","cull","face","FRONT","BACK","destroy","isGlobel","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","buffersize","Array","isArray","STATIC_DRAW","normal","coordinates","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAOA;;AAEA;;AAEA;;AACA;;AACA;;;;;;;;;IAIqBA,Y;;;;;;;;;;;;;;;6FACU,C;8FACC,C;;;;;;WAC9B,wBAAsB;AACpB,iBAoBI,KAAKC,KAAL,CAAWC,cAAX,EApBJ;AAAA,oCACEC,aADF;AAAA,UACEA,aADF,mCACkB;AACdC,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,KAAK,EAAE,IAFO;AAGdC,QAAAA,MAAM,EAAE;AAHM,OADlB;AAAA,8BAMEC,OANF;AAAA,UAMEA,OANF,6BAMY,CANZ;AAAA,UAQEC,WARF,QAQEA,WARF;AAAA,UASEC,WATF,QASEA,WATF;AAAA,gCAWEC,SAXF;AAAA,UAWEA,SAXF,+BAWc,KAXd;AAAA,kCAYEC,WAZF;AAAA,UAYEA,WAZF,iCAYgB,KAZhB;AAAA,oCAcEC,aAdF;AAAA,UAcEA,aAdF,mCAckB;AACdR,QAAAA,MAAM,EAAE,KADM;AAEdS,QAAAA,GAAG,EAAE;AAFS,OAdlB;AAAA,kCAmBEC,WAnBF;AAAA,UAmBEA,WAnBF,iCAmBgB,IAnBhB;;AAuBA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBT,QAAAA,OAAO,EAAPA;AADyB,OAA3B,CAFF,EAKE;AACA,aAAKU,oBAAL,CAA0B;AACxBV,UAAAA,OAAO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AAAA,KAAK,EAAEnD,WAAG8D,WAFJ;AAGNvE,YAAAA,IAAI,EAAE,EAHA;AAINW,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQVkD,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKNK,MALM,EAMH;AACH,mBAAOA,MAAP;AACD;AAjBS;AAHoC,OAAlD;AAuBA,WAAKnB,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,KAD0C;AAEhD5C,QAAAA,IAAI,EAAE6C,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,OADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEnD,WAAGoD,YAFJ;AAGN7D,YAAAA,IAAI,EAAE,EAHA;AAINW,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQVkD,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBAACC,OAAD,EAA0BC,UAA1B,EAAiD;AACvD,gBAAMQ,WAAW,GAAG,4BAAkBT,OAAO,CAACS,WAA1B,CAApB;;AACA,gBAAIrB,QAAJ,EAAc;AAEZ,qBAAO,qBAAS,CAACqB,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,CAAT,CAAP;AAKD,aAPD,MAOO;AACL,qBAAO,CAACA,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,EAAiC,CAAjC,CAAP;AACD;AACF;AArBS;AAHoC,OAAlD;AA2BD;;;EAjPuCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n} from '@antv/l7-core';\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport { PointExtrudeTriangulation } from '../../core/triangulation';\nimport { lglt2xyz } from '../../earth/utils';\nimport { calculateCentroid } from '../../utils/geo';\nimport pointExtrudeFrag from '../shaders/extrude/extrude_frag.glsl';\nimport pointExtrudeVert from '../shaders/extrude/extrude_vert.glsl';\n\nexport default class ExtrudeModel extends BaseModel {\n private raiseCount: number = 0;\n private raiserepeat: number = 0;\n public getUninforms() {\n const {\n animateOption = {\n enable: false,\n speed: 0.01,\n repeat: false,\n },\n opacity = 1,\n\n sourceColor,\n targetColor,\n\n pickLight = false,\n heightfixed = false,\n\n opacityLinear = {\n enable: false,\n dir: 'up',\n },\n\n lightEnable = true,\n } = this.layer.getLayerConfig() as Partial<\n ILayerConfig & IPointLayerStyleOptions\n >;\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\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\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n if (this.raiseCount < 1 && this.raiserepeat > 0) {\n if (animateOption.enable) {\n const { speed = 0.01, repeat = false } = animateOption;\n this.raiseCount += speed;\n if (this.raiseCount >= 1) {\n if (this.raiserepeat > 1) {\n this.raiseCount = 0;\n this.raiserepeat--;\n } else {\n this.raiseCount = 1;\n }\n }\n }\n }\n\n return {\n // 圆柱体的拾取高亮是否要计算光照\n u_pickLight: Number(pickLight),\n // 圆柱体是否固定高度\n u_heightfixed: Number(heightfixed),\n\n u_r: animateOption.enable && this.raiserepeat > 0 ? this.raiseCount : 1.0,\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,\n\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity || 1.0,\n // u_offsets: offsets || [0, 0],\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 透明度渐变\n u_opacitylinear: Number(opacityLinear.enable),\n u_opacitylinear_dir: opacityLinear.dir === 'up' ? 1.0 : 0.0,\n\n // 光照计算开关\n u_lightEnable: Number(lightEnable),\n };\n }\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n // GAODE1.x GAODE2.x MAPBOX\n const {\n depth = true,\n animateOption: { repeat = 1 },\n } = this.layer.getLayerConfig() as ILayerConfig;\n this.raiserepeat = repeat;\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointExtrude2',\n vertexShader: pointExtrudeVert,\n fragmentShader: pointExtrudeFrag,\n triangulation: PointExtrudeTriangulation,\n blend: this.getBlend(),\n cull: {\n enable: true,\n face: this.mapService.version === 'MAPBOX' ? gl.FRONT : gl.BACK,\n },\n depth: {\n enable: depth,\n },\n // primitive: gl.POINTS,\n }),\n ];\n }\n public clearModels() {\n this.dataTexture?.destroy();\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\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: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size } = feature;\n if (size) {\n let buffersize: number[] = [];\n if (Array.isArray(size)) {\n buffersize =\n size.length === 2 ? [size[0], size[0], size[1]] : size;\n }\n if (!Array.isArray(size)) {\n buffersize = [size, size, size];\n }\n return buffersize;\n } else {\n return [2, 2, 2];\n }\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\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 return normal;\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'pos',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Pos',\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: 3,\n update: (feature: IEncodeFeature, featureIdx: number) => {\n const coordinates = calculateCentroid(feature.coordinates);\n if (isGlobel) {\n // TODO: 在地球模式下需要将传入 shader 的经纬度转化成对应的 xyz 坐标\n return lglt2xyz([coordinates[0], coordinates[1]]) as [\n number,\n number,\n number,\n ];\n } else {\n return [coordinates[0], coordinates[1], 0];\n }\n },\n },\n });\n }\n}\n"],"file":"extrude.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/models/fill.ts"],"names":["FillModel","layer","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_isMeter","Number","isMeter","u_additive","u_globel","mapService","version","Version","GLOBEL","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_stroke_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_offsets","isOffsetStatic","animateOption","enable","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","styleAttributeService","createAttributesAndIndices","PointFillTriangulation","unit","L7MAP","calMeter2Coord","buildModels","getSource","extent","minLng","minLat","maxLng","maxLat","center","MAPBOX","window","mapboxgl","MercatorCoordinate","coord","fromLngLat","lng","lat","offsetInMeters","offsetInMercatorCoordinateUnits","meterInMercatorCoordinateUnits","westCoord","x","y","z","westLnglat","toLngLat","meter2coord","m1","meterToCoord","m2","Boolean","mask","maskInside","getShaders","frag","vert","isGlobel","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","GlobelPointFillTriangulation","depth","getBlend","stencil","waveFillFrag","pointFillVert","pointFillFrag","destroy","option","speed","rings","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","extrude","n1","vec3","fromValues","n2","xzReg","angle","Math","PI","yReg","asin","m","mat4","create","rotateY","rotateX","v1","transformMat4","normalize","v2","v3","v4","extrudeIndex","Array","isArray","shape","shape2d","shapeIndex","indexOf","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAUA;;AACA;;AAEA;;AAYA;;AACA;;;;;;;;;;IACqBA,S;;;;;;;;;;;;;;;8FACU,C;0FACF,K;;;;;;WAC3B,wBAAqC;AACnC,iBAOI,KAAKC,KAAL,CAAWC,cAAX,EAPJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,oCAEEC,aAFF;AA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AD,GAAmB,MAAI,CAACnC,WAAzB,CAFJ;AAGD;AApBS;AAHoC,OAAlD;AA4BA,WAAK/B,qBAAL,CAA2B0D,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,OAD0C;AAEhDtF,QAAAA,IAAI,EAAEuF,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,SADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAE7F,WAAG8F,YAFJ;AAGNvG,YAAAA,IAAI,EAAE,EAHA;AAINW,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQV4F,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,iCAAsBH,OAAtB,CAAQ6B,KAAR;AAAA,gBAAQA,KAAR,+BAAgB,CAAhB;;AACA,gBAAMC,OAAO,GAAG,MAAI,CAACxJ,KAAL,CAAWC,cAAX,GAA4BuJ,OAA5C;;AACA,gBAAMC,UAAU,GAAGD,OAAO,CAACE,OAAR,CAAgBH,KAAhB,CAAnB;AACA,mBAAO,CAACE,UAAD,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;EA3VoCE,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IAttribute,\n IElements,\n IEncodeFeature,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport {\n GlobelPointFillTriangulation,\n PointFillTriangulation,\n} from '../../core/triangulation';\n// animate pointLayer shader - support animate\nimport waveFillFrag from '../shaders/animate/wave_frag.glsl';\n// static pointLayer shader - not support animate\nimport pointFillFrag from '../shaders/fill_frag.glsl';\nimport pointFillVert from '../shaders/fill_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { Version } from '@antv/l7-maps';\nimport { mat4, vec3 } from 'gl-matrix';\nexport default class FillModel extends BaseModel {\n public meter2coord: number = 1;\n private isMeter: boolean = false;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\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_isMeter: Number(this.isMeter),\n\n u_additive: blend === 'additive' ? 1.0 : 0.0,\n u_globel: this.mapService.version === Version.GLOBEL ? 1 : 0,\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.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 u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const {\n animateOption = { enable: false },\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n return {\n u_aimate: this.animateOption2Array(animateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n const {\n unit = 'l7size',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { version } = this.mapService;\n if (\n unit === 'meter' &&\n version !== Version.L7MAP &&\n version !== Version.GLOBEL\n ) {\n this.isMeter = true;\n this.calMeter2Coord();\n }\n\n return this.buildModels();\n }\n\n /**\n * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例\n * @returns\n */\n public calMeter2Coord() {\n // @ts-ignore\n const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;\n const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];\n\n const { version } = this.mapService;\n if (version === Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {\n const coord = window.mapboxgl.MercatorCoordinate.fromLngLat(\n { lng: center[0], lat: center[1] },\n 0,\n );\n const offsetInMeters = 1;\n const offsetInMercatorCoordinateUnits =\n offsetInMeters * coord.meterInMercatorCoordinateUnits();\n const westCoord = new window.mapboxgl.MercatorCoordinate(\n coord.x - offsetInMercatorCoordinateUnits,\n coord.y,\n coord.z,\n );\n const westLnglat = westCoord.toLngLat();\n\n this.meter2coord = center[0] - westLnglat.lng;\n return;\n }\n\n // @ts-ignore\n const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);\n // @ts-ignore\n const m2 = this.mapService.meterToCoord(center, [\n maxLng === minLng ? maxLng + 0.1 : maxLng,\n maxLat === minLat ? minLat + 0.1 : maxLat,\n ]);\n this.meter2coord = (m1 + m2) / 2;\n if (!Boolean(this.meter2coord)) {\n // Tip: 兼容单个数据导致的 m1、m2 为 NaN\n this.meter2coord = 7.70681090738883;\n }\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n animateOption = { enable: false },\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { frag, vert, type } = this.getShaders(animateOption);\n\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill-' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: isGlobel\n ? GlobelPointFillTriangulation\n : PointFillTriangulation,\n // depth: { enable: false },\n depth: { enable: isGlobel },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据 animateOption 的值返回对应的 shader 代码\n * @returns\n */\n public getShaders(\n animateOption: IAnimateOption,\n ): { frag: string; vert: string; type: string } {\n if (animateOption.enable) {\n switch (animateOption.type) {\n case 'wave':\n return {\n frag: waveFillFrag,\n vert: pointFillVert,\n type: 'wave',\n };\n default:\n return {\n frag: waveFillFrag,\n vert: pointFillVert,\n type: 'wave',\n };\n }\n } else {\n return {\n frag: pointFillFrag,\n vert: pointFillVert,\n type: 'normal',\n };\n }\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n // overwrite baseModel func\n protected animateOption2Array(option: IAnimateOption): number[] {\n return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\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: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n let extrude;\n // 地球模式\n if (isGlobel) {\n const [x, y, z] = vertex;\n const n1 = vec3.fromValues(0, 0, 1);\n const n2 = vec3.fromValues(x, 0, z);\n\n const xzReg =\n x >= 0 ? vec3.angle(n1, n2) : Math.PI * 2 - vec3.angle(n1, n2);\n\n const yReg = Math.PI * 2 - Math.asin(y / 100);\n\n const m = mat4.create();\n mat4.rotateY(m, m, xzReg);\n mat4.rotateX(m, m, yReg);\n\n const v1 = vec3.fromValues(1, 1, 0);\n vec3.transformMat4(v1, v1, m);\n vec3.normalize(v1, v1);\n\n const v2 = vec3.fromValues(-1, 1, 0);\n vec3.transformMat4(v2, v2, m);\n vec3.normalize(v2, v2);\n\n const v3 = vec3.fromValues(-1, -1, 0);\n vec3.transformMat4(v3, v3, m);\n vec3.normalize(v3, v3);\n\n const v4 = vec3.fromValues(1, -1, 0);\n vec3.transformMat4(v4, v4, m);\n vec3.normalize(v4, v4);\n\n extrude = [...v1, ...v2, ...v3, ...v4];\n } else {\n // 平面模式\n extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n }\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\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 = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size)\n ? [size[0] * this.meter2coord]\n : [(size as number) * this.meter2coord];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'shape',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Shape',\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 { shape = 2 } = feature;\n const shape2d = this.layer.getLayerConfig().shape2d as string[];\n const shapeIndex = shape2d.indexOf(shape as string);\n return [shapeIndex];\n },\n },\n });\n }\n}\n"],"file":"fill.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/point/models/fill.ts"],"names":["FillModel","layer","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_isMeter","Number","isMeter","u_additive","u_globel","mapService","version","Version","GLOBEL","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_stroke_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_offsets","isOffsetStatic","animateOption","enable","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","styleAttributeService","createAttributesAndIndices","PointFillTriangulation","unit","L7MAP","calMeter2Coord","buildModels","getSource","extent","minLng","minLat","maxLng","maxLat","center","MAPBOX","window","mapboxgl","MercatorCoordinate","coord","fromLngLat","lng","lat","offsetInMeters","offsetInMercatorCoordinateUnits","meterInMercatorCoordinateUnits","westCoord","x","y","z","westLnglat","toLngLat","meter2coord","m1","meterToCoord","m2","Boolean","mask","maskInside","getShaders","frag","vert","isGlobel","buildLayerModel","moduleName","vertexShader","fragmentShader","triangulation","GlobelPointFillTriangulation","depth","getBlend","stencil","waveFillFrag","pointFillVert","pointFillFrag","destroy","option","speed","rings","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","extrude","n1","vec3","fromValues","n2","xzReg","angle","Math","PI","yReg","asin","m","mat4","create","rotateY","rotateX","v1","transformMat4","normalize","v2","v3","v4","extrudeIndex","Array","isArray","shape","shape2d","shapeIndex","indexOf","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAWA;;AACA;;AAEA;;AAYA;;AACA;;;;;;;;;;IACqBA,S;;;;;;;;;;;;;;;8FACU,C;0FACF,K;;;;;;WAC3B,wBAAqC;AACnC,iBAOI,KAAKC,KAAL,CAAWC,cAAX,EAPJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,oCAEEC,aAFF;AAAA,UAEEA,aAFF,mCAEkB,CAFlB;AAAA,kCAGEC,WAHF;AAAA,UAGEA,WAHF,iCAGgB,CAHhB;AAAA,6BAIEC,MAJF;AAAA,UAIEA,MAJF,4BAIW,eAJX;AAAA,8BAKEC,OALF;AAAA,UAKEA,OALF,6BAKY,CAAC,CAAD,EAAI,CAAJ,CALZ;AAAA,UAMEC,KANF,QAMEA,KANF;;AASA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBP,QAAAA,OAAO,EAAPA,OADyB;AAEzBC,QAAAA,aAAa,EAAbA,aAFyB;AAGzBC,QAAAA,WAAW,EAAXA,WAHyB;AAIzBC,QAAAA,MAAM,EAANA,MAJyB;AAKzBC,QAAAA,OAAO,EAAPA;AALyB,OAA3B,CAFF,EASE;AAEA,aAAKI,oBAAL,CAA0B;AACxBR,UAAAA,OAAO,EAAPA,OADwB;AAExBC,UAAAA,aAAa,EAAbA,aAFwB;AAGxBC,UAAAA,WAAW,EAAXA,WAHwB;AAIxBC,UAAAA,MAAM,EAANA,MAJwB;AAKxBC,UAAAA,OAAO,EAAPA;AALwB,SAA1B;AAQA,YAAMK,UAAU,GAAG,KAAKX,KAAL,CAAWY,cAAX,EAAnB;;AACA,iCAAgC,KAAKC,YAAL,CAC9B,KAAKC,UADyB,EAE9BH,UAF8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["import {\n AttributeType,\n gl,\n IAnimateOption,\n IAttribute,\n IElements,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport { getMask } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IPointLayerStyleOptions } from '../../core/interface';\nimport {\n GlobelPointFillTriangulation,\n PointFillTriangulation,\n} from '../../core/triangulation';\n// animate pointLayer shader - support animate\nimport waveFillFrag from '../shaders/animate/wave_frag.glsl';\n// static pointLayer shader - not support animate\nimport pointFillFrag from '../shaders/fill_frag.glsl';\nimport pointFillVert from '../shaders/fill_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { Version } from '@antv/l7-maps';\nimport { mat4, vec3 } from 'gl-matrix';\nexport default class FillModel extends BaseModel {\n public meter2coord: number = 1;\n private isMeter: boolean = false;\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\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_isMeter: Number(this.isMeter),\n\n u_additive: blend === 'additive' ? 1.0 : 0.0,\n u_globel: this.mapService.version === Version.GLOBEL ? 1 : 0,\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.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 u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const {\n animateOption = { enable: false },\n } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n const {\n unit = 'l7size',\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n const { version } = this.mapService;\n if (\n unit === 'meter' &&\n version !== Version.L7MAP &&\n version !== Version.GLOBEL\n ) {\n this.isMeter = true;\n this.calMeter2Coord();\n }\n\n return this.buildModels();\n }\n\n /**\n * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例\n * @returns\n */\n public calMeter2Coord() {\n // @ts-ignore\n const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;\n const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];\n\n const { version } = this.mapService;\n if (version === Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {\n const coord = window.mapboxgl.MercatorCoordinate.fromLngLat(\n { lng: center[0], lat: center[1] },\n 0,\n );\n const offsetInMeters = 1;\n const offsetInMercatorCoordinateUnits =\n offsetInMeters * coord.meterInMercatorCoordinateUnits();\n const westCoord = new window.mapboxgl.MercatorCoordinate(\n coord.x - offsetInMercatorCoordinateUnits,\n coord.y,\n coord.z,\n );\n const westLnglat = westCoord.toLngLat();\n\n this.meter2coord = center[0] - westLnglat.lng;\n return;\n }\n\n // @ts-ignore\n const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);\n // @ts-ignore\n const m2 = this.mapService.meterToCoord(center, [\n maxLng === minLng ? maxLng + 0.1 : maxLng,\n maxLat === minLat ? minLat + 0.1 : maxLat,\n ]);\n this.meter2coord = (m1 + m2) / 2;\n if (!Boolean(this.meter2coord)) {\n // Tip: 兼容单个数据导致的 m1、m2 为 NaN\n this.meter2coord = 7.70681090738883;\n }\n }\n\n public buildModels(): IModel[] {\n const {\n mask = false,\n maskInside = true,\n animateOption = { enable: false },\n } = this.layer.getLayerConfig() as Partial<\n ILayerConfig & IPointLayerStyleOptions\n >;\n const { frag, vert, type } = this.getShaders(animateOption);\n\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill-' + type,\n vertexShader: vert,\n fragmentShader: frag,\n triangulation: isGlobel\n ? GlobelPointFillTriangulation\n : PointFillTriangulation,\n // depth: { enable: false },\n depth: { enable: isGlobel },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n /**\n * 根据 animateOption 的值返回对应的 shader 代码\n * @returns\n */\n public getShaders(\n animateOption: Partial<IAnimateOption>,\n ): { frag: string; vert: string; type: string } {\n if (animateOption.enable) {\n switch (animateOption.type) {\n case 'wave':\n return {\n frag: waveFillFrag,\n vert: pointFillVert,\n type: 'wave',\n };\n default:\n return {\n frag: waveFillFrag,\n vert: pointFillVert,\n type: 'wave',\n };\n }\n } else {\n return {\n frag: pointFillFrag,\n vert: pointFillVert,\n type: 'normal',\n };\n }\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n // overwrite baseModel func\n protected animateOption2Array(option: Partial<IAnimateOption>): number[] {\n return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\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: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n let extrude;\n // 地球模式\n if (isGlobel) {\n const [x, y, z] = vertex;\n const n1 = vec3.fromValues(0, 0, 1);\n const n2 = vec3.fromValues(x, 0, z);\n\n const xzReg =\n x >= 0 ? vec3.angle(n1, n2) : Math.PI * 2 - vec3.angle(n1, n2);\n\n const yReg = Math.PI * 2 - Math.asin(y / 100);\n\n const m = mat4.create();\n mat4.rotateY(m, m, xzReg);\n mat4.rotateX(m, m, yReg);\n\n const v1 = vec3.fromValues(1, 1, 0);\n vec3.transformMat4(v1, v1, m);\n vec3.normalize(v1, v1);\n\n const v2 = vec3.fromValues(-1, 1, 0);\n vec3.transformMat4(v2, v2, m);\n vec3.normalize(v2, v2);\n\n const v3 = vec3.fromValues(-1, -1, 0);\n vec3.transformMat4(v3, v3, m);\n vec3.normalize(v3, v3);\n\n const v4 = vec3.fromValues(1, -1, 0);\n vec3.transformMat4(v4, v4, m);\n vec3.normalize(v4, v4);\n\n extrude = [...v1, ...v2, ...v3, ...v4];\n } else {\n // 平面模式\n extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n }\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\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 = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size)\n ? [size[0] * this.meter2coord]\n : [(size as number) * this.meter2coord];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'shape',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Shape',\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 { shape = 2 } = feature;\n const shape2d = this.layer.getLayerConfig().shape2d as string[];\n const shapeIndex = shape2d.indexOf(shape as string);\n return [shapeIndex];\n },\n },\n });\n }\n}\n"],"file":"fill.js"}
|