Navigation state & location observer
This commit is contained in:
parent
b5cc580cf8
commit
9a553cf563
5 changed files with 70 additions and 21 deletions
71
app/src/main/java/eu/ztsh/garmin/data/MapboxMapper.kt
Normal file
71
app/src/main/java/eu/ztsh/garmin/data/MapboxMapper.kt
Normal file
|
@ -0,0 +1,71 @@
|
|||
package eu.ztsh.garmin.data
|
||||
|
||||
import com.mapbox.navigation.core.trip.session.LocationMatcherResult
|
||||
import com.mapbox.navigation.ui.maneuver.model.Maneuver
|
||||
|
||||
class MapboxMapper {
|
||||
|
||||
companion object {
|
||||
|
||||
fun apply(maneuver: Maneuver): State {
|
||||
val state = State()
|
||||
maneuver.apply {
|
||||
this.primary.apply {
|
||||
state.direction = Direction()
|
||||
when (this.type) {
|
||||
"roundabout" -> {
|
||||
state.direction!!.out = OutType.RightRoundabout
|
||||
}
|
||||
|
||||
"arrive" -> {
|
||||
state.flag = true
|
||||
}
|
||||
}
|
||||
when (this.modifier) {
|
||||
"right" -> {
|
||||
when (this.type) {
|
||||
"turn" -> state.direction!!.angle = OutAngle.Right
|
||||
"roundabout" -> {
|
||||
when (this.degrees) {
|
||||
137.0 -> state.direction!!.angle = OutAngle.EasyRight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"left" -> {
|
||||
when (this.type) {
|
||||
"turn" -> state.direction!!.angle = OutAngle.Left
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.stepDistance.apply {
|
||||
this.distanceRemaining?.apply {
|
||||
distanceFormatter.formatDistance(distanceRemaining!!).split(" ").apply {
|
||||
state.distance = Distance(
|
||||
this[0].toInt(),
|
||||
when (this[1]) {
|
||||
"m" -> Unit.Metres
|
||||
"km" -> Unit.Kilometres
|
||||
else -> Unit.Any
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return state
|
||||
}
|
||||
|
||||
fun apply(locationMatcherResult: LocationMatcherResult): State {
|
||||
val state = State()
|
||||
// TODO: speed, limit, location?, bearing
|
||||
return state
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue