Test, Lanes
This commit is contained in:
@@ -55,17 +55,12 @@ data class ContactData(
|
||||
|
||||
data class StepData (
|
||||
var instruction: String,
|
||||
|
||||
var street: String,
|
||||
var leftStepDistance: Double,
|
||||
|
||||
var currentManeuverType: Int,
|
||||
|
||||
var icon: Int,
|
||||
|
||||
var arrivalTime : Long,
|
||||
|
||||
var leftDistance: Double,
|
||||
|
||||
var lane: List<Lane> = listOf(Lane(location(0.0, 0.0), valid = false, indications = emptyList())),
|
||||
var exitNumber: Int = 0,
|
||||
)
|
||||
@@ -76,7 +71,7 @@ data class Locations (
|
||||
var lat : Double,
|
||||
var lon : Double,
|
||||
var street : String = "",
|
||||
val search_filter: String,
|
||||
val searchFilter: String,
|
||||
)
|
||||
|
||||
data class SearchFilter(
|
||||
@@ -123,7 +118,7 @@ object Constants {
|
||||
val homeVogelhart = location(11.5793748, 48.185749)
|
||||
val homeHohenwaldeck = location( 11.594322, 48.1164817)
|
||||
|
||||
const val NEXT_STEP_THRESHOLD = 300.0
|
||||
const val NEXT_STEP_THRESHOLD = 1000.0
|
||||
|
||||
const val MAXIMAL_SNAP_CORRECTION = 50.0
|
||||
|
||||
@@ -138,6 +133,8 @@ object Constants {
|
||||
const val GMS_CAR_SPEED_PERMISSION = "com.google.android.gms.permission.CAR_SPEED"
|
||||
|
||||
const val AUTOMOTIVE_CAR_SPEED_PERMISSION = "android.car.permission.CAR_SPEED"
|
||||
|
||||
const val TILT = 60.0
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,6 @@ data class NavigationState (
|
||||
val currentRouteIndex: Int = 0,
|
||||
val destination: Place = Place(),
|
||||
val carConnection: Int = 0,
|
||||
var routingEngine: Int = 0,
|
||||
|
||||
val routingEngine: Int = 0,
|
||||
val nextStep: Boolean = false,
|
||||
)
|
||||
@@ -36,8 +36,8 @@ class TomTomRoute {
|
||||
val allIntersections = mutableListOf<Intersection>()
|
||||
val steps = mutableListOf<Step>()
|
||||
var lastPointIndex = 0
|
||||
for (index in 1..< route.guidance.instructions.size) {
|
||||
val lastInstruction = route.guidance.instructions[index-1]
|
||||
for (index in 1..<route.guidance.instructions.size) {
|
||||
val lastInstruction = route.guidance.instructions[index - 1]
|
||||
val instruction = route.guidance.instructions[index]
|
||||
val street = lastInstruction.street ?: ""
|
||||
val maneuverStreet = instruction.street ?: ""
|
||||
@@ -47,7 +47,7 @@ class TomTomRoute {
|
||||
type = convertType(instruction.maneuver),
|
||||
waypoints = points.subList(
|
||||
lastPointIndex,
|
||||
instruction.pointIndex+1,
|
||||
instruction.pointIndex + 1,
|
||||
),
|
||||
exit = exitNumber(instruction),
|
||||
location = location(
|
||||
@@ -61,20 +61,19 @@ class TomTomRoute {
|
||||
route.sections?.forEach { section ->
|
||||
val lanes = mutableListOf<Lane>()
|
||||
var startIndex = 0
|
||||
|
||||
section.lanes?.forEach { itLane ->
|
||||
val lane = Lane(
|
||||
location(
|
||||
waypoints[section.startPointIndex][0],
|
||||
waypoints[section.startPointIndex][1]
|
||||
),
|
||||
itLane.directions.first() == itLane.follow,
|
||||
itLane.directions
|
||||
)
|
||||
startIndex = section.startPointIndex
|
||||
lanes.add(lane)
|
||||
}
|
||||
intersections.add(Intersection(waypoints[startIndex], lanes))
|
||||
section.lanes?.forEach { itLane ->
|
||||
val lane = Lane(
|
||||
location(
|
||||
waypoints[section.startPointIndex][0],
|
||||
waypoints[section.startPointIndex][1]
|
||||
),
|
||||
itLane.directions.first() == itLane.follow,
|
||||
itLane.directions
|
||||
)
|
||||
startIndex = section.startPointIndex
|
||||
lanes.add(lane)
|
||||
}
|
||||
intersections.add(Intersection(waypoints[startIndex], lanes))
|
||||
|
||||
}
|
||||
allIntersections.addAll(intersections)
|
||||
@@ -140,6 +139,7 @@ class TomTomRoute {
|
||||
"BEAR_RIGHT" -> {
|
||||
newType = androidx.car.app.navigation.model.Maneuver.TYPE_TURN_SLIGHT_RIGHT
|
||||
}
|
||||
|
||||
"BEAR_LEFT" -> {
|
||||
newType = androidx.car.app.navigation.model.Maneuver.TYPE_TURN_SLIGHT_LEFT
|
||||
}
|
||||
@@ -171,12 +171,15 @@ class TomTomRoute {
|
||||
"ROUNDABOUT_LEFT" -> {
|
||||
newType = androidx.car.app.navigation.model.Maneuver.TYPE_ROUNDABOUT_ENTER_CW
|
||||
}
|
||||
|
||||
"MAKE_UTURN" -> {
|
||||
newType = androidx.car.app.navigation.model.Maneuver.TYPE_U_TURN_LEFT
|
||||
}
|
||||
|
||||
"ENTER_MOTORWAY" -> {
|
||||
newType = androidx.car.app.navigation.model.Maneuver.TYPE_MERGE_LEFT
|
||||
}
|
||||
|
||||
"TAKE_EXIT" -> {
|
||||
newType = androidx.car.app.navigation.model.Maneuver.TYPE_TURN_SHARP_RIGHT
|
||||
|
||||
@@ -187,10 +190,11 @@ class TomTomRoute {
|
||||
}
|
||||
|
||||
private fun exitNumber(
|
||||
instruction: Instruction
|
||||
instruction: Instruction
|
||||
): Int {
|
||||
return if ( instruction.exitNumber == null
|
||||
|| instruction.exitNumber.isEmpty()) {
|
||||
return if (instruction.exitNumber == null
|
||||
|| instruction.exitNumber.isEmpty()
|
||||
) {
|
||||
0
|
||||
} else {
|
||||
instruction.exitNumber.toInt()
|
||||
|
||||
@@ -33,9 +33,9 @@ class ValhallaRepository : NavigationRepository() {
|
||||
Locations(
|
||||
lat = currentLocation.latitude,
|
||||
lon = currentLocation.longitude,
|
||||
search_filter = exclude
|
||||
searchFilter = exclude
|
||||
),
|
||||
Locations(lat = location.latitude, lon = location.longitude, search_filter = exclude)
|
||||
Locations(lat = location.latitude, lon = location.longitude, searchFilter = exclude)
|
||||
)
|
||||
val valhallaLocation = ValhallaLocation(
|
||||
locations = vLocation,
|
||||
|
||||
@@ -15,7 +15,6 @@ import com.kouros.data.R
|
||||
import com.kouros.navigation.data.StepData
|
||||
import java.util.Collections
|
||||
import java.util.Locale
|
||||
import kotlin.collections.forEach
|
||||
|
||||
class IconMapper() {
|
||||
|
||||
@@ -148,22 +147,14 @@ class IconMapper() {
|
||||
return laneDirection
|
||||
}
|
||||
|
||||
fun createCarIcon(iconCompat: IconCompat): CarIcon {
|
||||
return CarIcon.Builder(iconCompat).build()
|
||||
}
|
||||
|
||||
fun createCarIconx(carContext: Context, @DrawableRes iconRes: Int): CarIcon {
|
||||
return CarIcon.Builder(IconCompat.createWithResource(carContext, iconRes)).build()
|
||||
}
|
||||
|
||||
fun createLaneIcon(context: Context, stepData: StepData): IconCompat {
|
||||
val bitmaps = mutableListOf<Bitmap>()
|
||||
stepData.lane.forEach {
|
||||
if (it.indications.isNotEmpty()) {
|
||||
Collections.sort<String>(it.indications)
|
||||
val resource = laneToResource(it.indications, stepData)
|
||||
stepData.lane.forEach { lane ->
|
||||
if (lane.indications.isNotEmpty()) {
|
||||
Collections.sort<String>(lane.indications)
|
||||
val resource = laneToResource(lane.indications, stepData)
|
||||
if (resource.isNotEmpty()) {
|
||||
val id = resourceId(resource);
|
||||
val id = resourceId(resource)
|
||||
val bitMap = BitmapFactory.decodeResource(context.resources, id)
|
||||
bitmaps.add(bitMap)
|
||||
}
|
||||
@@ -182,30 +173,30 @@ class IconMapper() {
|
||||
return bitmaps.first()
|
||||
}
|
||||
val bmOverlay = createBitmap(
|
||||
bitmaps.first().getWidth() * (bitmaps.size * 1.5).toInt(),
|
||||
bitmaps.first().getHeight(),
|
||||
bitmaps.first().getConfig()!!
|
||||
bitmaps.first().width * (bitmaps.size * 1.5).toInt(),
|
||||
bitmaps.first().height,
|
||||
bitmaps.first().config!!
|
||||
)
|
||||
val canvas = Canvas(bmOverlay)
|
||||
canvas.drawBitmap(bitmaps.first(), matrix, null)
|
||||
var i = 0
|
||||
bitmaps.forEach {
|
||||
bitmaps.forEach { bitmap ->
|
||||
if (i > 0) {
|
||||
matrix.setTranslate(i * 45F, 0F)
|
||||
canvas.drawBitmap(it, matrix, null)
|
||||
canvas.drawBitmap(bitmap, matrix, null)
|
||||
}
|
||||
i++
|
||||
}
|
||||
return bmOverlay
|
||||
}
|
||||
|
||||
private fun laneToResource(directions: List<String>, stepData: StepData): String {
|
||||
fun laneToResource(directions: List<String>, stepData: StepData): String {
|
||||
var direction = ""
|
||||
directions.forEach {
|
||||
directions.forEach { indication ->
|
||||
direction = if (direction.isEmpty()) {
|
||||
it.trim()
|
||||
indication.trim()
|
||||
} else {
|
||||
"${direction}_${it.trim()}"
|
||||
"${direction}_${indication.trim()}"
|
||||
}
|
||||
}
|
||||
direction = direction.lowercase()
|
||||
@@ -232,8 +223,10 @@ class IconMapper() {
|
||||
"right" -> if (stepData.currentManeuverType == Maneuver.TYPE_TURN_NORMAL_RIGHT) "${direction}_o" else "${direction}_x"
|
||||
"left" -> if (stepData.currentManeuverType == Maneuver.TYPE_TURN_NORMAL_LEFT) "${direction}_o" else "${direction}_x"
|
||||
"straight" -> if (stepData.currentManeuverType == Maneuver.TYPE_STRAIGHT) "${direction}_o" else "${direction}_x"
|
||||
"right_slight", "slight_right" -> if (stepData.currentManeuverType == Maneuver.TYPE_TURN_SLIGHT_RIGHT) "${direction}_o" else "${direction}_x"
|
||||
"left_slight", "slight_left" -> if (stepData.currentManeuverType == Maneuver.TYPE_TURN_SLIGHT_LEFT) "${direction}_o" else "${direction}_x"
|
||||
"right_slight", "slight_right" -> if (stepData.currentManeuverType == Maneuver.TYPE_TURN_SLIGHT_RIGHT
|
||||
|| stepData.currentManeuverType == Maneuver.TYPE_TURN_NORMAL_RIGHT) "slight_right_o" else "slight_right_x"
|
||||
"left_slight", "slight_left" -> if (stepData.currentManeuverType == Maneuver.TYPE_TURN_SLIGHT_LEFT
|
||||
|| stepData.currentManeuverType == Maneuver.TYPE_TURN_NORMAL_LEFT) "slight_left_o" else "slight_left_x"
|
||||
else -> {
|
||||
""
|
||||
}
|
||||
@@ -246,22 +239,22 @@ class IconMapper() {
|
||||
return when (variableName) {
|
||||
"left_x" -> R.drawable.left_x
|
||||
"left_o" -> R.drawable.left_o
|
||||
"left_o_right_x" -> R.drawable.left_o_right_x
|
||||
"left_o_straight_x" -> R.drawable.left_o_straight_x
|
||||
"left_x_straight_o" -> R.drawable.left_x_straight_o
|
||||
"slight_left_x" -> R.drawable.slight_left_x
|
||||
"slight_left_o" -> R.drawable.slight_left_o
|
||||
"right_x" -> R.drawable.right_x
|
||||
"right_o" -> R.drawable.right_o
|
||||
"slight_right_x" -> R.drawable.slight_right_x
|
||||
"slight_right_o" -> R.drawable.slight_right_o
|
||||
"slight_left_x" -> R.drawable.left_x
|
||||
"straight_x" -> R.drawable.straight_x
|
||||
"right_o_straight_x" -> R.drawable.right_o_straight_x
|
||||
"right_x_straight_x" -> R.drawable.right_x_straight_x
|
||||
"right_x_straight_o" -> R.drawable.right_x_straight_x
|
||||
"right_x_straight_o" -> R.drawable.right_x_straight_o
|
||||
"straight_o" -> R.drawable.straight_o
|
||||
"left_o_straight_x" -> R.drawable.left_o_straight_x
|
||||
"left_x_straight_o" -> R.drawable.left_x_straight_o
|
||||
else -> {
|
||||
R.drawable.left_x
|
||||
R.drawable.ic_zoom_out_24
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,9 +26,6 @@ class RouteCalculator(var routeModel: RouteModel) {
|
||||
routeModel.navState.route.currentStepIndex = step.index
|
||||
step.waypointIndex = wayIndex
|
||||
step.wayPointLocation = location(waypoint[0], waypoint[1])
|
||||
//routeModel.navState = routeModel.navState.copy(
|
||||
// routeBearing = routeModel.navState.lastLocation.bearingTo(location)
|
||||
// )
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,8 +61,13 @@ class RouteCalculator(var routeModel: RouteModel) {
|
||||
val loc1 = location(step.maneuver.waypoints[i][0], step.maneuver.waypoints[i][1])
|
||||
val loc2 =
|
||||
location(step.maneuver.waypoints[i + 1][0], step.maneuver.waypoints[i + 1][1])
|
||||
val locationDistance = loc1.distanceTo(routeModel.navState.lastLocation)
|
||||
val distance = loc1.distanceTo(loc2)
|
||||
leftDistance += distance
|
||||
leftDistance += if (locationDistance < distance) {
|
||||
locationDistance
|
||||
} else {
|
||||
distance
|
||||
}
|
||||
}
|
||||
return (leftDistance / 10.0).roundToInt() * 10.0
|
||||
}
|
||||
@@ -73,10 +75,12 @@ class RouteCalculator(var routeModel: RouteModel) {
|
||||
/** Returns the left distance in m. */
|
||||
fun travelLeftDistance(): Double {
|
||||
var leftDistance = 0.0
|
||||
// distance for next steps
|
||||
for (i in routeModel.route.currentStepIndex + 1..<routeModel.curLeg.steps.size) {
|
||||
val step = routeModel.route.legs()[0].steps[i]
|
||||
leftDistance += step.distance
|
||||
}
|
||||
// distance for current step
|
||||
leftDistance += leftStepDistance()
|
||||
return leftDistance
|
||||
}
|
||||
|
||||
@@ -74,9 +74,11 @@ open class RouteModel {
|
||||
val currentStep = navState.route.nextStep(0)
|
||||
var streetName = currentStep.maneuver.street
|
||||
var curManeuverType = currentStep.maneuver.type
|
||||
if (distanceToNextStep > NEXT_STEP_THRESHOLD) {
|
||||
streetName = currentStep.street
|
||||
curManeuverType = Maneuver.TYPE_STRAIGHT
|
||||
if (navState.nextStep) {
|
||||
if (distanceToNextStep > NEXT_STEP_THRESHOLD) {
|
||||
streetName = currentStep.street
|
||||
curManeuverType = Maneuver.TYPE_STRAIGHT
|
||||
}
|
||||
}
|
||||
val exitNumber = currentStep.maneuver.exit
|
||||
val maneuverIcon = navState.iconMapper.maneuverIcon(curManeuverType)
|
||||
@@ -84,6 +86,7 @@ open class RouteModel {
|
||||
// Construct and return the final StepData object
|
||||
return StepData(
|
||||
instruction = streetName,
|
||||
street = currentStep.street,
|
||||
leftStepDistance = distanceToNextStep,
|
||||
currentManeuverType = navState.maneuverType,
|
||||
icon = maneuverIcon,
|
||||
@@ -109,6 +112,7 @@ open class RouteModel {
|
||||
// Construct and return the final StepData object
|
||||
return StepData(
|
||||
instruction = streetName,
|
||||
street = "",
|
||||
leftStepDistance = distanceToNextStep,
|
||||
currentManeuverType = maneuverType,
|
||||
icon = maneuverIcon,
|
||||
|
||||
@@ -57,6 +57,12 @@ class SettingsViewModel(private val repository: SettingsRepository) : ViewModel(
|
||||
""
|
||||
)
|
||||
|
||||
val recentPlaces = repository.recentPlacesFlow.stateIn(
|
||||
viewModelScope,
|
||||
SharingStarted.WhileSubscribed(5_000),
|
||||
""
|
||||
)
|
||||
|
||||
fun onShow3DChanged(enabled: Boolean) {
|
||||
viewModelScope.launch { repository.setShow3D(enabled) }
|
||||
}
|
||||
|
||||
BIN
common/data/src/main/res/drawable/empty.png
Normal file
BIN
common/data/src/main/res/drawable/empty.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 883 B |
BIN
common/data/src/main/res/drawable/slight_left_o.png
Normal file
BIN
common/data/src/main/res/drawable/slight_left_o.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
BIN
common/data/src/main/res/drawable/slight_left_x.png
Normal file
BIN
common/data/src/main/res/drawable/slight_left_x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
@@ -0,0 +1,98 @@
|
||||
package com.kouros.navigation.model
|
||||
|
||||
import androidx.car.app.navigation.model.LaneDirection
|
||||
import androidx.car.app.navigation.model.Maneuver
|
||||
import com.kouros.data.R
|
||||
import com.kouros.navigation.data.StepData
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class IconMapperTest {
|
||||
|
||||
private val iconMapper = IconMapper()
|
||||
|
||||
@Test
|
||||
fun `maneuverIcon returns correct icon for each maneuver type`() {
|
||||
assertEquals(R.drawable.ic_turn_name_change, iconMapper.maneuverIcon(Maneuver.TYPE_STRAIGHT))
|
||||
assertEquals(R.drawable.ic_turn_destination, iconMapper.maneuverIcon(Maneuver.TYPE_DESTINATION))
|
||||
assertEquals(R.drawable.ic_turn_destination, iconMapper.maneuverIcon(Maneuver.TYPE_DESTINATION_RIGHT))
|
||||
assertEquals(R.drawable.ic_turn_destination, iconMapper.maneuverIcon(Maneuver.TYPE_DESTINATION_LEFT))
|
||||
assertEquals(R.drawable.ic_turn_destination, iconMapper.maneuverIcon(Maneuver.TYPE_DESTINATION_STRAIGHT))
|
||||
assertEquals(R.drawable.ic_turn_normal_right, iconMapper.maneuverIcon(Maneuver.TYPE_TURN_NORMAL_RIGHT))
|
||||
assertEquals(R.drawable.ic_turn_normal_left, iconMapper.maneuverIcon(Maneuver.TYPE_TURN_NORMAL_LEFT))
|
||||
assertEquals(R.drawable.ic_turn_slight_right, iconMapper.maneuverIcon(Maneuver.TYPE_OFF_RAMP_SLIGHT_RIGHT))
|
||||
assertEquals(R.drawable.ic_turn_slight_right, iconMapper.maneuverIcon(Maneuver.TYPE_TURN_SLIGHT_RIGHT))
|
||||
assertEquals(R.drawable.ic_turn_name_change, iconMapper.maneuverIcon(Maneuver.TYPE_KEEP_RIGHT))
|
||||
assertEquals(R.drawable.ic_turn_name_change, iconMapper.maneuverIcon(Maneuver.TYPE_KEEP_LEFT))
|
||||
assertEquals(R.drawable.ic_roundabout_ccw, iconMapper.maneuverIcon(Maneuver.TYPE_ROUNDABOUT_ENTER_CCW))
|
||||
assertEquals(R.drawable.ic_roundabout_ccw, iconMapper.maneuverIcon(Maneuver.TYPE_ROUNDABOUT_EXIT_CCW))
|
||||
assertEquals(R.drawable.ic_turn_u_turn_left, iconMapper.maneuverIcon(Maneuver.TYPE_U_TURN_LEFT))
|
||||
assertEquals(R.drawable.ic_turn_u_turn_right, iconMapper.maneuverIcon(Maneuver.TYPE_U_TURN_RIGHT))
|
||||
assertEquals(R.drawable.ic_turn_merge_symmetrical, iconMapper.maneuverIcon(Maneuver.TYPE_MERGE_LEFT))
|
||||
assertEquals(R.drawable.ic_turn_name_change, iconMapper.maneuverIcon(Maneuver.TYPE_UNKNOWN))
|
||||
assertEquals(R.drawable.ic_turn_name_change, iconMapper.maneuverIcon(Maneuver.TYPE_DEPART))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `addLanes returns correct lane direction`() {
|
||||
val stepDataNormalLeft = StepData("", 0.0, Maneuver.TYPE_TURN_NORMAL_LEFT, 0, 0L, 0.0)
|
||||
assertEquals(LaneDirection.SHAPE_NORMAL_LEFT, iconMapper.addLanes("left_straight", stepDataNormalLeft))
|
||||
assertEquals(LaneDirection.SHAPE_NORMAL_LEFT, iconMapper.addLanes("left", stepDataNormalLeft))
|
||||
assertEquals(LaneDirection.SHAPE_SLIGHT_LEFT, iconMapper.addLanes("left_slight", stepDataNormalLeft))
|
||||
assertEquals(LaneDirection.SHAPE_SLIGHT_LEFT, iconMapper.addLanes("slight_left", stepDataNormalLeft))
|
||||
|
||||
val stepDataStraight = StepData("", 0.0, Maneuver.TYPE_STRAIGHT, 0, 0L, 0.0)
|
||||
assertEquals(LaneDirection.SHAPE_STRAIGHT, iconMapper.addLanes("left_straight", stepDataStraight))
|
||||
assertEquals(LaneDirection.SHAPE_STRAIGHT, iconMapper.addLanes("straight", stepDataStraight))
|
||||
assertEquals(LaneDirection.SHAPE_STRAIGHT, iconMapper.addLanes("right_straight", stepDataStraight))
|
||||
|
||||
val stepDataKeepLeft = StepData("", 0.0, Maneuver.TYPE_KEEP_LEFT, 0, 0L, 0.0)
|
||||
assertEquals(LaneDirection.SHAPE_STRAIGHT, iconMapper.addLanes("straight", stepDataKeepLeft))
|
||||
assertEquals(LaneDirection.SHAPE_SLIGHT_LEFT, iconMapper.addLanes("left_slight", stepDataKeepLeft))
|
||||
|
||||
val stepDataKeepRight = StepData("", 0.0, Maneuver.TYPE_KEEP_RIGHT, 0, 0L, 0.0)
|
||||
assertEquals(LaneDirection.SHAPE_STRAIGHT, iconMapper.addLanes("straight", stepDataKeepRight))
|
||||
|
||||
val stepDataNormalRight = StepData("", 0.0, Maneuver.TYPE_TURN_NORMAL_RIGHT, 0, 0L, 0.0)
|
||||
assertEquals(LaneDirection.SHAPE_NORMAL_RIGHT, iconMapper.addLanes("right", stepDataNormalRight))
|
||||
assertEquals(LaneDirection.SHAPE_NORMAL_RIGHT, iconMapper.addLanes("right_straight", stepDataNormalRight))
|
||||
|
||||
val stepDataSlightRight = StepData("", 0.0, Maneuver.TYPE_TURN_SLIGHT_RIGHT, 0, 0L, 0.0)
|
||||
assertEquals(LaneDirection.SHAPE_NORMAL_RIGHT, iconMapper.addLanes("right_slight", stepDataSlightRight))
|
||||
assertEquals(LaneDirection.SHAPE_NORMAL_RIGHT, iconMapper.addLanes("slight_right", stepDataSlightRight))
|
||||
|
||||
val stepDataUnknown = StepData("", 0.0, Maneuver.TYPE_UNKNOWN, 0, 0L, 0.0)
|
||||
assertEquals(LaneDirection.SHAPE_UNKNOWN, iconMapper.addLanes("left_straight", stepDataUnknown))
|
||||
assertEquals(LaneDirection.SHAPE_UNKNOWN, iconMapper.addLanes("left", stepDataUnknown))
|
||||
assertEquals(LaneDirection.SHAPE_UNKNOWN, iconMapper.addLanes("straight", stepDataUnknown))
|
||||
assertEquals(LaneDirection.SHAPE_UNKNOWN, iconMapper.addLanes("right", stepDataUnknown))
|
||||
assertEquals(LaneDirection.SHAPE_UNKNOWN, iconMapper.addLanes("right_straight", stepDataUnknown))
|
||||
assertEquals(LaneDirection.SHAPE_UNKNOWN, iconMapper.addLanes("left_slight", stepDataUnknown))
|
||||
assertEquals(LaneDirection.SHAPE_UNKNOWN, iconMapper.addLanes("right_slight", stepDataUnknown))
|
||||
assertEquals(LaneDirection.SHAPE_UNKNOWN, iconMapper.addLanes("invalid_direction", stepDataNormalLeft))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `laneToResource returns correct resource string`() {
|
||||
val stepDataNormalLeft = StepData("", 0.0, Maneuver.TYPE_TURN_NORMAL_LEFT, 0, 0L, 0.0)
|
||||
assertEquals("left_o_straight_x", iconMapper.laneToResource(listOf("left", "straight"), stepDataNormalLeft))
|
||||
assertEquals("left_o", iconMapper.laneToResource(listOf("left"), stepDataNormalLeft))
|
||||
assertEquals("slight_left_o", iconMapper.laneToResource(listOf("slight_left"), stepDataNormalLeft))
|
||||
|
||||
val stepDataStraight = StepData("", 0.0, Maneuver.TYPE_STRAIGHT, 0, 0L, 0.0)
|
||||
assertEquals("left_x_straight_o", iconMapper.laneToResource(listOf("left", "straight"), stepDataStraight))
|
||||
assertEquals("straight_o", iconMapper.laneToResource(listOf("straight"), stepDataStraight))
|
||||
assertEquals("right_x_straight_o", iconMapper.laneToResource(listOf("right_straight"), stepDataStraight))
|
||||
|
||||
val stepDataNormalRight = StepData("", 0.0, Maneuver.TYPE_TURN_NORMAL_RIGHT, 0, 0L, 0.0)
|
||||
assertEquals("right_x_straight_x", iconMapper.laneToResource(listOf("right_straight"), stepDataNormalRight))
|
||||
assertEquals("right_o", iconMapper.laneToResource(listOf("right"), stepDataNormalRight))
|
||||
|
||||
val stepDataSlightRight = StepData("", 0.0, Maneuver.TYPE_TURN_SLIGHT_RIGHT, 0, 0L, 0.0)
|
||||
assertEquals("right_o_straight_o", iconMapper.laneToResource(listOf("right_straight"), stepDataSlightRight))
|
||||
|
||||
val stepDataUnknown = StepData("", 0.0, Maneuver.TYPE_UNKNOWN, 0, 0L, 0.0)
|
||||
assertEquals("left_x_straight_x", iconMapper.laneToResource(listOf("left", "straight"), stepDataUnknown))
|
||||
assertEquals("", iconMapper.laneToResource(listOf("invalid"), stepDataUnknown))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user