@stadiamaps/ferrostar 0.43.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
  /**
@@ -415,37 +437,174 @@ export interface GeographicCoordinate {
415
437
  lng: number;
416
438
  }
417
439
 
418
- export type SimulationError = { PolylineError: { error: string } } | "NotEnoughPoints";
419
-
420
440
  /**
421
- * Controls how simulated locations deviate from the actual route line.
422
- * This simulates real-world GPS behavior where readings often have systematic bias.
441
+ * A set of optional filters to exclude candidate edges based on their attributes.
423
442
  */
424
- export type LocationBias = { Left: number } | { Right: number } | { Random: number } | "None";
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
+ }
425
483
 
426
484
  /**
427
- * The current state of the simulation.
485
+ * A road class in the Valhalla taxonomy.
486
+ *
487
+ * These are ordered from highest (fastest travel speed) to lowest.
428
488
  */
429
- export interface LocationSimulationState {
430
- current_location: UserLocation;
431
- remaining_locations: GeographicCoordinate[];
432
- bias: LocationBias;
433
- }
489
+ export type ValhallaRoadClass = "motorway" | "trunk" | "primary" | "secondary" | "tertiary" | "unclassified" | "residential" | "service_other";
434
490
 
435
- 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[] } };
491
+ /**
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.
499
+ */
500
+ export type ValhallaWaypointPreferredSide = "same" | "opposite" | "either";
436
501
 
437
502
  /**
438
- * Status information that describes whether the user is proceeding according to the route or not.
503
+ * Waypoint properties supported by Valhalla servers.
439
504
  *
440
- * Note that the name is intentionally a bit generic to allow for expansion of other states.
441
- * For example, we could conceivably add a \"wrong way\" status in the future.
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.
442
513
  */
443
- export type RouteDeviation = "NoDeviation" | { OffRoute: { deviationFromRouteLine: number } };
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
+ }
444
588
 
445
589
  /**
446
- * Determines if the user has deviated from the expected route.
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.
447
597
  */
448
- export type RouteDeviationTracking = "None" | { StaticThreshold: { minimumHorizontalAccuracy: number; maxAcceptableDeviation: number } };
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
+ }
449
608
 
450
609
  /**
451
610
  * The event type.
@@ -470,6 +629,8 @@ export interface NavigationRecordingEvent {
470
629
  event_data: NavigationRecordingEventData;
471
630
  }
472
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
+
473
634
  export interface SerializableNavigationControllerConfig {
474
635
  /**
475
636
  * Configures when navigation advances to the next waypoint in the route.
@@ -519,7 +680,7 @@ export interface SerializableNavigationControllerConfig {
519
680
  * manually advancing to the next step does not *necessarily* imply
520
681
  * that the waypoint will be marked as complete!
521
682
  */
522
- export type WaypointAdvanceMode = { WaypointWithinRange: number };
683
+ export type WaypointAdvanceMode = { WaypointWithinRange: number } | { WaypointAlongAdvancingStep: number };
523
684
 
524
685
  /**
525
686
  * Controls filtering/post-processing of user course by the [`NavigationController`].
@@ -583,6 +744,36 @@ export interface SerializableNavState {
583
744
  stepAdvanceCondition: SerializableStepAdvanceCondition;
584
745
  }
585
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
+
760
+ export type SimulationError = { PolylineError: { error: string } } | "NotEnoughPoints";
761
+
762
+ /**
763
+ * Controls how simulated locations deviate from the actual route line.
764
+ * This simulates real-world GPS behavior where readings often have systematic bias.
765
+ */
766
+ export type LocationBias = { Left: number } | { Right: number } | { Random: number } | "None";
767
+
768
+ /**
769
+ * The current state of the simulation.
770
+ */
771
+ export interface LocationSimulationState {
772
+ current_location: UserLocation;
773
+ remaining_locations: GeographicCoordinate[];
774
+ bias: LocationBias;
775
+ }
776
+
586
777
  /**
587
778
  * JavaScript wrapper for `NavigationController`.
588
779
  * This wrapper is required because `NavigationController` cannot be directly converted to a JavaScript object
package/ferrostar_bg.js CHANGED
@@ -662,7 +662,7 @@ export function __wbg_entries_3265d4158b33e5dc(arg0) {
662
662
  return ret;
663
663
  };
664
664
 
665
- export function __wbg_getRandomValues_38097e921c2494c3() { return handleError(function (arg0, arg1) {
665
+ export function __wbg_getRandomValues_38a1ff1ea09f6cc7() { return handleError(function (arg0, arg1) {
666
666
  globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
667
667
  }, arguments) };
668
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.43.0",
10
+ "version": "0.44.0",
11
11
  "license": "BSD-3-Clause",
12
12
  "repository": {
13
13
  "type": "git",