-
Notifications
You must be signed in to change notification settings - Fork 3
/
TMap.kt
98 lines (87 loc) · 3.31 KB
/
TMap.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package me.zipi.navitotesla.model
import com.google.gson.annotations.SerializedName
class TMap {
data class SearchPoiResponse(
val searchPoiInfo: SearchPoiInfo? = null
)
data class SearchPoiInfo(
val count: Int = 0,
val page: Int = 0,
val totalCount: Int = 0,
val pois: PoiItems,
)
data class PoiItems(
val poi: List<PoiItem> = listOf()
)
data class PoiItem(
var name: String? = null,
var upperAddrName: String? = null,
var middleAddrName: String? = null,
var lowerAddrName: String? = null,
var detailAddrName: String? = null,
var mlClass: String? = null,
var firstNo: String? = null,
var secondNo: String? = null,
var roadName: String? = null,
var firstBuildNo: String? = null,
var secondBuildNo: String? = null,
@SerializedName("noorLat")
var latitude: String? = null,
@SerializedName("noorLon")
var longitude: String? = null,
) {
fun getRoadAddress(withLocalName: Boolean): String {
if (roadName!!.isNotEmpty() && firstBuildNo!!.isNotEmpty()) {
val sb = StringBuilder()
sb.append(upperAddrName)
if (middleAddrName!!.isNotEmpty()) {
sb.append(" ").append(middleAddrName)
}
if (roadName!!.isNotEmpty()) {
sb.append(" ").append(roadName)
}
if (firstBuildNo!!.isNotEmpty()) {
sb.append(" ").append(firstBuildNo)
}
if (secondBuildNo!!.isNotEmpty() && secondBuildNo != "0") {
sb.append("-").append(secondBuildNo)
}
// 법정동(동/로/가)가 있을 경우 추가항목으로 (법정동)을 붙여준다.
// 건물명이 있을 경우 (법정동, 건물명) 표시도 가능하다.
if (lowerAddrName!!.isNotEmpty() && withLocalName) {
val lastChar = lowerAddrName!!.substring(lowerAddrName!!.length - 1)
if (lastChar == "동" || lastChar == "로" || lastChar == "가") {
sb.append(" (").append(lowerAddrName).append(")")
}
}
return sb.toString()
}
return ""
}
val address: String
get() {
if (firstNo == null || firstNo!!.length == 0) {
return ""
}
val sb = StringBuilder()
sb.append(upperAddrName)
if (middleAddrName!!.isNotEmpty()) {
sb.append(" ").append(middleAddrName)
}
if (lowerAddrName!!.isNotEmpty()) {
sb.append(" ").append(lowerAddrName)
}
if (detailAddrName!!.isNotEmpty()) {
sb.append(" ").append(detailAddrName)
}
if (mlClass == "2") {
sb.append(" 산")
}
sb.append(" ").append(firstNo)
if (secondNo!!.isNotEmpty() && secondNo != "0") {
sb.append("-").append(secondNo)
}
return sb.toString()
}
}
}