/
CellSpace.ts
66 lines (61 loc) · 2.02 KB
/
CellSpace.ts
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
import {
Absolute2DPosition,
Absolute3DPosition,
GeographicalPosition,
SerializableArrayMember,
SerializableMember,
SerializableObject,
} from '@openhps/core';
import { CellBoundary } from './CellBoundary';
import { Floor } from '../Floor';
import { SymbolicSpace } from '../SymbolicSpace';
import { Slant } from './Slant';
/**
* A cell space is an OGC standard from the IndoorGML schema that identifies a space
*/
@SerializableObject()
export class CellSpace extends SymbolicSpace<Absolute3DPosition | Absolute2DPosition> {
@SerializableArrayMember(CellBoundary)
boundaries: CellBoundary[] = [];
@SerializableMember()
slant?: Slant;
/**
* Set the floor this cell space belongs to
* @param {Floor} floor Floor object
* @returns {CellSpace} cell space instance
*/
setFloor(floor: Floor): this {
this.parent = floor;
this.priority = floor.priority + 1;
return this;
}
set parent(floor: Floor) {
super.parent = floor;
}
get parent(): Floor {
return super.parent as Floor;
}
protected setArrayBounds(localBounds: Absolute3DPosition[] | Absolute2DPosition[]): void {
if (localBounds.length > 0 && localBounds[0] instanceof GeographicalPosition) {
return super.setArrayBounds(localBounds);
}
const bounds: Absolute3DPosition[] = localBounds.map((bound: Absolute3DPosition) => {
const vector = bound.toVector3();
return new Absolute3DPosition(vector.x, vector.y, 0);
});
if (this.parent && this.parent.ceilingHeight) {
bounds.push(
...bounds.map((bound) => {
const clonedBound = bound.clone();
clonedBound.z = clonedBound.z + this.parent.ceilingHeight;
return clonedBound;
}),
);
if (localBounds.length === 2) {
bounds.splice(1, 2);
}
}
super.setArrayBounds(bounds);
return;
}
}