Merge branch 'mapbox' into mapbox-sdkv3

This commit is contained in:
Piotr Dec 2024-07-30 18:21:02 +02:00
commit c67f9f9726
Signed by: stawros
GPG key ID: F89F27AD8F881A91
14 changed files with 962 additions and 202 deletions

View file

@ -0,0 +1,76 @@
package eu.ztsh.garmin.data
import com.mapbox.navigation.tripdata.maneuver.model.Maneuver
import com.mapbox.navigation.core.trip.session.LocationMatcherResult
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
180.0 -> state.direction!!.angle = OutAngle.Straight
}
}
}
}
"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].replace(',', '.').toDouble().toInt(),
when (this[1]) {
"m" -> Unit.Metres
"km" -> Unit.Kilometres
else -> Unit.Any
}
)
}
}
}
this.laneGuidance?.apply {
this.allLanes.apply {
println()
}
}
}
return state
}
fun apply(locationMatcherResult: LocationMatcherResult): State {
val state = State()
// TODO: speed, limit, location?, bearing
return state
}
}
}