import { point } from "@turf/turf"; interface IIoIServer { /** * 控制点uid */ controlPointUid?: string; /** * 名称 */ name: string; /** * 信息点类型 */ objectType: number; /** * 父uid */ parentUid?: string; /** * 路段uid */ segmentUid?: string; /** * 唯一标识 */ uid: string; /** * 是否可见 */ visible?: number; latitude?: number; longitude?: number; } class IoIModel { lng!: number; lat!: number; /** * 控制点uid */ controlPointUid?: string; /** * 名称 */ name!: string; /** * 父uid */ parentUid?: string; /** * 路段uid */ segmentUid?: string; /** * 唯一标识 */ id!: string; type!: number; active = false; toTurf() { return point([this.lng, this.lat]); } getLngLatString() { return this.lng + "," + this.lat; } copyFromIoI(p: IoIModel) { Object.assign(this, p); return this; } toServerJson(): IIoIServer { const result: IIoIServer = { latitude: this.lat, longitude: this.lng, name: this.name, objectType: this.type, parentUid: this.parentUid, segmentUid: this.segmentUid, controlPointUid: this.controlPointUid, uid: this.id, }; return result; } fromServerJson(json: any) { this.lat = json.latitude; this.lng = json.longitude; this.name = json.name; this.type = json.objectType; this.id = json.uid; this.segmentUid = json.segmentUid; this.controlPointUid = json.controlPointUid; this.parentUid = json.parentUid; } } export default IoIModel;