State to IntArray mapper

This commit is contained in:
Piotr Dec 2023-08-24 00:23:40 +02:00
parent 2b0746f6c4
commit ff2e163983
No known key found for this signature in database
GPG key ID: ABD6CB83D6110D27
4 changed files with 173 additions and 32 deletions

View file

@ -0,0 +1,60 @@
package eu.ztsh.garmin.data
import com.mapbox.navigation.ui.maneuver.model.Maneuver
class ManeuverMapper {
companion object {
fun apply(maneuver: Maneuver): State {
val state = State()
maneuver.apply {
this.primary.apply {
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 = this[0].toInt()
state.unit = when (this[1]) {
"m" -> Unit.Metres
"km" -> Unit.Kilometres
else -> {
Unit.Any}
}
}
}
}
}
return state
}
}
}