diff --git a/packages/layers/src/core/triangulation.ts b/packages/layers/src/core/triangulation.ts index 483c6953f9..d9b2403c3c 100644 --- a/packages/layers/src/core/triangulation.ts +++ b/packages/layers/src/core/triangulation.ts @@ -3,7 +3,7 @@ import { aProjectFlat, lngLatToMeters } from '@antv/l7-utils'; import earcut from 'earcut'; import { vec3 } from 'gl-matrix'; import ExtrudePolyline from '../utils/extrude_polyline'; -import { calculteCentroid } from '../utils/geo'; +import { calculateCentroid } from '../utils/geo'; import extrudePolygon, { extrude_PolygonNormal, fillPolygon, @@ -24,8 +24,9 @@ const GeometryCache: IGeometryCache = {}; * 计算2D 填充点图顶点 * @param feature 映射feature */ + export function PointFillTriangulation(feature: IEncodeFeature) { - const coordinates = calculteCentroid(feature.coordinates); + const coordinates = calculateCentroid(feature.coordinates); return { vertices: [...coordinates, ...coordinates, ...coordinates, ...coordinates], indices: [0, 1, 2, 2, 3, 0], @@ -57,7 +58,7 @@ export function PointExtrudeTriangulation(feature: IEncodeFeature) { * @param feature 映射feature */ export function PointImageTriangulation(feature: IEncodeFeature) { - const coordinates = calculteCentroid(feature.coordinates); + const coordinates = calculateCentroid(feature.coordinates); return { vertices: [...coordinates], indices: [0], diff --git a/packages/layers/src/point/models/extrude.ts b/packages/layers/src/point/models/extrude.ts index 50c22ae227..a59978c241 100644 --- a/packages/layers/src/point/models/extrude.ts +++ b/packages/layers/src/point/models/extrude.ts @@ -2,7 +2,7 @@ import { AttributeType, gl, IEncodeFeature, IModel } from '@antv/l7-core'; import { isNumber } from 'lodash'; import BaseModel, { styleOffset, styleSingle } from '../../core/BaseModel'; import { PointExtrudeTriangulation } from '../../core/triangulation'; -import { calculteCentroid } from '../../utils/geo'; +import { calculateCentroid } from '../../utils/geo'; import pointExtrudeFrag from '../shaders/extrude_frag.glsl'; import pointExtrudeVert from '../shaders/extrude_vert.glsl'; interface IPointLayerStyleOptions { @@ -151,7 +151,7 @@ export default class ExtrudeModel extends BaseModel { }, size: 3, update: (feature: IEncodeFeature, featureIdx: number) => { - const coordinates = calculteCentroid(feature.coordinates); + const coordinates = calculateCentroid(feature.coordinates); return [coordinates[0], coordinates[1], 0]; }, }, diff --git a/packages/layers/src/point/models/text.ts b/packages/layers/src/point/models/text.ts index da5dc40b34..973d07245e 100644 --- a/packages/layers/src/point/models/text.ts +++ b/packages/layers/src/point/models/text.ts @@ -17,7 +17,7 @@ import BaseModel, { styleSingle, } from '../../core/BaseModel'; import CollisionIndex from '../../utils/collision-index'; -import { calculteCentroid } from '../../utils/geo'; +import { calculateCentroid } from '../../utils/geo'; import { anchorType, getGlyphQuads, @@ -429,18 +429,18 @@ export default class TextModel extends BaseModel { feature.glyphQuads = glyphQuads; // feature.centroid = calculteCentroid(coordinates); - feature.centroid = calculteCentroid(feature.coordinates); + feature.centroid = calculateCentroid(feature.coordinates); // 此时地图高德2.0 originCentroid == centroid feature.originCentroid = feature.version === 'GAODE2.x' - ? calculteCentroid(feature.originCoordinates) + ? calculateCentroid(feature.originCoordinates) : (feature.originCentroid = feature.centroid); this.glyphInfoMap[id as number] = { shaping, glyphQuads, - centroid: calculteCentroid(feature.coordinates), + centroid: calculateCentroid(feature.coordinates), }; return feature; }); diff --git a/packages/layers/src/utils/geo.ts b/packages/layers/src/utils/geo.ts index 4d40ae3072..8a623dad42 100644 --- a/packages/layers/src/utils/geo.ts +++ b/packages/layers/src/utils/geo.ts @@ -1,6 +1,6 @@ type Position = number[]; import { isNumber } from 'lodash'; -export function calculteCentroid( +export function calculateCentroid( coord: Position | Position[] | Position[][], ): Position { // let pos = coord as Position;