@stadiamaps/ferrostar 0.44.0 → 0.46.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,216 +1,138 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * JavaScript wrapper for `location_simulation_from_coordinates`.
4
+ * JavaScript wrapper for `location_simulation_from_polyline`.
5
5
  */
6
- export function locationSimulationFromCoordinates(coordinates: any, resample_distance: number | null | undefined, bias: LocationBias): any;
6
+ export function locationSimulationFromPolyline(polyline: string, precision: number, resample_distance: number | null | undefined, bias: LocationBias): any;
7
+ /**
8
+ * JavaScript wrapper for `advance_location_simulation`.
9
+ */
10
+ export function advanceLocationSimulation(state: any): any;
7
11
  /**
8
12
  * JavaScript wrapper for `location_simulation_from_route`.
9
13
  */
10
14
  export function locationSimulationFromRoute(route: any, resample_distance: number | null | undefined, bias: LocationBias): any;
11
15
  /**
12
- * JavaScript wrapper for `location_simulation_from_polyline`.
16
+ * JavaScript wrapper for `location_simulation_from_coordinates`.
13
17
  */
14
- export function locationSimulationFromPolyline(polyline: string, precision: number, resample_distance: number | null | undefined, bias: LocationBias): any;
18
+ export function locationSimulationFromCoordinates(coordinates: any, resample_distance: number | null | undefined, bias: LocationBias): any;
15
19
  /**
16
- * JavaScript wrapper for `advance_location_simulation`.
20
+ * The broad class of maneuver to perform.
21
+ *
22
+ * This is usually combined with [`ManeuverModifier`] in [`VisualInstructionContent`].
17
23
  */
18
- export function advanceLocationSimulation(state: any): any;
24
+ 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";
25
+
19
26
  /**
20
- * An instruction for visual display (usually as banners) at a specific point along a [`RouteStep`].
27
+ * The lane type blocked by the incident.
21
28
  */
22
- export interface VisualInstruction {
23
- /**
24
- * The primary instruction content.
25
- *
26
- * This is usually given more visual weight.
27
- */
28
- primaryContent: VisualInstructionContent;
29
- /**
30
- * Optional secondary instruction content.
31
- */
32
- secondaryContent: VisualInstructionContent | undefined;
33
- /**
34
- * Optional sub-maneuver instruction content.
35
- */
36
- subContent: VisualInstructionContent | undefined;
37
- /**
38
- * How far (in meters) from the upcoming maneuver the instruction should start being displayed
39
- */
40
- triggerDistanceBeforeManeuver: number;
41
- }
29
+ export type BlockedLane = "left" | "left center" | "left turn lane" | "center" | "right" | "right center" | "right turn lane" | "hov";
42
30
 
43
31
  /**
44
- * The content of a visual instruction.
32
+ * A waypoint along a route.
33
+ *
34
+ * Within the context of Ferrostar, a route request consists of exactly one [`UserLocation`]
35
+ * and at least one [`Waypoint`]. The route starts from the user\'s location (which may
36
+ * contain other useful information like their current course for the [`crate::routing_adapters::RouteRequestGenerator`]
37
+ * to use) and proceeds through one or more waypoints.
38
+ *
39
+ * Waypoints are used during route calculation, are tracked throughout the lifecycle of a trip,
40
+ * and are used for recalculating when the user deviates from the expected route.
41
+ *
42
+ * Note that support for properties beyond basic geographic coordinates varies by routing engine.
45
43
  */
46
- export interface VisualInstructionContent {
47
- /**
48
- * The text to display.
49
- */
50
- text: string;
51
- /**
52
- * A standardized maneuver type (if any).
53
- */
54
- maneuverType: ManeuverType | undefined;
55
- /**
56
- * A standardized maneuver modifier (if any).
57
- */
58
- maneuverModifier: ManeuverModifier | undefined;
44
+ export interface Waypoint {
45
+ coordinate: GeographicCoordinate;
46
+ kind: WaypointKind;
59
47
  /**
60
- * If applicable, the number of degrees you need to go around the roundabout before exiting.
48
+ * Optional additional properties that will be passed on to the [`crate::routing_adapters::RouteRequestGenerator`].
61
49
  *
62
- * For example, entering and exiting the roundabout in the same direction of travel
63
- * (as if you had gone straight, apart from the detour)
64
- * would be an exit angle of 180 degrees.
65
- */
66
- roundaboutExitDegrees: number | undefined;
67
- /**
68
- * Detailed information about the lanes. This is typically only present in sub-maneuver instructions.
69
- */
70
- laneInfo: LaneInfo[] | undefined;
71
- /**
72
- * The exit number (or similar identifier like \"8B\").
50
+ * Most users should prefer convenience functions like [`Waypoint::new_with_valhalla_properties`]
51
+ * (or, on platforms like iOS and Android with `UniFFI` bindings, [`crate::routing_adapters::valhalla::create_waypoint_with_valhalla_properties`]).
52
+ *
53
+ * # Format guidelines
54
+ *
55
+ * This MAY be any format agreed upon by both the request generator and response parser.
56
+ * However, to promote interoperability, all implementations in the Ferrostar codebase
57
+ * MUST use JSON.
58
+ *
59
+ * We selected JSON is selected not because it is good,
60
+ * but because generics (i.e., becoming `Waypoint<T>`, where an example `T` is `ValhallaProperties`)
61
+ * would be way too painful, particularly for foreign code.
62
+ * Especially JavaScript.
63
+ *
64
+ * In any case, [`crate::routing_adapters::RouteRequestGenerator`] and [`crate::routing_adapters::RouteResponseParser`]
65
+ * implementations SHOULD document their level support for this,
66
+ * ideally with an exportable record type.
73
67
  */
74
- exitNumbers: string[];
75
- }
76
-
77
- /**
78
- * The content of a visual instruction.
79
- */
80
- export interface LaneInfo {
81
- active: boolean;
82
- directions: string[];
83
- activeDirection: string | undefined;
68
+ properties: number[] | undefined;
84
69
  }
85
70
 
86
71
  /**
87
- * An incident affecting the free flow of traffic,
88
- * such as constructions, accidents, and congestion.
72
+ * A maneuver (such as a turn or merge) followed by travel of a certain distance until reaching
73
+ * the next step.
89
74
  */
90
- export interface Incident {
91
- /**
92
- * A unique identifier for the incident.
93
- */
94
- id: string;
95
- /**
96
- * The type of incident.
97
- */
98
- incidentType: IncidentType;
99
- /**
100
- * A short description of the incident.
101
- */
102
- description: string | undefined;
103
- /**
104
- * A longer description of the incident.
105
- */
106
- longDescription: string | undefined;
107
- /**
108
- * The time at which the incident was *last* created.
109
- *
110
- * NB: This can change throughout the life of the incident.
111
- */
112
- creationTime: Date | null;
113
- /**
114
- * The time at which the incident started or is expected to start (ex: planned closure).
115
- */
116
- startTime: Date | null;
117
- /**
118
- * The time at which the incident ended or is expected to end.
119
- */
120
- endTime: Date | null;
121
- /**
122
- * The level of impact to traffic.
123
- */
124
- impact: Impact | undefined;
125
- /**
126
- * Lanes which are blocked by the incident.
127
- */
128
- lanesBlocked: BlockedLane[];
75
+ export interface RouteStep {
129
76
  /**
130
- * Info about the amount of congestion on the road around the incident.
77
+ * The full route geometry for this step.
131
78
  */
132
- congestion: Congestion | undefined;
79
+ geometry: GeographicCoordinate[];
133
80
  /**
134
- * Is the road completely closed?
81
+ * The distance, in meters, to travel along the route after the maneuver to reach the next step.
135
82
  */
136
- closed: boolean | undefined;
83
+ distance: number;
137
84
  /**
138
- * The index into the [`RouteStep`] geometry where the incident starts.
85
+ * The estimated duration, in seconds, that it will take to complete this step.
139
86
  */
140
- geometryIndexStart: number;
87
+ duration: number;
141
88
  /**
142
- * The index into the [`RouteStep`] geometry where the incident ends.
89
+ * The name of the road being traveled on (useful for certain UI styles).
143
90
  */
144
- geometryIndexEnd: number | undefined;
91
+ roadName: string | undefined;
145
92
  /**
146
- * Optional additional information about the type of incident (free-form text).
93
+ * A list of exits (name or number).
147
94
  */
148
- subType: string | undefined;
95
+ exits: string[];
149
96
  /**
150
- * Optional descriptions about the type of incident (free-form text).
97
+ * A description of the maneuver (ex: \"Turn wright onto main street\").
98
+ *
99
+ * Note for UI implementers: the context this appears in (or doesn\'t)
100
+ * depends somewhat on your use case and routing engine.
101
+ * For example, this field is useful as a written instruction in Valhalla.
151
102
  */
152
- subTypeDescription: string | undefined;
103
+ instruction: string;
153
104
  /**
154
- * The ISO 3166-1 alpha-2 code of the country in which the incident occurs.
105
+ * A list of instructions for visual display (usually as banners) at specific points along the step.
155
106
  */
156
- iso31661Alpha2: string | undefined;
107
+ visualInstructions: VisualInstruction[];
157
108
  /**
158
- * The ISO 3166-1 alpha-3 code of the country in which the incident occurs.
109
+ * A list of prompts to announce (via speech synthesis) at specific points along the step.
159
110
  */
160
- iso31661Alpha3: string | undefined;
111
+ spokenInstructions: SpokenInstruction[];
161
112
  /**
162
- * A list of road names affected by the incident.
113
+ * A list of json encoded strings representing annotations between each coordinate along the step.
163
114
  */
164
- affectedRoadNames: string[];
115
+ annotations: string[] | undefined;
165
116
  /**
166
- * The bounding box over which the incident occurs.
117
+ * A list of incidents that occur along the step.
167
118
  */
168
- bbox: BoundingBox | undefined;
119
+ incidents: Incident[];
169
120
  }
170
121
 
171
122
  /**
172
- * Details about congestion for an incident.
123
+ * A geographic coordinate in WGS84.
173
124
  */
174
- export interface Congestion {
125
+ export interface GeographicCoordinate {
175
126
  /**
176
- * The level of congestion caused by the incident.
177
- *
178
- * 0 = no congestion
179
- *
180
- * 100 = road closed
181
- *
182
- * Other values mean no congestion was calculated
127
+ * The latitude (in degrees).
183
128
  */
184
- value: number;
129
+ lat: number;
130
+ /**
131
+ * The Longitude (in degrees).
132
+ */
133
+ lng: number;
185
134
  }
186
135
 
187
- /**
188
- * The lane type blocked by the incident.
189
- */
190
- export type BlockedLane = "left" | "left center" | "left turn lane" | "center" | "right" | "right center" | "right turn lane" | "hov";
191
-
192
- /**
193
- * The impact of the incident that has occurred.
194
- */
195
- export type Impact = "unknown" | "critical" | "major" | "minor" | "low";
196
-
197
- /**
198
- * The type of incident that has occurred.
199
- */
200
- export type IncidentType = "accident" | "congestion" | "construction" | "disabled_vehicle" | "lane_restriction" | "mass_transit" | "miscellaneous" | "other_news" | "planned_event" | "road_closure" | "road_hazard" | "weather";
201
-
202
- /**
203
- * Additional information to further specify a [`ManeuverType`].
204
- */
205
- export type ManeuverModifier = "uturn" | "sharp right" | "right" | "slight right" | "straight" | "slight left" | "left" | "sharp left";
206
-
207
- /**
208
- * The broad class of maneuver to perform.
209
- *
210
- * This is usually combined with [`ManeuverModifier`] in [`VisualInstructionContent`].
211
- */
212
- 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";
213
-
214
136
  /**
215
137
  * An instruction that can be synthesized using a TTS engine to announce an upcoming maneuver.
216
138
  *
@@ -226,7 +148,7 @@ export interface SpokenInstruction {
226
148
  */
227
149
  ssml: string | undefined;
228
150
  /**
229
- * How far (in meters) from the upcoming maneuver the instruction should start being displayed
151
+ * How far (in meters) from the upcoming maneuver the instruction should start being spoken.
230
152
  */
231
153
  triggerDistanceBeforeManeuver: number;
232
154
  /**
@@ -243,54 +165,100 @@ export interface SpokenInstruction {
243
165
  }
244
166
 
245
167
  /**
246
- * A maneuver (such as a turn or merge) followed by travel of a certain distance until reaching
247
- * the next step.
168
+ * The direction in which the user/device is observed to be traveling.
248
169
  */
249
- export interface RouteStep {
170
+ export interface CourseOverGround {
250
171
  /**
251
- * The full route geometry for this step.
172
+ * The direction in which the user\'s device is traveling, measured in clockwise degrees from
173
+ * true north (N = 0, E = 90, S = 180, W = 270).
252
174
  */
253
- geometry: GeographicCoordinate[];
175
+ degrees: number;
254
176
  /**
255
- * The distance, in meters, to travel along the route after the maneuver to reach the next step.
177
+ * The accuracy of the course value, measured in degrees.
256
178
  */
257
- distance: number;
179
+ accuracy: number | undefined;
180
+ }
181
+
182
+ /**
183
+ * A geographic bounding box defined by its corners.
184
+ */
185
+ export interface BoundingBox {
258
186
  /**
259
- * The estimated duration, in seconds, that it will take to complete this step.
187
+ * The southwest corner of the bounding box.
260
188
  */
261
- duration: number;
189
+ sw: GeographicCoordinate;
262
190
  /**
263
- * The name of the road being traveled on (useful for certain UI styles).
191
+ * The northeast corner of the bounding box.
264
192
  */
265
- roadName: string | undefined;
193
+ ne: GeographicCoordinate;
194
+ }
195
+
196
+ /**
197
+ * The location of the user that is navigating.
198
+ *
199
+ * In addition to coordinates, this includes estimated accuracy and course information,
200
+ * which can influence navigation logic and UI.
201
+ *
202
+ * NOTE: Heading is absent on purpose.
203
+ * Heading updates are not related to a change in the user\'s location.
204
+ */
205
+ export interface UserLocation {
206
+ coordinates: GeographicCoordinate;
266
207
  /**
267
- * A list of exits (name or number).
208
+ * The estimated accuracy of the coordinate (in meters)
268
209
  */
269
- exits: string[];
210
+ horizontalAccuracy: number;
211
+ courseOverGround: CourseOverGround | undefined;
212
+ timestamp: { secs_since_epoch: number; nanos_since_epoch: number };
213
+ speed: Speed | undefined;
214
+ }
215
+
216
+ /**
217
+ * The content of a visual instruction.
218
+ */
219
+ export interface VisualInstructionContent {
270
220
  /**
271
- * A description of the maneuver (ex: \"Turn wright onto main street\").
272
- *
273
- * Note for UI implementers: the context this appears in (or doesn\'t)
274
- * depends somewhat on your use case and routing engine.
275
- * For example, this field is useful as a written instruction in Valhalla.
221
+ * The text to display.
276
222
  */
277
- instruction: string;
223
+ text: string;
278
224
  /**
279
- * A list of instructions for visual display (usually as banners) at specific points along the step.
225
+ * A standardized maneuver type (if any).
280
226
  */
281
- visualInstructions: VisualInstruction[];
227
+ maneuverType: ManeuverType | undefined;
282
228
  /**
283
- * A list of prompts to announce (via speech synthesis) at specific points along the step.
229
+ * A standardized maneuver modifier (if any).
284
230
  */
285
- spokenInstructions: SpokenInstruction[];
231
+ maneuverModifier: ManeuverModifier | undefined;
286
232
  /**
287
- * A list of json encoded strings representing annotations between each coordinate along the step.
233
+ * If applicable, the number of degrees you need to go around the roundabout before exiting.
234
+ *
235
+ * For example, entering and exiting the roundabout in the same direction of travel
236
+ * (as if you had gone straight, apart from the detour)
237
+ * would be an exit angle of 180 degrees.
288
238
  */
289
- annotations: string[] | undefined;
239
+ roundaboutExitDegrees: number | undefined;
290
240
  /**
291
- * A list of incidents that occur along the step.
241
+ * Detailed information about the lanes. This is typically only present in sub-maneuver instructions.
292
242
  */
293
- incidents: Incident[];
243
+ laneInfo: LaneInfo[] | undefined;
244
+ /**
245
+ * The exit number (or similar identifier like \"8B\").
246
+ */
247
+ exitNumbers: string[];
248
+ }
249
+
250
+ /**
251
+ * Describes characteristics of the waypoint for routing purposes.
252
+ */
253
+ export type WaypointKind = "Break" | "Via";
254
+
255
+ /**
256
+ * The content of a visual instruction.
257
+ */
258
+ export interface LaneInfo {
259
+ active: boolean;
260
+ directions: string[];
261
+ activeDirection: string | undefined;
294
262
  }
295
263
 
296
264
  /**
@@ -316,23 +284,24 @@ export interface Route {
316
284
  }
317
285
 
318
286
  /**
319
- * The location of the user that is navigating.
320
- *
321
- * In addition to coordinates, this includes estimated accuracy and course information,
322
- * which can influence navigation logic and UI.
323
- *
324
- * NOTE: Heading is absent on purpose.
325
- * Heading updates are not related to a change in the user\'s location.
287
+ * Additional information to further specify a [`ManeuverType`].
326
288
  */
327
- export interface UserLocation {
328
- coordinates: GeographicCoordinate;
289
+ export type ManeuverModifier = "uturn" | "sharp right" | "right" | "slight right" | "straight" | "slight left" | "left" | "sharp left";
290
+
291
+ /**
292
+ * Details about congestion for an incident.
293
+ */
294
+ export interface Congestion {
329
295
  /**
330
- * The estimated accuracy of the coordinate (in meters)
296
+ * The level of congestion caused by the incident.
297
+ *
298
+ * 0 = no congestion
299
+ *
300
+ * 100 = road closed
301
+ *
302
+ * Other values mean no congestion was calculated
331
303
  */
332
- horizontalAccuracy: number;
333
- courseOverGround: CourseOverGround | undefined;
334
- timestamp: { secs_since_epoch: number; nanos_since_epoch: number };
335
- speed: Speed | undefined;
304
+ value: number;
336
305
  }
337
306
 
338
307
  /**
@@ -350,93 +319,151 @@ export interface Speed {
350
319
  }
351
320
 
352
321
  /**
353
- * The direction in which the user/device is observed to be traveling.
322
+ * The type of incident that has occurred.
354
323
  */
355
- export interface CourseOverGround {
324
+ export type IncidentType = "accident" | "congestion" | "construction" | "disabled_vehicle" | "lane_restriction" | "mass_transit" | "miscellaneous" | "other_news" | "planned_event" | "road_closure" | "road_hazard" | "weather";
325
+
326
+ /**
327
+ * The impact of the incident that has occurred.
328
+ */
329
+ export type Impact = "unknown" | "critical" | "major" | "minor" | "low";
330
+
331
+ /**
332
+ * An instruction for visual display (usually as banners) at a specific point along a [`RouteStep`].
333
+ */
334
+ export interface VisualInstruction {
356
335
  /**
357
- * The direction in which the user\'s device is traveling, measured in clockwise degrees from
358
- * true north (N = 0, E = 90, S = 180, W = 270).
336
+ * The primary instruction content.
337
+ *
338
+ * This is usually given more visual weight.
359
339
  */
360
- degrees: number;
340
+ primaryContent: VisualInstructionContent;
361
341
  /**
362
- * The accuracy of the course value, measured in degrees.
342
+ * Optional secondary instruction content.
363
343
  */
364
- accuracy: number | undefined;
365
- }
366
-
367
- /**
368
- * A geographic bounding box defined by its corners.
369
- */
370
- export interface BoundingBox {
344
+ secondaryContent: VisualInstructionContent | undefined;
371
345
  /**
372
- * The southwest corner of the bounding box.
346
+ * Optional sub-maneuver instruction content.
373
347
  */
374
- sw: GeographicCoordinate;
348
+ subContent: VisualInstructionContent | undefined;
375
349
  /**
376
- * The northeast corner of the bounding box.
350
+ * How far (in meters) from the upcoming maneuver the instruction should start being displayed
377
351
  */
378
- ne: GeographicCoordinate;
352
+ triggerDistanceBeforeManeuver: number;
379
353
  }
380
354
 
381
355
  /**
382
- * Describes characteristics of the waypoint for the routing backend.
383
- */
384
- export type WaypointKind = "Break" | "Via";
385
-
386
- /**
387
- * A waypoint along a route.
388
- *
389
- * Within the context of Ferrostar, a route request consists of exactly one [`UserLocation`]
390
- * and at least one [`Waypoint`]. The route starts from the user\'s location (which may
391
- * contain other useful information like their current course for the [`crate::routing_adapters::RouteRequestGenerator`]
392
- * to use) and proceeds through one or more waypoints.
393
- *
394
- * Waypoints are used during route calculation, are tracked throughout the lifecycle of a trip,
395
- * and are used for recalculating when the user deviates from the expected route.
396
- *
397
- * Note that support for properties beyond basic geographic coordinates varies by routing engine.
356
+ * An incident affecting the free flow of traffic,
357
+ * such as constructions, accidents, and congestion.
398
358
  */
399
- export interface Waypoint {
400
- coordinate: GeographicCoordinate;
401
- kind: WaypointKind;
359
+ export interface Incident {
360
+ /**
361
+ * A unique identifier for the incident.
362
+ */
363
+ id: string;
364
+ /**
365
+ * The type of incident.
366
+ */
367
+ incidentType: IncidentType;
368
+ /**
369
+ * A short description of the incident.
370
+ */
371
+ description: string | undefined;
372
+ /**
373
+ * A longer description of the incident.
374
+ */
375
+ longDescription: string | undefined;
376
+ /**
377
+ * The time at which the incident was *last* created.
378
+ *
379
+ * NB: This can change throughout the life of the incident.
380
+ */
381
+ creationTime: Date | null;
382
+ /**
383
+ * The time at which the incident started or is expected to start (ex: planned closure).
384
+ */
385
+ startTime: Date | null;
386
+ /**
387
+ * The time at which the incident ended or is expected to end.
388
+ */
389
+ endTime: Date | null;
390
+ /**
391
+ * The level of impact to traffic.
392
+ */
393
+ impact: Impact | undefined;
394
+ /**
395
+ * Lanes which are blocked by the incident.
396
+ */
397
+ lanesBlocked: BlockedLane[];
398
+ /**
399
+ * Info about the amount of congestion on the road around the incident.
400
+ */
401
+ congestion: Congestion | undefined;
402
+ /**
403
+ * Is the road completely closed?
404
+ */
405
+ closed: boolean | undefined;
406
+ /**
407
+ * The index into the [`RouteStep`] geometry where the incident starts.
408
+ */
409
+ geometryIndexStart: number;
410
+ /**
411
+ * The index into the [`RouteStep`] geometry where the incident ends.
412
+ */
413
+ geometryIndexEnd: number | undefined;
414
+ /**
415
+ * Optional additional information about the type of incident (free-form text).
416
+ */
417
+ subType: string | undefined;
418
+ /**
419
+ * Optional descriptions about the type of incident (free-form text).
420
+ */
421
+ subTypeDescription: string | undefined;
422
+ /**
423
+ * The ISO 3166-1 alpha-2 code of the country in which the incident occurs.
424
+ */
425
+ iso31661Alpha2: string | undefined;
426
+ /**
427
+ * The ISO 3166-1 alpha-3 code of the country in which the incident occurs.
428
+ */
429
+ iso31661Alpha3: string | undefined;
430
+ /**
431
+ * A list of road names affected by the incident.
432
+ */
433
+ affectedRoadNames: string[];
402
434
  /**
403
- * Optional additional properties that will be passed on to the [`crate::routing_adapters::RouteRequestGenerator`].
404
- *
405
- * Most users should prefer convenience functions like [`Waypoint::new_with_valhalla_properties`]
406
- * (or, on platforms like iOS and Android with UniFFI bindings, [`crate::routing_adapters::valhalla::create_waypoint_with_valhalla_properties`]).
407
- *
408
- * # Format guidelines
409
- *
410
- * This MAY be any format agreed upon by both the request generator and response parser.
411
- * However, to promote interoperability, all implementations in the Ferrostar codebase
412
- * MUST use JSON.
413
- *
414
- * We selected JSON is selected not because it is good,
415
- * but because generics (i.e., becoming `Waypoint<T>`, where an example `T` is `ValhallaProperties`)
416
- * would be way too painful, particularly for foreign code.
417
- * Especially JavaScript.
418
- *
419
- * In any case, [`crate::routing_adapters::RouteRequestGenerator`] and [`crate::routing_adapters::RouteResponseParser`]
420
- * implementations SHOULD document their level support for this,
421
- * ideally with an exportable record type.
435
+ * The bounding box over which the incident occurs.
422
436
  */
423
- properties: number[] | undefined;
437
+ bbox: BoundingBox | undefined;
424
438
  }
425
439
 
426
440
  /**
427
- * A geographic coordinate in WGS84.
441
+ * Waypoint properties parsed from an OSRM-compatible server response.
442
+ *
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.
428
448
  */
429
- export interface GeographicCoordinate {
449
+ export interface OsrmWaypointProperties {
430
450
  /**
431
- * The latitude (in degrees).
451
+ * The name of the street that the waypoint snapped to.
432
452
  */
433
- lat: number;
453
+ name: string | undefined;
434
454
  /**
435
- * The Longitude (in degrees).
455
+ * The distance (in meters) between the snapped point and the input coordinate.
436
456
  */
437
- lng: number;
457
+ distance: number | undefined;
438
458
  }
439
459
 
460
+ /**
461
+ * A road class in the Valhalla taxonomy.
462
+ *
463
+ * These are ordered from highest (fastest travel speed) to lowest.
464
+ */
465
+ export type ValhallaRoadClass = "motorway" | "trunk" | "primary" | "secondary" | "tertiary" | "unclassified" | "residential" | "service_other";
466
+
440
467
  /**
441
468
  * A set of optional filters to exclude candidate edges based on their attributes.
442
469
  */
@@ -481,13 +508,6 @@ export interface ValhallaLocationSearchFilter {
481
508
  level?: number;
482
509
  }
483
510
 
484
- /**
485
- * A road class in the Valhalla taxonomy.
486
- *
487
- * These are ordered from highest (fastest travel speed) to lowest.
488
- */
489
- export type ValhallaRoadClass = "motorway" | "trunk" | "primary" | "secondary" | "tertiary" | "unclassified" | "residential" | "service_other";
490
-
491
511
  /**
492
512
  * Specifies a preferred side for departing from / arriving at a location.
493
513
  *
@@ -514,6 +534,10 @@ export type ValhallaWaypointPreferredSide = "same" | "opposite" | "either";
514
534
  export interface ValhallaWaypointProperties {
515
535
  /**
516
536
  * Preferred direction of travel for the start from the location.
537
+ *
538
+ * The heading is indicated in degrees from north in a clockwise direction, where north is 0°, east is 90°, south is 180°, and west is 270°.
539
+ * Avoid specifying this unless you really know what you\'re doing.
540
+ * Most use cases for this are better served by `preferred_side`.
517
541
  */
518
542
  heading: number | undefined;
519
543
  /**
@@ -532,6 +556,13 @@ export interface ValhallaWaypointProperties {
532
556
  * will be considered as candidates for said location.
533
557
  * If there are no candidates within this distance,
534
558
  * it will return the closest candidate within reason.
559
+ *
560
+ * This allows the routing engine to match another edge which is NOT
561
+ * the closest to your location, but in within this range.
562
+ * This can be useful if you have other constraints and want to disambiguate,
563
+ * but beware that this can lead to very strange results,
564
+ * particularly if you have specified other parameters like `heading`.
565
+ * This is an advanced feature and should only be used with extreme care.
535
566
  */
536
567
  radius: number | undefined;
537
568
  /**
@@ -586,51 +617,82 @@ export interface ValhallaWaypointProperties {
586
617
  search_filter: ValhallaLocationSearchFilter | undefined;
587
618
  }
588
619
 
620
+ 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[] } };
621
+
589
622
  /**
590
- * Waypoint properties parsed from an OSRM-compatible server response.
591
- *
592
- * NOTE: Some servers (such as Valhalla) may support additional parameters at request time
593
- * which are _not_ echoed back in the response time.
594
- * This is unfortunate; PRs upstream would likely be welcomed!
595
- * Similarly, if your server is OSRM-compatible and returns additional attributes,
596
- * feel free to open a PR to include these as optional properties.
623
+ * Information pertaining to the user\'s full navigation trip. This includes
624
+ * simple stats like total duration and distance.
597
625
  */
598
- export interface OsrmWaypointProperties {
626
+ export interface TripSummary {
599
627
  /**
600
- * The name of the street that the waypoint snapped to.
628
+ * The total raw distance traveled in the trip, in meters.
601
629
  */
602
- name: string | undefined;
630
+ distanceTraveled: number;
603
631
  /**
604
- * The distance (in meters) between the snapped point and the input coordinate.
632
+ * The total snapped distance traveled in the trip, in meters.
605
633
  */
606
- distance: number | undefined;
634
+ snappedDistanceTraveled: number;
635
+ /**
636
+ * When the trip was started.
637
+ */
638
+ startedAt: Date;
639
+ /**
640
+ * When the trip was completed or canceled.
641
+ */
642
+ endedAt: Date | null;
607
643
  }
608
644
 
609
645
  /**
610
- * The event type.
646
+ * Controls when a waypoint should be marked as complete.
611
647
  *
612
- * For full replayability, we record things like rerouting, and not just location updates.
648
+ * While a route may consist of thousands of points, waypoints are special.
649
+ * A simple trip will have only one waypoint: the final destination.
650
+ * A more complex trip may have several intermediate stops.
651
+ * Just as the navigation state keeps track of which steps remain in the route,
652
+ * it also tracks which waypoints are still remaining.
653
+ *
654
+ * Tracking waypoints enables Ferrostar to reroute users when they stray off the route line.
655
+ * The waypoint advance mode specifies how the framework decides
656
+ * that a waypoint has been visited (and is removed from the list).
657
+ *
658
+ * NOTE: Advancing to the next *step* and advancing to the next *waypoint*
659
+ * are separate processes.
660
+ * This will not normally cause any issues, but keep in mind that
661
+ * manually advancing to the next step does not *necessarily* imply
662
+ * that the waypoint will be marked as complete!
613
663
  */
614
- export type NavigationRecordingEventData = { StateUpdate: { trip_state: TripState; step_advance_condition: SerializableStepAdvanceCondition } } | { RouteUpdate: { route: Route } };
664
+ export type WaypointAdvanceMode = { WaypointWithinRange: number } | { WaypointAlongAdvancingStep: number };
615
665
 
616
666
  /**
617
- * An event that occurs during navigation.
618
- *
619
- * This is used for the optional session recording / telemetry.
667
+ * Controls filtering/post-processing of user course by the [`NavigationController`].
620
668
  */
621
- export interface NavigationRecordingEvent {
669
+ export type CourseFiltering = "SnapToRoute" | "Raw";
670
+
671
+ export interface SerializableNavState {
672
+ tripState: TripState;
673
+ stepAdvanceCondition: SerializableStepAdvanceCondition;
674
+ }
675
+
676
+ /**
677
+ * High-level state describing progress through a route.
678
+ */
679
+ export interface TripProgress {
622
680
  /**
623
- * The timestamp of the event in milliseconds since Jan 1, 1970 UTC.
681
+ * The distance to the next maneuver, in meters.
624
682
  */
625
- timestamp: number;
683
+ distanceToNextManeuver: number;
626
684
  /**
627
- * Data associated with the event.
685
+ * The total distance remaining in the trip, in meters.
686
+ *
687
+ * This is the sum of the distance remaining in the current step and the distance remaining in all subsequent steps.
628
688
  */
629
- event_data: NavigationRecordingEventData;
689
+ distanceRemaining: number;
690
+ /**
691
+ * The total duration remaining in the trip, in seconds.
692
+ */
693
+ durationRemaining: number;
630
694
  }
631
695
 
632
- 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[] } };
633
-
634
696
  export interface SerializableNavigationControllerConfig {
635
697
  /**
636
698
  * Configures when navigation advances to the next waypoint in the route.
@@ -661,32 +723,6 @@ export interface SerializableNavigationControllerConfig {
661
723
  snappedLocationCourseFiltering: CourseFiltering;
662
724
  }
663
725
 
664
- /**
665
- * Controls when a waypoint should be marked as complete.
666
- *
667
- * While a route may consist of thousands of points, waypoints are special.
668
- * A simple trip will have only one waypoint: the final destination.
669
- * A more complex trip may have several intermediate stops.
670
- * Just as the navigation state keeps track of which steps remain in the route,
671
- * it also tracks which waypoints are still remaining.
672
- *
673
- * Tracking waypoints enables Ferrostar to reroute users when they stray off the route line.
674
- * The waypoint advance mode specifies how the framework decides
675
- * that a waypoint has been visited (and is removed from the list).
676
- *
677
- * NOTE: Advancing to the next *step* and advancing to the next *waypoint*
678
- * are separate processes.
679
- * This will not normally cause any issues, but keep in mind that
680
- * manually advancing to the next step does not *necessarily* imply
681
- * that the waypoint will be marked as complete!
682
- */
683
- export type WaypointAdvanceMode = { WaypointWithinRange: number } | { WaypointAlongAdvancingStep: number };
684
-
685
- /**
686
- * Controls filtering/post-processing of user course by the [`NavigationController`].
687
- */
688
- export type CourseFiltering = "SnapToRoute" | "Raw";
689
-
690
726
  /**
691
727
  * The state of a navigation session.
692
728
  *
@@ -697,65 +733,32 @@ export type CourseFiltering = "SnapToRoute" | "Raw";
697
733
  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 } };
698
734
 
699
735
  /**
700
- * Information pertaining to the user\'s full navigation trip. This includes
701
- * simple stats like total duration and distance.
736
+ * The event type.
737
+ *
738
+ * For full replayability, we record things like rerouting, and not just location updates.
702
739
  */
703
- export interface TripSummary {
704
- /**
705
- * The total raw distance traveled in the trip, in meters.
706
- */
707
- distanceTraveled: number;
708
- /**
709
- * The total snapped distance traveled in the trip, in meters.
710
- */
711
- snappedDistanceTraveled: number;
712
- /**
713
- * When the trip was started.
714
- */
715
- startedAt: Date;
716
- /**
717
- * When the trip was completed or canceled.
718
- */
719
- endedAt: Date | null;
720
- }
740
+ export type NavigationRecordingEventData = { StateUpdate: { trip_state: TripState; step_advance_condition: SerializableStepAdvanceCondition } } | { RouteUpdate: { route: Route } };
721
741
 
722
742
  /**
723
- * High-level state describing progress through a route.
743
+ * An event that occurs during navigation.
744
+ *
745
+ * This is used for the optional session recording / telemetry.
724
746
  */
725
- export interface TripProgress {
726
- /**
727
- * The distance to the next maneuver, in meters.
728
- */
729
- distanceToNextManeuver: number;
747
+ export interface NavigationRecordingEvent {
730
748
  /**
731
- * The total distance remaining in the trip, in meters.
732
- *
733
- * This is the sum of the distance remaining in the current step and the distance remaining in all subsequent steps.
749
+ * The timestamp of the event in milliseconds since Jan 1, 1970 UTC.
734
750
  */
735
- distanceRemaining: number;
751
+ timestamp: number;
736
752
  /**
737
- * The total duration remaining in the trip, in seconds.
753
+ * Data associated with the event.
738
754
  */
739
- durationRemaining: number;
740
- }
741
-
742
- export interface SerializableNavState {
743
- tripState: TripState;
744
- stepAdvanceCondition: SerializableStepAdvanceCondition;
755
+ event_data: NavigationRecordingEventData;
745
756
  }
746
757
 
747
758
  /**
748
- * Status information that describes whether the user is proceeding according to the route or not.
749
- *
750
- * Note that the name is intentionally a bit generic to allow for expansion of other states.
751
- * For example, we could conceivably add a \"wrong way\" status in the future.
752
- */
753
- export type RouteDeviation = "NoDeviation" | { OffRoute: { deviationFromRouteLine: number } };
754
-
755
- /**
756
- * Determines if the user has deviated from the expected route.
759
+ * Configurations for built-in route providers.
757
760
  */
758
- export type RouteDeviationTracking = "None" | { StaticThreshold: { minimumHorizontalAccuracy: number; maxAcceptableDeviation: number } };
761
+ export type WellKnownRouteProvider = { Valhalla: { endpointUrl: string; profile: string; optionsJson?: string | undefined } } | { GraphHopper: { endpointUrl: string; profile: string; locale: string; voiceUnits: GraphHopperVoiceUnits; optionsJson?: string | undefined } };
759
762
 
760
763
  export type SimulationError = { PolylineError: { error: string } } | "NotEnoughPoints";
761
764
 
@@ -774,6 +777,21 @@ export interface LocationSimulationState {
774
777
  bias: LocationBias;
775
778
  }
776
779
 
780
+ /**
781
+ * Status information that describes whether the user is proceeding according to the route or not.
782
+ *
783
+ * Note that the name is intentionally a bit generic to allow for expansion of other states.
784
+ * For example, we could conceivably add a \"wrong way\" status in the future.
785
+ */
786
+ export type RouteDeviation = "NoDeviation" | { OffRoute: { deviationFromRouteLine: number } };
787
+
788
+ /**
789
+ * Determines if the user has deviated from the expected route.
790
+ */
791
+ export type RouteDeviationTracking = "None" | { StaticThreshold: { minimumHorizontalAccuracy: number; maxAcceptableDeviation: number } };
792
+
793
+ export type GraphHopperVoiceUnits = "metric" | "imperial";
794
+
777
795
  /**
778
796
  * JavaScript wrapper for `NavigationController`.
779
797
  * This wrapper is required because `NavigationController` cannot be directly converted to a JavaScript object
@@ -781,10 +799,11 @@ export interface LocationSimulationState {
781
799
  */
782
800
  export class NavigationController {
783
801
  free(): void;
784
- constructor(route: any, config: any, should_record: any);
802
+ [Symbol.dispose](): void;
785
803
  getInitialState(location: any): any;
786
804
  advanceToNextStep(state: any): any;
787
805
  updateUserLocation(location: any, state: any): any;
806
+ constructor(route: any, config: any, should_record: any);
788
807
  }
789
808
  /**
790
809
  * A WebAssembly-compatible wrapper for `NavigationReplay` that exposes its functionality as a JavaScript object.
@@ -794,47 +813,51 @@ export class NavigationController {
794
813
  */
795
814
  export class NavigationReplay {
796
815
  free(): void;
797
- constructor(json: any);
798
- getEventByIndex(current_index: any): any;
816
+ [Symbol.dispose](): void;
799
817
  getAllEvents(): any;
818
+ getInitialRoute(): any;
819
+ getEventByIndex(current_index: any): any;
800
820
  getTotalDuration(): any;
801
821
  getInitialTimestamp(): any;
802
- getInitialRoute(): any;
822
+ constructor(json: any);
803
823
  }
804
824
  /**
805
- * JavaScript wrapper for `NavigationSession` (simple version).
825
+ * JavaScript wrapper for [`NavigationSession`] (simple version).
806
826
  * This wrapper provides basic navigation functionality without observers.
807
827
  */
808
828
  export class NavigationSession {
809
829
  free(): void;
810
- constructor(route: any, config: any);
830
+ [Symbol.dispose](): void;
811
831
  getInitialState(location: any): any;
812
832
  advanceToNextStep(state: any): any;
813
833
  updateUserLocation(location: any, state: any): any;
834
+ constructor(route: any, config: any);
814
835
  }
815
836
  /**
816
- * JavaScript wrapper for `NavigationSession` with recording capabilities.
837
+ * JavaScript wrapper for [`NavigationSession`] with recording capabilities.
817
838
  * This version includes a NavigationRecorder observer and provides direct access to recording functionality.
818
839
  */
819
840
  export class NavigationSessionRecording {
820
841
  free(): void;
821
- constructor(route: any, config: any);
842
+ [Symbol.dispose](): void;
843
+ getEvents(): any;
844
+ getRecording(): any;
822
845
  getInitialState(location: any): any;
823
846
  advanceToNextStep(state: any): any;
824
847
  updateUserLocation(location: any, state: any): any;
825
- getRecording(): any;
826
- getEvents(): any;
848
+ constructor(route: any, config: any);
827
849
  }
828
850
  /**
829
851
  * JavaScript wrapper for `RouteAdapter`.
830
852
  */
831
853
  export class RouteAdapter {
832
854
  free(): void;
855
+ [Symbol.dispose](): void;
856
+ parseResponse(response: Uint8Array): any;
857
+ generateRequest(user_location: any, waypoints: any): any;
833
858
  /**
834
859
  * Creates a new RouteAdapter with a Valhalla HTTP request generator and an OSRM response parser.
835
860
  * At the moment, this is the only supported combination.
836
861
  */
837
- constructor(endpoint_url: string, profile: string, costing_options_json?: string | null);
838
- generateRequest(user_location: any, waypoints: any): any;
839
- parseResponse(response: Uint8Array): any;
862
+ constructor(well_known_route_provider: WellKnownRouteProvider);
840
863
  }