_3DContainer.ts 1.34 KB
Newer Older
Hanadi's avatar
Hanadi committed
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
import {Extent} from "./Extent";
import {BoundingVolume} from "./BoundingVolume";
import {Link} from "./Link";
import {validateRequiredFields} from "./Helpers";

export class _3DContainer {
    id!: string;
    title?: string;
    description?: string;
    collectionType?: string;
    itemType?: string;
    extent!: Extent;
    contentExtent?: BoundingVolume;
    crs?: string[];
    links!: Link[];
    children?: _3DContainer[];
    content?: Link[];

    static fromJson(jsonObj: any): _3DContainer {
        validateRequiredFields(jsonObj, ["id", "extent", "links"], _3DContainer.name);

        const container = new _3DContainer();
        container.id = jsonObj["id"];
        container.title = jsonObj["title"];
        container.description = jsonObj["description"];
        container.collectionType = jsonObj["collectionType"];
        container.itemType = jsonObj["itemType"];
        container.extent = Extent.fromJson(jsonObj["extent"]);
        if (jsonObj.hasOwnProperty("contentExtent"))
            container.contentExtent = BoundingVolume.fromJson(jsonObj["contentExtent"]);
        container.crs = jsonObj["crs"];
        container.links = jsonObj["links"].map(Link.fromJson);
        container.children = jsonObj["children"]?.map(_3DContainer.fromJson);
        container.content = jsonObj["content"].map(Link.fromJson);
        return container;
    }
}