Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
cancel-in-progress: true

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
submodules: true

Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
packages: read

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
submodules: true

Expand Down Expand Up @@ -99,7 +99,7 @@ jobs:
packages: read

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
submodules: true

Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:
packages: read

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
submodules: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cargo-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
publish_crate:
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Cargo Publish
run: cargo publish -p ferrostar
working-directory: common
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- name: Check out repo
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Set up JDK 21
uses: actions/setup-java@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0 # Ensure that we can operate on the full history
ref: main
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Check format
id: check-format
Expand All @@ -37,7 +37,7 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Ensure that Package.swift is NOT configured for local development at this stage (easy to forget)
run: |
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Configure Package.swift for local development
run: sed -i '' 's/let useLocalFramework = false/let useLocalFramework = true/' Package.swift
Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Configure Package.swift for local development
run: sed -i '' 's/let useLocalFramework = false/let useLocalFramework = true/' Package.swift
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Install wasm-pack
run: cargo install wasm-pack
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
pages: write # To push to a GitHub Pages site
id-token: write # To update the deployment status
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install latest mdbook
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
group: ${{ github.workflow }}-${{ github.ref }}-rust-msrv
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: taiki-e/install-action@v2
with:
tool: cargo-hack
Expand All @@ -31,7 +31,7 @@ jobs:
cancel-in-progress: true
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2
with:
Expand All @@ -45,7 +45,7 @@ jobs:
cancel-in-progress: true
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: rustfmt checks
run: cargo fmt --check
working-directory: common
Expand All @@ -56,7 +56,7 @@ jobs:
group: ${{ github.workflow }}-${{ github.ref }}-rust-build
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: taiki-e/install-action@nextest

- name: Cargo Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/typos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Run typos
uses: crate-ci/typos@master
2 changes: 1 addition & 1 deletion .github/workflows/wasm-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
group: ${{ github.workflow }}-${{ github.ref }}-wasm-build
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Install wasm-pack
run: cargo install wasm-pack
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if useLocalFramework {
path: "./common/target/ios/libferrostar-rs.xcframework"
)
} else {
let releaseTag = "0.49.0"
let releaseTag = "0.50.0"
let releaseChecksum = "7b201e32a4e55ea127ccb9c72d8fdbf09540755471b7794de90ca369b10ed314"
binaryTarget = .binaryTarget(
name: "FerrostarCoreRS",
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ ext {

allprojects {
group = "com.stadiamaps.ferrostar"
version = "0.49.0"
version = "0.50.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import uniffi.ferrostar.VisualInstructionContent
import uniffi.ferrostar.Waypoint
import uniffi.ferrostar.WaypointAdvanceMode
import uniffi.ferrostar.WaypointKind
import uniffi.ferrostar.DeviationCalculationPolicy
import uniffi.ferrostar.DeviationKind
import uniffi.ferrostar.stepAdvanceDistanceFromStep
import uniffi.ferrostar.stepAdvanceDistanceToEndOfStep
import uniffi.ferrostar.stepAdvanceManual
Expand Down Expand Up @@ -130,14 +132,16 @@ class FerrostarCoreTest {
secondaryContent = null,
subContent = null,
triggerDistanceBeforeManeuver = 42.0,
)),
),
),
spokenInstructions = listOf(),
duration = 0.0,
annotations = null,
incidents = listOf(),
drivingSide = DrivingSide.RIGHT,
roundaboutExitNumber = null,
)),
),
),
)

@Test
Expand Down Expand Up @@ -191,7 +195,8 @@ class FerrostarCoreTest {
Waypoint(
coordinate = GeographicCoordinate(60.5349908, -149.5485806),
kind = WaypointKind.BREAK,
)),
),
),
)
fail("Expected the request to fail")
} catch (e: InvalidStatusCodeException) {
Expand Down Expand Up @@ -247,7 +252,8 @@ class FerrostarCoreTest {
Waypoint(
coordinate = GeographicCoordinate(lat = 60.5349908, lng = -149.5485806),
kind = WaypointKind.BREAK,
)),
),
),
)

assertEquals(listOf(mockRoute), routes)
Expand Down Expand Up @@ -301,7 +307,8 @@ class FerrostarCoreTest {
Waypoint(
coordinate = GeographicCoordinate(lat = 60.5349908, lng = -149.5485806),
kind = WaypointKind.BREAK,
)),
),
),
)

assertEquals(listOf(mockRoute), routes)
Expand Down Expand Up @@ -362,7 +369,8 @@ class FerrostarCoreTest {
Waypoint(
coordinate = GeographicCoordinate(lat = 60.5349908, lng = -149.5485806),
kind = WaypointKind.BREAK,
)),
),
),
)

assertEquals(listOf(mockRoute), routes)
Expand All @@ -385,11 +393,11 @@ class FerrostarCoreTest {

override fun correctiveActionForDeviation(
core: FerrostarCore,
deviationInMeters: Double,
remainingWaypoints: List<Waypoint>,
deviation: DeviationKind,
remainingWaypoints: List<Waypoint>
): CorrectiveAction {
called = true
assertEquals(42.0, deviationInMeters, Double.MIN_VALUE)
assertEquals(DeviationKind.CompletelyOffRoute(42.0), deviation)
return CorrectiveAction.GetNewRoutes(remainingWaypoints)
}
}
Expand Down Expand Up @@ -451,14 +459,19 @@ class FerrostarCoreTest {
Waypoint(
coordinate = GeographicCoordinate(lat = 60.5349908, lng = -149.5485806),
kind = WaypointKind.BREAK,
)),
),
),
)

core.startNavigation(
routes.first(),
NavigationControllerConfig(
WaypointAdvanceMode.WaypointWithinRange(100.0),
stepAdvanceDistanceFromStep(16u, 32u, true),
stepAdvanceDistanceFromStep(
distance = 16u,
minimumHorizontalAccuracy = 32u,
calculationPolicy = DeviationCalculationPolicy.ALWAYS,
),
stepAdvanceDistanceToEndOfStep(16u, 32u),
routeDeviationTracking =
RouteDeviationTracking.Custom(
Expand All @@ -468,9 +481,10 @@ class FerrostarCoreTest {
route: Route,
tripState: TripState,
): RouteDeviation {
return RouteDeviation.OffRoute(42.0)
return RouteDeviation.Deviation(DeviationKind.CompletelyOffRoute(42.0))
}
}),
},
),
CourseFiltering.RAW,
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,15 @@ class FerrostarCore(
private fun handleStateUpdate(newState: NavState, location: UserLocation) {
val tripState = newState.tripState
if (tripState is TripState.Navigating) {
if (tripState.deviation is RouteDeviation.OffRoute) {
val deviation = tripState.deviation
if (deviation is RouteDeviation.Deviation) {
if (!_routeRequestInFlight && // We can't have a request in flight already
hasWaitedMinimumRecalculationDelay(
_lastAutomaticRecalculation, minimumTimeBeforeRecalculation) &&
hasUserMovedSignificantlySinceLastRecalc(location)) {
val action =
deviationHandler?.correctiveActionForDeviation(
this, tripState.deviation.deviationFromRouteLine, tripState.remainingWaypoints)
this, deviation.kind, tripState.remainingWaypoints)
?: CorrectiveAction.GetNewRoutes(tripState.remainingWaypoints)
when (action) {
is CorrectiveAction.DoNothing -> {
Expand All @@ -391,7 +392,7 @@ class FerrostarCore(
val state = _state.value
// Make sure we are still navigating and the new route is still relevant
if (state.tripState is TripState.Navigating &&
state.tripState.deviation is RouteDeviation.OffRoute) {
state.tripState.deviation is RouteDeviation.Deviation) {
if (processor != null) {
processor.loadedAlternativeRoutes(this@FerrostarCore, routes)
} else if (routes.isNotEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.stadiamaps.ferrostar.core

import uniffi.ferrostar.DeviationKind
import uniffi.ferrostar.Waypoint

/** Corrective action to take when the user deviates from the route. */
Expand All @@ -26,7 +27,7 @@ sealed class CorrectiveAction {
fun interface RouteDeviationHandler {
fun correctiveActionForDeviation(
core: FerrostarCore,
deviationInMeters: Double,
deviation: DeviationKind,
remainingWaypoints: List<Waypoint>,
): CorrectiveAction
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fun TripState.preferredUserLocation() =
is TripState.Navigating -> {
when (this.deviation) {
is RouteDeviation.NoDeviation -> this.snappedUserLocation
is RouteDeviation.OffRoute -> this.userLocation
is RouteDeviation.Deviation -> this.userLocation
}
}
is TripState.Idle -> this.userLocation
Expand Down
2 changes: 1 addition & 1 deletion apple/DemoApp/Demo/NavigationDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class NavigationDelegate: FerrostarCoreDelegate {
// TODO: Create defaults extension on FerrostarCoreDelegate
}

func core(_: FerrostarCore, correctiveActionForDeviation _: Double,
func core(_: FerrostarCore, correctiveActionForDeviation _: DeviationKind,
remainingWaypoints waypoints: [Waypoint]) -> CorrectiveAction
{
// If the user is off course, we'll try to calculate a new route using the remaining waypoints.
Expand Down
6 changes: 3 additions & 3 deletions apple/Sources/FerrostarCore/FerrostarCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public protocol FerrostarCoreDelegate: AnyObject {
/// This hook enables app developers to take the most appropriate corrective action.
func core(
_ core: FerrostarCore,
correctiveActionForDeviation deviationInMeters: Double,
correctiveActionForDeviation deviation: DeviationKind,
remainingWaypoints waypoints: [Waypoint]
) -> CorrectiveAction

Expand Down Expand Up @@ -437,7 +437,7 @@ public protocol FerrostarCoreDelegate: AnyObject {
case .noDeviation:
// No action
break
case let .offRoute(deviationFromRouteLine: deviationFromRouteLine):
case let .deviation(kind: kind):
guard !self.routeRequestInFlight, // We can't have a request in flight already
// Ensure a minimum cool down before a new route fetch
self.lastAutomaticRecalculation?.timeIntervalSinceNow ?? -TimeInterval
Expand All @@ -454,7 +454,7 @@ public protocol FerrostarCoreDelegate: AnyObject {

switch self.delegate?.core(
self,
correctiveActionForDeviation: deviationFromRouteLine,
correctiveActionForDeviation: kind,
remainingWaypoints: remainingWaypoints
) ?? .getNewRoutes(waypoints: remainingWaypoints) {
case .doNothing:
Expand Down
Loading
Loading