@@ -10,6 +10,8 @@ internal class GetRouteUseCaseImpl @Inject constructor(
10
10
private val routeRepository : RouteRepository
11
11
) : GetRouteUseCase {
12
12
13
+ private val nameParsingRegex = """ \(+[^)]+\)""" .toRegex()
14
+
13
15
override suspend operator fun invoke (routeRequest : RouteRequest ): List <Itinerary > {
14
16
val originItineraries = routeRepository.getRoute(routeRequest)
15
17
@@ -49,7 +51,7 @@ internal class GetRouteUseCaseImpl @Inject constructor(
49
51
distance = leg.distance,
50
52
end = with (leg.end) {
51
53
Place (
52
- name = name.replace( " (중) " , " " ),
54
+ name = parsingName(name ),
53
55
coordinate = Coordinate (
54
56
latitude = lat.toString(),
55
57
longitude = lon.toString()
@@ -61,7 +63,7 @@ internal class GetRouteUseCaseImpl @Inject constructor(
61
63
proportionOfSectionTime = calculateProportionOfSectionTime(leg.sectionTime, totalTime),
62
64
start = with (leg.start) {
63
65
Place (
64
- name = name.replace( " (중) " , " " ),
66
+ name = parsingName(name ),
65
67
coordinate = Coordinate (
66
68
latitude = lat.toString(),
67
69
longitude = lon.toString()
@@ -78,7 +80,7 @@ internal class GetRouteUseCaseImpl @Inject constructor(
78
80
longitude = lon
79
81
),
80
82
stationId = stationID,
81
- stationName = stationName.replace( " (중) " , " " ),
83
+ stationName = parsingName(stationName ),
82
84
)
83
85
}
84
86
} ? : listOf (),
@@ -88,6 +90,10 @@ internal class GetRouteUseCaseImpl @Inject constructor(
88
90
)
89
91
}
90
92
93
+ private fun parsingName (originName : String ): String {
94
+ return originName.replace(nameParsingRegex, " " )
95
+ }
96
+
91
97
private fun calculateProportionOfSectionTime (sectionTime : Double , totalTime : Int ): Float {
92
98
return (sectionTime / totalTime * 100 ).toInt().toFloat() / 100
93
99
}
@@ -104,7 +110,7 @@ internal class GetRouteUseCaseImpl @Inject constructor(
104
110
distance = leg.distance,
105
111
end = with (leg.end) {
106
112
Place (
107
- name = name,
113
+ name = parsingName( name) ,
108
114
coordinate = Coordinate (
109
115
latitude = lat.toString(),
110
116
longitude = lon.toString()
@@ -116,7 +122,7 @@ internal class GetRouteUseCaseImpl @Inject constructor(
116
122
proportionOfSectionTime = calculateProportionOfSectionTime(leg.sectionTime, totalTime),
117
123
start = with (leg.start) {
118
124
Place (
119
- name = name,
125
+ name = parsingName( name) ,
120
126
coordinate = Coordinate (
121
127
latitude = lat.toString(),
122
128
longitude = lon.toString()
0 commit comments