-
Notifications
You must be signed in to change notification settings - Fork 1
/
MPRouteCoordinate.ts
95 lines (89 loc) · 2.33 KB
/
MPRouteCoordinate.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
import MPRouteStep from "../../index";
/**
* A coordinate used for routing, it is contained within a {@link MPRouteStep}.
*
* @export
* @class MPRouteCoordinate
* @typedef {MPRouteCoordinate}
*/
export default class MPRouteCoordinate {
/**
* Creates an instance of MPRouteCoordinate.
*
* @constructor
* @private
* @param {?number} [latitude] The latitude part of the coordinate.
* @param {?number} [longitude] The longitude part of the coordinate.
* @param {?number} [floorIndex] The index of the floor the coordinate is on.
* @param {?string} [floorName] The name of the floor the coordinate is on.
*/
private constructor(
public readonly latitude?: number,
public readonly longitude?: number,
public readonly floorIndex?: number,
public readonly floorName?: string,
) { }
/**
* Creator for MPRouteCoordinate, used to decode JSON from the MapsIndoors SDK.
*
* @public
* @static
* @param {MPRouteCoordinateParams} object
* @returns {MPRouteCoordinate}
*/
public static create(object: MPRouteCoordinateParams): MPRouteCoordinate {
return new MPRouteCoordinate(
object?.lat,
object?.lng,
object?.zLevel,
object?.floor_name,
);
}
/**
* Parses the object to a JSON object that is compatible with the MapsIndoors SDK.
*
* @public
* @returns {MPRouteCoordinateParams}
*/
public toJSON(): MPRouteCoordinateParams {
return {
lat: this.latitude,
lng: this.longitude,
zLevel: this.floorIndex,
floor_name: this.floorName,
};
}
}
/**
* Parameter interface for {@link MPRouteCoordinate}.
*
* @export
* @interface MPRouteCoordinateParams
* @typedef {MPRouteCoordinateParams}
*/
export interface MPRouteCoordinateParams {
/**
* The latitude part of the coordinate.
*
* @type {?number}
*/
lat?: number;
/**
* The longitude part of the coordinate.
*
* @type {?number}
*/
lng?: number;
/**
* The index of the floor the coordinate is on.
*
* @type {?number}
*/
zLevel?: number;
/**
* The name of the floor the coordinate is on.
*
* @type {?string}
*/
floor_name?: string;
}