Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
HyungJu committed Sep 25, 2024
1 parent 072a6f7 commit 966b539
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class NaverGcService(

return asyncHttpClient
.prepareGet(
"https://naveropenapi.apigw.ntruss.com/map-reversegeocode/v2/gc?coords=${input.lon},${input.lat}&output=json&orders=roadaddr",
"https://naveropenapi.apigw.ntruss.com/map-reversegeocode/v2/gc?coords=${input.lon},${input.lat}&output=json&orders=legalcode,roadaddr",
).setHeader("X-NCP-APIGW-API-KEY", clientSecret)
.setHeader("X-NCP-APIGW-API-KEY-ID", clientId)
.execute()
Expand All @@ -41,9 +41,21 @@ class NaverGcService(
return@thenApply null
}

if(response.results.size == 1) {
val city =
response.results[0]
.region.area1.name

val roadName =
response.results[0]
.region.area4.name

return@thenApply Location(input.lat, input.lon, "$roadName 근처 어딘가", city)
}

val buildingName =
response.results[0]
.land.addition0.value
response.results[1]
.land?.addition0?.value ?: ""

val city =
response.results[0]
Expand All @@ -52,7 +64,7 @@ class NaverGcService(
if (buildingName == "") {
val roadName =
response.results[0]
.land.name
.land?.name
return@thenApply Location(input.lat, input.lon, "$roadName 근처 어딘가", city)
} else {
return@thenApply Location(input.lat, input.lon, buildingName, city)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data class Result(
val name: String,
val code: Code,
val region: Region,
val land: Land,
val land: Land?,
)

data class Code(
Expand Down

0 comments on commit 966b539

Please sign in to comment.