-
Notifications
You must be signed in to change notification settings - Fork 1
/
MPSolutionConfig.ts
127 lines (117 loc) · 2.96 KB
/
MPSolutionConfig.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
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
import { MPCollisionHandling, MPSettings3D } from "../../index";
import MPUtils from "./MPUtils";
/**
* An object that governs solution level settings such as:
* * Marker clustering
* * Marker collision handling
* * {@link MPSettings3D}
*
* @export
* @class MPSolutionConfig
* @typedef {MPSolutionConfig}
*/
export default class MPSolutionConfig {
/**
* Creates an instance of MPSolutionConfig.
*
* @constructor
* @private
* @param {string} id
* @param {MPSettings3D} settings3D
* @param {?boolean} [_enableClustering]
* @param {?MPCollisionHandling} [_mpCollisionHandling]
*/
private constructor(
public readonly id: string,
public readonly settings3D: MPSettings3D,
private _enableClustering?: boolean,
private _mpCollisionHandling?: MPCollisionHandling,
) { }
/**
* Creator for MPSolutionConfig, used to decode JSON from the MapsIndoors SDK.
*
* @public
* @static
* @param {MPSolutionConfigParams} object
* @returns {MPSolutionConfig}
*/
public static create(object: MPSolutionConfigParams): MPSolutionConfig {
return new MPSolutionConfig(
object?.id,
MPSettings3D.create(object?.settings3D),
object?.enableClustering,
object?.collisionHandling,
);
}
/**
* Set the type of collisionHandling.
*
* @public
* @type {*}
*/
public set collisionHandling(collisionHandling: MPCollisionHandling) {
this._mpCollisionHandling = collisionHandling;
MPUtils.setCollisionHandling(collisionHandling);
}
/**
* Get the type of collisionHandling that is set.
*
* @public
* @type {MPCollisionHandling}
*/
public get collisionHandling(): MPCollisionHandling {
return this._mpCollisionHandling ?? MPCollisionHandling.allowOverlap;
}
/**
* Set whether clustering is enabled.
*
* @public
* @type {boolean}
*/
public set enableClustering(enable: boolean) {
this._enableClustering = enable;
MPUtils.setEnableClustering(enable);
}
/**
* Get whether clustering is enabled.
*
* @public
* @type {boolean}
*/
public get enableClustering(): boolean {
return this._enableClustering ?? true;
}
}
/**
* Parameter interface for {@link MPSolutionConfig}.
*
* @export
* @interface MPSolutionConfigParams
* @typedef {MPSolutionConfigParams}
*/
export interface MPSolutionConfigParams {
/**
* The configuration object's ID.
*
* @type {string}
*/
id: string,
/**
* Settings related to 3D rendering.
*
* @type {MPSettings3D}
*/
settings3D: MPSettings3D,
/**
* Clustering setting.
*
* @type {?boolean}
*/
enableClustering?: boolean,
/**
* Collision setting.
*
* @type {?MPCollisionHandling}
*/
collisionHandling?: MPCollisionHandling,
}