@antv/l7-layers 2.5.40 → 2.5.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/core/BaseLayer.js +7 -4
- package/es/core/BaseLayer.js.map +1 -1
- package/es/core/BaseModel.js +1 -1
- package/es/core/BaseModel.js.map +1 -1
- package/es/heatmap/models/heatmap.js +13 -18
- package/es/heatmap/models/heatmap.js.map +1 -1
- package/es/image/models/image.js +27 -7
- package/es/image/models/image.js.map +1 -1
- package/es/line/index.d.ts +2 -0
- package/es/line/index.js +3 -0
- package/es/line/index.js.map +1 -1
- package/es/line/models/arcmini.d.ts +9 -0
- package/es/line/models/arcmini.js +144 -0
- package/es/line/models/arcmini.js.map +1 -0
- package/es/line/models/index.d.ts +1 -1
- package/es/line/models/index.js +2 -0
- package/es/line/models/index.js.map +1 -1
- package/es/plugins/DataMappingPlugin.js +1 -1
- package/es/plugins/FeatureScalePlugin.js.map +1 -1
- package/es/plugins/LayerAnimateStylePlugin.js +1 -1
- package/es/plugins/LayerStylePlugin.js.map +1 -1
- package/es/plugins/LightingPlugin.js +4 -2
- package/es/plugins/LightingPlugin.js.map +1 -1
- package/es/plugins/ShaderUniformPlugin.js +2 -1
- package/es/plugins/ShaderUniformPlugin.js.map +1 -1
- package/es/plugins/UpdateStyleAttributePlugin.js +6 -6
- package/es/plugins/UpdateStyleAttributePlugin.js.map +1 -1
- package/es/point/models/image.js.map +1 -1
- package/es/point/models/text.js +1 -1
- package/es/point/models/text.js.map +1 -1
- package/es/raster/raster.js +1 -1
- package/lib/core/BaseLayer.js +8 -4
- package/lib/core/BaseLayer.js.map +1 -1
- package/lib/core/BaseModel.js +1 -1
- package/lib/core/BaseModel.js.map +1 -1
- package/lib/core/shape/Path.js +5 -4
- package/lib/core/shape/Path.js.map +1 -1
- package/lib/core/shape/extrude.js +1 -1
- package/lib/core/triangulation.js +13 -9
- package/lib/core/triangulation.js.map +1 -1
- package/lib/earth/utils.js +1 -1
- package/lib/heatmap/models/heatmap.js +13 -18
- package/lib/heatmap/models/heatmap.js.map +1 -1
- package/lib/image/models/image.js +28 -7
- package/lib/image/models/image.js.map +1 -1
- package/lib/index.js +8 -8
- package/lib/line/index.js +3 -0
- package/lib/line/index.js.map +1 -1
- package/lib/line/models/arcmini.js +160 -0
- package/lib/line/models/arcmini.js.map +1 -0
- package/lib/line/models/index.js +3 -0
- package/lib/line/models/index.js.map +1 -1
- package/lib/plugins/DataMappingPlugin.js +1 -1
- package/lib/plugins/DataSourcePlugin.js +5 -1
- package/lib/plugins/DataSourcePlugin.js.map +1 -1
- package/lib/plugins/FeatureScalePlugin.js +5 -1
- package/lib/plugins/FeatureScalePlugin.js.map +1 -1
- package/lib/plugins/LayerAnimateStylePlugin.js +1 -1
- package/lib/plugins/LayerStylePlugin.js.map +1 -1
- package/lib/plugins/LightingPlugin.js +5 -3
- package/lib/plugins/LightingPlugin.js.map +1 -1
- package/lib/plugins/MultiPassRendererPlugin.js +1 -1
- package/lib/plugins/ShaderUniformPlugin.js +3 -1
- package/lib/plugins/ShaderUniformPlugin.js.map +1 -1
- package/lib/plugins/UpdateStyleAttributePlugin.js +6 -6
- package/lib/plugins/UpdateStyleAttributePlugin.js.map +1 -1
- package/lib/point/models/image.js.map +1 -1
- package/lib/point/models/text.js +1 -1
- package/lib/point/models/text.js.map +1 -1
- package/lib/point/shape/Path.js +5 -4
- package/lib/point/shape/Path.js.map +1 -1
- package/lib/raster/raster.js +1 -1
- package/lib/utils/dataMappingStyle.js +1 -1
- package/lib/utils/extrude_polyline.js +1 -1
- package/lib/utils/polylineNormal.js +1 -1
- package/lib/utils/symbol-layout.js +1 -1
- package/package.json +5 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/models/text.ts"],"names":["TextTriangulation","feature","that","id","vertices","indices","glyphInfoMap","size","centroid","coord","length","glyphQuads","forEach","quad","index","push","tex","x","y","height","tl","width","tr","br","bl","TextModel","initGlyph","updateTexture","filterGlyphs","reBuildModel","layer","buildLayerModel","moduleName","vertexShader","textVert","fragmentShader","textFrag","triangulation","bind","depth","enable","blend","getBlend","getLayerConfig","opacity","stroke","strokeWidth","textAnchor","textAllowOverlap","halo","gamma","fontService","canvas","mapping","Object","keys","textCount","preTextStyle","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","rowCount","dataTexture","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_sdf_map","texture","u_halo_blur","u_gamma_scale","u_sdf_map_size","on","buildModels","extent","textExtent","zoom","mapService","getZoom","getBounds","flag","Math","abs","currentZoom","destroy","off","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","update","featureIdx","vertex","attributeIdx","rotate","Array","isArray","STATIC_DRAW","bounds","fontWeight","fontFamily","characterSet","item","shape","toString","char","indexOf","setFontOptions","iconfont","spacing","glyphInfo","map","textOffset","shaping","coordinates","originCentroid","version","originCoordinates","padding","rendererService","getViewportSize","collisionIndex","CollisionIndex","filterData","filter","fontScale","pixels","lngLatToContainer","placeCollisionBox","x1","left","x2","right","y1","top","y2","bottom","anchorPointX","anchorPointY","box","insertCollisionBox","initIconFontTex","initTextFont","generateGlyphLayout","textureHeight","mag","LINEAR","min","models","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAWA;;AAEA;;AAKA;;AACA;;AACA;;;;;;;;;;;;;;;AAuBO,SAASA,iBAAT,CAA2BC,OAA3B,EAAoD;AAEzD,MAAMC,IAAI,GAAG,IAAb;AACA,MAAMC,EAAE,GAAGF,OAAO,CAACE,EAAnB;AACA,MAAMC,QAAkB,GAAG,EAA3B;AACA,MAAMC,OAAiB,GAAG,EAA1B;;AAEA,MAAI,CAACH,IAAI,CAACI,YAAN,IAAs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W;AAGzBC,QAAAA,cAAc,EAAEC,QAHS;AAIzBC,QAAAA,aAAa,EAAErC,iBAAiB,CAACsC,IAAlB,CAAuB,IAAvB,CAJU;AAKzBC,QAAAA,KAAK,EAAE;AAAEC,UAAAA,MAAM,EAAE;AAAV,SALkB;AAMzBC,QAAAA,KAAK,EAAE,KAAKC,QAAL;AANkB,OAA3B,CADkB,CAApB;AAUD;;;EAxboCgI,mB","sourcesContent":["import {\n AttributeType,\n BlendType,\n gl,\n IEncodeFeature,\n ILayer,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { boundsContains, padBounds, rgb2arr } from '@antv/l7-utils';\nimport { isNumber, isString } from 'lodash';\nimport BaseModel, {\n styleColor,\n styleOffset,\n styleSingle,\n} from '../../core/BaseModel';\nimport CollisionIndex from '../../utils/collision-index';\nimport { calculateCentroid } from '../../utils/geo';\nimport {\n anchorType,\n getGlyphQuads,\n IGlyphQuad,\n shapeText,\n} from '../../utils/symbol-layout';\nimport textFrag from '../shaders/text_frag.glsl';\nimport textVert from '../shaders/text_vert.glsl';\ninterface IPointTextLayerStyleOptions {\n opacity: styleSingle;\n strokeWidth: styleSingle;\n stroke: styleColor;\n textOffset: [number, number];\n\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}\nexport function TextTriangulation(feature: IEncodeFeature) {\n // @ts-ignore\n const that = this as TextModel;\n const id = feature.id as number;\n const vertices: number[] = [];\n const indices: number[] = [];\n\n if (!that.glyphInfoMap || !that.glyphInfoMap[id]) {\n return {\n vertices: [], // [ x, y, z, tex.x,tex.y, offset.x. offset.y]\n indices: [],\n size: 7,\n };\n }\n const centroid = that.glyphInfoMap[id].centroid as number[]; // 计算中心点\n const coord =\n centroid.length === 2 ? [centroid[0], centroid[1], 0] : centroid;\n that.glyphInfoMap[id].glyphQuads.forEach(\n (quad: IGlyphQuad, index: number) => {\n vertices.push(\n ...coord,\n quad.tex.x,\n quad.tex.y + quad.tex.height,\n quad.tl.x,\n quad.tl.y,\n ...coord,\n quad.tex.x + quad.tex.width,\n quad.tex.y + quad.tex.height,\n quad.tr.x,\n quad.tr.y,\n ...coord,\n quad.tex.x + quad.tex.width,\n quad.tex.y,\n quad.br.x,\n quad.br.y,\n ...coord,\n quad.tex.x,\n quad.tex.y,\n quad.bl.x,\n quad.bl.y,\n );\n indices.push(\n 0 + index * 4,\n 1 + index * 4,\n 2 + index * 4,\n 2 + index * 4,\n 3 + index * 4,\n 0 + index * 4,\n );\n },\n );\n return {\n vertices, // [ x, y, z, tex.x,tex.y, offset.x. offset.y]\n indices,\n size: 7,\n };\n}\n\nexport default class TextModel extends BaseModel {\n public glyphInfo: IEncodeFeature[];\n public glyphInfoMap: {\n [key: string]: {\n shaping: any;\n glyphQuads: IGlyphQuad[];\n centroid: number[];\n };\n } = {};\n private texture: ITexture2D;\n private currentZoom: number = -1;\n private extent: [[number, number], [number, number]];\n private textureHeight: number = 0;\n private textCount: number = 0;\n private preTextStyle: Partial<IPointTextLayerStyleOptions> = {};\n public getUninforms(): IModelUniform {\n const {\n opacity = 1.0,\n stroke = '#fff',\n strokeWidth = 0,\n textAnchor = 'center',\n textAllowOverlap = false,\n halo = 0.5,\n gamma = 2.0,\n } = this.layer.getLayerConfig() as IPointTextLayerStyleOptions;\n const { canvas, mapping } = this.fontService;\n if (Object.keys(mapping).length !== this.textCount) {\n this.updateTexture();\n this.textCount = Object.keys(mapping).length;\n }\n this.preTextStyle = {\n textAnchor,\n textAllowOverlap,\n };\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeWidth,\n stroke,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\n strokeWidth,\n stroke,\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\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 0.0,\n u_stroke_color: this.getStrokeColor(stroke),\n\n u_sdf_map: this.texture,\n u_halo_blur: halo,\n u_gamma_scale: gamma,\n u_sdf_map_size: [canvas.width, canvas.height],\n };\n }\n\n public initModels(): IModel[] {\n this.layer.on('remapping', this.buildModels);\n this.extent = this.textExtent();\n const {\n textAnchor = 'center',\n textAllowOverlap = true,\n } = this.layer.getLayerConfig() as IPointTextLayerStyleOptions;\n this.preTextStyle = {\n textAnchor,\n textAllowOverlap,\n };\n return this.buildModels();\n }\n\n public buildModels = () => {\n this.initGlyph();\n this.updateTexture();\n this.filterGlyphs();\n this.reBuildModel();\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointText',\n vertexShader: textVert,\n fragmentShader: textFrag,\n triangulation: TextTriangulation.bind(this),\n depth: { enable: false },\n blend: this.getBlend(),\n }),\n ];\n };\n public needUpdate() {\n const {\n textAllowOverlap = false,\n } = this.layer.getLayerConfig() as IPointTextLayerStyleOptions;\n // textAllowOverlap 发生改变\n const zoom = this.mapService.getZoom();\n const extent = this.mapService.getBounds();\n const flag = boundsContains(this.extent, extent);\n // 文本不能压盖则进行过滤\n if (\n (!textAllowOverlap && (Math.abs(this.currentZoom - zoom) > 1 || !flag)) ||\n textAllowOverlap !== this.preTextStyle.textAllowOverlap\n ) {\n this.reBuildModel();\n return true;\n }\n return false;\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n this.layer.off('remapping', this.buildModels);\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'rotate',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Rotate',\n buffer: {\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 { rotate = 0 } = feature;\n return Array.isArray(rotate) ? [rotate[0]] : [rotate as number];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'textOffsets',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_textOffsets',\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: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n // console.log([vertex[5], vertex[6]])\n return [vertex[5], vertex[6]];\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 = 12 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'textUv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_tex',\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: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4]];\n },\n },\n });\n }\n private textExtent(): [[number, number], [number, number]] {\n const bounds = this.mapService.getBounds();\n return padBounds(bounds, 0.5);\n }\n /**\n * 生成文字纹理(生成文字纹理字典)\n */\n private initTextFont() {\n const {\n fontWeight = '400',\n fontFamily = 'sans-serif',\n } = this.layer.getLayerConfig() as IPointTextLayerStyleOptions;\n const data = this.layer.getEncodedData();\n const characterSet: string[] = [];\n data.forEach((item: IEncodeFeature) => {\n let { shape = '' } = item;\n shape = shape.toString();\n for (const char of shape) {\n // 去重\n if (characterSet.indexOf(char) === -1) {\n characterSet.push(char);\n }\n }\n });\n this.fontService.setFontOptions({\n characterSet,\n fontWeight,\n fontFamily,\n iconfont: false,\n });\n }\n\n /**\n * 生成 iconfont 纹理字典\n */\n private initIconFontTex() {\n const {\n fontWeight = '400',\n fontFamily = 'sans-serif',\n } = this.layer.getLayerConfig() as IPointTextLayerStyleOptions;\n const data = this.layer.getEncodedData();\n const characterSet: string[] = [];\n data.forEach((item: IEncodeFeature) => {\n let { shape = '' } = item;\n shape = shape.toString();\n if (characterSet.indexOf(shape) === -1) {\n characterSet.push(shape);\n }\n });\n this.fontService.setFontOptions({\n characterSet,\n fontWeight,\n fontFamily,\n iconfont: true,\n });\n }\n\n /**\n * 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)\n */\n private generateGlyphLayout(iconfont: boolean) {\n // TODO:更新文字布局\n const { mapping } = this.fontService;\n const {\n spacing = 2,\n textAnchor = 'center',\n // textOffset,\n } = this.layer.getLayerConfig() as IPointTextLayerStyleOptions;\n const data = this.layer.getEncodedData();\n\n this.glyphInfo = data.map((feature: IEncodeFeature) => {\n const { shape = '', id, size = 1, textOffset = [0, 0] } = feature;\n\n const shaping = shapeText(\n shape.toString(),\n mapping,\n // @ts-ignore\n size,\n textAnchor,\n 'center',\n spacing,\n textOffset,\n iconfont,\n );\n const glyphQuads = getGlyphQuads(shaping, textOffset, false);\n feature.shaping = shaping;\n feature.glyphQuads = glyphQuads;\n // feature.centroid = calculteCentroid(coordinates);\n\n feature.centroid = calculateCentroid(feature.coordinates);\n\n // 此时地图高德2.0 originCentroid == centroid\n feature.originCentroid =\n feature.version === 'GAODE2.x'\n ? calculateCentroid(feature.originCoordinates)\n : (feature.originCentroid = feature.centroid);\n\n this.glyphInfoMap[id as number] = {\n shaping,\n glyphQuads,\n centroid: calculateCentroid(feature.coordinates),\n };\n return feature;\n });\n }\n /**\n * 文字避让 depend on originCentorid\n */\n private filterGlyphs() {\n const {\n padding = [4, 4],\n textAllowOverlap = false,\n } = this.layer.getLayerConfig() as IPointTextLayerStyleOptions;\n if (textAllowOverlap) {\n // 如果允许文本覆盖\n // this.layer.setEncodedData(this.glyphInfo);\n return;\n }\n this.glyphInfoMap = {};\n this.currentZoom = this.mapService.getZoom();\n this.extent = this.textExtent();\n const { width, height } = this.rendererService.getViewportSize();\n const collisionIndex = new CollisionIndex(width, height);\n const filterData = this.glyphInfo.filter((feature: IEncodeFeature) => {\n const { shaping, id = 0 } = feature;\n // const centroid = feature.centroid as [number, number];\n // const centroid = feature.originCentroid as [number, number];\n const centroid = (feature.version === 'GAODE2.x'\n ? feature.originCentroid\n : feature.centroid) as [number, number];\n const size = feature.size as number;\n const fontScale: number = size / 24;\n const pixels = this.mapService.lngLatToContainer(centroid);\n const { box } = collisionIndex.placeCollisionBox({\n x1: shaping.left * fontScale - padding[0],\n x2: shaping.right * fontScale + padding[0],\n y1: shaping.top * fontScale - padding[1],\n y2: shaping.bottom * fontScale + padding[1],\n anchorPointX: pixels.x,\n anchorPointY: pixels.y,\n });\n if (box && box.length) {\n // TODO:featureIndex\n collisionIndex.insertCollisionBox(box, id);\n return true;\n } else {\n return false;\n }\n });\n filterData.forEach((item) => {\n // @ts-ignore\n this.glyphInfoMap[item.id as number] = item;\n });\n // this.layer.setEncodedData(filterData);\n }\n /**\n * 初始化文字布局\n */\n private initGlyph() {\n const { iconfont = false } = this.layer.getLayerConfig();\n // 1.生成文字纹理(或是生成 iconfont)\n iconfont ? this.initIconFontTex() : this.initTextFont();\n // this.initTextFont();\n\n // 2.生成文字布局\n this.generateGlyphLayout(iconfont);\n }\n /**\n * 更新文字纹理\n */\n private updateTexture() {\n const { createTexture2D } = this.rendererService;\n const { canvas } = this.fontService;\n this.textureHeight = canvas.height;\n if (this.texture) {\n this.texture.destroy();\n }\n\n this.texture = createTexture2D({\n data: canvas,\n mag: gl.LINEAR,\n min: gl.LINEAR,\n width: canvas.width,\n height: canvas.height,\n });\n }\n\n private reBuildModel() {\n this.filterGlyphs();\n this.layer.models = [\n this.layer.buildLayerModel({\n moduleName: 'pointText',\n vertexShader: textVert,\n fragmentShader: textFrag,\n triangulation: TextTriangulation.bind(this),\n depth: { enable: false },\n blend: this.getBlend(),\n }),\n ];\n }\n}\n"],"file":"text.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/point/models/text.ts"],"names":["TextTriangulation","feature","that","id","vertices","indices","glyphInfoMap","size","centroid","coord","length","glyphQuads","forEach","quad","index","push","tex","x","y","height","tl","width","tr","br","bl","TextModel","initGlyph","updateTexture","filterGlyphs","reBuildModel","layer","buildLayerModel","moduleName","vertexShader","textVert","fragmentShader","textFrag","triangulation","bind","depth","enable","blend","getBlend","getLayerConfig","opacity","stroke","strokeWidth","textAnchor","textAllowOverlap","halo","gamma","fontService","canvas","mapping","Object","keys","textCount","preTextStyle","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","rowCount","dataTexture","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_sdf_map","texture","u_halo_blur","u_gamma_scale","u_sdf_map_size","on","buildModels","extent","textExtent","zoom","mapService","getZoom","getBounds","flag","Math","abs","currentZoom","destroy","off","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","update","featureIdx","vertex","attributeIdx","rotate","Array","isArray","STATIC_DRAW","bounds","fontWeight","fontFamily","characterSet","item","shape","toString","char","indexOf","setFontOptions","iconfont","spacing","glyphInfo","map","textOffset","shaping","coordinates","originCentroid","version","originCoordinates","padding","rendererService","getViewportSize","collisionIndex","CollisionIndex","filterData","filter","fontScale","pixels","lngLatToContainer","placeCollisionBox","x1","left","x2","right","y1","top","y2","bottom","anchorPointX","anchorPointY","box","insertCollisionBox","initIconFontTex","initTextFont","generateGlyphLayout","textureHeight","mag","LINEAR","min","models","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAWA;;AAEA;;AAKA;;AACA;;AACA;;;;;;;;;;;;;;;AAuBO,SAASA,iBAAT,CAA2BC,OAA3B,EAAoD;AAEzD,MAAMC,IAAI,GAAG,IAAb;AACA,MAAMC,EAAE,GAAGF,OAAO,CAACE,EAAnB;AACA,MAAMC,QAAkB,GAAG,EAA3B;AACA,MAAMC,OAAiB,GAAG,EAA1B;;AAEA,MAAI,CAACH,IAAI,CAACI,YAAN,IAAsB,CAACJ,IAAI,CAACI,YAAL,CAAkBH,EAAlB,CAA3B,EAAkD;AAChD,WAAO;AACLC,MAAAA,QAAQ,EAAE,EADL;AAELC,MAAAA,OAAO,EAAE,EAFJ;AAGLE,MAAAA,IAAI,EAAE;AAHD,KAAP;AAKD;;AACD,MAAMC,QAAQ,GAAGN,IAAI,CAACI,YAAL,CAAkBH,EAAlB,EAAsBK,QAAvC;AACA,MAAMC,KAAK,GACTD,QAAQ,CAACE,MAAT,KAAoB,CAApB,GAAwB,CAACF,QAAQ,CAAC,CAAD,CAAT,EAAcA,QAAQ,CAAC,CAAD,CAAtB,EAA2B,CAA3B,CAAxB,GAAwDA,QAD1D;AAEAN,EAAAA,IAAI,CAACI,YAAL,CAAkBH,EAAlB,EAAsBQ,UAAtB,CAAiCC,OAAjC,CACE,UAACC,IAAD,EAAmBC,KAAnB,EAAqC;AACnCV,IAAAA,QAAQ,CAACW,IAAT,OAAA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AACA,UAAQjB,MAAR,GAAmB,KAAKD,WAAxB,CAAQC,MAAR;AACA,WAAKiH,aAAL,GAAqBjH,MAAM,CAACjC,MAA5B;;AACA,UAAI,KAAKiE,OAAT,EAAkB;AAChB,aAAKA,OAAL,CAAagB,OAAb;AACD;;AAED,WAAKhB,OAAL,GAAef,eAAe,CAAC;AAC7BH,QAAAA,IAAI,EAAEd,MADuB;AAE7BkH,QAAAA,GAAG,EAAE9F,WAAG+F,MAFqB;AAG7BC,QAAAA,GAAG,EAAEhG,WAAG+F,MAHqB;AAI7BlJ,QAAAA,KAAK,EAAE+B,MAAM,CAAC/B,KAJe;AAK7BF,QAAAA,MAAM,EAAEiC,MAAM,CAACjC;AALc,OAAD,CAA9B;AAOD;;;WAED,wBAAuB;AACrB,WAAKS,YAAL;AACA,WAAKE,KAAL,CAAW2I,MAAX,GAAoB,CAClB,KAAK3I,KAAL,CAAWC,eAAX,CAA2B;AACzBC,QAAAA,UAAU,EAAE,WADa;AAEzBC,QAAAA,YAAY,EAAEC,QAFW;AAGzBC,QAAAA,cAAc,EAAEC,QAHS;AAIzBC,QAAAA,aAAa,EAAErC,iBAAiB,CAACsC,IAAlB,CAAuB,IAAvB,CAJU;AAKzBC,QAAAA,KAAK,EAAE;AAAEC,UAAAA,MAAM,EAAE;AAAV,SALkB;AAMzBC,QAAAA,KAAK,EAAE,KAAKC,QAAL;AANkB,OAA3B,CADkB,CAApB;AAUD;;;EAxboCgI,mB","sourcesContent":["import {\n AttributeType,\n BlendType,\n gl,\n IEncodeFeature,\n ILayer,\n ILayerConfig,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { boundsContains, padBounds, rgb2arr } from '@antv/l7-utils';\nimport { isNumber, isString } from 'lodash';\nimport BaseModel, {\n styleColor,\n styleOffset,\n styleSingle,\n} from '../../core/BaseModel';\nimport CollisionIndex from '../../utils/collision-index';\nimport { calculateCentroid } from '../../utils/geo';\nimport {\n anchorType,\n getGlyphQuads,\n IGlyphQuad,\n shapeText,\n} from '../../utils/symbol-layout';\nimport textFrag from '../shaders/text_frag.glsl';\nimport textVert from '../shaders/text_vert.glsl';\ninterface IPointTextLayerStyleOptions {\n opacity: styleSingle;\n strokeWidth: styleSingle;\n stroke: styleColor;\n textOffset: [number, number];\n\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}\nexport function TextTriangulation(feature: IEncodeFeature) {\n // @ts-ignore\n const that = this as TextModel;\n const id = feature.id as number;\n const vertices: number[] = [];\n const indices: number[] = [];\n\n if (!that.glyphInfoMap || !that.glyphInfoMap[id]) {\n return {\n vertices: [], // [ x, y, z, tex.x,tex.y, offset.x. offset.y]\n indices: [],\n size: 7,\n };\n }\n const centroid = that.glyphInfoMap[id].centroid as number[]; // 计算中心点\n const coord =\n centroid.length === 2 ? [centroid[0], centroid[1], 0] : centroid;\n that.glyphInfoMap[id].glyphQuads.forEach(\n (quad: IGlyphQuad, index: number) => {\n vertices.push(\n ...coord,\n quad.tex.x,\n quad.tex.y + quad.tex.height,\n quad.tl.x,\n quad.tl.y,\n ...coord,\n quad.tex.x + quad.tex.width,\n quad.tex.y + quad.tex.height,\n quad.tr.x,\n quad.tr.y,\n ...coord,\n quad.tex.x + quad.tex.width,\n quad.tex.y,\n quad.br.x,\n quad.br.y,\n ...coord,\n quad.tex.x,\n quad.tex.y,\n quad.bl.x,\n quad.bl.y,\n );\n indices.push(\n 0 + index * 4,\n 1 + index * 4,\n 2 + index * 4,\n 2 + index * 4,\n 3 + index * 4,\n 0 + index * 4,\n );\n },\n );\n return {\n vertices, // [ x, y, z, tex.x,tex.y, offset.x. offset.y]\n indices,\n size: 7,\n };\n}\n\nexport default class TextModel extends BaseModel {\n public glyphInfo: IEncodeFeature[];\n public glyphInfoMap: {\n [key: string]: {\n shaping: any;\n glyphQuads: IGlyphQuad[];\n centroid: number[];\n };\n } = {};\n private texture: ITexture2D;\n private currentZoom: number = -1;\n private extent: [[number, number], [number, number]];\n private textureHeight: number = 0;\n private textCount: number = 0;\n private preTextStyle: Partial<IPointTextLayerStyleOptions> = {};\n public getUninforms(): IModelUniform {\n const {\n opacity = 1.0,\n stroke = '#fff',\n strokeWidth = 0,\n textAnchor = 'center',\n textAllowOverlap = false,\n halo = 0.5,\n gamma = 2.0,\n } = this.layer.getLayerConfig() as IPointTextLayerStyleOptions;\n const { canvas, mapping } = this.fontService;\n if (Object.keys(mapping).length !== this.textCount) {\n this.updateTexture();\n this.textCount = Object.keys(mapping).length;\n }\n this.preTextStyle = {\n textAnchor,\n textAllowOverlap,\n };\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeWidth,\n stroke,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\n strokeWidth,\n stroke,\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\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 0.0,\n u_stroke_color: this.getStrokeColor(stroke),\n\n u_sdf_map: this.texture,\n u_halo_blur: halo,\n u_gamma_scale: gamma,\n u_sdf_map_size: [canvas.width, canvas.height],\n };\n }\n\n public initModels(): IModel[] {\n this.layer.on('remapping', this.buildModels);\n this.extent = this.textExtent();\n const {\n textAnchor = 'center',\n textAllowOverlap = true,\n } = this.layer.getLayerConfig() as IPointTextLayerStyleOptions;\n this.preTextStyle = {\n textAnchor,\n textAllowOverlap,\n };\n return this.buildModels();\n }\n\n public buildModels = () => {\n this.initGlyph();\n this.updateTexture();\n this.filterGlyphs();\n this.reBuildModel();\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointText',\n vertexShader: textVert,\n fragmentShader: textFrag,\n triangulation: TextTriangulation.bind(this),\n depth: { enable: false },\n blend: this.getBlend(),\n }),\n ];\n };\n public needUpdate() {\n const {\n textAllowOverlap = false,\n } = this.layer.getLayerConfig() as IPointTextLayerStyleOptions;\n // textAllowOverlap 发生改变\n const zoom = this.mapService.getZoom();\n const extent = this.mapService.getBounds();\n const flag = boundsContains(this.extent, extent);\n // 文本不能压盖则进行过滤\n if (\n (!textAllowOverlap && (Math.abs(this.currentZoom - zoom) > 1 || !flag)) ||\n textAllowOverlap !== this.preTextStyle.textAllowOverlap\n ) {\n this.reBuildModel();\n return true;\n }\n return false;\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n this.layer.off('remapping', this.buildModels);\n }\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'rotate',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Rotate',\n buffer: {\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 { rotate = 0 } = feature;\n return Array.isArray(rotate) ? [rotate[0]] : [rotate as number];\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'textOffsets',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_textOffsets',\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: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n // console.log([vertex[5], vertex[6]])\n return [vertex[5], vertex[6]];\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 = 12 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'textUv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_tex',\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: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4]];\n },\n },\n });\n }\n private textExtent(): [[number, number], [number, number]] {\n const bounds = this.mapService.getBounds();\n return padBounds(bounds, 0.5);\n }\n /**\n * 生成文字纹理(生成文字纹理字典)\n */\n private initTextFont() {\n const {\n fontWeight = '400',\n fontFamily = 'sans-serif',\n } = this.layer.getLayerConfig() as IPointTextLayerStyleOptions;\n const data = this.layer.getEncodedData();\n const characterSet: string[] = [];\n data.forEach((item: IEncodeFeature) => {\n let { shape = '' } = item;\n shape = shape.toString();\n for (const char of shape) {\n // 去重\n if (characterSet.indexOf(char) === -1) {\n characterSet.push(char);\n }\n }\n });\n this.fontService.setFontOptions({\n characterSet,\n fontWeight,\n fontFamily,\n iconfont: false,\n });\n }\n\n /**\n * 生成 iconfont 纹理字典\n */\n private initIconFontTex() {\n const {\n fontWeight = '400',\n fontFamily = 'sans-serif',\n } = this.layer.getLayerConfig() as IPointTextLayerStyleOptions;\n const data = this.layer.getEncodedData();\n const characterSet: string[] = [];\n data.forEach((item: IEncodeFeature) => {\n let { shape = '' } = item;\n shape = `${shape}`;\n if (characterSet.indexOf(shape) === -1) {\n characterSet.push(shape);\n }\n });\n this.fontService.setFontOptions({\n characterSet,\n fontWeight,\n fontFamily,\n iconfont: true,\n });\n }\n\n /**\n * 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)\n */\n private generateGlyphLayout(iconfont: boolean) {\n // TODO:更新文字布局\n const { mapping } = this.fontService;\n const {\n spacing = 2,\n textAnchor = 'center',\n // textOffset,\n } = this.layer.getLayerConfig() as IPointTextLayerStyleOptions;\n const data = this.layer.getEncodedData();\n\n this.glyphInfo = data.map((feature: IEncodeFeature) => {\n const { shape = '', id, size = 1, textOffset = [0, 0] } = feature;\n\n const shaping = shapeText(\n shape.toString(),\n mapping,\n // @ts-ignore\n size,\n textAnchor,\n 'center',\n spacing,\n textOffset,\n iconfont,\n );\n const glyphQuads = getGlyphQuads(shaping, textOffset, false);\n feature.shaping = shaping;\n feature.glyphQuads = glyphQuads;\n // feature.centroid = calculteCentroid(coordinates);\n\n feature.centroid = calculateCentroid(feature.coordinates);\n\n // 此时地图高德2.0 originCentroid == centroid\n feature.originCentroid =\n feature.version === 'GAODE2.x'\n ? calculateCentroid(feature.originCoordinates)\n : (feature.originCentroid = feature.centroid);\n\n this.glyphInfoMap[id as number] = {\n shaping,\n glyphQuads,\n centroid: calculateCentroid(feature.coordinates),\n };\n return feature;\n });\n }\n /**\n * 文字避让 depend on originCentorid\n */\n private filterGlyphs() {\n const {\n padding = [4, 4],\n textAllowOverlap = false,\n } = this.layer.getLayerConfig() as IPointTextLayerStyleOptions;\n if (textAllowOverlap) {\n // 如果允许文本覆盖\n // this.layer.setEncodedData(this.glyphInfo);\n return;\n }\n this.glyphInfoMap = {};\n this.currentZoom = this.mapService.getZoom();\n this.extent = this.textExtent();\n const { width, height } = this.rendererService.getViewportSize();\n const collisionIndex = new CollisionIndex(width, height);\n const filterData = this.glyphInfo.filter((feature: IEncodeFeature) => {\n const { shaping, id = 0 } = feature;\n // const centroid = feature.centroid as [number, number];\n // const centroid = feature.originCentroid as [number, number];\n const centroid = (feature.version === 'GAODE2.x'\n ? feature.originCentroid\n : feature.centroid) as [number, number];\n const size = feature.size as number;\n const fontScale: number = size / 24;\n const pixels = this.mapService.lngLatToContainer(centroid);\n const { box } = collisionIndex.placeCollisionBox({\n x1: shaping.left * fontScale - padding[0],\n x2: shaping.right * fontScale + padding[0],\n y1: shaping.top * fontScale - padding[1],\n y2: shaping.bottom * fontScale + padding[1],\n anchorPointX: pixels.x,\n anchorPointY: pixels.y,\n });\n if (box && box.length) {\n // TODO:featureIndex\n collisionIndex.insertCollisionBox(box, id);\n return true;\n } else {\n return false;\n }\n });\n filterData.forEach((item) => {\n // @ts-ignore\n this.glyphInfoMap[item.id as number] = item;\n });\n // this.layer.setEncodedData(filterData);\n }\n /**\n * 初始化文字布局\n */\n private initGlyph() {\n const { iconfont = false } = this.layer.getLayerConfig();\n // 1.生成文字纹理(或是生成 iconfont)\n iconfont ? this.initIconFontTex() : this.initTextFont();\n // this.initTextFont();\n\n // 2.生成文字布局\n this.generateGlyphLayout(iconfont);\n }\n /**\n * 更新文字纹理\n */\n private updateTexture() {\n const { createTexture2D } = this.rendererService;\n const { canvas } = this.fontService;\n this.textureHeight = canvas.height;\n if (this.texture) {\n this.texture.destroy();\n }\n\n this.texture = createTexture2D({\n data: canvas,\n mag: gl.LINEAR,\n min: gl.LINEAR,\n width: canvas.width,\n height: canvas.height,\n });\n }\n\n private reBuildModel() {\n this.filterGlyphs();\n this.layer.models = [\n this.layer.buildLayerModel({\n moduleName: 'pointText',\n vertexShader: textVert,\n fragmentShader: textFrag,\n triangulation: TextTriangulation.bind(this),\n depth: { enable: false },\n blend: this.getBlend(),\n }),\n ];\n }\n}\n"],"file":"text.js"}
|
package/lib/point/shape/Path.js
CHANGED
|
@@ -5,13 +5,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.ShapeType3D = exports.ShapeType2D = void 0;
|
|
9
9
|
exports.circle = circle;
|
|
10
|
-
exports.
|
|
11
|
-
exports.triangle = triangle;
|
|
10
|
+
exports.geometryShape = void 0;
|
|
12
11
|
exports.hexagon = hexagon;
|
|
13
12
|
exports.pentagon = pentagon;
|
|
14
|
-
exports.
|
|
13
|
+
exports.polygonPath = polygonPath;
|
|
14
|
+
exports.square = square;
|
|
15
|
+
exports.triangle = triangle;
|
|
15
16
|
|
|
16
17
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
18
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/shape/Path.ts"],"names":["ShapeType3D","ShapeType2D","polygonPath","pointCount","start","step","Math","PI","line","i","push","path","map","t","x","sin","y","cos","circle","square","triangle","hexagon","pentagon","geometryShape","CIRCLE","HEXAGON","TRIANGLE","SQUARE","PENTAGON","CYLINDER","HEXAGONCOLUMN","TRIANGLECOLUMN","SQUARECOLUMN","PENTAGONCOLUMN"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/point/shape/Path.ts"],"names":["ShapeType3D","ShapeType2D","polygonPath","pointCount","start","step","Math","PI","line","i","push","path","map","t","x","sin","y","cos","circle","square","triangle","hexagon","pentagon","geometryShape","CIRCLE","HEXAGON","TRIANGLE","SQUARE","PENTAGON","CYLINDER","HEXAGONCOLUMN","TRIANGLECOLUMN","SQUARECOLUMN","PENTAGONCOLUMN"],"mappings":";;;;;;;;;;;;;;;;;;;;IAEYA,W;;;WAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,2BAAAA,W;;IAOAC,W;;;WAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,E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N,MADE,iDAEvBjB,WAAW,CAACwB,OAFW,EAEDJ,OAFC,iDAGvBpB,WAAW,CAACyB,QAHW,EAGAN,QAHA,iDAIvBnB,WAAW,CAAC0B,MAJW,EAIFR,MAJE,iDAKvBlB,WAAW,CAAC2B,QALW,EAKAN,QALA,iDAMvBtB,WAAW,CAAC6B,QANW,EAMAX,MANA,iDAOvBlB,WAAW,CAAC8B,aAPW,EAOKT,OAPL,iDAQvBrB,WAAW,CAAC+B,cARW,EAQMX,QARN,iDASvBpB,WAAW,CAACgC,YATW,EASIb,MATJ,iDAUvBnB,WAAW,CAACiC,cAVW,EAUMX,QAVN,kBAAnB","sourcesContent":["type IPosition = [number, number, number];\nexport type IPath = IPosition[];\nexport enum ShapeType3D {\n CYLINDER = 'cylinder',\n SQUARECOLUMN = 'squareColumn',\n TRIANGLECOLUMN = 'triangleColumn',\n HEXAGONCOLUMN = 'hexagonColumn',\n PENTAGONCOLUMN = 'pentagonColumn',\n}\nexport enum ShapeType2D {\n CIRCLE = 'circle',\n SQUARE = 'square',\n TRIANGLE = 'triangle',\n HEXAGON = 'hexagon',\n PENTAGON = 'pentagon',\n}\n\n/**\n * 生成规则多边形顶点个数\n * @param pointCount 顶点个数 3 => 三角形\n * @param start 顶点起始角度 调整图形的方向\n */\nexport function polygonPath(pointCount: number, start: number = 0): IPath {\n const step = (Math.PI * 2) / pointCount;\n const line = [];\n for (let i = 0; i < pointCount; i++) {\n line.push(step * i + (start * Math.PI) / 12);\n }\n const path: IPath = line.map((t) => {\n const x = Math.sin(t + Math.PI / 4);\n const y = Math.cos(t + Math.PI / 4);\n return [x, y, 0];\n });\n // path.push(path[0]);\n return path;\n}\n\nexport function circle(): IPath {\n return polygonPath(30);\n}\nexport function square(): IPath {\n return polygonPath(4);\n}\nexport function triangle(): IPath {\n return polygonPath(3);\n}\nexport function hexagon(): IPath {\n return polygonPath(6);\n}\nexport function pentagon(): IPath {\n return polygonPath(5);\n}\n\nexport const geometryShape = {\n [ShapeType2D.CIRCLE]: circle,\n [ShapeType2D.HEXAGON]: hexagon,\n [ShapeType2D.TRIANGLE]: triangle,\n [ShapeType2D.SQUARE]: square,\n [ShapeType2D.PENTAGON]: pentagon,\n [ShapeType3D.CYLINDER]: circle,\n [ShapeType3D.HEXAGONCOLUMN]: hexagon,\n [ShapeType3D.TRIANGLECOLUMN]: triangle,\n [ShapeType3D.SQUARECOLUMN]: square,\n [ShapeType3D.PENTAGONCOLUMN]: pentagon,\n};\n"],"file":"Path.js"}
|
package/lib/raster/raster.js
CHANGED
|
@@ -31,7 +31,7 @@ var _BaseLayer2 = _interopRequireDefault(require("../core/BaseLayer"));
|
|
|
31
31
|
|
|
32
32
|
var _triangulation = require("./buffers/triangulation");
|
|
33
33
|
|
|
34
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
34
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
35
35
|
|
|
36
36
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
37
37
|
|
|
@@ -5,9 +5,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.handleStyleColor = handleStyleColor;
|
|
8
9
|
exports.handleStyleDataMapping = handleStyleDataMapping;
|
|
9
10
|
exports.handleStyleFloat = handleStyleFloat;
|
|
10
|
-
exports.handleStyleColor = handleStyleColor;
|
|
11
11
|
|
|
12
12
|
var _isString2 = _interopRequireDefault(require("lodash/isString"));
|
|
13
13
|
|
|
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.computeMiter = computeMiter;
|
|
9
9
|
exports.computeNormal = computeNormal;
|
|
10
|
-
exports.direction = direction;
|
|
11
10
|
exports.default = void 0;
|
|
11
|
+
exports.direction = direction;
|
|
12
12
|
|
|
13
13
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
14
14
|
|
|
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.computeMiter = computeMiter;
|
|
9
9
|
exports.computeNormal = computeNormal;
|
|
10
|
-
exports.direction = direction;
|
|
11
10
|
exports.default = _default;
|
|
11
|
+
exports.direction = direction;
|
|
12
12
|
|
|
13
13
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
14
14
|
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.shapeText = shapeText;
|
|
7
6
|
exports.getGlyphQuads = getGlyphQuads;
|
|
7
|
+
exports.shapeText = shapeText;
|
|
8
8
|
|
|
9
9
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
10
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.45",
|
|
4
4
|
"description": "L7's collection of built-in layers",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -23,11 +23,10 @@
|
|
|
23
23
|
"author": "xiaoiver",
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@antv/async-hook": "^2.1.0",
|
|
27
26
|
"@antv/geo-coord": "^1.0.8",
|
|
28
|
-
"@antv/l7-core": "
|
|
29
|
-
"@antv/l7-source": "
|
|
30
|
-
"@antv/l7-utils": "
|
|
27
|
+
"@antv/l7-core": "2.5.45",
|
|
28
|
+
"@antv/l7-source": "2.5.45",
|
|
29
|
+
"@antv/l7-utils": "2.5.45",
|
|
31
30
|
"@babel/runtime": "^7.7.7",
|
|
32
31
|
"@mapbox/martini": "^0.2.0",
|
|
33
32
|
"@turf/meta": "^6.0.2",
|
|
@@ -53,7 +52,7 @@
|
|
|
53
52
|
"@types/gl-matrix": "^2.4.5",
|
|
54
53
|
"@types/lodash": "^4.14.138"
|
|
55
54
|
},
|
|
56
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "de7c3a6a4358c84359e4e31a85f4f0fa8a40ff25",
|
|
57
56
|
"publishConfig": {
|
|
58
57
|
"access": "public"
|
|
59
58
|
}
|