Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김시환
/
emergency_room_ChatBot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
1
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김시환
2022-11-24 11:20:21 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
29a39c54af4338a3da45b6897fd74d79843bc5fe
29a39c54
2 parents
f3ad9e3e
24442a3c
Merge branch 'Yerim' into 'main'
Yerim See merge request
!8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
2 deletions
Directions_15_sample.js
sharing.json
Directions_15_sample.js
View file @
29a39c5
var
request
=
require
(
'request'
);
//필요한 주소 정보 (data 형식 확정 x )
let
address
=
{
"current_address"
:
{
"address"
:
"현재 위치 주소"
,
"x"
:
127.1058342
,
"y"
:
37.359708
},
"number"
:
10
,
"hospital_data"
:[
{
"name"
:
"병원명"
,
"address"
:
"병원 주소"
,
"x"
:
129.075986
,
"y"
:
35.179470
},
{
"name"
:
"병원명"
,
"address"
:
"병원 주소"
,
"x"
:
127.1058342
,
"y"
:
37.359708
}
]
}
var
options
=
{
'method'
:
'GET'
,
'url'
:
'https://naveropenapi.apigw.ntruss.com/map-direction-15/v1/driving?start=127.1058342,37.359708&goal=129.075986,35.179470&option=trafast'
,
'url'
:
'https://naveropenapi.apigw.ntruss.com/map-direction-15/v1/driving?start='
+
address
.
current_address
.
x
+
','
+
address
.
current_address
.
y
+
'&goal='
+
address
.
hospital_data
[
0
].
x
+
','
+
address
.
hospital_data
[
0
].
y
+
'&option=trafast'
,
'headers'
:
{
'X-NCP-APIGW-API-KEY-ID'
:
'12rhzhzq7g'
,
'X-NCP-APIGW-API-KEY'
:
'FhD45P91TxG2820MadrsiPOUjI6bQMJhddnHZIeI'
}
};
request
(
options
,
function
(
error
,
response
)
{
if
(
error
)
throw
new
Error
(
error
);
console
.
log
(
response
.
body
);
let
body
=
JSON
.
parse
(
response
.
body
);
var
distance
=
body
.
route
.
trafast
[
0
].
summary
.
distance
/
1000
;
// km 단위
var
duration
=
body
.
route
.
trafast
[
0
].
summary
.
duration
/
1000
/
60
;
// 분 단위
const
data
=
{
"distance"
:
distance
,
"duration"
:
duration
}
console
.
log
(
data
);
});
//duration으로 정렬
function
durationSort
(
a
,
b
)
{
if
(
a
.
x
==
b
.
x
){
return
0
}
return
a
.
x
>
b
.
x
?
1
:
-
1
;
}
address
.
hospital_data
.
sort
(
durationSort
);
console
.
log
(
address
);
/*
최종 데이터 형식
{
"current_address" : { "address" : "현재 위치 주소", "x" : 127.1058342, "y" : 37.359708},
"number" : 10,
"hospital_data" :[
{"name" : "병원명", "address" : "병원 주소", "x" : 129.075986, "y" : 35.179470, "distance" : 377830, "duration" : 15177133},
{"name" : "병원명", "address" : "병원 주소", "x" : 127.1058342, "y" : 37.359708, "distance" : 377830, "duration" : 15177133}
]
}*/
...
...
sharing.json
0 → 100644
View file @
29a39c5
{
"current_address"
:
{
"address"
:
"현재 위치 주소"
,
"x"
:
127.1058342
,
"y"
:
37.359708
},
"number"
:
10
,
"hospital_data"
:[
{
"name"
:
"병원명"
,
"address"
:
"병원 주소"
,
"x"
:
129.075986
,
"y"
:
35.179470
,
"distance"
:
377830
,
"duration"
:
15177133
},
{
"name"
:
"병원명"
,
"address"
:
"병원 주소"
,
"x"
:
127.1058342
,
"y"
:
37.359708
,
"distance"
:
377830
,
"duration"
:
15177133
}
]
}
Please
register
or
login
to post a comment