Extent.ts 603 Bytes
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
import {SpatialExtent} from "./SpatialExtent";
import {TemporalExtent} from "./TemporalExtent";
import {validateRequiredFields} from "./Helpers";

export class Extent {
    spatial!: SpatialExtent;
    temporal?: TemporalExtent;

    static fromJson(jsonObj: any): Extent {
        validateRequiredFields(jsonObj, ["spatial"], Extent.name);

        const extent = new Extent();
        extent.spatial = SpatialExtent.fromJson(jsonObj["spatial"]);
        if (jsonObj.hasOwnProperty("temporal"))
            extent.temporal = TemporalExtent.fromJson(jsonObj["temporal"]);

        return extent;
    }
}