Skip to content

Commit 1622c34

Browse files
committed
fix: 환승 거리가 0m로 나오는 오류 수정
1 parent 12d71fd commit 1622c34

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

presentation/src/main/java/com/stop/ui/route/RouteViewModel.kt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class RouteViewModel @Inject constructor(
110110
name = getRouteItemName(index, route),
111111
coordinate = route.start.coordinate,
112112
mode = getRouteItemMode(route),
113-
distance = route.distance,
113+
distance = getRouteItemDistance(route),
114114
travelTime = route.sectionTime.toInt(),
115115
lastTime = tempLastTime[index],
116116
beforeColor = getRouteItemColor(route, false),
@@ -145,6 +145,21 @@ class RouteViewModel @Inject constructor(
145145
}
146146
}
147147

148+
private fun getRouteItemDistance(route: Route): Double {
149+
return if (route.mode == MoveType.TRANSFER) {
150+
val startPoint = android.location.Location("Start")
151+
val endPoint = android.location.Location("End")
152+
153+
startPoint.latitude = route.start.coordinate.latitude.toDouble()
154+
startPoint.longitude = route.start.coordinate.longitude.toDouble()
155+
endPoint.latitude = route.end.coordinate.latitude.toDouble()
156+
endPoint.longitude = route.end.coordinate.longitude.toDouble()
157+
startPoint.distanceTo(endPoint).toDouble()
158+
} else {
159+
route.distance
160+
}
161+
}
162+
148163
private fun getRouteItemColor(route: Route, isCurrent: Boolean): Int {
149164
return if (isCurrent) {
150165
routeItemColor = if (route is TransportRoute) {

0 commit comments

Comments
 (0)