-
-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
444 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
app/src/main/java/de/westnordost/streetcomplete/map/Bearing.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.westnordost.streetcomplete.map | ||
|
||
import android.location.Location | ||
|
||
/** Utility functions to estimate current bearing from a track. This is necessary because | ||
* Location.bearingAccuracy doesn't exist on Android versions below Android API 26, otherwise | ||
* a solution based on this would be less code. E.g. take bearing if accuracy < X */ | ||
|
||
fun getTrackBearing(track: List<Location>): Float? { | ||
val last = track.lastOrNull() ?: return null | ||
val point = track.findLast { it.distanceTo(last) > MIN_TRACK_DISTANCE_FOR_BEARING } ?: return null | ||
return point.bearingTo(last) | ||
} | ||
|
||
private const val MIN_TRACK_DISTANCE_FOR_BEARING = 15f // 15 meters |
Oops, something went wrong.