-
Notifications
You must be signed in to change notification settings - Fork 1
/
MPRoute.ts
95 lines (92 loc) · 2.49 KB
/
MPRoute.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 { MPBounds, MPRouteLeg, MPBoundsParams, MPRouteLegParams } from "../../index";
/**
* A route from a origin to a destination broken up into {@link legs}.
*
* @export
* @class MPRoute
* @typedef {MPRoute}
*/
export default class MPRoute {
/**
* Creates an instance of MPRoute.
*
* @constructor
* @private
* @param {?MPRouteLeg[]} [legs] The legs the route consists of.
* @param {?string} [copyrights] The copyrights for this route, if any exists.
* @param {?string} [summary] A summary of the route.
* @param {?string[]} [warnings] Any warnings issued for any paths on the route.
* @param {?string[]} [restrictions] All restrictions in place for the route.
* @param {?MPBounds} [bounds] The outer bounds of the route.
*/
private constructor(
public readonly legs?: MPRouteLeg[],
public readonly copyrights?: string,
public readonly summary?: string,
public readonly warnings?: string[],
public readonly restrictions?: string[],
public readonly bounds?: MPBounds,
) { }
/**
* Creator for MPRoute, used to decode JSON from the MapsIndoors SDK.
*
* @static
* @param {MPRouteParams} object
* @returns {MPRoute}
*/
static create(object: MPRouteParams): MPRoute {
return new MPRoute(
object?.legs ? object?.legs.map((leg: any) => MPRouteLeg.create(leg)) : undefined,
object?.copyrights,
object?.summary,
object?.warnings,
object?.restrictions,
object?.bounds ? MPBounds.create(object?.bounds) : undefined,
);
}
}
/**
* Parameter interface for {@link MPRoute}.
*
* @export
* @interface MPRouteParams
* @typedef {MPRouteParams}
*/
export interface MPRouteParams {
/**
* The legs the route consists of.
*
* @type {?MPRouteLegParams[]}
*/
legs?: MPRouteLegParams[],
/**
* The copyrights for this route, if any exists.
*
* @type {?string}
*/
copyrights?: string,
/**
* A summary of the route.
*
* @type {?string}
*/
summary?: string,
/**
* Any warnings issued for any paths on the route.
*
* @type {?string[]}
*/
warnings?: string[],
/**
* All restrictions in place for the route.
*
* @type {?string[]}
*/
restrictions?: string[],
/**
* The outer bounds of the route.
*
* @type {?MPBoundsParams}
*/
bounds?: MPBoundsParams,
}