diff --git a/app/src/main/java/ee/taltech/iti0213/sportsapp/track/Track.kt b/app/src/main/java/ee/taltech/iti0213/sportsapp/track/Track.kt index 9e431cd..ef3cc24 100644 --- a/app/src/main/java/ee/taltech/iti0213/sportsapp/track/Track.kt +++ b/app/src/main/java/ee/taltech/iti0213/sportsapp/track/Track.kt @@ -84,16 +84,16 @@ class Track { if (pauses.isEmpty() || pauses.last() != track?.size) { movingTime += location.elapsedTimestamp - currentTimeElapsed - val distanceFromLast = TrackLocation.calcDistanceBetween(location, lastLocation ?: location) - val bearingFromLast = TrackLocation.calcBearingBetween(lastLocation ?: location, location) / 180.0f * PI - val moveVector = speedFilter.process( + val distanceFromLast = 3.6 * 1_000_000_000 * TrackLocation.calcDistanceBetween(location, lastLocation!!) + val bearingFromLast = TrackLocation.calcBearingBetween(lastLocation!!, location) * PI / 180.0f + val speedVector = speedFilter.process( Vector2D( - distanceFromLast * sin(bearingFromLast), - distanceFromLast * cos(bearingFromLast) + distanceFromLast * sin(bearingFromLast) / (location.elapsedTimestamp - currentTimeElapsed), + distanceFromLast * cos(bearingFromLast) / (location.elapsedTimestamp - currentTimeElapsed) ) ) - val currSpeed = 3.6 * 1_000_000_000 * moveVector.length() / (location.elapsedTimestamp - currentTimeElapsed) + val currSpeed = speedVector.length() if (currSpeed > maxSpeed) { maxSpeed = currSpeed } diff --git a/build.gradle b/build.gradle index 2eac75d..2341922 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.0.0' + classpath 'com.android.tools.build:gradle:4.0.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong