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
root
2022-11-29 08:43:19 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d5ed20ac8950aa1affbc4fbc8bf4762e471435a4
d5ed20ac
1 parent
ab4ba6a1
.3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
15 deletions
sample.js
sample.js
View file @
d5ed20a
const
express
=
require
(
'express'
);
const
app
=
express
();
var
request
=
require
(
'request'
);
const
got
=
require
(
'got'
);
//필요한 주소 정보 (data 형식 확정 x )
let
addresses
=
{
let
addresses
=
`
{
"current_address" : { "address" : "현재 위치 주소", "x" : 127.1058342, "y" : 37.359708},
"number"
:
10
,
"number" :
2
,
"hospital_data" :[
{"name" : "병원명", "address" : "병원 주소", "x" : 129.075986, "y" : 35.179470, "distance" : 0, "duration" : 0},
{"name" : "병원명", "address" : "병원 주소", "x" : 127.1058342, "y" : 37.359708, "distance" : 0, "duration" : 0}
]
}
}`
const
address
=
JSON
.
parse
(
addresses
)
var
options
=
{
'method'
:
'GET'
,
...
...
@@ -19,7 +22,7 @@ var options = {
'headers'
:
{
'X-NCP-APIGW-API-KEY-ID'
:
'12rhzhzq7g'
,
'X-NCP-APIGW-API-KEY'
:
'FhD45P91TxG2820MadrsiPOUjI6bQMJhddnHZIeI'
}
}
,
};
const
ID
=
'12rhzhzq7g'
;
...
...
@@ -28,17 +31,20 @@ const KEY = 'FhD45P91TxG2820MadrsiPOUjI6bQMJhddnHZIeI';
function
direction
(
data
){
var
num
=
data
.
number
;
for
(
let
i
=
0
;
i
<
num
;
i
++
){
const
_url
=
'https://naveropenapi.apigw.ntruss.com/map-direction-15/v1/driving?start='
+
data
.
current_address
.
x
+
','
+
data
.
current_address
.
y
+
'&goal='
+
data
.
hospital_data
[
i
].
x
+
','
+
data
.
hospital_data
[
i
].
y
+
'&option=trafast'
;
options
.
url
=
_url
;
request
(
options
,
function
(
error
,
respose
){
var
databody
=
JSON
.
parse
(
respose
.
body
);
var
distance
=
databody
.
route
.
trafast
[
0
].
summary
.
distance
/
1000
;
// km 단위
var
duration
=
databody
.
route
.
trafast
[
0
].
summary
.
duration
/
1000
/
60
;
// 분 단위dy
data
.
hospital_data
[
count
].
distance
=
distance
;
data
.
hospital_data
[
count
].
duration
=
duration
;
}
)
const
_url
=
'https://naveropenapi.apigw.ntruss.com/map-direction-15/v1/driving?start='
+
data
.
current_address
.
x
+
','
+
data
.
current_address
.
y
+
'&goal='
+
data
.
hospital_data
[
i
].
x
+
','
+
data
.
hospital_data
[
i
].
y
+
'&option=trafast'
;
options
.
url
=
_url
;
request
(
options
,
function
(
error
,
respose
){
var
databody
=
JSON
.
parse
(
respose
.
body
);
if
(
databody
.
code
!=
1
){
console
.
log
(
databody
)
var
distance
=
databody
.
route
.
trafast
[
0
].
summary
.
distance
/
1000
;
// km 단위
var
duration
=
databody
.
route
.
trafast
[
0
].
summary
.
duration
/
1000
/
60
;
// 분 단위dy
data
.
hospital_data
[
i
].
distance
=
distance
;
data
.
hospital_data
[
i
].
duration
=
duration
;
}
}
)
}
console
.
log
(
"TTTTTTTTTTTTT"
)
return
data
}
console
.
log
(
direction
(
address
))
\ No newline at end of file
...
...
Please
register
or
login
to post a comment