Skip to content

Commit

Permalink
Modify: 휠체어리프트 이동경로별로 구분하여 response
Browse files Browse the repository at this point in the history
휠체어리프트 이동경로별로 구분하여 response
  • Loading branch information
sw0501 committed Dec 9, 2022
1 parent 5a3e883 commit d74856f
Showing 1 changed file with 44 additions and 8 deletions.
52 changes: 44 additions & 8 deletions Backend/routes/subwaydata.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ function getLiftMove(stCd, stNm, railCd, lnCd, callback) {
try {

console.log("LiftMove");
//console.log(stNm);

let liftMoveInfo = [];

const url = 'https://openapi.kric.go.kr/openapi/vulnerableUserInfo/stationWheelchairLiftMovement';
let queryParams = '?' + encodeURIComponent('serviceKey');
Expand All @@ -158,13 +159,32 @@ function getLiftMove(stCd, stNm, railCd, lnCd, callback) {

console.log(url + queryParams);



return request({
url: url + queryParams,
method: 'GET'
}, function (error, response, body) {

liftMoveInfo = JSON.parse(body).body;
console.log(liftMoveInfo.length);
//목적지 별로 구분하여 제공
const liftMoveParse = JSON.parse(body).body;

let liftInfo = [];

for (let i = 0; i < liftMoveParse.length; i++) {
if (liftMoveParse[i].mvTpOrdr == 1) {
if (liftInfo.length != 0) {
liftMoveInfo.push(liftInfo);
liftInfo = [];
}
}
liftInfo.push(liftMoveParse[i]);
}
if (liftInfo.length != 0) {
liftMoveInfo.push(liftInfo);
liftInfo = [];
}

callback(liftMoveInfo);
});
}
Expand Down Expand Up @@ -219,12 +239,30 @@ function getElevatorMove(stCd, stNm, railCd, lnCd, callback) {

console.log(url + queryParams);

let elevatorMove = [];

return request({
url: url + queryParams,
method: 'GET'
}, function (error, response, body) {
JSON.parse(body).body;
callback(JSON.parse(body).body);

let count = 0;
let index = "1";
const elevatorMoveParse = JSON.parse(body).body;
for (let i = 0; i < elevatorMoveParse.length; i++) {
let elevatorInfo = [];
if (elevatorMoveParse[i].mvTpOrdr == 1) {
count++;
elevatorInfo.push(elevatorMoveParse[i]);
elevatorMove.push(elevatorInfo);
}
else {

}

}
//11223344 이런형식으로 나옴
callback(elevatorMove);
});
}
catch (e) {
Expand Down Expand Up @@ -529,9 +567,7 @@ router.get('/ElevatorMove/:stCd/:stNm/:railCd/:lnCd', async (req, res) => {

await getElevatorMove(stCd, stNm, railCd, lnCd, callback => {
console.log(callback);
return res.json({
callback
})
return res.json(callback);
});
}
catch (e) {
Expand Down

0 comments on commit d74856f

Please sign in to comment.