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: starting point for course snapping #219

Merged
merged 16 commits into from
Sep 17, 2024
Merged
Prev Previous commit
Next Next commit
Corrected apple and android test failures
  • Loading branch information
Archdoog committed Sep 15, 2024
commit cb25a4084beffffa4fe23bbb860c06bd9eeccea9
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let binaryTarget: Target
let maplibreSwiftUIDSLPackage: Package.Dependency
let useLocalFramework = false
let useLocalFramework = true
let useLocalMapLibreSwiftUIDSL = false

if useLocalFramework {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import uniffi.ferrostar.RouteRequest
import uniffi.ferrostar.RouteRequestGenerator
import uniffi.ferrostar.RouteResponseParser
import uniffi.ferrostar.RouteStep
import uniffi.ferrostar.SnapCourseTo
import uniffi.ferrostar.StepAdvanceMode
import uniffi.ferrostar.UserLocation
import uniffi.ferrostar.VisualInstruction
Expand Down Expand Up @@ -132,7 +133,8 @@ class FerrostarCoreTest {
locationProvider = SimulatedLocationProvider(),
foregroundServiceManager = MockForegroundNotificationManager(),
navigationControllerConfig =
NavigationControllerConfig(StepAdvanceMode.Manual, RouteDeviationTracking.None))
NavigationControllerConfig(
StepAdvanceMode.Manual, RouteDeviationTracking.None, SnapCourseTo.NO_SNAPPING))

try {
// Tests that the core generates a request and attempts to process it, but throws due to the
Expand Down Expand Up @@ -179,7 +181,8 @@ class FerrostarCoreTest {
locationProvider = SimulatedLocationProvider(),
foregroundServiceManager = MockForegroundNotificationManager(),
navigationControllerConfig =
NavigationControllerConfig(StepAdvanceMode.Manual, RouteDeviationTracking.None))
NavigationControllerConfig(
StepAdvanceMode.Manual, RouteDeviationTracking.None, SnapCourseTo.NO_SNAPPING))
val routes =
core.getRoutes(
initialLocation =
Expand Down Expand Up @@ -229,7 +232,8 @@ class FerrostarCoreTest {
locationProvider = SimulatedLocationProvider(),
foregroundServiceManager = MockForegroundNotificationManager(),
navigationControllerConfig =
NavigationControllerConfig(StepAdvanceMode.Manual, RouteDeviationTracking.None))
NavigationControllerConfig(
StepAdvanceMode.Manual, RouteDeviationTracking.None, SnapCourseTo.NO_SNAPPING))
val routes =
core.getRoutes(
initialLocation =
Expand Down Expand Up @@ -299,7 +303,8 @@ class FerrostarCoreTest {
locationProvider = locationProvider,
foregroundServiceManager = foregroundServiceManager,
navigationControllerConfig =
NavigationControllerConfig(StepAdvanceMode.Manual, RouteDeviationTracking.None))
NavigationControllerConfig(
StepAdvanceMode.Manual, RouteDeviationTracking.None, SnapCourseTo.NO_SNAPPING))

val deviationHandler = DeviationHandler()
core.deviationHandler = deviationHandler
Expand Down Expand Up @@ -348,7 +353,8 @@ class FerrostarCoreTest {
): RouteDeviation {
return RouteDeviation.OffRoute(42.0)
}
})))
}),
SnapCourseTo.NO_SNAPPING))

assert(foregroundServiceManager.startCalled)
assert(deviationHandler.called)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.junit.Test
import uniffi.ferrostar.GeographicCoordinate
import uniffi.ferrostar.NavigationControllerConfig
import uniffi.ferrostar.RouteDeviationTracking
import uniffi.ferrostar.SnapCourseTo
import uniffi.ferrostar.StepAdvanceMode
import uniffi.ferrostar.UserLocation
import uniffi.ferrostar.Waypoint
Expand Down Expand Up @@ -252,7 +253,8 @@ class ValhallaCoreTest {
locationProvider = SimulatedLocationProvider(),
foregroundServiceManager = MockForegroundNotificationManager(),
navigationControllerConfig =
NavigationControllerConfig(StepAdvanceMode.Manual, RouteDeviationTracking.None))
NavigationControllerConfig(
StepAdvanceMode.Manual, RouteDeviationTracking.None, SnapCourseTo.NO_SNAPPING))

return runTest {
val routes =
Expand Down Expand Up @@ -299,7 +301,8 @@ class ValhallaCoreTest {
locationProvider = SimulatedLocationProvider(),
foregroundServiceManager = MockForegroundNotificationManager(),
navigationControllerConfig =
NavigationControllerConfig(StepAdvanceMode.Manual, RouteDeviationTracking.None),
NavigationControllerConfig(
StepAdvanceMode.Manual, RouteDeviationTracking.None, SnapCourseTo.NO_SNAPPING),
costingOptions = mapOf("auto" to mapOf("useTolls" to 0)))

return runTest {
Expand Down
33 changes: 27 additions & 6 deletions apple/Tests/FerrostarCoreTests/FerrostarCoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ final class FerrostarCoreTests: XCTestCase {
let core = FerrostarCore(
routeAdapter: routeAdapter,
locationProvider: SimulatedLocationProvider(),
navigationControllerConfig: .init(stepAdvance: .manual, routeDeviationTracking: .none),
navigationControllerConfig: .init(
stepAdvance: .manual,
routeDeviationTracking: .none,
snapCourse: .noSnapping
),
networkSession: mockSession
)

Expand Down Expand Up @@ -134,7 +138,11 @@ final class FerrostarCoreTests: XCTestCase {
let core = FerrostarCore(
routeAdapter: mockRouteAdapter,
locationProvider: SimulatedLocationProvider(),
navigationControllerConfig: .init(stepAdvance: .manual, routeDeviationTracking: .none),
navigationControllerConfig: .init(
stepAdvance: .manual,
routeDeviationTracking: .none,
snapCourse: .noSnapping
),
networkSession: mockSession
)

Expand Down Expand Up @@ -167,7 +175,11 @@ final class FerrostarCoreTests: XCTestCase {
valhallaEndpointUrl: valhallaEndpointUrl,
profile: "low_speed_vehicle",
locationProvider: SimulatedLocationProvider(),
navigationControllerConfig: .init(stepAdvance: .manual, routeDeviationTracking: .none),
navigationControllerConfig: .init(
stepAdvance: .manual,
routeDeviationTracking: .none,
snapCourse: .noSnapping
),
costingOptions: ["low_speed_vehicle": ["vehicle_type": "golf_cart"]],
networkSession: mockSession
)
Expand Down Expand Up @@ -195,7 +207,11 @@ final class FerrostarCoreTests: XCTestCase {
let core = FerrostarCore(
customRouteProvider: mockCustomRouteProvider,
locationProvider: SimulatedLocationProvider(),
navigationControllerConfig: .init(stepAdvance: .manual, routeDeviationTracking: .none),
navigationControllerConfig: .init(
stepAdvance: .manual,
routeDeviationTracking: .none,
snapCourse: .noSnapping
),
networkSession: mockSession
)

Expand Down Expand Up @@ -232,7 +248,11 @@ final class FerrostarCoreTests: XCTestCase {
let core = FerrostarCore(
routeAdapter: mockRouteAdapter,
locationProvider: locationProvider,
navigationControllerConfig: .init(stepAdvance: .manual, routeDeviationTracking: .none),
navigationControllerConfig: .init(
stepAdvance: .manual,
routeDeviationTracking: .none,
snapCourse: .noSnapping
),
networkSession: mockSession
)

Expand Down Expand Up @@ -286,7 +306,8 @@ final class FerrostarCoreTests: XCTestCase {
routeDeviationTracking: .custom(detector: { _, _, _ in
// Pretend that the user is always off route
.offRoute(deviationFromRouteLine: 42)
})
}),
snapCourse: .noSnapping
)

try core.startNavigation(route: routes.first!, config: config)
Expand Down
6 changes: 5 additions & 1 deletion apple/Tests/FerrostarCoreTests/ValhallaCoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ final class ValhallaCoreTests: XCTestCase {
valhallaEndpointUrl: valhallaEndpointUrl,
profile: "auto",
locationProvider: SimulatedLocationProvider(),
navigationControllerConfig: .init(stepAdvance: .manual, routeDeviationTracking: .none),
navigationControllerConfig: .init(
stepAdvance: .manual,
routeDeviationTracking: .none,
snapCourse: .noSnapping
),
networkSession: mockSession
)
let routes = try await core.getRoutes(
Expand Down
Loading