@@ -3,25 +3,33 @@ package com.stop.domain.usecase.geoLocation
3
3
import com.stop.domain.model.geoLocation.AddressType
4
4
import com.stop.domain.model.geoLocation.GeoLocationInfo
5
5
import com.stop.domain.model.route.tmap.custom.Coordinate
6
+ import com.stop.domain.model.route.tmap.origin.AddressInfo
6
7
import com.stop.domain.repository.RouteRepository
7
8
import javax.inject.Inject
8
9
9
10
class GeoLocationUseCaseImpl @Inject constructor(
10
11
private val routeRepository : RouteRepository
11
12
) : GeoLocationUseCase {
12
-
13
13
override suspend fun getGeoLocationInfo (lat : Double , lon : Double ): GeoLocationInfo {
14
14
val result = routeRepository.reverseGeocoding(
15
15
Coordinate (lat.toString(), lon.toString()),
16
16
AddressType .FULL_ADDRESS
17
17
).addressInfo
18
-
19
18
val address = result.fullAddress.split(" ," ).drop(1 )
19
+
20
20
return GeoLocationInfo (
21
- title = result.buildingName ,
21
+ title = getTitle( result) ,
22
22
roadAddress = address.first(),
23
23
lotAddress = address.last().replace(result.buildingName, " " ),
24
24
distance = result.mappingDistance
25
25
)
26
26
}
27
+
28
+ private fun getTitle (result : AddressInfo ): String {
29
+ return if (result.buildingName != " " ) {
30
+ result.buildingName
31
+ } else {
32
+ result.fullAddress.split(" ," ).drop(1 ).first()
33
+ }
34
+ }
27
35
}
0 commit comments