Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: separate waypoint logic #457

Merged
merged 7 commits into from
Feb 18, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import uniffi.ferrostar.UserLocation
import uniffi.ferrostar.VisualInstruction
import uniffi.ferrostar.VisualInstructionContent
import uniffi.ferrostar.Waypoint
import uniffi.ferrostar.WaypointAdvanceMode
import uniffi.ferrostar.WaypointKind

private val valhallaEndpointUrl = "https://api.stadiamaps.com/navigate/v1"
Expand Down Expand Up @@ -148,7 +149,10 @@ class FerrostarCoreTest {
foregroundServiceManager = MockForegroundNotificationManager(),
navigationControllerConfig =
NavigationControllerConfig(
StepAdvanceMode.Manual, RouteDeviationTracking.None, CourseFiltering.RAW))
WaypointAdvanceMode.WaypointWithinRange(100.0),
StepAdvanceMode.Manual,
RouteDeviationTracking.None,
CourseFiltering.RAW))

try {
// Tests that the core generates a request and attempts to process it, but throws due to the
Expand Down Expand Up @@ -196,7 +200,10 @@ class FerrostarCoreTest {
foregroundServiceManager = MockForegroundNotificationManager(),
navigationControllerConfig =
NavigationControllerConfig(
StepAdvanceMode.Manual, RouteDeviationTracking.None, CourseFiltering.RAW))
WaypointAdvanceMode.WaypointWithinRange(100.0),
StepAdvanceMode.Manual,
RouteDeviationTracking.None,
CourseFiltering.RAW))
val routes =
core.getRoutes(
initialLocation =
Expand Down Expand Up @@ -239,7 +246,10 @@ class FerrostarCoreTest {
foregroundServiceManager = MockForegroundNotificationManager(),
navigationControllerConfig =
NavigationControllerConfig(
StepAdvanceMode.Manual, RouteDeviationTracking.None, CourseFiltering.RAW))
WaypointAdvanceMode.WaypointWithinRange(100.0),
StepAdvanceMode.Manual,
RouteDeviationTracking.None,
CourseFiltering.RAW))
val routes =
core.getRoutes(
initialLocation =
Expand Down Expand Up @@ -290,7 +300,10 @@ class FerrostarCoreTest {
foregroundServiceManager = MockForegroundNotificationManager(),
navigationControllerConfig =
NavigationControllerConfig(
StepAdvanceMode.Manual, RouteDeviationTracking.None, CourseFiltering.RAW))
WaypointAdvanceMode.WaypointWithinRange(100.0),
StepAdvanceMode.Manual,
RouteDeviationTracking.None,
CourseFiltering.RAW))
val routes =
core.getRoutes(
initialLocation =
Expand Down Expand Up @@ -361,7 +374,10 @@ class FerrostarCoreTest {
foregroundServiceManager = foregroundServiceManager,
navigationControllerConfig =
NavigationControllerConfig(
StepAdvanceMode.Manual, RouteDeviationTracking.None, CourseFiltering.RAW))
WaypointAdvanceMode.WaypointWithinRange(100.0),
StepAdvanceMode.Manual,
RouteDeviationTracking.None,
CourseFiltering.RAW))

val deviationHandler = DeviationHandler()
core.deviationHandler = deviationHandler
Expand Down Expand Up @@ -398,6 +414,7 @@ class FerrostarCoreTest {
core.startNavigation(
routes.first(),
NavigationControllerConfig(
WaypointAdvanceMode.WaypointWithinRange(100.0),
stepAdvance =
StepAdvanceMode.RelativeLineStringDistance(
16U,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import uniffi.ferrostar.RouteDeviationTracking
import uniffi.ferrostar.StepAdvanceMode
import uniffi.ferrostar.UserLocation
import uniffi.ferrostar.Waypoint
import uniffi.ferrostar.WaypointAdvanceMode
import uniffi.ferrostar.WaypointKind

const val simpleRoute =
Expand Down Expand Up @@ -254,7 +255,10 @@ class ValhallaCoreTest {
foregroundServiceManager = MockForegroundNotificationManager(),
navigationControllerConfig =
NavigationControllerConfig(
StepAdvanceMode.Manual, RouteDeviationTracking.None, CourseFiltering.RAW))
WaypointAdvanceMode.WaypointWithinRange(100.0),
StepAdvanceMode.Manual,
RouteDeviationTracking.None,
CourseFiltering.RAW))

return runTest {
val routes =
Expand Down Expand Up @@ -302,7 +306,10 @@ class ValhallaCoreTest {
foregroundServiceManager = MockForegroundNotificationManager(),
navigationControllerConfig =
NavigationControllerConfig(
StepAdvanceMode.Manual, RouteDeviationTracking.None, CourseFiltering.RAW),
WaypointAdvanceMode.WaypointWithinRange(100.0),
StepAdvanceMode.Manual,
RouteDeviationTracking.None,
CourseFiltering.RAW),
options = mapOf("costing_options" to mapOf("auto" to mapOf("useTolls" to 0))))

return runTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import uniffi.ferrostar.NavigationControllerConfig
import uniffi.ferrostar.RouteDeviationTracking
import uniffi.ferrostar.SpecialAdvanceConditions
import uniffi.ferrostar.StepAdvanceMode
import uniffi.ferrostar.WaypointAdvanceMode

/**
* A basic sample of a dependency injection module for the demo app. This is only used to
Expand Down Expand Up @@ -86,6 +87,7 @@ object AppModule {
foregroundServiceManager = foregroundServiceManager,
navigationControllerConfig =
NavigationControllerConfig(
WaypointAdvanceMode.WaypointWithinRange(100.0),
StepAdvanceMode.RelativeLineStringDistance(
minimumHorizontalAccuracy = 25U,
specialAdvanceConditions =
Expand Down
4 changes: 2 additions & 2 deletions android/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ kotlinx-coroutines = "1.10.1"
kotlinx-datetime = "0.6.1"
androidx-appcompat = "1.7.0"
androidx-activity-compose = "1.10.0"
compose = "2024.12.01"
compose = "2025.02.00"
okhttp = "4.12.0"
moshi = "1.15.1"
maplibre-compose = "0.4.0"
playServicesLocation = "21.3.0"
junit = "4.13.2"
junitVersion = "1.2.1"
junitCompose = "1.7.6"
junitCompose = "1.7.8"
espressoCore = "3.6.1"
okhttp-mock = "2.0.0"
mockk = "1.13.16"
Expand Down
1 change: 1 addition & 0 deletions apple/DemoApp/Demo/AppEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class AppEnvironment: ObservableObject {
// Configure the navigation session.
// You have a lot of flexibility here based on your use case.
let config = SwiftNavigationControllerConfig(
waypointAdvance: .waypointWithinRange(100.0),
stepAdvance: .relativeLineStringDistance(
minimumHorizontalAccuracy: 32,
specialAdvanceConditions: .minimumDistanceFromCurrentStepLine(10)
Expand Down
1 change: 1 addition & 0 deletions apple/DemoApp/Demo/NavigationDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class NavigationDelegate: FerrostarCoreDelegate {
// Most implementations will probably reuse existing configs (the default implementation does),
// but we provide devs with flexibility here.
let config = SwiftNavigationControllerConfig(
waypointAdvance: .waypointWithinRange(100.0),
stepAdvance: .relativeLineStringDistance(minimumHorizontalAccuracy: 32,
specialAdvanceConditions: .minimumDistanceFromCurrentStepLine(
10
Expand Down
4 changes: 3 additions & 1 deletion apple/Sources/FerrostarCore/Models/ModelWrappers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ public enum SwiftRouteDeviationTracking {

/// A Swift wrapper around `UniFFI.NavigationControllerConfig`.
public struct SwiftNavigationControllerConfig {
public init(stepAdvance: StepAdvanceMode,
public init(waypointAdvance: WaypointAdvanceMode,
stepAdvance: StepAdvanceMode,
routeDeviationTracking: SwiftRouteDeviationTracking,
snappedLocationCourseFiltering: CourseFiltering)
{
ffiValue = FerrostarCoreFFI.NavigationControllerConfig(
waypointAdvance: waypointAdvance,
stepAdvance: stepAdvance,
routeDeviationTracking: routeDeviationTracking.ffiValue,
snappedLocationCourseFiltering: snappedLocationCourseFiltering
Expand Down
92 changes: 92 additions & 0 deletions apple/Sources/UniFFI/ferrostar.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions apple/Tests/FerrostarCoreTests/FerrostarCoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ final class FerrostarCoreTests: XCTestCase {
routeAdapter: routeAdapter,
locationProvider: SimulatedLocationProvider(),
navigationControllerConfig: .init(
waypointAdvance: .waypointWithinRange(100.0),
stepAdvance: .manual,
routeDeviationTracking: .none,
snappedLocationCourseFiltering: .raw
Expand Down Expand Up @@ -166,6 +167,7 @@ final class FerrostarCoreTests: XCTestCase {
routeAdapter: mockPOSTRouteAdapter,
locationProvider: SimulatedLocationProvider(),
navigationControllerConfig: .init(
waypointAdvance: .waypointWithinRange(100.0),
stepAdvance: .manual,
routeDeviationTracking: .none,
snappedLocationCourseFiltering: .raw
Expand Down Expand Up @@ -201,6 +203,7 @@ final class FerrostarCoreTests: XCTestCase {
routeAdapter: mockGETRouteAdapter,
locationProvider: SimulatedLocationProvider(),
navigationControllerConfig: .init(
waypointAdvance: .waypointWithinRange(100.0),
stepAdvance: .manual,
routeDeviationTracking: .none,
snappedLocationCourseFiltering: .raw
Expand Down Expand Up @@ -239,6 +242,7 @@ final class FerrostarCoreTests: XCTestCase {
profile: "low_speed_vehicle",
locationProvider: SimulatedLocationProvider(),
navigationControllerConfig: .init(
waypointAdvance: .waypointWithinRange(100.0),
stepAdvance: .manual,
routeDeviationTracking: .none,
snappedLocationCourseFiltering: .raw
Expand Down Expand Up @@ -285,6 +289,7 @@ final class FerrostarCoreTests: XCTestCase {
customRouteProvider: mockCustomRouteProvider,
locationProvider: SimulatedLocationProvider(),
navigationControllerConfig: .init(
waypointAdvance: .waypointWithinRange(100.0),
stepAdvance: .manual,
routeDeviationTracking: .none,
snappedLocationCourseFiltering: .raw
Expand Down Expand Up @@ -331,6 +336,7 @@ final class FerrostarCoreTests: XCTestCase {
routeAdapter: mockPOSTRouteAdapter,
locationProvider: locationProvider,
navigationControllerConfig: .init(
waypointAdvance: .waypointWithinRange(100.0),
stepAdvance: .manual,
routeDeviationTracking: .none,
snappedLocationCourseFiltering: .raw
Expand Down Expand Up @@ -385,6 +391,7 @@ final class FerrostarCoreTests: XCTestCase {

locationProvider.lastLocation = CLLocation(latitude: 0, longitude: 0).userLocation
let config = SwiftNavigationControllerConfig(
waypointAdvance: .waypointWithinRange(100.0),
stepAdvance: .relativeLineStringDistance(
minimumHorizontalAccuracy: 16,
specialAdvanceConditions: .advanceAtDistanceFromEnd(16)
Expand Down
1 change: 1 addition & 0 deletions apple/Tests/FerrostarCoreTests/ValhallaCoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ final class ValhallaCoreTests: XCTestCase {
profile: "auto",
locationProvider: SimulatedLocationProvider(),
navigationControllerConfig: .init(
waypointAdvance: .waypointWithinRange(100.0),
stepAdvance: .manual,
routeDeviationTracking: .none,
snappedLocationCourseFiltering: .raw
Expand Down
2 changes: 1 addition & 1 deletion common/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion common/ferrostar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ lints.workspace = true

[package]
name = "ferrostar"
version = "0.27.0"
version = "0.28.0"
readme = "README.md"
description = "The core of modern turn-by-turn navigation."
keywords = ["navigation", "routing", "valhalla", "osrm"]
Expand Down
Loading
Loading