@stadiamaps/ferrostar 0.47.1 → 0.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ferrostar.d.ts CHANGED
@@ -1,30 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * The location of the user that is navigating.
5
- *
6
- * In addition to coordinates, this includes estimated accuracy and course information,
7
- * which can influence navigation logic and UI.
8
- *
9
- * NOTE: Heading is absent on purpose.
10
- * Heading updates are not related to a change in the user\'s location.
11
- */
12
- export interface UserLocation {
13
- coordinates: GeographicCoordinate;
14
- /**
15
- * The estimated accuracy of the coordinate (in meters)
16
- */
17
- horizontalAccuracy: number;
18
- courseOverGround: CourseOverGround | undefined;
19
- timestamp: { secs_since_epoch: number; nanos_since_epoch: number };
20
- speed: Speed | undefined;
21
- }
22
-
23
- /**
24
- * The type of incident that has occurred.
25
- */
26
- export type IncidentType = "accident" | "congestion" | "construction" | "disabled_vehicle" | "lane_restriction" | "mass_transit" | "miscellaneous" | "other_news" | "planned_event" | "road_closure" | "road_hazard" | "weather";
27
-
28
3
  /**
29
4
  * A geographic coordinate in WGS84.
30
5
  */
@@ -40,173 +15,60 @@ export interface GeographicCoordinate {
40
15
  }
41
16
 
42
17
  /**
43
- * A geographic bounding box defined by its corners.
18
+ * The speed of the user from the location provider.
44
19
  */
45
- export interface BoundingBox {
20
+ export interface Speed {
46
21
  /**
47
- * The southwest corner of the bounding box.
22
+ * The user\'s speed in meters per second.
48
23
  */
49
- sw: GeographicCoordinate;
24
+ value: number;
50
25
  /**
51
- * The northeast corner of the bounding box.
26
+ * The accuracy of the speed value, measured in meters per second.
52
27
  */
53
- ne: GeographicCoordinate;
28
+ accuracy: number | undefined;
54
29
  }
55
30
 
56
31
  /**
57
- * An incident affecting the free flow of traffic,
58
- * such as constructions, accidents, and congestion.
32
+ * The content of a visual instruction.
59
33
  */
60
- export interface Incident {
61
- /**
62
- * A unique identifier for the incident.
63
- */
64
- id: string;
34
+ export interface LaneInfo {
35
+ active: boolean;
36
+ directions: string[];
37
+ activeDirection: string | undefined;
38
+ }
39
+
40
+ /**
41
+ * The content of a visual instruction.
42
+ */
43
+ export interface VisualInstructionContent {
65
44
  /**
66
- * The type of incident.
45
+ * The text to display.
67
46
  */
68
- incidentType: IncidentType;
47
+ text: string;
69
48
  /**
70
- * A short description of the incident.
49
+ * A standardized maneuver type (if any).
71
50
  */
72
- description: string | undefined;
51
+ maneuverType: ManeuverType | undefined;
73
52
  /**
74
- * A longer description of the incident.
53
+ * A standardized maneuver modifier (if any).
75
54
  */
76
- longDescription: string | undefined;
55
+ maneuverModifier: ManeuverModifier | undefined;
77
56
  /**
78
- * The time at which the incident was *last* created.
57
+ * If applicable, the number of degrees you need to go around the roundabout before exiting.
79
58
  *
80
- * NB: This can change throughout the life of the incident.
81
- */
82
- creationTime: Date | null;
83
- /**
84
- * The time at which the incident started or is expected to start (ex: planned closure).
85
- */
86
- startTime: Date | null;
87
- /**
88
- * The time at which the incident ended or is expected to end.
89
- */
90
- endTime: Date | null;
91
- /**
92
- * The level of impact to traffic.
93
- */
94
- impact: Impact | undefined;
95
- /**
96
- * Lanes which are blocked by the incident.
97
- */
98
- lanesBlocked: BlockedLane[];
99
- /**
100
- * Info about the amount of congestion on the road around the incident.
101
- */
102
- congestion: Congestion | undefined;
103
- /**
104
- * Is the road completely closed?
105
- */
106
- closed: boolean | undefined;
107
- /**
108
- * The index into the [`RouteStep`] geometry where the incident starts.
109
- */
110
- geometryIndexStart: number;
111
- /**
112
- * The index into the [`RouteStep`] geometry where the incident ends.
113
- */
114
- geometryIndexEnd: number | undefined;
115
- /**
116
- * Optional additional information about the type of incident (free-form text).
117
- */
118
- subType: string | undefined;
119
- /**
120
- * Optional descriptions about the type of incident (free-form text).
121
- */
122
- subTypeDescription: string | undefined;
123
- /**
124
- * The ISO 3166-1 alpha-2 code of the country in which the incident occurs.
125
- */
126
- iso31661Alpha2: string | undefined;
127
- /**
128
- * The ISO 3166-1 alpha-3 code of the country in which the incident occurs.
129
- */
130
- iso31661Alpha3: string | undefined;
131
- /**
132
- * A list of road names affected by the incident.
133
- */
134
- affectedRoadNames: string[];
135
- /**
136
- * The bounding box over which the incident occurs.
137
- */
138
- bbox: BoundingBox | undefined;
139
- }
140
-
141
- /**
142
- * Which side of the road traffic drives on.
143
- *
144
- * This is needed by consumers like Android Auto to determine whether
145
- * a roundabout should be rendered as clockwise (right-hand traffic)
146
- * or counterclockwise (left-hand traffic).
147
- */
148
- export type DrivingSide = "left" | "right";
149
-
150
- /**
151
- * The direction in which the user/device is observed to be traveling.
152
- */
153
- export interface CourseOverGround {
154
- /**
155
- * The direction in which the user\'s device is traveling, measured in clockwise degrees from
156
- * true north (N = 0, E = 90, S = 180, W = 270).
59
+ * For example, entering and exiting the roundabout in the same direction of travel
60
+ * (as if you had gone straight, apart from the detour)
61
+ * would be an exit angle of 180 degrees.
157
62
  */
158
- degrees: number;
63
+ roundaboutExitDegrees: number | undefined;
159
64
  /**
160
- * The accuracy of the course value, measured in degrees.
65
+ * Detailed information about the lanes. This is typically only present in sub-maneuver instructions.
161
66
  */
162
- accuracy: number | undefined;
163
- }
164
-
165
- /**
166
- * The broad class of maneuver to perform.
167
- *
168
- * This is usually combined with [`ManeuverModifier`] in [`VisualInstructionContent`].
169
- */
170
- export type ManeuverType = "turn" | "new name" | "depart" | "arrive" | "merge" | "on ramp" | "off ramp" | "fork" | "end of road" | "continue" | "roundabout" | "rotary" | "roundabout turn" | "notification" | "exit roundabout" | "exit rotary";
171
-
172
- /**
173
- * A waypoint along a route.
174
- *
175
- * Within the context of Ferrostar, a route request consists of exactly one [`UserLocation`]
176
- * and at least one [`Waypoint`]. The route starts from the user\'s location (which may
177
- * contain other useful information like their current course for the [`crate::routing_adapters::RouteRequestGenerator`]
178
- * to use) and proceeds through one or more waypoints.
179
- *
180
- * Waypoints are used during route calculation, are tracked throughout the lifecycle of a trip,
181
- * and are used for recalculating when the user deviates from the expected route.
182
- *
183
- * Note that support for properties beyond basic geographic coordinates varies by routing engine.
184
- */
185
- export interface Waypoint {
186
- coordinate: GeographicCoordinate;
187
- kind: WaypointKind;
67
+ laneInfo: LaneInfo[] | undefined;
188
68
  /**
189
- * Optional additional properties that will be passed on to the [`crate::routing_adapters::RouteRequestGenerator`].
190
- *
191
- * Most users should prefer convenience functions like [`Waypoint::new_with_valhalla_properties`]
192
- * (or, on platforms like iOS and Android with `UniFFI` bindings, [`crate::routing_adapters::valhalla::create_waypoint_with_valhalla_properties`]).
193
- *
194
- * # Format guidelines
195
- *
196
- * This MAY be any format agreed upon by both the request generator and response parser.
197
- * However, to promote interoperability, all implementations in the Ferrostar codebase
198
- * MUST use JSON.
199
- *
200
- * We selected JSON is selected not because it is good,
201
- * but because generics (i.e., becoming `Waypoint<T>`, where an example `T` is `ValhallaProperties`)
202
- * would be way too painful, particularly for foreign code.
203
- * Especially JavaScript.
204
- *
205
- * In any case, [`crate::routing_adapters::RouteRequestGenerator`] and [`crate::routing_adapters::RouteResponseParser`]
206
- * implementations SHOULD document their level support for this,
207
- * ideally with an exportable record type.
69
+ * The exit number (or similar identifier like \"8B\").
208
70
  */
209
- properties: number[] | undefined;
71
+ exitNumbers: string[];
210
72
  }
211
73
 
212
74
  /**
@@ -241,39 +103,34 @@ export interface SpokenInstruction {
241
103
  }
242
104
 
243
105
  /**
244
- * The content of a visual instruction.
106
+ * An instruction for visual display (usually as banners) at a specific point along a [`RouteStep`].
245
107
  */
246
- export interface VisualInstructionContent {
247
- /**
248
- * The text to display.
249
- */
250
- text: string;
251
- /**
252
- * A standardized maneuver type (if any).
253
- */
254
- maneuverType: ManeuverType | undefined;
108
+ export interface VisualInstruction {
255
109
  /**
256
- * A standardized maneuver modifier (if any).
110
+ * The primary instruction content.
111
+ *
112
+ * This is usually given more visual weight.
257
113
  */
258
- maneuverModifier: ManeuverModifier | undefined;
114
+ primaryContent: VisualInstructionContent;
259
115
  /**
260
- * If applicable, the number of degrees you need to go around the roundabout before exiting.
261
- *
262
- * For example, entering and exiting the roundabout in the same direction of travel
263
- * (as if you had gone straight, apart from the detour)
264
- * would be an exit angle of 180 degrees.
116
+ * Optional secondary instruction content.
265
117
  */
266
- roundaboutExitDegrees: number | undefined;
118
+ secondaryContent: VisualInstructionContent | undefined;
267
119
  /**
268
- * Detailed information about the lanes. This is typically only present in sub-maneuver instructions.
120
+ * Optional sub-maneuver instruction content.
269
121
  */
270
- laneInfo: LaneInfo[] | undefined;
122
+ subContent: VisualInstructionContent | undefined;
271
123
  /**
272
- * The exit number (or similar identifier like \"8B\").
124
+ * How far (in meters) from the upcoming maneuver the instruction should start being displayed
273
125
  */
274
- exitNumbers: string[];
126
+ triggerDistanceBeforeManeuver: number;
275
127
  }
276
128
 
129
+ /**
130
+ * The lane type blocked by the incident.
131
+ */
132
+ export type BlockedLane = "left" | "left center" | "left turn lane" | "center" | "right" | "right center" | "right turn lane" | "hov";
133
+
277
134
  /**
278
135
  * A maneuver (such as a turn or merge) followed by travel of a certain distance until reaching
279
136
  * the next step.
@@ -337,13 +194,9 @@ export interface RouteStep {
337
194
  }
338
195
 
339
196
  /**
340
- * The content of a visual instruction.
197
+ * The type of incident that has occurred.
341
198
  */
342
- export interface LaneInfo {
343
- active: boolean;
344
- directions: string[];
345
- activeDirection: string | undefined;
346
- }
199
+ export type IncidentType = "accident" | "congestion" | "construction" | "disabled_vehicle" | "lane_restriction" | "mass_transit" | "miscellaneous" | "other_news" | "planned_event" | "road_closure" | "road_hazard" | "weather";
347
200
 
348
201
  /**
349
202
  * The impact of the incident that has occurred.
@@ -351,28 +204,9 @@ export interface LaneInfo {
351
204
  export type Impact = "unknown" | "critical" | "major" | "minor" | "low";
352
205
 
353
206
  /**
354
- * An instruction for visual display (usually as banners) at a specific point along a [`RouteStep`].
207
+ * Describes characteristics of the waypoint for routing purposes.
355
208
  */
356
- export interface VisualInstruction {
357
- /**
358
- * The primary instruction content.
359
- *
360
- * This is usually given more visual weight.
361
- */
362
- primaryContent: VisualInstructionContent;
363
- /**
364
- * Optional secondary instruction content.
365
- */
366
- secondaryContent: VisualInstructionContent | undefined;
367
- /**
368
- * Optional sub-maneuver instruction content.
369
- */
370
- subContent: VisualInstructionContent | undefined;
371
- /**
372
- * How far (in meters) from the upcoming maneuver the instruction should start being displayed
373
- */
374
- triggerDistanceBeforeManeuver: number;
375
- }
209
+ export type WaypointKind = "Break" | "Via";
376
210
 
377
211
  /**
378
212
  * Additional information to further specify a [`ManeuverType`].
@@ -380,44 +214,23 @@ export interface VisualInstruction {
380
214
  export type ManeuverModifier = "uturn" | "sharp right" | "right" | "slight right" | "straight" | "slight left" | "left" | "sharp left";
381
215
 
382
216
  /**
383
- * Information describing the series of steps needed to travel between two or more points.
217
+ * The location of the user that is navigating.
384
218
  *
385
- * NOTE: This type is unstable and is still under active development and should be
386
- * considered unstable.
387
- */
388
- export interface Route {
389
- geometry: GeographicCoordinate[];
390
- bbox: BoundingBox;
391
- /**
392
- * The total route distance, in meters.
393
- */
394
- distance: number;
395
- /**
396
- * The ordered list of waypoints to visit, including the starting point.
397
- * Note that this is distinct from the *geometry* which includes all points visited.
398
- * A waypoint represents a start/end point for a route leg.
399
- */
400
- waypoints: Waypoint[];
401
- steps: RouteStep[];
402
- }
403
-
404
- /**
405
- * The lane type blocked by the incident.
406
- */
407
- export type BlockedLane = "left" | "left center" | "left turn lane" | "center" | "right" | "right center" | "right turn lane" | "hov";
408
-
409
- /**
410
- * The speed of the user from the location provider.
219
+ * In addition to coordinates, this includes estimated accuracy and course information,
220
+ * which can influence navigation logic and UI.
221
+ *
222
+ * NOTE: Heading is absent on purpose.
223
+ * Heading updates are not related to a change in the user\'s location.
411
224
  */
412
- export interface Speed {
413
- /**
414
- * The user\'s speed in meters per second.
415
- */
416
- value: number;
225
+ export interface UserLocation {
226
+ coordinates: GeographicCoordinate;
417
227
  /**
418
- * The accuracy of the speed value, measured in meters per second.
228
+ * The estimated accuracy of the coordinate (in meters)
419
229
  */
420
- accuracy: number | undefined;
230
+ horizontalAccuracy: number;
231
+ courseOverGround: CourseOverGround | undefined;
232
+ timestamp: { secs_since_epoch: number; nanos_since_epoch: number };
233
+ speed: Speed | undefined;
421
234
  }
422
235
 
423
236
  /**
@@ -437,128 +250,223 @@ export interface Congestion {
437
250
  }
438
251
 
439
252
  /**
440
- * Describes characteristics of the waypoint for routing purposes.
441
- */
442
- export type WaypointKind = "Break" | "Via";
443
-
444
- /**
445
- * Configurations for built-in route providers.
253
+ * A geographic bounding box defined by its corners.
446
254
  */
447
- export type WellKnownRouteProvider = { Valhalla: { endpointUrl: string; profile: string; optionsJson?: string | undefined } } | { GraphHopper: { endpointUrl: string; profile: string; locale: string; voiceUnits: GraphHopperVoiceUnits; optionsJson?: string | undefined } };
448
-
449
- export type GraphHopperVoiceUnits = "metric" | "imperial";
255
+ export interface BoundingBox {
256
+ /**
257
+ * The southwest corner of the bounding box.
258
+ */
259
+ sw: GeographicCoordinate;
260
+ /**
261
+ * The northeast corner of the bounding box.
262
+ */
263
+ ne: GeographicCoordinate;
264
+ }
450
265
 
451
266
  /**
452
- * The state of a navigation session.
267
+ * A waypoint along a route.
453
268
  *
454
- * This is produced by [`NavigationController`](super::NavigationController) methods
455
- * including [`get_initial_state`](super::NavigationController::get_initial_state)
456
- * and [`update_user_location`](super::NavigationController::update_user_location).
269
+ * Within the context of Ferrostar, a route request consists of exactly one [`UserLocation`]
270
+ * and at least one [`Waypoint`]. The route starts from the user\'s location (which may
271
+ * contain other useful information like their current course for the [`crate::routing_adapters::RouteRequestGenerator`]
272
+ * to use) and proceeds through one or more waypoints.
273
+ *
274
+ * Waypoints are used during route calculation, are tracked throughout the lifecycle of a trip,
275
+ * and are used for recalculating when the user deviates from the expected route.
276
+ *
277
+ * Note that support for properties beyond basic geographic coordinates varies by routing engine.
457
278
  */
458
- export type TripState = { Idle: { user_location: UserLocation | undefined } } | { Navigating: { currentStepGeometryIndex: number | undefined; userLocation: UserLocation; snappedUserLocation: UserLocation; remainingSteps: RouteStep[]; remainingWaypoints: Waypoint[]; progress: TripProgress; summary: TripSummary; deviation: RouteDeviation; visualInstruction: VisualInstruction | undefined; spokenInstruction: SpokenInstruction | undefined; annotationJson: string | undefined } } | { Complete: { user_location: UserLocation; summary: TripSummary } };
279
+ export interface Waypoint {
280
+ coordinate: GeographicCoordinate;
281
+ kind: WaypointKind;
282
+ /**
283
+ * Optional additional properties that will be passed on to the [`crate::routing_adapters::RouteRequestGenerator`].
284
+ *
285
+ * Most users should prefer convenience functions like [`Waypoint::new_with_valhalla_properties`]
286
+ * (or, on platforms like iOS and Android with `UniFFI` bindings, [`crate::routing_adapters::valhalla::create_waypoint_with_valhalla_properties`]).
287
+ *
288
+ * # Format guidelines
289
+ *
290
+ * This MAY be any format agreed upon by both the request generator and response parser.
291
+ * However, to promote interoperability, all implementations in the Ferrostar codebase
292
+ * MUST use JSON.
293
+ *
294
+ * We selected JSON is selected not because it is good,
295
+ * but because generics (i.e., becoming `Waypoint<T>`, where an example `T` is `ValhallaProperties`)
296
+ * would be way too painful, particularly for foreign code.
297
+ * Especially JavaScript.
298
+ *
299
+ * In any case, [`crate::routing_adapters::RouteRequestGenerator`] and [`crate::routing_adapters::RouteResponseParser`]
300
+ * implementations SHOULD document their level support for this,
301
+ * ideally with an exportable record type.
302
+ */
303
+ properties: number[] | undefined;
304
+ }
459
305
 
460
306
  /**
461
- * High-level state describing progress through a route.
307
+ * An incident affecting the free flow of traffic,
308
+ * such as constructions, accidents, and congestion.
462
309
  */
463
- export interface TripProgress {
310
+ export interface Incident {
464
311
  /**
465
- * The distance to the next maneuver, in meters.
312
+ * A unique identifier for the incident.
466
313
  */
467
- distanceToNextManeuver: number;
314
+ id: string;
468
315
  /**
469
- * The total distance remaining in the trip, in meters.
316
+ * The type of incident.
317
+ */
318
+ incidentType: IncidentType;
319
+ /**
320
+ * A short description of the incident.
321
+ */
322
+ description: string | undefined;
323
+ /**
324
+ * A longer description of the incident.
325
+ */
326
+ longDescription: string | undefined;
327
+ /**
328
+ * The time at which the incident was *last* created.
470
329
  *
471
- * This is the sum of the distance remaining in the current step and the distance remaining in all subsequent steps.
330
+ * NB: This can change throughout the life of the incident.
472
331
  */
473
- distanceRemaining: number;
332
+ creationTime: Date | null;
474
333
  /**
475
- * The total duration remaining in the trip, in seconds.
334
+ * The time at which the incident started or is expected to start (ex: planned closure).
476
335
  */
477
- durationRemaining: number;
336
+ startTime: Date | null;
337
+ /**
338
+ * The time at which the incident ended or is expected to end.
339
+ */
340
+ endTime: Date | null;
341
+ /**
342
+ * The level of impact to traffic.
343
+ */
344
+ impact: Impact | undefined;
345
+ /**
346
+ * Lanes which are blocked by the incident.
347
+ */
348
+ lanesBlocked: BlockedLane[];
349
+ /**
350
+ * Info about the amount of congestion on the road around the incident.
351
+ */
352
+ congestion: Congestion | undefined;
353
+ /**
354
+ * Is the road completely closed?
355
+ */
356
+ closed: boolean | undefined;
357
+ /**
358
+ * The index into the [`RouteStep`] geometry where the incident starts.
359
+ */
360
+ geometryIndexStart: number;
361
+ /**
362
+ * The index into the [`RouteStep`] geometry where the incident ends.
363
+ */
364
+ geometryIndexEnd: number | undefined;
365
+ /**
366
+ * Optional additional information about the type of incident (free-form text).
367
+ */
368
+ subType: string | undefined;
369
+ /**
370
+ * Optional descriptions about the type of incident (free-form text).
371
+ */
372
+ subTypeDescription: string | undefined;
373
+ /**
374
+ * The ISO 3166-1 alpha-2 code of the country in which the incident occurs.
375
+ */
376
+ iso31661Alpha2: string | undefined;
377
+ /**
378
+ * The ISO 3166-1 alpha-3 code of the country in which the incident occurs.
379
+ */
380
+ iso31661Alpha3: string | undefined;
381
+ /**
382
+ * A list of road names affected by the incident.
383
+ */
384
+ affectedRoadNames: string[];
385
+ /**
386
+ * The bounding box over which the incident occurs.
387
+ */
388
+ bbox: BoundingBox | undefined;
478
389
  }
479
390
 
480
391
  /**
481
- * Controls filtering/post-processing of user course by the [`NavigationController`].
392
+ * Information describing the series of steps needed to travel between two or more points.
393
+ *
394
+ * NOTE: This type is unstable and is still under active development and should be
395
+ * considered unstable.
482
396
  */
483
- export type CourseFiltering = "SnapToRoute" | "Raw";
484
-
485
- export interface SerializableNavigationControllerConfig {
486
- /**
487
- * Configures when navigation advances to the next waypoint in the route.
488
- */
489
- waypointAdvance: WaypointAdvanceMode;
397
+ export interface Route {
398
+ geometry: GeographicCoordinate[];
399
+ bbox: BoundingBox;
490
400
  /**
491
- * Configures when navigation advances to the next step in the route.
401
+ * The total route distance, in meters.
492
402
  */
493
- stepAdvanceCondition: SerializableStepAdvanceCondition;
403
+ distance: number;
494
404
  /**
495
- * A special advance condition used for the final 2 route steps (last and arrival).
496
- *
497
- * This exists because several of our step advance conditions require entry and
498
- * exit from a step\'s geometry. The end of the route/arrival doesn\'t always accommodate
499
- * the expected location updates for the core step advance condition.
405
+ * The ordered list of waypoints to visit, including the starting point.
406
+ * Note that this is distinct from the *geometry* which includes all points visited.
407
+ * A waypoint represents a start/end point for a route leg.
500
408
  */
501
- arrivalStepAdvanceCondition: SerializableStepAdvanceCondition;
409
+ waypoints: Waypoint[];
410
+ steps: RouteStep[];
411
+ }
412
+
413
+ /**
414
+ * The direction in which the user/device is observed to be traveling.
415
+ */
416
+ export interface CourseOverGround {
502
417
  /**
503
- * Configures when the user is deemed to be off course.
504
- *
505
- * NOTE: This is distinct from the action that is taken.
506
- * It is only the determination that the user has deviated from the expected route.
418
+ * The direction in which the user\'s device is traveling, measured in clockwise degrees from
419
+ * true north (N = 0, E = 90, S = 180, W = 270).
507
420
  */
508
- routeDeviationTracking: RouteDeviationTracking;
421
+ degrees: number;
509
422
  /**
510
- * Configures how the heading component of the snapped location is reported in [`TripState`].
423
+ * The accuracy of the course value, measured in degrees.
511
424
  */
512
- snappedLocationCourseFiltering: CourseFiltering;
425
+ accuracy: number | undefined;
513
426
  }
514
427
 
515
428
  /**
516
- * Controls when a waypoint should be marked as complete.
517
- *
518
- * While a route may consist of thousands of points, waypoints are special.
519
- * A simple trip will have only one waypoint: the final destination.
520
- * A more complex trip may have several intermediate stops.
521
- * Just as the navigation state keeps track of which steps remain in the route,
522
- * it also tracks which waypoints are still remaining.
429
+ * Which side of the road traffic drives on.
523
430
  *
524
- * Tracking waypoints enables Ferrostar to reroute users when they stray off the route line.
525
- * The waypoint advance mode specifies how the framework decides
526
- * that a waypoint has been visited (and is removed from the list).
431
+ * This is needed by consumers like Android Auto to determine whether
432
+ * a roundabout should be rendered as clockwise (right-hand traffic)
433
+ * or counterclockwise (left-hand traffic).
434
+ */
435
+ export type DrivingSide = "left" | "right";
436
+
437
+ /**
438
+ * The broad class of maneuver to perform.
527
439
  *
528
- * NOTE: Advancing to the next *step* and advancing to the next *waypoint*
529
- * are separate processes.
530
- * This will not normally cause any issues, but keep in mind that
531
- * manually advancing to the next step does not *necessarily* imply
532
- * that the waypoint will be marked as complete!
440
+ * This is usually combined with [`ManeuverModifier`] in [`VisualInstructionContent`].
533
441
  */
534
- export type WaypointAdvanceMode = { WaypointWithinRange: number } | { WaypointAlongAdvancingStep: number };
442
+ export type ManeuverType = "turn" | "new name" | "depart" | "arrive" | "merge" | "on ramp" | "off ramp" | "fork" | "end of road" | "continue" | "roundabout" | "rotary" | "roundabout turn" | "notification" | "exit roundabout" | "exit rotary";
535
443
 
536
- export interface SerializableNavState {
537
- tripState: TripState;
538
- stepAdvanceCondition: SerializableStepAdvanceCondition;
539
- }
444
+ /**
445
+ * Configurations for built-in route providers.
446
+ */
447
+ export type WellKnownRouteProvider = { Valhalla: { endpointUrl: string; profile: string; optionsJson?: string | undefined } } | { GraphHopper: { endpointUrl: string; profile: string; locale: string; voiceUnits: GraphHopperVoiceUnits; optionsJson?: string | undefined } };
448
+
449
+ /**
450
+ * The event type.
451
+ *
452
+ * For full replayability, we record things like rerouting, and not just location updates.
453
+ */
454
+ export type NavigationRecordingEventData = { StateUpdate: { trip_state: TripState; step_advance_condition: SerializableStepAdvanceCondition } } | { RouteUpdate: { route: Route } };
540
455
 
541
456
  /**
542
- * Information pertaining to the user\'s full navigation trip. This includes
543
- * simple stats like total duration and distance.
457
+ * An event that occurs during navigation.
458
+ *
459
+ * This is used for the optional session recording / telemetry.
544
460
  */
545
- export interface TripSummary {
546
- /**
547
- * The total raw distance traveled in the trip, in meters.
548
- */
549
- distanceTraveled: number;
550
- /**
551
- * The total snapped distance traveled in the trip, in meters.
552
- */
553
- snappedDistanceTraveled: number;
461
+ export interface NavigationRecordingEvent {
554
462
  /**
555
- * When the trip was started.
463
+ * The timestamp of the event in milliseconds since Jan 1, 1970 UTC.
556
464
  */
557
- startedAt: Date;
465
+ timestamp: number;
558
466
  /**
559
- * When the trip was completed or canceled.
467
+ * Data associated with the event.
560
468
  */
561
- endedAt: Date | null;
469
+ event_data: NavigationRecordingEventData;
562
470
  }
563
471
 
564
472
  /**
@@ -579,15 +487,48 @@ export interface LocationSimulationState {
579
487
  }
580
488
 
581
489
  /**
582
- * Specifies a preferred side for departing from / arriving at a location.
583
- *
584
- * Examples:
585
- * - Germany drives on the right side of the road. A value of `same` will only allow leaving
586
- * or arriving at a location such that it is on your right.
587
- * - Australia drives on the left side of the road. Passing a value of `same` will only allow
588
- * leaving or arriving at a location such that it is on your left.
490
+ * A set of optional filters to exclude candidate edges based on their attributes.
589
491
  */
590
- export type ValhallaWaypointPreferredSide = "same" | "opposite" | "either";
492
+ export interface ValhallaLocationSearchFilter {
493
+ /**
494
+ * Whether to exclude roads marked as tunnels.
495
+ */
496
+ exclude_tunnel?: boolean;
497
+ /**
498
+ * Whether to exclude roads marked as bridges.
499
+ */
500
+ exclude_bridge?: boolean;
501
+ /**
502
+ * Whether to exclude roads with tolls.
503
+ */
504
+ exclude_tolls?: boolean;
505
+ /**
506
+ * Whether to exclude ferries.
507
+ */
508
+ exclude_ferry?: boolean;
509
+ /**
510
+ * Whether to exclude roads marked as ramps.
511
+ */
512
+ exclude_ramp?: boolean;
513
+ /**
514
+ * Whether to exclude roads marked as closed due to a live traffic closure.
515
+ */
516
+ exclude_closures?: boolean;
517
+ /**
518
+ * The lowest road class allowed.
519
+ */
520
+ min_road_class?: ValhallaRoadClass;
521
+ /**
522
+ * The highest road class allowed.
523
+ */
524
+ max_road_class?: ValhallaRoadClass;
525
+ /**
526
+ * If specified, will only consider edges that are on or traverse the passed floor level.
527
+ * It will set `search_cutoff` to a default value of 300 meters if no cutoff value is passed.
528
+ * Additionally, if a `search_cutoff` is passed, it will be clamped to 1000 meters.
529
+ */
530
+ level?: number;
531
+ }
591
532
 
592
533
  /**
593
534
  * Waypoint properties supported by Valhalla servers.
@@ -685,6 +626,14 @@ export interface ValhallaWaypointProperties {
685
626
  * A set of optional filters to exclude candidate edges based on their attributes.
686
627
  */
687
628
  search_filter: ValhallaLocationSearchFilter | undefined;
629
+ /**
630
+ * Determines whether U-Turns are allowed at the waypoint
631
+ * (if it is an intermediate waypoint, not the first or last).
632
+ *
633
+ * Defaults to `true`. This has the effect of converting a [`WaypointKind::Break`]
634
+ * into a Valhalla `break_through`, and a [`WaypointKind::Via`] into a `through`.
635
+ */
636
+ allow_uturns: boolean | undefined;
688
637
  }
689
638
 
690
639
  /**
@@ -695,106 +644,165 @@ export interface ValhallaWaypointProperties {
695
644
  export type ValhallaRoadClass = "motorway" | "trunk" | "primary" | "secondary" | "tertiary" | "unclassified" | "residential" | "service_other";
696
645
 
697
646
  /**
698
- * A set of optional filters to exclude candidate edges based on their attributes.
647
+ * Specifies a preferred side for departing from / arriving at a location.
648
+ *
649
+ * Examples:
650
+ * - Germany drives on the right side of the road. A value of `same` will only allow leaving
651
+ * or arriving at a location such that it is on your right.
652
+ * - Australia drives on the left side of the road. Passing a value of `same` will only allow
653
+ * leaving or arriving at a location such that it is on your left.
699
654
  */
700
- export interface ValhallaLocationSearchFilter {
655
+ export type ValhallaWaypointPreferredSide = "same" | "opposite" | "either";
656
+
657
+ /**
658
+ * Waypoint properties parsed from an OSRM-compatible server response.
659
+ *
660
+ * NOTE: Some servers (such as Valhalla) may support additional parameters at request time
661
+ * which are _not_ echoed back in the response time.
662
+ * This is unfortunate; PRs upstream would likely be welcomed!
663
+ * Similarly, if your server is OSRM-compatible and returns additional attributes,
664
+ * feel free to open a PR to include these as optional properties.
665
+ */
666
+ export interface OsrmWaypointProperties {
701
667
  /**
702
- * Whether to exclude roads marked as tunnels.
668
+ * The name of the street that the waypoint snapped to.
703
669
  */
704
- exclude_tunnel?: boolean;
670
+ name: string | undefined;
705
671
  /**
706
- * Whether to exclude roads marked as bridges.
672
+ * The distance (in meters) between the snapped point and the input coordinate.
707
673
  */
708
- exclude_bridge?: boolean;
674
+ distance: number | undefined;
675
+ }
676
+
677
+ /**
678
+ * Determines if the user has deviated from the expected route.
679
+ */
680
+ export type RouteDeviationTracking = "None" | { StaticThreshold: { minimumHorizontalAccuracy: number; maxAcceptableDeviation: number } };
681
+
682
+ /**
683
+ * Status information that describes whether the user is proceeding according to the route or not.
684
+ *
685
+ * Note that the name is intentionally a bit generic to allow for expansion of other states.
686
+ * For example, we could conceivably add a \"wrong way\" status in the future.
687
+ */
688
+ export type RouteDeviation = "NoDeviation" | { OffRoute: { deviationFromRouteLine: number } };
689
+
690
+ export type SerializableStepAdvanceCondition = "Manual" | { DistanceToEndOfStep: { distance: number; minimumHorizontalAccuracy: number } } | { DistanceFromStep: { distance: number; minimumHorizontalAccuracy: number; calculateWhileOffRoute: boolean } } | { DistanceEntryExit: { distanceToEndOfStep: number; distanceAfterEndStep: number; minimumHorizontalAccuracy: number; hasReachedEndOfCurrentStep: boolean } } | { DistanceEntryAndSnappedExit: { distanceToEndOfStep: number; distanceAfterEndStep: number; minimumHorizontalAccuracy: number; hasReachedEndOfCurrentStep: boolean } } | { OrAdvanceConditions: { conditions: SerializableStepAdvanceCondition[] } } | { AndAdvanceConditions: { conditions: SerializableStepAdvanceCondition[] } };
691
+
692
+ export type GraphHopperVoiceUnits = "metric" | "imperial";
693
+
694
+ /**
695
+ * High-level state describing progress through a route.
696
+ */
697
+ export interface TripProgress {
709
698
  /**
710
- * Whether to exclude roads with tolls.
699
+ * The distance to the next maneuver, in meters.
711
700
  */
712
- exclude_tolls?: boolean;
701
+ distanceToNextManeuver: number;
713
702
  /**
714
- * Whether to exclude ferries.
703
+ * The total distance remaining in the trip, in meters.
704
+ *
705
+ * This is the sum of the distance remaining in the current step and the distance remaining in all subsequent steps.
715
706
  */
716
- exclude_ferry?: boolean;
707
+ distanceRemaining: number;
717
708
  /**
718
- * Whether to exclude roads marked as ramps.
709
+ * The total duration remaining in the trip, in seconds.
719
710
  */
720
- exclude_ramp?: boolean;
711
+ durationRemaining: number;
712
+ }
713
+
714
+ export interface SerializableNavigationControllerConfig {
721
715
  /**
722
- * Whether to exclude roads marked as closed due to a live traffic closure.
716
+ * Configures when navigation advances to the next waypoint in the route.
723
717
  */
724
- exclude_closures?: boolean;
718
+ waypointAdvance: WaypointAdvanceMode;
725
719
  /**
726
- * The lowest road class allowed.
720
+ * Configures when navigation advances to the next step in the route.
727
721
  */
728
- min_road_class?: ValhallaRoadClass;
722
+ stepAdvanceCondition: SerializableStepAdvanceCondition;
729
723
  /**
730
- * The highest road class allowed.
724
+ * A special advance condition used for the final 2 route steps (last and arrival).
725
+ *
726
+ * This exists because several of our step advance conditions require entry and
727
+ * exit from a step\'s geometry. The end of the route/arrival doesn\'t always accommodate
728
+ * the expected location updates for the core step advance condition.
731
729
  */
732
- max_road_class?: ValhallaRoadClass;
730
+ arrivalStepAdvanceCondition: SerializableStepAdvanceCondition;
733
731
  /**
734
- * If specified, will only consider edges that are on or traverse the passed floor level.
735
- * It will set `search_cutoff` to a default value of 300 meters if no cutoff value is passed.
736
- * Additionally, if a `search_cutoff` is passed, it will be clamped to 1000 meters.
732
+ * Configures when the user is deemed to be off course.
733
+ *
734
+ * NOTE: This is distinct from the action that is taken.
735
+ * It is only the determination that the user has deviated from the expected route.
737
736
  */
738
- level?: number;
737
+ routeDeviationTracking: RouteDeviationTracking;
738
+ /**
739
+ * Configures how the heading component of the snapped location is reported in [`TripState`].
740
+ */
741
+ snappedLocationCourseFiltering: CourseFiltering;
739
742
  }
740
743
 
741
744
  /**
742
- * The event type.
745
+ * The state of a navigation session.
743
746
  *
744
- * For full replayability, we record things like rerouting, and not just location updates.
747
+ * This is produced by [`NavigationController`](super::NavigationController) methods
748
+ * including [`get_initial_state`](super::NavigationController::get_initial_state)
749
+ * and [`update_user_location`](super::NavigationController::update_user_location).
745
750
  */
746
- export type NavigationRecordingEventData = { StateUpdate: { trip_state: TripState; step_advance_condition: SerializableStepAdvanceCondition } } | { RouteUpdate: { route: Route } };
751
+ export type TripState = { Idle: { user_location: UserLocation | undefined } } | { Navigating: { currentStepGeometryIndex: number | undefined; userLocation: UserLocation; snappedUserLocation: UserLocation; remainingSteps: RouteStep[]; remainingWaypoints: Waypoint[]; progress: TripProgress; summary: TripSummary; deviation: RouteDeviation; visualInstruction: VisualInstruction | undefined; spokenInstruction: SpokenInstruction | undefined; annotationJson: string | undefined } } | { Complete: { user_location: UserLocation; summary: TripSummary } };
747
752
 
748
753
  /**
749
- * An event that occurs during navigation.
754
+ * Controls when a waypoint should be marked as complete.
750
755
  *
751
- * This is used for the optional session recording / telemetry.
756
+ * While a route may consist of thousands of points, waypoints are special.
757
+ * A simple trip will have only one waypoint: the final destination.
758
+ * A more complex trip may have several intermediate stops.
759
+ * Just as the navigation state keeps track of which steps remain in the route,
760
+ * it also tracks which waypoints are still remaining.
761
+ *
762
+ * Tracking waypoints enables Ferrostar to reroute users when they stray off the route line.
763
+ * The waypoint advance mode specifies how the framework decides
764
+ * that a waypoint has been visited (and is removed from the list).
765
+ *
766
+ * NOTE: Advancing to the next *step* and advancing to the next *waypoint*
767
+ * are separate processes.
768
+ * This will not normally cause any issues, but keep in mind that
769
+ * manually advancing to the next step does not *necessarily* imply
770
+ * that the waypoint will be marked as complete!
752
771
  */
753
- export interface NavigationRecordingEvent {
772
+ export type WaypointAdvanceMode = { WaypointWithinRange: number } | { WaypointAlongAdvancingStep: number };
773
+
774
+ /**
775
+ * Information pertaining to the user\'s full navigation trip. This includes
776
+ * simple stats like total duration and distance.
777
+ */
778
+ export interface TripSummary {
754
779
  /**
755
- * The timestamp of the event in milliseconds since Jan 1, 1970 UTC.
780
+ * The total raw distance traveled in the trip, in meters.
756
781
  */
757
- timestamp: number;
782
+ distanceTraveled: number;
758
783
  /**
759
- * Data associated with the event.
784
+ * The total snapped distance traveled in the trip, in meters.
760
785
  */
761
- event_data: NavigationRecordingEventData;
762
- }
763
-
764
- /**
765
- * Waypoint properties parsed from an OSRM-compatible server response.
766
- *
767
- * NOTE: Some servers (such as Valhalla) may support additional parameters at request time
768
- * which are _not_ echoed back in the response time.
769
- * This is unfortunate; PRs upstream would likely be welcomed!
770
- * Similarly, if your server is OSRM-compatible and returns additional attributes,
771
- * feel free to open a PR to include these as optional properties.
772
- */
773
- export interface OsrmWaypointProperties {
786
+ snappedDistanceTraveled: number;
774
787
  /**
775
- * The name of the street that the waypoint snapped to.
788
+ * When the trip was started.
776
789
  */
777
- name: string | undefined;
790
+ startedAt: Date;
778
791
  /**
779
- * The distance (in meters) between the snapped point and the input coordinate.
792
+ * When the trip was completed or canceled.
780
793
  */
781
- distance: number | undefined;
794
+ endedAt: Date | null;
782
795
  }
783
796
 
784
797
  /**
785
- * Status information that describes whether the user is proceeding according to the route or not.
786
- *
787
- * Note that the name is intentionally a bit generic to allow for expansion of other states.
788
- * For example, we could conceivably add a \"wrong way\" status in the future.
789
- */
790
- export type RouteDeviation = "NoDeviation" | { OffRoute: { deviationFromRouteLine: number } };
791
-
792
- /**
793
- * Determines if the user has deviated from the expected route.
798
+ * Controls filtering/post-processing of user course by the [`NavigationController`].
794
799
  */
795
- export type RouteDeviationTracking = "None" | { StaticThreshold: { minimumHorizontalAccuracy: number; maxAcceptableDeviation: number } };
800
+ export type CourseFiltering = "SnapToRoute" | "Raw";
796
801
 
797
- export type SerializableStepAdvanceCondition = "Manual" | { DistanceToEndOfStep: { distance: number; minimumHorizontalAccuracy: number } } | { DistanceFromStep: { distance: number; minimumHorizontalAccuracy: number; calculateWhileOffRoute: boolean } } | { DistanceEntryExit: { distanceToEndOfStep: number; distanceAfterEndStep: number; minimumHorizontalAccuracy: number; hasReachedEndOfCurrentStep: boolean } } | { DistanceEntryAndSnappedExit: { distanceToEndOfStep: number; distanceAfterEndStep: number; minimumHorizontalAccuracy: number; hasReachedEndOfCurrentStep: boolean } } | { OrAdvanceConditions: { conditions: SerializableStepAdvanceCondition[] } } | { AndAdvanceConditions: { conditions: SerializableStepAdvanceCondition[] } };
802
+ export interface SerializableNavState {
803
+ tripState: TripState;
804
+ stepAdvanceCondition: SerializableStepAdvanceCondition;
805
+ }
798
806
 
799
807
 
800
808
  export class NavigationController {
package/ferrostar_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "Luke Seelenbinder <luke@stadiamaps.com>"
8
8
  ],
9
9
  "description": "The core of modern turn-by-turn navigation.",
10
- "version": "0.47.1",
10
+ "version": "0.48.0",
11
11
  "license": "BSD-3-Clause",
12
12
  "repository": {
13
13
  "type": "git",