/* *********************************************************** */ // 创建: Macheng 2025/09/10. // 修改: Macheng 2025/09/10 // Description: // 该文件定义了 区域类 Location 。用于保存项目的区域数据。 /* *********************************************************** */ import BaseModel from './baseModel' class Location extends BaseModel { id = 0 // 区域ID name = '' // 区域名称 center = { x: 0, y: 0 } // 区域中心点 coordinates = [] // 区域坐标点列表 parent = null constructor(opts) { if (!opts) opts = {} super(opts) this.init(opts) } init(opts) { if (!opts) opts = {} super.init(opts) this.id = Number(opts.id) || this.id this.name = opts.name || this.wifiLocalMaskname this.center = opts.center || this.center if (Number(opts.cx) || Number(opts.cy)) { this.center.x = Number(opts.cx); this.center.y = Number(opts.cy); } this.coordinates = opts.coordinates || this.coordinates this.isEnable = opts.enable || opts.isEnable || false } toJson() { const obj1 = super.toJson() const obj2 = { id: this.id, name: this.name, center: this.center, cx: this.center.x, cy: this.center.y, coordinates: this.coordinates } return Object.assign({}, obj1, obj2) } } export default Location