Toggle navigation
Toggle navigation
This project
Loading...
Sign in
zuzitsu
/
UR_Village
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
안지영
2020-12-07 16:59:32 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
44e388395e8cf12f4a52f77dc5aeec3a9c0525e4
44e38839
1 parent
08c01e52
complete transport category
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
2 deletions
routes/category.js
views/transport.ejs
routes/category.js
View file @
44e3883
...
...
@@ -318,8 +318,55 @@ router.get('/park', function(req, res) {
})
});
router
.
get
(
'/transport'
,
function
(
req
,
res
)
{
let
router
.
get
(
'/transport'
,
function
(
req
,
res
)
{
let
apikey
=
process
.
env
.
ODSAY_APIKEY
let
bus_url
=
'https://api.odsay.com/v1/api/pointSearch?lang=0&x='
+
user_latitude
+
'&y='
+
user_logitude
+
'&radius=500&stationClass=1&apiKey='
+
apikey
;
let
subway_url
=
'https://api.odsay.com/v1/api/pointSearch?lang=0&x='
+
user_latitude
+
'&y='
+
user_logitude
+
'&radius=1000&stationClass=2&apiKey='
+
apikey
;
let
busCnt
=
0
;
let
subwayCnt
=
0
;
console
.
log
(
bus_url
);
request
({
url
:
bus_url
,
method
:
'GET'
},
function
(
err
,
response
,
body
)
{
if
(
!
err
&&
res
.
statusCode
==
200
)
{
//console.log("inside");
let
bus_result
=
JSON
.
parse
(
body
);
//console.log(bus_result);
let
busStations
=
[];
busCnt
=
bus_result
.
result
.
count
;
console
.
log
(
'in!'
);
for
(
var
i
=
0
;
i
<
busCnt
;
i
++
)
{
busStations
.
push
(
bus_result
.
result
.
station
[
i
].
stationName
);
}
console
.
log
(
busStations
);
request
({
url
:
subway_url
,
method
:
'GET'
},
function
(
err
,
response
,
body
)
{
if
(
!
err
&&
res
.
statusCode
==
200
)
{
let
subway_result
=
JSON
.
parse
(
body
);
let
subwayStations
=
[];
subwayCnt
=
subway_result
.
result
.
count
;
console
.
log
(
"지하철역 개수:"
+
subwayCnt
);
console
.
log
(
'in3!'
);
for
(
var
i
=
0
;
i
<
subwayCnt
;
i
++
)
{
console
.
log
(
subway_result
.
result
.
station
[
i
]);
subwayStations
.
push
(
subway_result
.
result
.
station
[
i
].
stationName
);
}
console
.
log
(
busStations
);
console
.
log
(
subwayStations
);
res
.
render
(
'transport'
,{
busCnt
:
busCnt
,
busStations
:
busStations
,
subwayCnt
:
subwayCnt
,
subwayStations
:
subwayStations
,
total
:
busCnt
+
subwayCnt
})
}
})
}
})
});
router
.
get
(
'/safe'
,
function
(
req
,
res
)
{
...
...
views/transport.ejs
0 → 100644
View file @
44e3883
<!DOCTYPE html>
<html
lang=
"ko"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
✍️ 결과 페이지
</title>
</head>
<body>
<h1>
대중교통 현황
</h1>
주변 버스 정류장 :
<
%for (var i =0; i
<busCnt
;
i
++){%
>
<li>
<
%=busStations[i]%>
</li>
<
%}%>
<h3>
총 버스정류장 개수 :
<
%=busCnt%>
</h3>
<h1>
지하철역 현황
</h1>
주변 지하철역 :
<
%for (var i =0; i
<subwayCnt
;
i
++){%
>
<li>
<
%=subwayStations[i]%>
</li>
<
%}%>
<h3>
총 지하철역 개수 :
<
%=subwayCnt%>
</h3>
<h3>
총 대중교통 개수 :
<
%=total%>
</h3>
</body>
</html>
\ No newline at end of file
Please
register
or
login
to post a comment