mirror of https://gitee.com/antv-l7/antv-l7
commit
105607e43e
|
@ -3,7 +3,7 @@ import { aProjectFlat, lngLatToMeters } from '@antv/l7-utils';
|
||||||
import earcut from 'earcut';
|
import earcut from 'earcut';
|
||||||
import { vec3 } from 'gl-matrix';
|
import { vec3 } from 'gl-matrix';
|
||||||
import ExtrudePolyline from '../utils/extrude_polyline';
|
import ExtrudePolyline from '../utils/extrude_polyline';
|
||||||
import { calculteCentroid } from '../utils/geo';
|
import { calculateCentroid } from '../utils/geo';
|
||||||
import extrudePolygon, {
|
import extrudePolygon, {
|
||||||
extrude_PolygonNormal,
|
extrude_PolygonNormal,
|
||||||
fillPolygon,
|
fillPolygon,
|
||||||
|
@ -24,8 +24,9 @@ const GeometryCache: IGeometryCache = {};
|
||||||
* 计算2D 填充点图顶点
|
* 计算2D 填充点图顶点
|
||||||
* @param feature 映射feature
|
* @param feature 映射feature
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function PointFillTriangulation(feature: IEncodeFeature) {
|
export function PointFillTriangulation(feature: IEncodeFeature) {
|
||||||
const coordinates = calculteCentroid(feature.coordinates);
|
const coordinates = calculateCentroid(feature.coordinates);
|
||||||
return {
|
return {
|
||||||
vertices: [...coordinates, ...coordinates, ...coordinates, ...coordinates],
|
vertices: [...coordinates, ...coordinates, ...coordinates, ...coordinates],
|
||||||
indices: [0, 1, 2, 2, 3, 0],
|
indices: [0, 1, 2, 2, 3, 0],
|
||||||
|
@ -57,7 +58,7 @@ export function PointExtrudeTriangulation(feature: IEncodeFeature) {
|
||||||
* @param feature 映射feature
|
* @param feature 映射feature
|
||||||
*/
|
*/
|
||||||
export function PointImageTriangulation(feature: IEncodeFeature) {
|
export function PointImageTriangulation(feature: IEncodeFeature) {
|
||||||
const coordinates = calculteCentroid(feature.coordinates);
|
const coordinates = calculateCentroid(feature.coordinates);
|
||||||
return {
|
return {
|
||||||
vertices: [...coordinates],
|
vertices: [...coordinates],
|
||||||
indices: [0],
|
indices: [0],
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { AttributeType, gl, IEncodeFeature, IModel } from '@antv/l7-core';
|
||||||
import { isNumber } from 'lodash';
|
import { isNumber } from 'lodash';
|
||||||
import BaseModel, { styleOffset, styleSingle } from '../../core/BaseModel';
|
import BaseModel, { styleOffset, styleSingle } from '../../core/BaseModel';
|
||||||
import { PointExtrudeTriangulation } from '../../core/triangulation';
|
import { PointExtrudeTriangulation } from '../../core/triangulation';
|
||||||
import { calculteCentroid } from '../../utils/geo';
|
import { calculateCentroid } from '../../utils/geo';
|
||||||
import pointExtrudeFrag from '../shaders/extrude_frag.glsl';
|
import pointExtrudeFrag from '../shaders/extrude_frag.glsl';
|
||||||
import pointExtrudeVert from '../shaders/extrude_vert.glsl';
|
import pointExtrudeVert from '../shaders/extrude_vert.glsl';
|
||||||
interface IPointLayerStyleOptions {
|
interface IPointLayerStyleOptions {
|
||||||
|
@ -151,7 +151,7 @@ export default class ExtrudeModel extends BaseModel {
|
||||||
},
|
},
|
||||||
size: 3,
|
size: 3,
|
||||||
update: (feature: IEncodeFeature, featureIdx: number) => {
|
update: (feature: IEncodeFeature, featureIdx: number) => {
|
||||||
const coordinates = calculteCentroid(feature.coordinates);
|
const coordinates = calculateCentroid(feature.coordinates);
|
||||||
return [coordinates[0], coordinates[1], 0];
|
return [coordinates[0], coordinates[1], 0];
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,7 +17,7 @@ import BaseModel, {
|
||||||
styleSingle,
|
styleSingle,
|
||||||
} from '../../core/BaseModel';
|
} from '../../core/BaseModel';
|
||||||
import CollisionIndex from '../../utils/collision-index';
|
import CollisionIndex from '../../utils/collision-index';
|
||||||
import { calculteCentroid } from '../../utils/geo';
|
import { calculateCentroid } from '../../utils/geo';
|
||||||
import {
|
import {
|
||||||
anchorType,
|
anchorType,
|
||||||
getGlyphQuads,
|
getGlyphQuads,
|
||||||
|
@ -429,18 +429,18 @@ export default class TextModel extends BaseModel {
|
||||||
feature.glyphQuads = glyphQuads;
|
feature.glyphQuads = glyphQuads;
|
||||||
// feature.centroid = calculteCentroid(coordinates);
|
// feature.centroid = calculteCentroid(coordinates);
|
||||||
|
|
||||||
feature.centroid = calculteCentroid(feature.coordinates);
|
feature.centroid = calculateCentroid(feature.coordinates);
|
||||||
|
|
||||||
// 此时地图高德2.0 originCentroid == centroid
|
// 此时地图高德2.0 originCentroid == centroid
|
||||||
feature.originCentroid =
|
feature.originCentroid =
|
||||||
feature.version === 'GAODE2.x'
|
feature.version === 'GAODE2.x'
|
||||||
? calculteCentroid(feature.originCoordinates)
|
? calculateCentroid(feature.originCoordinates)
|
||||||
: (feature.originCentroid = feature.centroid);
|
: (feature.originCentroid = feature.centroid);
|
||||||
|
|
||||||
this.glyphInfoMap[id as number] = {
|
this.glyphInfoMap[id as number] = {
|
||||||
shaping,
|
shaping,
|
||||||
glyphQuads,
|
glyphQuads,
|
||||||
centroid: calculteCentroid(feature.coordinates),
|
centroid: calculateCentroid(feature.coordinates),
|
||||||
};
|
};
|
||||||
return feature;
|
return feature;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
type Position = number[];
|
type Position = number[];
|
||||||
import { isNumber } from 'lodash';
|
import { isNumber } from 'lodash';
|
||||||
export function calculteCentroid(
|
export function calculateCentroid(
|
||||||
coord: Position | Position[] | Position[][],
|
coord: Position | Position[] | Position[][],
|
||||||
): Position {
|
): Position {
|
||||||
// let pos = coord as Position;
|
// let pos = coord as Position;
|
||||||
|
|
Loading…
Reference in New Issue