-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_floor.ts
More file actions
169 lines (162 loc) · 6.18 KB
/
api_floor.ts
File metadata and controls
169 lines (162 loc) · 6.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import { Matrix3 } from "three";
import addInstantGetterAndSetterToApiModel from "../../mixins/add_instant_getter_and_setter_to_api_model";
import addReadOnlyPropertiesToModel from "../../mixins/add_read_only_properties_to_model";
import Matrix3Converter from "../../converters/matrix_3_converter";
import type ApiConstructionGrid from "./api_construction_grid";
import type ApiMatrix3 from "./api_matrix_3";
import type { DateLike, Matrix3Like, ModifyPartial, Vector2Like } from "type_aliases";
export type ApiFloorArgument = ModifyPartial<ApiFloor, {
scanDate?: DateLike,
photoAreaMinimapPixelToBimMinimapPixel?: Matrix3Like;
bimMinimapToWorld?: Matrix3Like;
areaLocationInFloorPlan?: Vector2Like[]
}>
export class ApiFloor {
constructor({
id,
firebaseId,
ordinal,
floorNumber,
defaultFirebaseScanDatasetId,
firebaseProjectId,
firebaseScanDatasetIds,
constructionGrid,
plannedElementCount,
plannedElementsExist,
scanDate,
scanDateString,
photoAreaId,
offset,
photoAreaMinimapPixelToBimMinimapPixel,
bimMinimapToWorld,
floorElevation,
floorPlanOffset,
areaLocationInFloorPlan,
globalOffsetYaw,
isLocked
}: ApiFloorArgument = {})
{
addReadOnlyPropertiesToModel(this, { id, firebaseId, firebaseProjectId });
addInstantGetterAndSetterToApiModel(this, "scanDate", scanDate);
let offsetVal: Vector2Like, photoMinimapToBimMinimapTransformVal: ApiMatrix3,
bimMinimapToWorldTransformVal: ApiMatrix3, areaLocationInFloorPlanVal: Vector2Like[];
Object.defineProperties(this, {
offset: {
get() {
return offsetVal;
},
set(val: Vector2Like) {
if (val) {
offsetVal = { x: val.x, y: val.y };
} else {
offsetVal = null;
}
},
enumerable: true
},
photoAreaMinimapPixelToBimMinimapPixel: {
get() {
return photoMinimapToBimMinimapTransformVal;
},
set(val: Matrix3Like) {
if (val instanceof Matrix3) {
photoMinimapToBimMinimapTransformVal = Matrix3Converter.fromMatrix3ToApiMatrix3(val);
} else if (val) {
photoMinimapToBimMinimapTransformVal = val;
} else {
photoMinimapToBimMinimapTransformVal = null;
}
},
enumerable: true
},
bimMinimapToWorld: {
get() {
return bimMinimapToWorldTransformVal;
},
set(val: Matrix3Like) {
if (val instanceof Matrix3) {
bimMinimapToWorldTransformVal = Matrix3Converter.fromMatrix3ToApiMatrix3(val);
} else if (val) {
bimMinimapToWorldTransformVal = val;
} else {
bimMinimapToWorldTransformVal = null;
}
},
enumerable: true
},
areaLocationInFloorPlan: {
get() {
return areaLocationInFloorPlanVal;
},
set(val: Vector2Like[]) {
if (val && Array.isArray(val)) {
if (val.length) {
areaLocationInFloorPlanVal = val.map(point => {
return { x: point.x, y: point.y };
});
} else {
areaLocationInFloorPlanVal = [];
}
} else {
areaLocationInFloorPlanVal = null;
}
},
enumerable: true
}
});
this.ordinal = ordinal;
this.floorNumber = floorNumber;
this.defaultFirebaseScanDatasetId = defaultFirebaseScanDatasetId;
this.firebaseScanDatasetIds = firebaseScanDatasetIds || [];
this.constructionGrid = constructionGrid || null;
this.plannedElementCount = plannedElementCount || 0;
this.plannedElementsExist = plannedElementsExist || null;
// @ts-ignore
this.scanDate = scanDate || null;
this.scanDateString = scanDateString || null;
this.photoAreaId = photoAreaId;
this.offset = offset || null;
// @ts-ignore
this.photoAreaMinimapPixelToBimMinimapPixel = photoAreaMinimapPixelToBimMinimapPixel || null;
// @ts-ignore
this.bimMinimapToWorld = bimMinimapToWorld || null;
this.floorElevation = floorElevation || null;
this.floorPlanOffset = floorPlanOffset || 0;
this.areaLocationInFloorPlan = areaLocationInFloorPlan;
this.globalOffsetYaw = globalOffsetYaw;
this.isLocked = isLocked;
}
/** Internal identifier, not used in URLs. */
readonly id: number;
/** External identifier, suitable for use in URLs. */
readonly firebaseId: string;
/** External identifier of the project that this area belongs to. */
readonly firebaseProjectId: string;
/** Ordinal number to sort this area by when showing all the areas in a project. */
ordinal: number;
/** The name or title of this area. */
floorNumber: string;
/** External identifier of the default capture dataset associated with this area. */
defaultFirebaseScanDatasetId: string;
/** An array of external identifiers of the capture datasets associated with this area. */
firebaseScanDatasetIds: string[];
constructionGrid: ApiConstructionGrid | null = null;
plannedElementCount: number | null = null;
plannedElementsExist: boolean | null = null;
/** The date of the current default capture dataset */
scanDate: number | null = null;
/** The string representation of the {@link scanDate} */
scanDateString: string | null = null;
readonly offset: Vector2Like = null;
photoAreaId: number | null = null;
photoAreaMinimapPixelToBimMinimapPixel: ApiMatrix3 | null = null;
bimMinimapToWorld: ApiMatrix3 | null = null;
floorElevation: number | null;
/** The vertical offset of the floor plan from the {@link floorElevation}, useful for adjusting the height of the floor plan to make it more visible */
floorPlanOffset: number;
/** The coordinates on the floor plan that define the boundaries of the area. Stored as normalized coordinates */
areaLocationInFloorPlan: Vector2Like[];
globalOffsetYaw: number | null;
isLocked: boolean;
}
export default ApiFloor;