@stadiamaps/ferrostar 0.45.0 → 0.46.1

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,25 +1,20 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * JavaScript wrapper for `advance_location_simulation`.
5
- */
6
- export function advanceLocationSimulation(state: any): any;
7
- /**
8
- * JavaScript wrapper for `location_simulation_from_coordinates`.
9
- */
10
- export function locationSimulationFromCoordinates(coordinates: any, resample_distance: number | null | undefined, bias: LocationBias): any;
11
- /**
12
- * JavaScript wrapper for `location_simulation_from_polyline`.
13
- */
14
- export function locationSimulationFromPolyline(polyline: string, precision: number, resample_distance: number | null | undefined, bias: LocationBias): any;
15
- /**
16
- * JavaScript wrapper for `location_simulation_from_route`.
17
- */
18
- export function locationSimulationFromRoute(route: any, resample_distance: number | null | undefined, bias: LocationBias): any;
19
- /**
20
- * The lane type blocked by the incident.
4
+ * Details about congestion for an incident.
21
5
  */
22
- export type BlockedLane = "left" | "left center" | "left turn lane" | "center" | "right" | "right center" | "right turn lane" | "hov";
6
+ export interface Congestion {
7
+ /**
8
+ * The level of congestion caused by the incident.
9
+ *
10
+ * 0 = no congestion
11
+ *
12
+ * 100 = road closed
13
+ *
14
+ * Other values mean no congestion was calculated
15
+ */
16
+ value: number;
17
+ }
23
18
 
24
19
  /**
25
20
  * The location of the user that is navigating.
@@ -42,67 +37,99 @@ export interface UserLocation {
42
37
  }
43
38
 
44
39
  /**
45
- * A maneuver (such as a turn or merge) followed by travel of a certain distance until reaching
46
- * the next step.
40
+ * The direction in which the user/device is observed to be traveling.
47
41
  */
48
- export interface RouteStep {
42
+ export interface CourseOverGround {
49
43
  /**
50
- * The full route geometry for this step.
44
+ * The direction in which the user\'s device is traveling, measured in clockwise degrees from
45
+ * true north (N = 0, E = 90, S = 180, W = 270).
51
46
  */
52
- geometry: GeographicCoordinate[];
47
+ degrees: number;
53
48
  /**
54
- * The distance, in meters, to travel along the route after the maneuver to reach the next step.
49
+ * The accuracy of the course value, measured in degrees.
55
50
  */
56
- distance: number;
51
+ accuracy: number | undefined;
52
+ }
53
+
54
+ /**
55
+ * An instruction that can be synthesized using a TTS engine to announce an upcoming maneuver.
56
+ *
57
+ * Note that these do not have any locale information attached.
58
+ */
59
+ export interface SpokenInstruction {
57
60
  /**
58
- * The estimated duration, in seconds, that it will take to complete this step.
61
+ * Plain-text instruction which can be synthesized with a TTS engine.
59
62
  */
60
- duration: number;
63
+ text: string;
61
64
  /**
62
- * The name of the road being traveled on (useful for certain UI styles).
65
+ * Speech Synthesis Markup Language, which should be preferred by clients capable of understanding it.
63
66
  */
64
- roadName: string | undefined;
67
+ ssml: string | undefined;
65
68
  /**
66
- * A list of exits (name or number).
69
+ * How far (in meters) from the upcoming maneuver the instruction should start being spoken.
67
70
  */
68
- exits: string[];
71
+ triggerDistanceBeforeManeuver: number;
69
72
  /**
70
- * A description of the maneuver (ex: \"Turn wright onto main street\").
73
+ * A unique identifier for this instruction.
71
74
  *
72
- * Note for UI implementers: the context this appears in (or doesn\'t)
73
- * depends somewhat on your use case and routing engine.
74
- * For example, this field is useful as a written instruction in Valhalla.
75
+ * This is provided so that platform-layer integrations can easily disambiguate between distinct utterances,
76
+ * which may have the same textual content.
77
+ * UUIDs conveniently fill this purpose.
78
+ *
79
+ * NOTE: While it is possible to deterministically create UUIDs, we do not do so at this time.
80
+ * This should be theoretically possible though if someone cares to write up a proposal and a PR.
75
81
  */
76
- instruction: string;
82
+ utteranceId: string;
83
+ }
84
+
85
+ /**
86
+ * An instruction for visual display (usually as banners) at a specific point along a [`RouteStep`].
87
+ */
88
+ export interface VisualInstruction {
77
89
  /**
78
- * A list of instructions for visual display (usually as banners) at specific points along the step.
90
+ * The primary instruction content.
91
+ *
92
+ * This is usually given more visual weight.
79
93
  */
80
- visualInstructions: VisualInstruction[];
94
+ primaryContent: VisualInstructionContent;
81
95
  /**
82
- * A list of prompts to announce (via speech synthesis) at specific points along the step.
96
+ * Optional secondary instruction content.
83
97
  */
84
- spokenInstructions: SpokenInstruction[];
98
+ secondaryContent: VisualInstructionContent | undefined;
85
99
  /**
86
- * A list of json encoded strings representing annotations between each coordinate along the step.
100
+ * Optional sub-maneuver instruction content.
87
101
  */
88
- annotations: string[] | undefined;
102
+ subContent: VisualInstructionContent | undefined;
89
103
  /**
90
- * A list of incidents that occur along the step.
104
+ * How far (in meters) from the upcoming maneuver the instruction should start being displayed
91
105
  */
92
- incidents: Incident[];
106
+ triggerDistanceBeforeManeuver: number;
93
107
  }
94
108
 
95
109
  /**
96
- * The direction in which the user/device is observed to be traveling.
110
+ * The content of a visual instruction.
97
111
  */
98
- export interface CourseOverGround {
112
+ export interface LaneInfo {
113
+ active: boolean;
114
+ directions: string[];
115
+ activeDirection: string | undefined;
116
+ }
117
+
118
+ /**
119
+ * The lane type blocked by the incident.
120
+ */
121
+ export type BlockedLane = "left" | "left center" | "left turn lane" | "center" | "right" | "right center" | "right turn lane" | "hov";
122
+
123
+ /**
124
+ * The speed of the user from the location provider.
125
+ */
126
+ export interface Speed {
99
127
  /**
100
- * The direction in which the user\'s device is traveling, measured in clockwise degrees from
101
- * true north (N = 0, E = 90, S = 180, W = 270).
128
+ * The user\'s speed in meters per second.
102
129
  */
103
- degrees: number;
130
+ value: number;
104
131
  /**
105
- * The accuracy of the course value, measured in degrees.
132
+ * The accuracy of the speed value, measured in meters per second.
106
133
  */
107
134
  accuracy: number | undefined;
108
135
  }
@@ -192,27 +219,6 @@ export interface Incident {
192
219
  bbox: BoundingBox | undefined;
193
220
  }
194
221
 
195
- /**
196
- * The speed of the user from the location provider.
197
- */
198
- export interface Speed {
199
- /**
200
- * The user\'s speed in meters per second.
201
- */
202
- value: number;
203
- /**
204
- * The accuracy of the speed value, measured in meters per second.
205
- */
206
- accuracy: number | undefined;
207
- }
208
-
209
- /**
210
- * The broad class of maneuver to perform.
211
- *
212
- * This is usually combined with [`ManeuverModifier`] in [`VisualInstructionContent`].
213
- */
214
- 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";
215
-
216
222
  /**
217
223
  * A geographic coordinate in WGS84.
218
224
  */
@@ -233,43 +239,152 @@ export interface GeographicCoordinate {
233
239
  export type IncidentType = "accident" | "congestion" | "construction" | "disabled_vehicle" | "lane_restriction" | "mass_transit" | "miscellaneous" | "other_news" | "planned_event" | "road_closure" | "road_hazard" | "weather";
234
240
 
235
241
  /**
236
- * A geographic bounding box defined by its corners.
242
+ * Additional information to further specify a [`ManeuverType`].
237
243
  */
238
- export interface BoundingBox {
244
+ export type ManeuverModifier = "uturn" | "sharp right" | "right" | "slight right" | "straight" | "slight left" | "left" | "sharp left";
245
+
246
+ /**
247
+ * The impact of the incident that has occurred.
248
+ */
249
+ export type Impact = "unknown" | "critical" | "major" | "minor" | "low";
250
+
251
+ /**
252
+ * A waypoint along a route.
253
+ *
254
+ * Within the context of Ferrostar, a route request consists of exactly one [`UserLocation`]
255
+ * and at least one [`Waypoint`]. The route starts from the user\'s location (which may
256
+ * contain other useful information like their current course for the [`crate::routing_adapters::RouteRequestGenerator`]
257
+ * to use) and proceeds through one or more waypoints.
258
+ *
259
+ * Waypoints are used during route calculation, are tracked throughout the lifecycle of a trip,
260
+ * and are used for recalculating when the user deviates from the expected route.
261
+ *
262
+ * Note that support for properties beyond basic geographic coordinates varies by routing engine.
263
+ */
264
+ export interface Waypoint {
265
+ coordinate: GeographicCoordinate;
266
+ kind: WaypointKind;
239
267
  /**
240
- * The southwest corner of the bounding box.
268
+ * Optional additional properties that will be passed on to the [`crate::routing_adapters::RouteRequestGenerator`].
269
+ *
270
+ * Most users should prefer convenience functions like [`Waypoint::new_with_valhalla_properties`]
271
+ * (or, on platforms like iOS and Android with `UniFFI` bindings, [`crate::routing_adapters::valhalla::create_waypoint_with_valhalla_properties`]).
272
+ *
273
+ * # Format guidelines
274
+ *
275
+ * This MAY be any format agreed upon by both the request generator and response parser.
276
+ * However, to promote interoperability, all implementations in the Ferrostar codebase
277
+ * MUST use JSON.
278
+ *
279
+ * We selected JSON is selected not because it is good,
280
+ * but because generics (i.e., becoming `Waypoint<T>`, where an example `T` is `ValhallaProperties`)
281
+ * would be way too painful, particularly for foreign code.
282
+ * Especially JavaScript.
283
+ *
284
+ * In any case, [`crate::routing_adapters::RouteRequestGenerator`] and [`crate::routing_adapters::RouteResponseParser`]
285
+ * implementations SHOULD document their level support for this,
286
+ * ideally with an exportable record type.
241
287
  */
242
- sw: GeographicCoordinate;
288
+ properties: number[] | undefined;
289
+ }
290
+
291
+ /**
292
+ * The content of a visual instruction.
293
+ */
294
+ export interface VisualInstructionContent {
243
295
  /**
244
- * The northeast corner of the bounding box.
296
+ * The text to display.
245
297
  */
246
- ne: GeographicCoordinate;
298
+ text: string;
299
+ /**
300
+ * A standardized maneuver type (if any).
301
+ */
302
+ maneuverType: ManeuverType | undefined;
303
+ /**
304
+ * A standardized maneuver modifier (if any).
305
+ */
306
+ maneuverModifier: ManeuverModifier | undefined;
307
+ /**
308
+ * If applicable, the number of degrees you need to go around the roundabout before exiting.
309
+ *
310
+ * For example, entering and exiting the roundabout in the same direction of travel
311
+ * (as if you had gone straight, apart from the detour)
312
+ * would be an exit angle of 180 degrees.
313
+ */
314
+ roundaboutExitDegrees: number | undefined;
315
+ /**
316
+ * Detailed information about the lanes. This is typically only present in sub-maneuver instructions.
317
+ */
318
+ laneInfo: LaneInfo[] | undefined;
319
+ /**
320
+ * The exit number (or similar identifier like \"8B\").
321
+ */
322
+ exitNumbers: string[];
247
323
  }
248
324
 
249
325
  /**
250
- * An instruction for visual display (usually as banners) at a specific point along a [`RouteStep`].
326
+ * Describes characteristics of the waypoint for routing purposes.
251
327
  */
252
- export interface VisualInstruction {
328
+ export type WaypointKind = "Break" | "Via";
329
+
330
+ /**
331
+ * A maneuver (such as a turn or merge) followed by travel of a certain distance until reaching
332
+ * the next step.
333
+ */
334
+ export interface RouteStep {
253
335
  /**
254
- * The primary instruction content.
336
+ * The full route geometry for this step.
337
+ */
338
+ geometry: GeographicCoordinate[];
339
+ /**
340
+ * The distance, in meters, to travel along the route after the maneuver to reach the next step.
341
+ */
342
+ distance: number;
343
+ /**
344
+ * The estimated duration, in seconds, that it will take to complete this step.
345
+ */
346
+ duration: number;
347
+ /**
348
+ * The name of the road being traveled on (useful for certain UI styles).
349
+ */
350
+ roadName: string | undefined;
351
+ /**
352
+ * A list of exits (name or number).
353
+ */
354
+ exits: string[];
355
+ /**
356
+ * A description of the maneuver (ex: \"Turn wright onto main street\").
255
357
  *
256
- * This is usually given more visual weight.
358
+ * Note for UI implementers: the context this appears in (or doesn\'t)
359
+ * depends somewhat on your use case and routing engine.
360
+ * For example, this field is useful as a written instruction in Valhalla.
257
361
  */
258
- primaryContent: VisualInstructionContent;
362
+ instruction: string;
259
363
  /**
260
- * Optional secondary instruction content.
364
+ * A list of instructions for visual display (usually as banners) at specific points along the step.
261
365
  */
262
- secondaryContent: VisualInstructionContent | undefined;
366
+ visualInstructions: VisualInstruction[];
263
367
  /**
264
- * Optional sub-maneuver instruction content.
368
+ * A list of prompts to announce (via speech synthesis) at specific points along the step.
265
369
  */
266
- subContent: VisualInstructionContent | undefined;
370
+ spokenInstructions: SpokenInstruction[];
267
371
  /**
268
- * How far (in meters) from the upcoming maneuver the instruction should start being displayed
372
+ * A list of json encoded strings representing annotations between each coordinate along the step.
269
373
  */
270
- triggerDistanceBeforeManeuver: number;
374
+ annotations: string[] | undefined;
375
+ /**
376
+ * A list of incidents that occur along the step.
377
+ */
378
+ incidents: Incident[];
271
379
  }
272
380
 
381
+ /**
382
+ * The broad class of maneuver to perform.
383
+ *
384
+ * This is usually combined with [`ManeuverModifier`] in [`VisualInstructionContent`].
385
+ */
386
+ 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";
387
+
273
388
  /**
274
389
  * Information describing the series of steps needed to travel between two or more points.
275
390
  *
@@ -293,217 +408,214 @@ export interface Route {
293
408
  }
294
409
 
295
410
  /**
296
- * Additional information to further specify a [`ManeuverType`].
411
+ * A geographic bounding box defined by its corners.
297
412
  */
298
- export type ManeuverModifier = "uturn" | "sharp right" | "right" | "slight right" | "straight" | "slight left" | "left" | "sharp left";
413
+ export interface BoundingBox {
414
+ /**
415
+ * The southwest corner of the bounding box.
416
+ */
417
+ sw: GeographicCoordinate;
418
+ /**
419
+ * The northeast corner of the bounding box.
420
+ */
421
+ ne: GeographicCoordinate;
422
+ }
299
423
 
300
424
  /**
301
- * The content of a visual instruction.
425
+ * The current state of the simulation.
302
426
  */
303
- export interface LaneInfo {
304
- active: boolean;
305
- directions: string[];
306
- activeDirection: string | undefined;
427
+ export interface LocationSimulationState {
428
+ current_location: UserLocation;
429
+ remaining_locations: GeographicCoordinate[];
430
+ bias: LocationBias;
307
431
  }
308
432
 
433
+ export type SimulationError = { PolylineError: { error: string } } | "NotEnoughPoints";
434
+
309
435
  /**
310
- * An instruction that can be synthesized using a TTS engine to announce an upcoming maneuver.
436
+ * Controls how simulated locations deviate from the actual route line.
437
+ * This simulates real-world GPS behavior where readings often have systematic bias.
438
+ */
439
+ export type LocationBias = { Left: number } | { Right: number } | { Random: number } | "None";
440
+
441
+ /**
442
+ * Configurations for built-in route providers.
443
+ */
444
+ export type WellKnownRouteProvider = { Valhalla: { endpointUrl: string; profile: string; optionsJson?: string | undefined } } | { GraphHopper: { endpointUrl: string; profile: string; locale: string; voiceUnits: GraphHopperVoiceUnits; optionsJson?: string | undefined } };
445
+
446
+ /**
447
+ * An event that occurs during navigation.
311
448
  *
312
- * Note that these do not have any locale information attached.
449
+ * This is used for the optional session recording / telemetry.
313
450
  */
314
- export interface SpokenInstruction {
315
- /**
316
- * Plain-text instruction which can be synthesized with a TTS engine.
317
- */
318
- text: string;
319
- /**
320
- * Speech Synthesis Markup Language, which should be preferred by clients capable of understanding it.
321
- */
322
- ssml: string | undefined;
451
+ export interface NavigationRecordingEvent {
323
452
  /**
324
- * How far (in meters) from the upcoming maneuver the instruction should start being spoken.
453
+ * The timestamp of the event in milliseconds since Jan 1, 1970 UTC.
325
454
  */
326
- triggerDistanceBeforeManeuver: number;
455
+ timestamp: number;
327
456
  /**
328
- * A unique identifier for this instruction.
329
- *
330
- * This is provided so that platform-layer integrations can easily disambiguate between distinct utterances,
331
- * which may have the same textual content.
332
- * UUIDs conveniently fill this purpose.
333
- *
334
- * NOTE: While it is possible to deterministically create UUIDs, we do not do so at this time.
335
- * This should be theoretically possible though if someone cares to write up a proposal and a PR.
457
+ * Data associated with the event.
336
458
  */
337
- utteranceId: string;
459
+ event_data: NavigationRecordingEventData;
338
460
  }
339
461
 
340
462
  /**
341
- * Details about congestion for an incident.
463
+ * The event type.
464
+ *
465
+ * For full replayability, we record things like rerouting, and not just location updates.
342
466
  */
343
- export interface Congestion {
467
+ export type NavigationRecordingEventData = { StateUpdate: { trip_state: TripState; step_advance_condition: SerializableStepAdvanceCondition } } | { RouteUpdate: { route: Route } };
468
+
469
+ /**
470
+ * Waypoint properties parsed from an OSRM-compatible server response.
471
+ *
472
+ * NOTE: Some servers (such as Valhalla) may support additional parameters at request time
473
+ * which are _not_ echoed back in the response time.
474
+ * This is unfortunate; PRs upstream would likely be welcomed!
475
+ * Similarly, if your server is OSRM-compatible and returns additional attributes,
476
+ * feel free to open a PR to include these as optional properties.
477
+ */
478
+ export interface OsrmWaypointProperties {
344
479
  /**
345
- * The level of congestion caused by the incident.
346
- *
347
- * 0 = no congestion
348
- *
349
- * 100 = road closed
350
- *
351
- * Other values mean no congestion was calculated
480
+ * The name of the street that the waypoint snapped to.
352
481
  */
353
- value: number;
482
+ name: string | undefined;
483
+ /**
484
+ * The distance (in meters) between the snapped point and the input coordinate.
485
+ */
486
+ distance: number | undefined;
354
487
  }
355
488
 
356
489
  /**
357
- * Describes characteristics of the waypoint for routing purposes.
490
+ * Status information that describes whether the user is proceeding according to the route or not.
491
+ *
492
+ * Note that the name is intentionally a bit generic to allow for expansion of other states.
493
+ * For example, we could conceivably add a \"wrong way\" status in the future.
358
494
  */
359
- export type WaypointKind = "Break" | "Via";
495
+ export type RouteDeviation = "NoDeviation" | { OffRoute: { deviationFromRouteLine: number } };
360
496
 
361
497
  /**
362
- * The impact of the incident that has occurred.
498
+ * Determines if the user has deviated from the expected route.
363
499
  */
364
- export type Impact = "unknown" | "critical" | "major" | "minor" | "low";
500
+ export type RouteDeviationTracking = "None" | { StaticThreshold: { minimumHorizontalAccuracy: number; maxAcceptableDeviation: number } };
501
+
502
+ 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[] } };
503
+
504
+ export type GraphHopperVoiceUnits = "metric" | "imperial";
365
505
 
366
506
  /**
367
- * A waypoint along a route.
368
- *
369
- * Within the context of Ferrostar, a route request consists of exactly one [`UserLocation`]
370
- * and at least one [`Waypoint`]. The route starts from the user\'s location (which may
371
- * contain other useful information like their current course for the [`crate::routing_adapters::RouteRequestGenerator`]
372
- * to use) and proceeds through one or more waypoints.
373
- *
374
- * Waypoints are used during route calculation, are tracked throughout the lifecycle of a trip,
375
- * and are used for recalculating when the user deviates from the expected route.
507
+ * The state of a navigation session.
376
508
  *
377
- * Note that support for properties beyond basic geographic coordinates varies by routing engine.
509
+ * This is produced by [`NavigationController`](super::NavigationController) methods
510
+ * including [`get_initial_state`](super::NavigationController::get_initial_state)
511
+ * and [`update_user_location`](super::NavigationController::update_user_location).
378
512
  */
379
- export interface Waypoint {
380
- coordinate: GeographicCoordinate;
381
- kind: WaypointKind;
382
- /**
383
- * Optional additional properties that will be passed on to the [`crate::routing_adapters::RouteRequestGenerator`].
384
- *
385
- * Most users should prefer convenience functions like [`Waypoint::new_with_valhalla_properties`]
386
- * (or, on platforms like iOS and Android with `UniFFI` bindings, [`crate::routing_adapters::valhalla::create_waypoint_with_valhalla_properties`]).
387
- *
388
- * # Format guidelines
389
- *
390
- * This MAY be any format agreed upon by both the request generator and response parser.
391
- * However, to promote interoperability, all implementations in the Ferrostar codebase
392
- * MUST use JSON.
393
- *
394
- * We selected JSON is selected not because it is good,
395
- * but because generics (i.e., becoming `Waypoint<T>`, where an example `T` is `ValhallaProperties`)
396
- * would be way too painful, particularly for foreign code.
397
- * Especially JavaScript.
398
- *
399
- * In any case, [`crate::routing_adapters::RouteRequestGenerator`] and [`crate::routing_adapters::RouteResponseParser`]
400
- * implementations SHOULD document their level support for this,
401
- * ideally with an exportable record type.
402
- */
403
- properties: number[] | undefined;
404
- }
513
+ 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 } };
405
514
 
406
515
  /**
407
- * The content of a visual instruction.
516
+ * High-level state describing progress through a route.
408
517
  */
409
- export interface VisualInstructionContent {
518
+ export interface TripProgress {
410
519
  /**
411
- * The text to display.
520
+ * The distance to the next maneuver, in meters.
412
521
  */
413
- text: string;
522
+ distanceToNextManeuver: number;
414
523
  /**
415
- * A standardized maneuver type (if any).
524
+ * The total distance remaining in the trip, in meters.
525
+ *
526
+ * This is the sum of the distance remaining in the current step and the distance remaining in all subsequent steps.
416
527
  */
417
- maneuverType: ManeuverType | undefined;
528
+ distanceRemaining: number;
418
529
  /**
419
- * A standardized maneuver modifier (if any).
530
+ * The total duration remaining in the trip, in seconds.
420
531
  */
421
- maneuverModifier: ManeuverModifier | undefined;
532
+ durationRemaining: number;
533
+ }
534
+
535
+ /**
536
+ * Information pertaining to the user\'s full navigation trip. This includes
537
+ * simple stats like total duration and distance.
538
+ */
539
+ export interface TripSummary {
422
540
  /**
423
- * If applicable, the number of degrees you need to go around the roundabout before exiting.
424
- *
425
- * For example, entering and exiting the roundabout in the same direction of travel
426
- * (as if you had gone straight, apart from the detour)
427
- * would be an exit angle of 180 degrees.
541
+ * The total raw distance traveled in the trip, in meters.
428
542
  */
429
- roundaboutExitDegrees: number | undefined;
543
+ distanceTraveled: number;
430
544
  /**
431
- * Detailed information about the lanes. This is typically only present in sub-maneuver instructions.
545
+ * The total snapped distance traveled in the trip, in meters.
432
546
  */
433
- laneInfo: LaneInfo[] | undefined;
547
+ snappedDistanceTraveled: number;
434
548
  /**
435
- * The exit number (or similar identifier like \"8B\").
549
+ * When the trip was started.
436
550
  */
437
- exitNumbers: string[];
551
+ startedAt: Date;
552
+ /**
553
+ * When the trip was completed or canceled.
554
+ */
555
+ endedAt: Date | null;
438
556
  }
439
557
 
440
558
  /**
441
- * Waypoint properties parsed from an OSRM-compatible server response.
559
+ * Controls when a waypoint should be marked as complete.
442
560
  *
443
- * NOTE: Some servers (such as Valhalla) may support additional parameters at request time
444
- * which are _not_ echoed back in the response time.
445
- * This is unfortunate; PRs upstream would likely be welcomed!
446
- * Similarly, if your server is OSRM-compatible and returns additional attributes,
447
- * feel free to open a PR to include these as optional properties.
561
+ * While a route may consist of thousands of points, waypoints are special.
562
+ * A simple trip will have only one waypoint: the final destination.
563
+ * A more complex trip may have several intermediate stops.
564
+ * Just as the navigation state keeps track of which steps remain in the route,
565
+ * it also tracks which waypoints are still remaining.
566
+ *
567
+ * Tracking waypoints enables Ferrostar to reroute users when they stray off the route line.
568
+ * The waypoint advance mode specifies how the framework decides
569
+ * that a waypoint has been visited (and is removed from the list).
570
+ *
571
+ * NOTE: Advancing to the next *step* and advancing to the next *waypoint*
572
+ * are separate processes.
573
+ * This will not normally cause any issues, but keep in mind that
574
+ * manually advancing to the next step does not *necessarily* imply
575
+ * that the waypoint will be marked as complete!
448
576
  */
449
- export interface OsrmWaypointProperties {
577
+ export type WaypointAdvanceMode = { WaypointWithinRange: number } | { WaypointAlongAdvancingStep: number };
578
+
579
+ export interface SerializableNavigationControllerConfig {
450
580
  /**
451
- * The name of the street that the waypoint snapped to.
581
+ * Configures when navigation advances to the next waypoint in the route.
452
582
  */
453
- name: string | undefined;
583
+ waypointAdvance: WaypointAdvanceMode;
454
584
  /**
455
- * The distance (in meters) between the snapped point and the input coordinate.
585
+ * Configures when navigation advances to the next step in the route.
456
586
  */
457
- distance: number | undefined;
458
- }
459
-
460
- /**
461
- * The event type.
462
- *
463
- * For full replayability, we record things like rerouting, and not just location updates.
464
- */
465
- export type NavigationRecordingEventData = { StateUpdate: { trip_state: TripState; step_advance_condition: SerializableStepAdvanceCondition } } | { RouteUpdate: { route: Route } };
466
-
467
- /**
468
- * An event that occurs during navigation.
469
- *
470
- * This is used for the optional session recording / telemetry.
471
- */
472
- export interface NavigationRecordingEvent {
587
+ stepAdvanceCondition: SerializableStepAdvanceCondition;
473
588
  /**
474
- * The timestamp of the event in milliseconds since Jan 1, 1970 UTC.
589
+ * A special advance condition used for the final 2 route steps (last and arrival).
590
+ *
591
+ * This exists because several of our step advance conditions require entry and
592
+ * exit from a step\'s geometry. The end of the route/arrival doesn\'t always accommodate
593
+ * the expected location updates for the core step advance condition.
475
594
  */
476
- timestamp: number;
595
+ arrivalStepAdvanceCondition: SerializableStepAdvanceCondition;
477
596
  /**
478
- * Data associated with the event.
597
+ * Configures when the user is deemed to be off course.
598
+ *
599
+ * NOTE: This is distinct from the action that is taken.
600
+ * It is only the determination that the user has deviated from the expected route.
479
601
  */
480
- event_data: NavigationRecordingEventData;
602
+ routeDeviationTracking: RouteDeviationTracking;
603
+ /**
604
+ * Configures how the heading component of the snapped location is reported in [`TripState`].
605
+ */
606
+ snappedLocationCourseFiltering: CourseFiltering;
481
607
  }
482
608
 
483
609
  /**
484
- * Configurations for built-in route providers.
485
- */
486
- export type WellKnownRouteProvider = { Valhalla: { endpointUrl: string; profile: string; optionsJson?: string | undefined } } | { GraphHopper: { endpointUrl: string; profile: string; locale: string; voiceUnits: GraphHopperVoiceUnits; optionsJson?: string | undefined } };
487
-
488
- export type SimulationError = { PolylineError: { error: string } } | "NotEnoughPoints";
489
-
490
- /**
491
- * Controls how simulated locations deviate from the actual route line.
492
- * This simulates real-world GPS behavior where readings often have systematic bias.
610
+ * Controls filtering/post-processing of user course by the [`NavigationController`].
493
611
  */
494
- export type LocationBias = { Left: number } | { Right: number } | { Random: number } | "None";
612
+ export type CourseFiltering = "SnapToRoute" | "Raw";
495
613
 
496
- /**
497
- * The current state of the simulation.
498
- */
499
- export interface LocationSimulationState {
500
- current_location: UserLocation;
501
- remaining_locations: GeographicCoordinate[];
502
- bias: LocationBias;
614
+ export interface SerializableNavState {
615
+ tripState: TripState;
616
+ stepAdvanceCondition: SerializableStepAdvanceCondition;
503
617
  }
504
618
 
505
- export type GraphHopperVoiceUnits = "metric" | "imperial";
506
-
507
619
  /**
508
620
  * Waypoint properties supported by Valhalla servers.
509
621
  *
@@ -602,24 +714,6 @@ export interface ValhallaWaypointProperties {
602
714
  search_filter: ValhallaLocationSearchFilter | undefined;
603
715
  }
604
716
 
605
- /**
606
- * Specifies a preferred side for departing from / arriving at a location.
607
- *
608
- * Examples:
609
- * - Germany drives on the right side of the road. A value of `same` will only allow leaving
610
- * or arriving at a location such that it is on your right.
611
- * - Australia drives on the left side of the road. Passing a value of `same` will only allow
612
- * leaving or arriving at a location such that it is on your left.
613
- */
614
- export type ValhallaWaypointPreferredSide = "same" | "opposite" | "either";
615
-
616
- /**
617
- * A road class in the Valhalla taxonomy.
618
- *
619
- * These are ordered from highest (fastest travel speed) to lowest.
620
- */
621
- export type ValhallaRoadClass = "motorway" | "trunk" | "primary" | "secondary" | "tertiary" | "unclassified" | "residential" | "service_other";
622
-
623
717
  /**
624
718
  * A set of optional filters to exclude candidate edges based on their attributes.
625
719
  */
@@ -665,138 +759,24 @@ export interface ValhallaLocationSearchFilter {
665
759
  }
666
760
 
667
761
  /**
668
- * Status information that describes whether the user is proceeding according to the route or not.
669
- *
670
- * Note that the name is intentionally a bit generic to allow for expansion of other states.
671
- * For example, we could conceivably add a \"wrong way\" status in the future.
672
- */
673
- export type RouteDeviation = "NoDeviation" | { OffRoute: { deviationFromRouteLine: number } };
674
-
675
- /**
676
- * Determines if the user has deviated from the expected route.
677
- */
678
- export type RouteDeviationTracking = "None" | { StaticThreshold: { minimumHorizontalAccuracy: number; maxAcceptableDeviation: number } };
679
-
680
- 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[] } };
681
-
682
- export interface SerializableNavState {
683
- tripState: TripState;
684
- stepAdvanceCondition: SerializableStepAdvanceCondition;
685
- }
686
-
687
- /**
688
- * Controls filtering/post-processing of user course by the [`NavigationController`].
689
- */
690
- export type CourseFiltering = "SnapToRoute" | "Raw";
691
-
692
- /**
693
- * Information pertaining to the user\'s full navigation trip. This includes
694
- * simple stats like total duration and distance.
695
- */
696
- export interface TripSummary {
697
- /**
698
- * The total raw distance traveled in the trip, in meters.
699
- */
700
- distanceTraveled: number;
701
- /**
702
- * The total snapped distance traveled in the trip, in meters.
703
- */
704
- snappedDistanceTraveled: number;
705
- /**
706
- * When the trip was started.
707
- */
708
- startedAt: Date;
709
- /**
710
- * When the trip was completed or canceled.
711
- */
712
- endedAt: Date | null;
713
- }
714
-
715
- /**
716
- * High-level state describing progress through a route.
717
- */
718
- export interface TripProgress {
719
- /**
720
- * The distance to the next maneuver, in meters.
721
- */
722
- distanceToNextManeuver: number;
723
- /**
724
- * The total distance remaining in the trip, in meters.
725
- *
726
- * This is the sum of the distance remaining in the current step and the distance remaining in all subsequent steps.
727
- */
728
- distanceRemaining: number;
729
- /**
730
- * The total duration remaining in the trip, in seconds.
731
- */
732
- durationRemaining: number;
733
- }
734
-
735
- /**
736
- * Controls when a waypoint should be marked as complete.
737
- *
738
- * While a route may consist of thousands of points, waypoints are special.
739
- * A simple trip will have only one waypoint: the final destination.
740
- * A more complex trip may have several intermediate stops.
741
- * Just as the navigation state keeps track of which steps remain in the route,
742
- * it also tracks which waypoints are still remaining.
743
- *
744
- * Tracking waypoints enables Ferrostar to reroute users when they stray off the route line.
745
- * The waypoint advance mode specifies how the framework decides
746
- * that a waypoint has been visited (and is removed from the list).
762
+ * Specifies a preferred side for departing from / arriving at a location.
747
763
  *
748
- * NOTE: Advancing to the next *step* and advancing to the next *waypoint*
749
- * are separate processes.
750
- * This will not normally cause any issues, but keep in mind that
751
- * manually advancing to the next step does not *necessarily* imply
752
- * that the waypoint will be marked as complete!
764
+ * Examples:
765
+ * - Germany drives on the right side of the road. A value of `same` will only allow leaving
766
+ * or arriving at a location such that it is on your right.
767
+ * - Australia drives on the left side of the road. Passing a value of `same` will only allow
768
+ * leaving or arriving at a location such that it is on your left.
753
769
  */
754
- export type WaypointAdvanceMode = { WaypointWithinRange: number } | { WaypointAlongAdvancingStep: number };
770
+ export type ValhallaWaypointPreferredSide = "same" | "opposite" | "either";
755
771
 
756
772
  /**
757
- * The state of a navigation session.
773
+ * A road class in the Valhalla taxonomy.
758
774
  *
759
- * This is produced by [`NavigationController`](super::NavigationController) methods
760
- * including [`get_initial_state`](super::NavigationController::get_initial_state)
761
- * and [`update_user_location`](super::NavigationController::update_user_location).
775
+ * These are ordered from highest (fastest travel speed) to lowest.
762
776
  */
763
- 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 } };
777
+ export type ValhallaRoadClass = "motorway" | "trunk" | "primary" | "secondary" | "tertiary" | "unclassified" | "residential" | "service_other";
764
778
 
765
- export interface SerializableNavigationControllerConfig {
766
- /**
767
- * Configures when navigation advances to the next waypoint in the route.
768
- */
769
- waypointAdvance: WaypointAdvanceMode;
770
- /**
771
- * Configures when navigation advances to the next step in the route.
772
- */
773
- stepAdvanceCondition: SerializableStepAdvanceCondition;
774
- /**
775
- * A special advance condition used for the final 2 route steps (last and arrival).
776
- *
777
- * This exists because several of our step advance conditions require entry and
778
- * exit from a step\'s geometry. The end of the route/arrival doesn\'t always accommodate
779
- * the expected location updates for the core step advance condition.
780
- */
781
- arrivalStepAdvanceCondition: SerializableStepAdvanceCondition;
782
- /**
783
- * Configures when the user is deemed to be off course.
784
- *
785
- * NOTE: This is distinct from the action that is taken.
786
- * It is only the determination that the user has deviated from the expected route.
787
- */
788
- routeDeviationTracking: RouteDeviationTracking;
789
- /**
790
- * Configures how the heading component of the snapped location is reported in [`TripState`].
791
- */
792
- snappedLocationCourseFiltering: CourseFiltering;
793
- }
794
779
 
795
- /**
796
- * JavaScript wrapper for `NavigationController`.
797
- * This wrapper is required because `NavigationController` cannot be directly converted to a JavaScript object
798
- * and requires serialization/deserialization of its methods' inputs and outputs.
799
- */
800
780
  export class NavigationController {
801
781
  free(): void;
802
782
  [Symbol.dispose](): void;
@@ -805,12 +785,7 @@ export class NavigationController {
805
785
  updateUserLocation(location: any, state: any): any;
806
786
  constructor(route: any, config: any, should_record: any);
807
787
  }
808
- /**
809
- * A WebAssembly-compatible wrapper for `NavigationReplay` that exposes its functionality as a JavaScript object.
810
- *
811
- * This wrapper is required because `NavigationReplay` cannot be directly converted to a JavaScript object
812
- * and requires serialization/deserialization of its methods' inputs and outputs.
813
- */
788
+
814
789
  export class NavigationReplay {
815
790
  free(): void;
816
791
  [Symbol.dispose](): void;
@@ -821,10 +796,7 @@ export class NavigationReplay {
821
796
  getInitialTimestamp(): any;
822
797
  constructor(json: any);
823
798
  }
824
- /**
825
- * JavaScript wrapper for [`NavigationSession`] (simple version).
826
- * This wrapper provides basic navigation functionality without observers.
827
- */
799
+
828
800
  export class NavigationSession {
829
801
  free(): void;
830
802
  [Symbol.dispose](): void;
@@ -833,10 +805,7 @@ export class NavigationSession {
833
805
  updateUserLocation(location: any, state: any): any;
834
806
  constructor(route: any, config: any);
835
807
  }
836
- /**
837
- * JavaScript wrapper for [`NavigationSession`] with recording capabilities.
838
- * This version includes a NavigationRecorder observer and provides direct access to recording functionality.
839
- */
808
+
840
809
  export class NavigationSessionRecording {
841
810
  free(): void;
842
811
  [Symbol.dispose](): void;
@@ -847,9 +816,7 @@ export class NavigationSessionRecording {
847
816
  updateUserLocation(location: any, state: any): any;
848
817
  constructor(route: any, config: any);
849
818
  }
850
- /**
851
- * JavaScript wrapper for `RouteAdapter`.
852
- */
819
+
853
820
  export class RouteAdapter {
854
821
  free(): void;
855
822
  [Symbol.dispose](): void;
@@ -861,3 +828,23 @@ export class RouteAdapter {
861
828
  */
862
829
  constructor(well_known_route_provider: WellKnownRouteProvider);
863
830
  }
831
+
832
+ /**
833
+ * JavaScript wrapper for `advance_location_simulation`.
834
+ */
835
+ export function advanceLocationSimulation(state: any): any;
836
+
837
+ /**
838
+ * JavaScript wrapper for `location_simulation_from_coordinates`.
839
+ */
840
+ export function locationSimulationFromCoordinates(coordinates: any, resample_distance: number | null | undefined, bias: LocationBias): any;
841
+
842
+ /**
843
+ * JavaScript wrapper for `location_simulation_from_polyline`.
844
+ */
845
+ export function locationSimulationFromPolyline(polyline: string, precision: number, resample_distance: number | null | undefined, bias: LocationBias): any;
846
+
847
+ /**
848
+ * JavaScript wrapper for `location_simulation_from_route`.
849
+ */
850
+ export function locationSimulationFromRoute(route: any, resample_distance: number | null | undefined, bias: LocationBias): any;