// @ts-nocheck import { MarkerEle, type MarkerDes } from "../../map_element/element/Marker" import { SimpleLineEle, type LineDes, type LineEle, GroundLineEle } from "../../map_element/element/Line" import { SimplePolygonEle, type PolygonDes, type PolygonEle } from "../../map_element/element/Polygon" import { BaseElement } from "../../map_element/BaseElement" import { SdkError } from "../../Error" export class PlottingEle extends BaseElement{ marker: MarkerEle | undefined = undefined; area: LineEle | PolygonEle | undefined = undefined; constructor(id: string) { super(id); } dispose(): void { this.marker?.dispose(); this.area?.dispose(); } init(marker: MarkerEle, area: LineEle | PolygonEle): PlottingEle { this.marker = marker; this.area = area; return this; } /** * 是否被完整创建(至少拥有一个图形信息) */ isQualified(): boolean { return (this.marker != undefined || this.area != undefined); } /** * 创建marker */ newMarker(id: string, position: Cesium.Cartesian3, text?: string, imgUrl?: string, des?: MarkerDes): PlottingEle { if (this.marker != undefined) { throw SdkError.createDefault('ElementError', '已拥有Marker'); } this.marker = MarkerEle.create(id, position, text, imgUrl, des).asGroup(this.id).init().inflate(); return this; } /** * 创建线 */ newSimpleLine(id: string, positionList: Array = [], des?: LineDes): PlottingEle { this.area?.dispose(); this.area = SimpleLineEle.create(id, positionList, des).asGroup(this.id).init().inflate(); return this; } newGroundLine(id: string, positionList: Array = [], des?: LineDes): PlottingEle { this.area?.dispose(); this.area = GroundLineEle.create(id, positionList, des).asGroup(this.id).init().inflate(); return this; } /** * 创建面 */ newSimplePolygon(id: string, positionList: Array = [], height?: number, des?: PolygonDes): PlottingEle { this.area?.dispose(); this.area = SimplePolygonEle.create(id, positionList, height, des).asGroup(this.id).init().inflate(); return this; } newGroundPolygon(id: string, positionList: Array = [], height?: number, des?: PolygonDes): PlottingEle { this.area?.dispose(); this.area = SimplePolygonEle.create(id, positionList, height, des).asGroup(this.id).init().inflate(); return this; } _inflateElement(): void { this.marker?._inflateElement(); this.area?._inflateElement(); } _removeElement(): void { this.marker?._removeElement(); this.area?._removeElement(); } _resetElement(): void { this.marker?._resetElement(); this.area?._resetElement(); } refreshGeo(): void { this.marker?.refreshGeo(); this.area?.refreshGeo(); } show(): PlottingEle { this.marker?.show(); this.area?.show(); return this; } hide(): PlottingEle { this.marker?.hide(); this.area?.hide(); return this; } startEdit(): PlottingEle { this.marker?.startEdit(); this.area?.startEdit(); return this; } stopEdit(): PlottingEle { this.marker?.stopEdit(); this.area?.stopEdit(); return this; } }