@stadiamaps/ferrostar 0.42.0 → 0.44.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
@@ -399,6 +399,28 @@ export type WaypointKind = "Break" | "Via";
399
399
  export interface Waypoint {
400
400
  coordinate: GeographicCoordinate;
401
401
  kind: WaypointKind;
402
+ /**
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.
422
+ */
423
+ properties: number[] | undefined;
402
424
  }
403
425
 
404
426
  /**
@@ -416,19 +438,173 @@ export interface GeographicCoordinate {
416
438
  }
417
439
 
418
440
  /**
419
- * Status information that describes whether the user is proceeding according to the route or not.
441
+ * A set of optional filters to exclude candidate edges based on their attributes.
442
+ */
443
+ export interface ValhallaLocationSearchFilter {
444
+ /**
445
+ * Whether to exclude roads marked as tunnels.
446
+ */
447
+ exclude_tunnel?: boolean;
448
+ /**
449
+ * Whether to exclude roads marked as bridges.
450
+ */
451
+ exclude_bridge?: boolean;
452
+ /**
453
+ * Whether to exclude roads with tolls.
454
+ */
455
+ exclude_tolls?: boolean;
456
+ /**
457
+ * Whether to exclude ferries.
458
+ */
459
+ exclude_ferry?: boolean;
460
+ /**
461
+ * Whether to exclude roads marked as ramps.
462
+ */
463
+ exclude_ramp?: boolean;
464
+ /**
465
+ * Whether to exclude roads marked as closed due to a live traffic closure.
466
+ */
467
+ exclude_closures?: boolean;
468
+ /**
469
+ * The lowest road class allowed.
470
+ */
471
+ min_road_class?: ValhallaRoadClass;
472
+ /**
473
+ * The highest road class allowed.
474
+ */
475
+ max_road_class?: ValhallaRoadClass;
476
+ /**
477
+ * If specified, will only consider edges that are on or traverse the passed floor level.
478
+ * It will set `search_cutoff` to a default value of 300 meters if no cutoff value is passed.
479
+ * Additionally, if a `search_cutoff` is passed, it will be clamped to 1000 meters.
480
+ */
481
+ level?: number;
482
+ }
483
+
484
+ /**
485
+ * A road class in the Valhalla taxonomy.
420
486
  *
421
- * Note that the name is intentionally a bit generic to allow for expansion of other states.
422
- * For example, we could conceivably add a \"wrong way\" status in the future.
487
+ * These are ordered from highest (fastest travel speed) to lowest.
423
488
  */
424
- export type RouteDeviation = "NoDeviation" | { OffRoute: { deviationFromRouteLine: number } };
489
+ export type ValhallaRoadClass = "motorway" | "trunk" | "primary" | "secondary" | "tertiary" | "unclassified" | "residential" | "service_other";
425
490
 
426
491
  /**
427
- * Determines if the user has deviated from the expected route.
492
+ * Specifies a preferred side for departing from / arriving at a location.
493
+ *
494
+ * Examples:
495
+ * - Germany drives on the right side of the road. A value of `same` will only allow leaving
496
+ * or arriving at a location such that it is on your right.
497
+ * - Australia drives on the left side of the road. Passing a value of `same` will only allow
498
+ * leaving or arriving at a location such that it is on your left.
428
499
  */
429
- export type RouteDeviationTracking = "None" | { StaticThreshold: { minimumHorizontalAccuracy: number; maxAcceptableDeviation: number } };
500
+ export type ValhallaWaypointPreferredSide = "same" | "opposite" | "either";
501
+
502
+ /**
503
+ * Waypoint properties supported by Valhalla servers.
504
+ *
505
+ * Our docstrings are short here, since Valhalla is the final authority.
506
+ * Refer to <https://valhalla.github.io/valhalla/api/turn-by-turn/api-reference/#locations>
507
+ * for more details, including default values.
508
+ * Other Valhalla-based APIs such as Stadia Maps or Mapbox may have slightly different defaults.
509
+ * Refer to your vendor\'s documentation when in doubt.
510
+ *
511
+ * NOTE: Waypoint properties will NOT currently be echoed back in OSRM format,
512
+ * so these are sent to the server one time.
513
+ */
514
+ export interface ValhallaWaypointProperties {
515
+ /**
516
+ * Preferred direction of travel for the start from the location.
517
+ */
518
+ heading: number | undefined;
519
+ /**
520
+ * How close in degrees a given street\'s angle must be
521
+ * in order for it to be considered as in the same direction of the heading parameter.
522
+ */
523
+ heading_tolerance: number | undefined;
524
+ /**
525
+ * Minimum number of nodes (intersections) reachable for a given edge
526
+ * (road between intersections) to consider that edge as belonging to a connected region.
527
+ * Disconnected edges are ignored.
528
+ */
529
+ minimum_reachability: number | undefined;
530
+ /**
531
+ * The number of meters about this input location within which edges
532
+ * will be considered as candidates for said location.
533
+ * If there are no candidates within this distance,
534
+ * it will return the closest candidate within reason.
535
+ */
536
+ radius: number | undefined;
537
+ /**
538
+ * Determines whether the location should be visited from the same, opposite or either side of the road,
539
+ * with respect to the side of the road the given locale drives on.
540
+ *
541
+ * NOTE: If the location is not offset from the road centerline
542
+ * or is very close to an intersection, this option has no effect!
543
+ */
544
+ preferred_side: ValhallaWaypointPreferredSide | undefined;
545
+ /**
546
+ * Latitude of the map location in degrees.
547
+ *
548
+ * If provided, the waypoint location will still be used for routing,
549
+ * but these coordinates will determine the side of the street.
550
+ */
551
+ display_coordinate: GeographicCoordinate | undefined;
552
+ /**
553
+ * The cutoff at which we will assume the input is too far away from civilization
554
+ * to be worth correlating to the nearest graph elements.
555
+ */
556
+ search_cutoff: number | undefined;
557
+ /**
558
+ * During edge correlation, this is the tolerance used to determine whether to snap
559
+ * to the intersection rather than along the street.
560
+ * If the snap location is within this distance from the intersection,
561
+ * the intersection is used instead.
562
+ */
563
+ node_snap_tolerance: number | undefined;
564
+ /**
565
+ * A tolerance in meters from the edge centerline used for determining the side of the street
566
+ * that the location is on.
567
+ * If the distance to the centerline is less than this tolerance,
568
+ * no side will be inferred.
569
+ * Otherwise, the left or right side will be selected depending on the direction of travel.
570
+ */
571
+ street_side_tolerance: number | undefined;
572
+ /**
573
+ * The max distance in meters that the input coordinates or display lat/lon can be
574
+ * from the edge centerline for them to be used for determining the side of the street.
575
+ * Beyond this distance, no street side is inferred.
576
+ */
577
+ street_side_max_distance: number | undefined;
578
+ /**
579
+ * Disables the `preferred_side` when set to `same` or `opposite`
580
+ * if the edge has a road class less than that provided by `street_side_cutoff`.
581
+ */
582
+ street_side_cutoff: ValhallaRoadClass | undefined;
583
+ /**
584
+ * A set of optional filters to exclude candidate edges based on their attributes.
585
+ */
586
+ search_filter: ValhallaLocationSearchFilter | undefined;
587
+ }
430
588
 
431
- export type SerializableStepAdvanceCondition = "Manual" | { DistanceToEndOfStep: { distance: number; minimumHorizontalAccuracy: number } } | { DistanceFromStep: { distance: number; minimumHorizontalAccuracy: number } } | { DistanceEntryExit: { distanceToEndOfStep: number; distanceAfterEndStep: number; minimumHorizontalAccuracy: number; hasReachedEndOfCurrentStep: boolean } } | { OrAdvanceConditions: { conditions: SerializableStepAdvanceCondition[] } } | { AndAdvanceConditions: { conditions: SerializableStepAdvanceCondition[] } };
589
+ /**
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.
597
+ */
598
+ export interface OsrmWaypointProperties {
599
+ /**
600
+ * The name of the street that the waypoint snapped to.
601
+ */
602
+ name: string | undefined;
603
+ /**
604
+ * The distance (in meters) between the snapped point and the input coordinate.
605
+ */
606
+ distance: number | undefined;
607
+ }
432
608
 
433
609
  /**
434
610
  * The event type.
@@ -453,6 +629,8 @@ export interface NavigationRecordingEvent {
453
629
  event_data: NavigationRecordingEventData;
454
630
  }
455
631
 
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
+
456
634
  export interface SerializableNavigationControllerConfig {
457
635
  /**
458
636
  * Configures when navigation advances to the next waypoint in the route.
@@ -502,7 +680,7 @@ export interface SerializableNavigationControllerConfig {
502
680
  * manually advancing to the next step does not *necessarily* imply
503
681
  * that the waypoint will be marked as complete!
504
682
  */
505
- export type WaypointAdvanceMode = { WaypointWithinRange: number };
683
+ export type WaypointAdvanceMode = { WaypointWithinRange: number } | { WaypointAlongAdvancingStep: number };
506
684
 
507
685
  /**
508
686
  * Controls filtering/post-processing of user course by the [`NavigationController`].
@@ -564,9 +742,21 @@ export interface TripProgress {
564
742
  export interface SerializableNavState {
565
743
  tripState: TripState;
566
744
  stepAdvanceCondition: SerializableStepAdvanceCondition;
567
- recordingEvents: NavigationRecordingEvent[] | undefined;
568
745
  }
569
746
 
747
+ /**
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.
757
+ */
758
+ export type RouteDeviationTracking = "None" | { StaticThreshold: { minimumHorizontalAccuracy: number; maxAcceptableDeviation: number } };
759
+
570
760
  export type SimulationError = { PolylineError: { error: string } } | "NotEnoughPoints";
571
761
 
572
762
  /**
@@ -595,7 +785,6 @@ export class NavigationController {
595
785
  getInitialState(location: any): any;
596
786
  advanceToNextStep(state: any): any;
597
787
  updateUserLocation(location: any, state: any): any;
598
- getRecording(events: any): any;
599
788
  }
600
789
  /**
601
790
  * A WebAssembly-compatible wrapper for `NavigationReplay` that exposes its functionality as a JavaScript object.
@@ -612,6 +801,30 @@ export class NavigationReplay {
612
801
  getInitialTimestamp(): any;
613
802
  getInitialRoute(): any;
614
803
  }
804
+ /**
805
+ * JavaScript wrapper for `NavigationSession` (simple version).
806
+ * This wrapper provides basic navigation functionality without observers.
807
+ */
808
+ export class NavigationSession {
809
+ free(): void;
810
+ constructor(route: any, config: any);
811
+ getInitialState(location: any): any;
812
+ advanceToNextStep(state: any): any;
813
+ updateUserLocation(location: any, state: any): any;
814
+ }
815
+ /**
816
+ * JavaScript wrapper for `NavigationSession` with recording capabilities.
817
+ * This version includes a NavigationRecorder observer and provides direct access to recording functionality.
818
+ */
819
+ export class NavigationSessionRecording {
820
+ free(): void;
821
+ constructor(route: any, config: any);
822
+ getInitialState(location: any): any;
823
+ advanceToNextStep(state: any): any;
824
+ updateUserLocation(location: any, state: any): any;
825
+ getRecording(): any;
826
+ getEvents(): any;
827
+ }
615
828
  /**
616
829
  * JavaScript wrapper for `RouteAdapter`.
617
830
  */
package/ferrostar_bg.js CHANGED
@@ -319,17 +319,6 @@ export class NavigationController {
319
319
  }
320
320
  return takeFromExternrefTable0(ret[0]);
321
321
  }
322
- /**
323
- * @param {any} events
324
- * @returns {any}
325
- */
326
- getRecording(events) {
327
- const ret = wasm.navigationcontroller_getRecording(this.__wbg_ptr, events);
328
- if (ret[2]) {
329
- throw takeFromExternrefTable0(ret[1]);
330
- }
331
- return takeFromExternrefTable0(ret[0]);
332
- }
333
322
  }
334
323
 
335
324
  const NavigationReplayFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -419,6 +408,164 @@ export class NavigationReplay {
419
408
  }
420
409
  }
421
410
 
411
+ const NavigationSessionFinalization = (typeof FinalizationRegistry === 'undefined')
412
+ ? { register: () => {}, unregister: () => {} }
413
+ : new FinalizationRegistry(ptr => wasm.__wbg_navigationsession_free(ptr >>> 0, 1));
414
+ /**
415
+ * JavaScript wrapper for `NavigationSession` (simple version).
416
+ * This wrapper provides basic navigation functionality without observers.
417
+ */
418
+ export class NavigationSession {
419
+
420
+ __destroy_into_raw() {
421
+ const ptr = this.__wbg_ptr;
422
+ this.__wbg_ptr = 0;
423
+ NavigationSessionFinalization.unregister(this);
424
+ return ptr;
425
+ }
426
+
427
+ free() {
428
+ const ptr = this.__destroy_into_raw();
429
+ wasm.__wbg_navigationsession_free(ptr, 0);
430
+ }
431
+ /**
432
+ * @param {any} route
433
+ * @param {any} config
434
+ */
435
+ constructor(route, config) {
436
+ const ret = wasm.navigationsession_new(route, config);
437
+ if (ret[2]) {
438
+ throw takeFromExternrefTable0(ret[1]);
439
+ }
440
+ this.__wbg_ptr = ret[0] >>> 0;
441
+ NavigationSessionFinalization.register(this, this.__wbg_ptr, this);
442
+ return this;
443
+ }
444
+ /**
445
+ * @param {any} location
446
+ * @returns {any}
447
+ */
448
+ getInitialState(location) {
449
+ const ret = wasm.navigationsession_getInitialState(this.__wbg_ptr, location);
450
+ if (ret[2]) {
451
+ throw takeFromExternrefTable0(ret[1]);
452
+ }
453
+ return takeFromExternrefTable0(ret[0]);
454
+ }
455
+ /**
456
+ * @param {any} state
457
+ * @returns {any}
458
+ */
459
+ advanceToNextStep(state) {
460
+ const ret = wasm.navigationsession_advanceToNextStep(this.__wbg_ptr, state);
461
+ if (ret[2]) {
462
+ throw takeFromExternrefTable0(ret[1]);
463
+ }
464
+ return takeFromExternrefTable0(ret[0]);
465
+ }
466
+ /**
467
+ * @param {any} location
468
+ * @param {any} state
469
+ * @returns {any}
470
+ */
471
+ updateUserLocation(location, state) {
472
+ const ret = wasm.navigationsession_updateUserLocation(this.__wbg_ptr, location, state);
473
+ if (ret[2]) {
474
+ throw takeFromExternrefTable0(ret[1]);
475
+ }
476
+ return takeFromExternrefTable0(ret[0]);
477
+ }
478
+ }
479
+
480
+ const NavigationSessionRecordingFinalization = (typeof FinalizationRegistry === 'undefined')
481
+ ? { register: () => {}, unregister: () => {} }
482
+ : new FinalizationRegistry(ptr => wasm.__wbg_navigationsessionrecording_free(ptr >>> 0, 1));
483
+ /**
484
+ * JavaScript wrapper for `NavigationSession` with recording capabilities.
485
+ * This version includes a NavigationRecorder observer and provides direct access to recording functionality.
486
+ */
487
+ export class NavigationSessionRecording {
488
+
489
+ __destroy_into_raw() {
490
+ const ptr = this.__wbg_ptr;
491
+ this.__wbg_ptr = 0;
492
+ NavigationSessionRecordingFinalization.unregister(this);
493
+ return ptr;
494
+ }
495
+
496
+ free() {
497
+ const ptr = this.__destroy_into_raw();
498
+ wasm.__wbg_navigationsessionrecording_free(ptr, 0);
499
+ }
500
+ /**
501
+ * @param {any} route
502
+ * @param {any} config
503
+ */
504
+ constructor(route, config) {
505
+ const ret = wasm.navigationsessionrecording_new(route, config);
506
+ if (ret[2]) {
507
+ throw takeFromExternrefTable0(ret[1]);
508
+ }
509
+ this.__wbg_ptr = ret[0] >>> 0;
510
+ NavigationSessionRecordingFinalization.register(this, this.__wbg_ptr, this);
511
+ return this;
512
+ }
513
+ /**
514
+ * @param {any} location
515
+ * @returns {any}
516
+ */
517
+ getInitialState(location) {
518
+ const ret = wasm.navigationsessionrecording_getInitialState(this.__wbg_ptr, location);
519
+ if (ret[2]) {
520
+ throw takeFromExternrefTable0(ret[1]);
521
+ }
522
+ return takeFromExternrefTable0(ret[0]);
523
+ }
524
+ /**
525
+ * @param {any} state
526
+ * @returns {any}
527
+ */
528
+ advanceToNextStep(state) {
529
+ const ret = wasm.navigationsessionrecording_advanceToNextStep(this.__wbg_ptr, state);
530
+ if (ret[2]) {
531
+ throw takeFromExternrefTable0(ret[1]);
532
+ }
533
+ return takeFromExternrefTable0(ret[0]);
534
+ }
535
+ /**
536
+ * @param {any} location
537
+ * @param {any} state
538
+ * @returns {any}
539
+ */
540
+ updateUserLocation(location, state) {
541
+ const ret = wasm.navigationsessionrecording_updateUserLocation(this.__wbg_ptr, location, state);
542
+ if (ret[2]) {
543
+ throw takeFromExternrefTable0(ret[1]);
544
+ }
545
+ return takeFromExternrefTable0(ret[0]);
546
+ }
547
+ /**
548
+ * @returns {any}
549
+ */
550
+ getRecording() {
551
+ const ret = wasm.navigationsessionrecording_getRecording(this.__wbg_ptr);
552
+ if (ret[2]) {
553
+ throw takeFromExternrefTable0(ret[1]);
554
+ }
555
+ return takeFromExternrefTable0(ret[0]);
556
+ }
557
+ /**
558
+ * @returns {any}
559
+ */
560
+ getEvents() {
561
+ const ret = wasm.navigationsessionrecording_getEvents(this.__wbg_ptr);
562
+ if (ret[2]) {
563
+ throw takeFromExternrefTable0(ret[1]);
564
+ }
565
+ return takeFromExternrefTable0(ret[0]);
566
+ }
567
+ }
568
+
422
569
  const RouteAdapterFinalization = (typeof FinalizationRegistry === 'undefined')
423
570
  ? { register: () => {}, unregister: () => {} }
424
571
  : new FinalizationRegistry(ptr => wasm.__wbg_routeadapter_free(ptr >>> 0, 1));
@@ -515,7 +662,7 @@ export function __wbg_entries_3265d4158b33e5dc(arg0) {
515
662
  return ret;
516
663
  };
517
664
 
518
- export function __wbg_getRandomValues_38097e921c2494c3() { return handleError(function (arg0, arg1) {
665
+ export function __wbg_getRandomValues_38a1ff1ea09f6cc7() { return handleError(function (arg0, arg1) {
519
666
  globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
520
667
  }, arguments) };
521
668
 
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.42.0",
10
+ "version": "0.44.0",
11
11
  "license": "BSD-3-Clause",
12
12
  "repository": {
13
13
  "type": "git",