Suyeon Jung

Modify transport query string(radius)

......@@ -33,6 +33,8 @@ let shop_A = 5;
let shop_B = 2;
let gym_A = 20;
let gym_B = 10;
let trans_A = 2;
let trans_B = 1;
......@@ -383,9 +385,8 @@ router.get('/transport', function(req, res) {
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 qs = `?lang=0&x=${user_latitude}&y=${user_longitude}&radius=2000&stationClass=2&apiKey=${ODSAY_API_KEY}`;
request({
url: bus_url + qs,
......@@ -393,14 +394,14 @@ router.get('/transport', function(req, res) {
}, function(err, response, body) {
if (!err && res.statusCode == 200) {
//console.log("inside");
let bus_result = JSON.parse(body);
// console.log('bus_result', bus_result.result.station);
console.log('bus_result', bus_result);
let busStations = [];
for (let i = 0; i < bus_result.result.station.length; i++) {
station = bus_result.result.station[i];
busStations.push(station);
}
bus_grade = evalGrade(trans_A, trans_B, busStations.length);
request({
url: subway_url + qs,
method: 'GET'
......@@ -412,9 +413,11 @@ router.get('/transport', function(req, res) {
station = subway_result.result.station[i];
subwayStations.push(station);
}
sub_grade = evalGrade(trans_A, trans_B, subwayStations.length);
grade = avgGrade(bus_grade, sub_grade);
console.log(busStations);
console.log('subwayStaions', subwayStations);
res.render('result', { category: 'transport', busStations: busStations, subwayStations: subwayStations, userLocation: userLocation, grade: 'A' })
res.render('result', { category: 'transport', busStations: busStations, subwayStations: subwayStations, userLocation: userLocation, grade: grade })
}
})
......