You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
511 lines
9.2 KiB
511 lines
9.2 KiB
import { Type } from "class-transformer"; |
|
import { TsTool } from "src/app/babylon/tool/ts-tool"; |
|
|
|
|
|
import { ArcRotateCameraData } from "../camera-data"; |
|
import { MarkData } from "./mark-data"; |
|
|
|
|
|
/** |
|
* 当前单位的所有标绘信息 |
|
*/ |
|
export class AllMarkPlanData { |
|
|
|
/** |
|
* 单位ID |
|
*/ |
|
institutionID: string; |
|
|
|
/** |
|
* 所有方案 |
|
*/ |
|
@Type(() => MarkPlanData) |
|
datas: MarkPlanData[]; |
|
|
|
|
|
|
|
|
|
/** |
|
* 创建新方案 |
|
* @param name |
|
*/ |
|
createPlanData(name): MarkPlanData { |
|
let id = this.getNextPlaneId(); |
|
let data = new MarkPlanData(id, name, []); |
|
this.datas.push(data); |
|
return data; |
|
} |
|
|
|
/** |
|
* 删除方案 |
|
*/ |
|
deletePlanData(id: number) { |
|
let planeData = this.getMarkPlanById(id); |
|
if (planeData != null) { |
|
TsTool.arrayRemove(this.datas, planeData); |
|
} |
|
} |
|
|
|
|
|
/** |
|
* 获取下一个方案的id |
|
*/ |
|
getNextPlaneId() { |
|
let index = -1; |
|
if (this.datas != null && this.datas.length > 0) { |
|
index = this.datas[this.datas.length - 1].id; |
|
} |
|
index++; |
|
return index; |
|
} |
|
|
|
|
|
/** |
|
* 根据id查找标绘方案 |
|
* @param markPlanId |
|
*/ |
|
getMarkPlanById(markPlanId: number) { |
|
if (this.datas != null) { |
|
for (let i = 0; i < this.datas.length; i++) { |
|
if (this.datas[i].id == markPlanId) { |
|
return this.datas[i]; |
|
} |
|
} |
|
} |
|
|
|
return null; |
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
/** |
|
* 方案数据 |
|
*/ |
|
export class MarkPlanData { |
|
|
|
/** |
|
* 唯一身份id |
|
*/ |
|
id: number; |
|
/** |
|
* 显示的名称 |
|
*/ |
|
name: string; |
|
|
|
/** |
|
* 用于UI上排序 |
|
*/ |
|
index: number = 0; |
|
|
|
/** |
|
* 所有的标绘节点 |
|
*/ |
|
@Type(() => MarkNodeData) |
|
nodes: MarkNodeData[] = []; |
|
|
|
constructor(id: number, name: string, nodes: MarkNodeData[] = []) { |
|
this.id = id; |
|
this.index = id; |
|
this.name = name; |
|
this.nodes = nodes; |
|
this.index = 0; |
|
} |
|
|
|
|
|
/** |
|
* 获取下一个节点的id |
|
*/ |
|
getNextNodeId() { |
|
let index = -1; |
|
|
|
if (this.nodes != null && this.nodes.length > 0) { |
|
index = this.nodes[this.nodes.length - 1].id; |
|
} |
|
|
|
index++; |
|
return index; |
|
|
|
|
|
} |
|
|
|
/** |
|
* 创建方案的子节点 |
|
* @param name |
|
*/ |
|
createMarkNode(name: string) { |
|
let id = this.getNextNodeId(); |
|
let result = new MarkNodeData(id, name); |
|
|
|
this.nodes.push(result); |
|
|
|
return result; |
|
} |
|
|
|
/** |
|
* 删除方案的节点 |
|
* @param id |
|
*/ |
|
deleteMarkNode(id: number) { |
|
let node = this.getNodeById(id); |
|
if (node != null) { |
|
TsTool.arrayRemove(this.nodes, node); |
|
} |
|
} |
|
|
|
/** |
|
* 根据id获取节点 |
|
* @param id |
|
*/ |
|
getNodeById(id: number) { |
|
if (this.nodes != null) { |
|
for (let i = 0; i < this.nodes.length; i++) { |
|
if (this.nodes[i].id == id) { |
|
return this.nodes[i]; |
|
} |
|
} |
|
} |
|
return null; |
|
} |
|
|
|
/** |
|
* 设置节点数据 |
|
* @param id //要替换的节点id |
|
* @param nodeData //新数据 |
|
*/ |
|
setNodeData(id: number, nodeData: MarkNodeData) { |
|
if (this.nodes != null) { |
|
for (let i = 0; i < this.nodes.length; i++) { |
|
if (this.nodes[i].id == id) { |
|
this.nodes[i] = nodeData; |
|
} |
|
} |
|
} |
|
} |
|
|
|
} |
|
|
|
/** |
|
* 标绘节点数据 |
|
*/ |
|
export class MarkNodeData { |
|
|
|
/** |
|
* 唯一身份id |
|
*/ |
|
id: number; |
|
|
|
/** |
|
* 显示的名称 |
|
*/ |
|
name: string; |
|
|
|
/** |
|
* 用于UI上排序 |
|
*/ |
|
index: number = 0; |
|
|
|
/** |
|
* 相机数据 |
|
*/ |
|
@Type(() => ArcRotateCameraData) |
|
cameraData: ArcRotateCameraData; |
|
|
|
/** |
|
* 展示罩棚 |
|
*/ |
|
showZP: boolean; |
|
|
|
/** |
|
* 所处环境的信息 |
|
*/ |
|
@Type(() => EnvironmentData) |
|
environmentData: EnvironmentData[]; |
|
|
|
/** |
|
* 自然信息 |
|
*/ |
|
@Type(() => NatureData) |
|
natureData: NatureData; |
|
|
|
/** |
|
* 描述 |
|
*/ |
|
describe: string; |
|
|
|
/** |
|
* 图片地址 |
|
*/ |
|
texture: string; |
|
|
|
/** |
|
* 视频地址 |
|
*/ |
|
video: string; |
|
|
|
constructor(id: number, name: string) { |
|
this.id = id; |
|
this.index = id; |
|
this.name = name; |
|
this.cameraData = new ArcRotateCameraData(); |
|
this.environmentData = []; |
|
this.natureData = new NatureData(); |
|
this.index = 0; |
|
|
|
} |
|
|
|
|
|
/** |
|
* 获取环境信息 |
|
* @param id |
|
*/ |
|
getEnvironmentData(id: number) { |
|
let result = null; |
|
for (let i = 0; i < this.environmentData.length; i++) { |
|
if (this.environmentData[i].id == id) { |
|
result = this.environmentData[i]; |
|
break; |
|
} |
|
} |
|
return result; |
|
} |
|
|
|
/** |
|
* 改变当前环境值 |
|
* @param id |
|
*/ |
|
changeNowEnvironmentData(id: number) { |
|
for (let i = 0; i < this.environmentData.length; i++) { |
|
if (this.environmentData[i].id == id) { |
|
this.environmentData[i].isNow = true; |
|
} |
|
else { |
|
this.environmentData[i].isNow = false; |
|
} |
|
} |
|
} |
|
|
|
/** |
|
* 根据内容获取 |
|
* @param isOutdoor |
|
* @param buildingId |
|
* @param floorId |
|
*/ |
|
getEnvironmentDataByValue(isOutdoor: boolean, |
|
|
|
/** |
|
* 建筑Id |
|
*/ |
|
buildingId: string, |
|
|
|
/** |
|
* 所处楼层的id(室内的话) |
|
*/ |
|
floorId: string) { |
|
let result: EnvironmentData = null; |
|
for (let i = 0; i < this.environmentData.length; i++) { |
|
if (isOutdoor == true && this.environmentData[i].isOutdoor == true) { |
|
result = this.environmentData[i]; |
|
break; |
|
} |
|
else if (this.environmentData[i].isOutdoor == isOutdoor && this.environmentData[i].buildingId == buildingId && this.environmentData[i].floorId == floorId) { |
|
result = this.environmentData[i]; |
|
break; |
|
} |
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
/** |
|
* 获取当前状态的环境数据 |
|
*/ |
|
getCurrentEnvironmentData() { |
|
let result = this.environmentData[0]; |
|
for (let i = 0; i < this.environmentData.length; i++) { |
|
if (this.environmentData[i].isNow) { |
|
result = this.environmentData[i]; |
|
break; |
|
} |
|
} |
|
result.isNow = true; |
|
return result; |
|
} |
|
|
|
addEnvironment(buildingId: string, isOutdoor: boolean, floorId: string) { |
|
let index = -1; |
|
for (let i = 0; i < this.environmentData.length; i++) { |
|
if (this.environmentData[i].id > index) { |
|
index = this.environmentData[i].id; |
|
} |
|
} |
|
index++; |
|
|
|
let newEnvironment = new EnvironmentData(index, buildingId, isOutdoor, floorId); |
|
this.environmentData.push(newEnvironment); |
|
|
|
return newEnvironment; |
|
} |
|
|
|
} |
|
|
|
/** |
|
* 环境信息 |
|
*/ |
|
export class EnvironmentData { |
|
|
|
id: number; |
|
/** |
|
* 室外、室内 |
|
*/ |
|
isOutdoor: boolean; |
|
|
|
/** |
|
* 建筑Id |
|
*/ |
|
buildingId: string; |
|
|
|
/** |
|
* 所处楼层的id(室内的话) |
|
*/ |
|
floorId: string; |
|
|
|
/** |
|
* 所有标绘物 |
|
*/ |
|
@Type(() => MarkData) |
|
markDatas: MarkData[] = []; |
|
|
|
/** |
|
* 是否是当前节点 |
|
*/ |
|
isNow: boolean; |
|
|
|
constructor(id: number, buildingId: string, isOutdoor: boolean, floorId: string) { |
|
this.id = id; |
|
this.buildingId = buildingId; |
|
this.isOutdoor = isOutdoor; |
|
this.floorId = floorId; |
|
this.markDatas = []; |
|
} |
|
|
|
/** |
|
* 添加markData |
|
* @param markData |
|
*/ |
|
addMarkData(markData: MarkData) { |
|
this.markDatas.push(markData); |
|
} |
|
|
|
/** |
|
* 移除markData |
|
* @param markData |
|
*/ |
|
removeMarkData(markData: MarkData) { |
|
TsTool.arrayRemove(this.markDatas, markData); |
|
} |
|
|
|
} |
|
|
|
/** |
|
* 自然信息 |
|
*/ |
|
export class NatureData { |
|
|
|
/** |
|
* 天气 |
|
*/ |
|
weather: WeatherType; |
|
/** |
|
* 温度 |
|
*/ |
|
temperature: number; |
|
|
|
/** |
|
* 风向 |
|
*/ |
|
windDirection: WindDirectionType; |
|
|
|
/** |
|
* 风力 |
|
*/ |
|
windPower: number; |
|
|
|
constructor() { |
|
this.weather = WeatherType.Sun; |
|
this.temperature = 26; |
|
this.windDirection = WindDirectionType.East; |
|
this.windPower = 3; |
|
} |
|
} |
|
|
|
/** |
|
* 天气类型 |
|
*/ |
|
export enum WeatherType { |
|
/** |
|
* 晴 |
|
*/ |
|
Sun = "Sun", |
|
/** |
|
* 阴 |
|
*/ |
|
Sloudy = "Sloudy", |
|
/** |
|
* 雨 |
|
*/ |
|
Rain = "Rain", |
|
/** |
|
* 雪 |
|
*/ |
|
Snow = "Snow" |
|
} |
|
|
|
/** |
|
* 方向类型 |
|
*/ |
|
export enum WindDirectionType { |
|
/** |
|
* 东 |
|
*/ |
|
East = "East", |
|
/** |
|
* 南 |
|
*/ |
|
South = "South", |
|
|
|
/** |
|
* 西 |
|
*/ |
|
West = "West", |
|
|
|
/** |
|
* 北 |
|
*/ |
|
North = "North", |
|
|
|
/** |
|
* 东南 |
|
*/ |
|
SouthEast = "SouthEast", |
|
|
|
/** |
|
* 西南 |
|
*/ |
|
SouthWest = "SouthWest", |
|
|
|
/** |
|
* 东北 |
|
*/ |
|
NorthEast = "NorthEast", |
|
|
|
/** |
|
* 西北 |
|
*/ |
|
NorthWest = "NorthWest", |
|
|
|
} |