WIP: WIP
This commit is contained in:
parent
49559993d8
commit
0a00d13706
6 changed files with 328 additions and 15 deletions
66
app/src/main/java/eu/ztsh/garmin/ManeuverMapper.kt
Normal file
66
app/src/main/java/eu/ztsh/garmin/ManeuverMapper.kt
Normal file
|
@ -0,0 +1,66 @@
|
|||
package eu.ztsh.garmin
|
||||
|
||||
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 {
|
||||
state.direction = Direction()
|
||||
when (this.type) {
|
||||
"turn" -> {
|
||||
state.direction.outType = OutType.Lane
|
||||
state.direction.roundabout = OutAngle.AsDirection
|
||||
}
|
||||
|
||||
"roundabout" -> {
|
||||
state.direction.outType = OutType.RightRoundabout
|
||||
}
|
||||
|
||||
"arrive" -> {
|
||||
state.flag = true
|
||||
}
|
||||
}
|
||||
when (this.modifier) {
|
||||
"right" -> {
|
||||
when (this.type) {
|
||||
"turn" -> state.direction.outAngle = OutAngle.Right
|
||||
"roundabout" -> {
|
||||
when (this.degrees) {
|
||||
137.0 -> state.direction.outAngle = OutAngle.EasyRight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"left" -> {
|
||||
when (this.type) {
|
||||
"turn" -> state.direction.outAngle = 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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue