Showing
1 changed file
with
9 additions
and
6 deletions
... | @@ -33,6 +33,8 @@ let shop_A = 5; | ... | @@ -33,6 +33,8 @@ let shop_A = 5; |
33 | let shop_B = 2; | 33 | let shop_B = 2; |
34 | let gym_A = 20; | 34 | let gym_A = 20; |
35 | let gym_B = 10; | 35 | let gym_B = 10; |
36 | +let trans_A = 2; | ||
37 | +let trans_B = 1; | ||
36 | 38 | ||
37 | 39 | ||
38 | 40 | ||
... | @@ -383,9 +385,8 @@ router.get('/transport', function(req, res) { | ... | @@ -383,9 +385,8 @@ router.get('/transport', function(req, res) { |
383 | 385 | ||
384 | let bus_url = 'https://api.odsay.com/v1/api/pointSearch?'; | 386 | let bus_url = 'https://api.odsay.com/v1/api/pointSearch?'; |
385 | let subway_url = 'https://api.odsay.com/v1/api/pointSearch?'; | 387 | let subway_url = 'https://api.odsay.com/v1/api/pointSearch?'; |
386 | - let qs = `?lang=0&x=${user_latitude}&y=${user_longitude}&radius=1000&stationClass=2&apiKey=${ODSAY_API_KEY}`; | 388 | + let qs = `?lang=0&x=${user_latitude}&y=${user_longitude}&radius=2000&stationClass=2&apiKey=${ODSAY_API_KEY}`; |
387 | - let busCnt = 0; | 389 | + |
388 | - let subwayCnt = 0; | ||
389 | 390 | ||
390 | request({ | 391 | request({ |
391 | url: bus_url + qs, | 392 | url: bus_url + qs, |
... | @@ -393,14 +394,14 @@ router.get('/transport', function(req, res) { | ... | @@ -393,14 +394,14 @@ router.get('/transport', function(req, res) { |
393 | }, function(err, response, body) { | 394 | }, function(err, response, body) { |
394 | 395 | ||
395 | if (!err && res.statusCode == 200) { | 396 | if (!err && res.statusCode == 200) { |
396 | - //console.log("inside"); | ||
397 | let bus_result = JSON.parse(body); | 397 | let bus_result = JSON.parse(body); |
398 | - // console.log('bus_result', bus_result.result.station); | 398 | + console.log('bus_result', bus_result); |
399 | let busStations = []; | 399 | let busStations = []; |
400 | for (let i = 0; i < bus_result.result.station.length; i++) { | 400 | for (let i = 0; i < bus_result.result.station.length; i++) { |
401 | station = bus_result.result.station[i]; | 401 | station = bus_result.result.station[i]; |
402 | busStations.push(station); | 402 | busStations.push(station); |
403 | } | 403 | } |
404 | + bus_grade = evalGrade(trans_A, trans_B, busStations.length); | ||
404 | request({ | 405 | request({ |
405 | url: subway_url + qs, | 406 | url: subway_url + qs, |
406 | method: 'GET' | 407 | method: 'GET' |
... | @@ -412,9 +413,11 @@ router.get('/transport', function(req, res) { | ... | @@ -412,9 +413,11 @@ router.get('/transport', function(req, res) { |
412 | station = subway_result.result.station[i]; | 413 | station = subway_result.result.station[i]; |
413 | subwayStations.push(station); | 414 | subwayStations.push(station); |
414 | } | 415 | } |
416 | + sub_grade = evalGrade(trans_A, trans_B, subwayStations.length); | ||
417 | + grade = avgGrade(bus_grade, sub_grade); | ||
415 | console.log(busStations); | 418 | console.log(busStations); |
416 | console.log('subwayStaions', subwayStations); | 419 | console.log('subwayStaions', subwayStations); |
417 | - res.render('result', { category: 'transport', busStations: busStations, subwayStations: subwayStations, userLocation: userLocation, grade: 'A' }) | 420 | + res.render('result', { category: 'transport', busStations: busStations, subwayStations: subwayStations, userLocation: userLocation, grade: grade }) |
418 | } | 421 | } |
419 | }) | 422 | }) |
420 | 423 | ... | ... |
-
Please register or login to post a comment