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
Suyeon Jung
2020-12-07 17:40:40 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0d25a01b60d3094c292f596b401b90038d361dd7
0d25a01b
1 parent
44e38839
Modify transport category
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
35 deletions
routes/category.js
views/transport.ejs → views/transport_result.ejs
routes/category.js
View file @
0d25a01
...
...
@@ -6,12 +6,13 @@ require('dotenv').config();
/* GET home page. */
let
SIGUN_CODE
;
let
GYEONGI_API_KEY
=
process
.
env
.
GYEONGGI_APIKEY
;
let
ODSAY_API_KEY
=
process
.
env
.
ODSAY_APIKEY
;
let
user_sigun
;
let
user_gu
;
let
user_dong
;
let
userLocation
;
let
user_latitude
;
let
user_logitude
;
let
user_lo
n
gitude
;
let
sigun
=
[{
sigun_name
:
'가평군'
,
sigun_code
:
41820
...
...
@@ -186,8 +187,8 @@ router.post('/', function(req, res) {
var
result
=
JSON
.
parse
(
body
);
console
.
log
(
'result'
,
result
);
user_latitude
=
result
.
documents
[
0
].
address
.
x
;
user_logitude
=
result
.
documents
[
0
].
address
.
y
;
console
.
log
(
'위도, 경도'
,
user_latitude
,
user_logitude
);
user_lo
n
gitude
=
result
.
documents
[
0
].
address
.
y
;
console
.
log
(
'위도, 경도'
,
user_latitude
,
user_lo
n
gitude
);
}
})
res
.
render
(
'category'
,
{
userLocation
:
userLocation
});
...
...
@@ -318,49 +319,48 @@ router.get('/park', function(req, res) {
})
});
router
.
get
(
'/transport'
,
function
(
req
,
res
)
{
let
apikey
=
process
.
env
.
ODSAY_APIKEY
router
.
get
(
'/transport'
,
function
(
req
,
res
)
{
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
bus_url
=
'https://api.odsay.com/v1/api/pointSearch?'
;
let
subway_url
=
'https://api.odsay.com/v1/api/pointSearch?'
;
let
qs
=
`?lang=0&x=
${
user_latitude
}
&y=
${
user_longitude
}
&radius=1000&stationClass=2&apiKey=
${
ODSAY_API_KEY
}
`
;
let
busCnt
=
0
;
let
subwayCnt
=
0
;
let
subwayCnt
=
0
;
console
.
log
(
bus_url
);
request
({
url
:
bus_url
,
url
:
bus_url
+
qs
,
method
:
'GET'
},
function
(
err
,
response
,
body
)
{
},
function
(
err
,
response
,
body
)
{
if
(
!
err
&&
res
.
statusCode
==
200
)
{
//console.log("inside");
let
bus_result
=
JSON
.
parse
(
body
);
//console.log(bus_result
);
console
.
log
(
'bus_result'
,
bus_result
.
result
.
station
);
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
(
bus_result
.
result
)
for
(
let
i
=
0
;
i
<
bus_result
.
result
.
station
.
length
;
i
++
)
{
station
=
bus_result
.
result
.
station
[
i
];
console
.
log
(
'station'
,
station
)
busStations
.
push
(
station
);
}
console
.
log
(
busStations
);
console
.
log
(
'busStations'
,
busStations
);
request
({
url
:
subway_url
,
url
:
subway_url
+
qs
,
method
:
'GET'
},
function
(
err
,
response
,
body
)
{
},
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
(
'subway_result'
,
subway_result
);
for
(
let
i
=
0
;
i
<
subway_result
.
result
.
station
.
length
;
i
++
)
{
station
=
subway_result
.
result
.
station
[
i
];
subwayStations
.
push
(
station
);
}
console
.
log
(
busStations
);
console
.
log
(
subwayStations
);
res
.
render
(
'transport
'
,{
busCnt
:
busCnt
,
busStations
:
busStations
,
subwayCnt
:
subwayCnt
,
subwayStations
:
subwayStations
,
total
:
busCnt
+
subwayCnt
})
console
.
log
(
'subwayStaions'
,
subwayStations
);
res
.
render
(
'transport
_result'
,
{
busStations
:
busStations
,
subwayStations
:
subwayStations
})
}
})
...
...
views/transport.ejs
→
views/transport
_result
.ejs
View file @
0d25a01
...
...
@@ -9,28 +9,28 @@
<body>
<h1>
대중교통 현황
</h1>
주변 버스 정류장 :
<
%for (var i =0; i
<bus
Cnt
;
i
++){%
>
<
%for (var i =0; i
<bus
Stations
.
length
;
i
++){%
>
<li>
<
%=busStations[i]%>
<
%=busStations[i]
.stationName
%>
</li>
<
%}%>
<h3>
총 버스정류장 개수 :
<
%=bus
Cnt
%>
<
%=bus
Stations.length
%>
</h3>
<h1>
지하철역 현황
</h1>
주변 지하철역 :
<
%for (var i =0; i
<subway
Cnt
;
i
++){%
>
<
%for (var i =0; i
<subway
Stations
.
length
;
i
++){%
>
<li>
<
%=subwayStations[i]%>
<
%=subwayStations[i]
.stationName
%>
</li>
<
%}%>
<h3>
총 지하철역 개수 :
<
%=subway
Cnt
%>
<
%=subway
Stations.length
%>
</h3>
<h3>
총 대중교통 개수 :
<
%=
total
%>
<
%=
busStations.length + subwayStations.length
%>
</h3>
...
...
Please
register
or
login
to post a comment