Skip to content

Commit

Permalink
More realistic GPS simulation with consistent lateral offset (#323)
Browse files Browse the repository at this point in the history
* More realistic GPS simulation with consistent lateral offset

* remove commented code

* Apply suggestions from code review

* JS and Android API fixes

* Update typos.yml

* Use rand

* Android runner tweaks; try switching to larger runners

---------

Co-authored-by: Ian Wagner <[email protected]>
Co-authored-by: Ian Wagner <[email protected]>
  • Loading branch information
3 people authored Oct 31, 2024
1 parent 4b883ae commit 649a68c
Show file tree
Hide file tree
Showing 14 changed files with 1,482 additions and 737 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
build:
runs-on: macos-14
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-android-build
cancel-in-progress: true
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:

test:

runs-on: macos-14
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-android-test
cancel-in-progress: true
Expand Down Expand Up @@ -99,7 +99,7 @@ jobs:

verify-snapshots:

runs-on: macos-14
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-android-snapshots
cancel-in-progress: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/typos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
uses: actions/checkout@v4

- name: Run typos
uses: crate-ci/typos@v1.26.0
uses: crate-ci/typos@master
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import kotlinx.coroutines.launch
import uniffi.ferrostar.CourseOverGround
import uniffi.ferrostar.GeographicCoordinate
import uniffi.ferrostar.Heading
import uniffi.ferrostar.LocationBias
import uniffi.ferrostar.LocationSimulationState
import uniffi.ferrostar.Route
import uniffi.ferrostar.Speed
Expand Down Expand Up @@ -168,8 +169,8 @@ class SimulatedLocationProvider : LocationProvider {
}
}

fun setSimulatedRoute(route: Route) {
simulationState = locationSimulationFromRoute(route, resampleDistance = 10.0)
fun setSimulatedRoute(route: Route, bias: LocationBias = LocationBias.None) {
simulationState = locationSimulationFromRoute(route, resampleDistance = 10.0, bias)
lastLocation = simulationState?.currentLocation

if (listeners.isNotEmpty() && simulationJob?.isActive != true) {
Expand Down
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
Expand Down
12 changes: 10 additions & 2 deletions apple/Sources/FerrostarCore/Location.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,16 @@ public class SimulatedLocationProvider: LocationProviding, ObservableObject {
lastLocation = location
}

public func setSimulatedRoute(_ route: Route, resampleDistance: Double = 10) throws {
simulationState = try locationSimulationFromRoute(route: route, resampleDistance: resampleDistance)
public func setSimulatedRoute(
_ route: Route,
resampleDistance: Double = 10,
bias: LocationBias = .none
) throws {
simulationState = try locationSimulationFromRoute(
route: route,
resampleDistance: resampleDistance,
bias: bias
)
lastLocation = simulationState?.currentLocation
}

Expand Down
132 changes: 117 additions & 15 deletions apple/Sources/UniFFI/ferrostar.swift

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

1 change: 1 addition & 0 deletions common/Cargo.lock

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

1 change: 1 addition & 0 deletions common/ferrostar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ wasm_js = [
[dependencies]
geo = "0.29.0"
polyline = "0.11.0"
rand = "0.8.5"
serde = { version = "1.0.210", features = ["derive"] }
serde_json = { version = "1.0.128", default-features = false }
serde-wasm-bindgen = { version = "0.6.5", optional = true }
Expand Down
Loading

0 comments on commit 649a68c

Please sign in to comment.