From bd13f1ce4becc95abdf108798ff9c759baa5634a Mon Sep 17 00:00:00 2001 From: cbwu <504-wuchengbo@htsdfp.com> Date: Thu, 11 Apr 2024 13:38:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4geometry.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/map/geometry/polygonEntity.ts | 47 +++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/utils/map/geometry/polygonEntity.ts diff --git a/src/utils/map/geometry/polygonEntity.ts b/src/utils/map/geometry/polygonEntity.ts new file mode 100644 index 0000000..87f94fa --- /dev/null +++ b/src/utils/map/geometry/polygonEntity.ts @@ -0,0 +1,47 @@ +/* + * @Author: cbwu 504-wuchengbo@htsdfp.com + * @Date: 2024-04-11 09:26:56 + * @LastEditors: cbwu + * @LastEditTime: 2024-04-11 13:26:25 + * @Description: 封装的Polygon对象 + */ +import { + Entity, + Cartesian3, + Color, + CallbackProperty, + Property, + PolygonGraphics, +} from 'cesium' +import { BaseGeometry } from './baseGeometry' +import { type EntityOptions } from './pointEntity' +export class PolygonEntity extends BaseGeometry { + static ID: number = 0 + // positions: Cartesian3[] = [] + controlPointsID: string[] = [] + options: EntityOptions = { + id: 'Polygon' + String(PolygonEntity.ID), + name: 'Polygon' + String(PolygonEntity.ID + 1), + show: true, + width: 2, + color: Color.RED, + fillColor: Color.RED.withAlpha(0.5), + fill: true, + } + constructor(ptArr: Cartesian3[] | Property, options?: EntityOptions) { + super() + this.options = { ...this.options, ...options } + this.geometry = new Entity({ + show: this.options.show, + name: this.options.name, + polygon: { + hierarchy: ptArr, + material: this.options.fillColor, //填充颜色 + fill: this.options.fill, //是否填充 + outlineWidth: this.options.width, //线宽 + outlineColor: this.options.color, //线颜色 + }, + }) + PolygonEntity.ID++ + } +}