Suyeon Jung

Modify userArea function

......@@ -13,6 +13,8 @@ let user_dong;
let userLocation;
let user_latitude;
let user_longitude;
// 결과 중 사용자 근처인지 검사하기 위한 변수
let user_target;
let sigun = [{
sigun_name: '가평군',
sigun_code: 41820
......@@ -158,9 +160,15 @@ router.post('/', function(req, res) {
user_gu = req.body.gu;
user_dong = req.body.dong;
userLocation = `${user_sigun} ${user_gu} ${user_dong}`;
console.log(user_sigun);
console.log(user_gu);
console.log(user_dong);
if (user_gu == '') {
user_target = user_dong;
} else {
user_target = user_gu;
}
console.log('user_sigun', user_sigun);
console.log('user_gu', user_gu);
console.log('user_dong', user_dong);
let KAKAO_API_KEY = process.env.KAKAO_APIKEY;
let kakaoOptions = {
url: 'https://dapi.kakao.com/v2/local/search/address.json',
......@@ -213,7 +221,7 @@ router.get('/food', function(req, res) {
for (let i = 0; i < food_result.PlaceThatDoATasteyFoodSt[1].row.length; i++) {
// 상호명, 음식명, 전화번호, 도로명주소(REFINE_ROADNM_ADDR), 지번 주소(REFINE_LOTNO_ADDR)
store = food_result.PlaceThatDoATasteyFoodSt[1].row[i];
if (userArea(store, 'REFINE_LOTNO_ADDR', user_dong)) {
if (userArea(store, 'REFINE_LOTNO_ADDR', user_target)) {
console.log('store', store);
stores.push(store);
}
......@@ -230,7 +238,7 @@ router.get('/food', function(req, res) {
for (let i = 0; i < fast_food_result.Genrestrtfastfood[1].row.length; i++) {
fast_food_store = fast_food_result.Genrestrtfastfood[1].row[i];
// 폐업인 지점 제외
if (fast_food_store['BSN_STATE_NM'] != '폐업' && userArea(fast_food_store, 'REFINE_LOTNO_ADDR', user_dong)) {
if (fast_food_store['BSN_STATE_NM'] != '폐업' && userArea(fast_food_store, 'REFINE_LOTNO_ADDR', user_target)) {
console.log('fast_store_name', fast_food_store);
fast_food_stores.push(fast_food_store);
}
......@@ -259,7 +267,7 @@ router.get('/school', function(req, res) {
let librarys = [];
for (let i = 0; i < library_result.Tbggibllbrm[1].row.length; i++) {
library = library_result.Tbggibllbrm[1].row[i];
if (userArea(library, 'REFINE_LOTNO_ADDR', user_dong)) {
if (userArea(library, 'REFINE_LOTNO_ADDR', user_target)) {
console.log('library', library);
librarys.push(library);
}
......@@ -275,7 +283,7 @@ router.get('/school', function(req, res) {
let institutes = [];
for (let i = 0; i < institute_result.TninsttInstutM[1].row.length; i++) {
institute = institute_result.TninsttInstutM[1].row[i];
if (userArea(institute, 'REFINE_LOTNO_ADDR', user_dong)) {
if (userArea(institute, 'REFINE_LOTNO_ADDR', user_target)) {
console.log('institute', institute);
institutes.push(institute);
}
......@@ -302,7 +310,7 @@ router.get('/park', function(req, res) {
let city_parks = [];
for (let i = 0; i < city_park_result.CityPark[1].row.length; i++) {
city_park = city_park_result.CityPark[1].row[i];
if (userArea(city_park, 'REFINE_LOTNO_ADDR', user_dong)) {
if (userArea(city_park, 'REFINE_LOTNO_ADDR', user_target)) {
city_parks.push(city_park);
}
}
......@@ -375,7 +383,7 @@ router.get('/safe', function(req, res) {
console.log(cctv_result);
for (let i = 0; i < cctv_result.CCTV[1].row.length; i++) {
cctv = cctv_result.CCTV[1].row[i];
if (userArea(cctv, 'REFINE_LOTNO_ADDR', user_dong)) {
if (userArea(cctv, 'REFINE_LOTNO_ADDR', user_target)) {
console.log('cctv', cctv);
cctvs.push(cctv);
}
......@@ -390,7 +398,7 @@ router.get('/safe', function(req, res) {
console.log(light_result);
for (let i = 0; i < light_result.SECRTLGT[1].row.length; i++) {
light = light_result.SECRTLGT[1].row[i];
if (userArea(light, 'REFINE_LOTNO_ADDR', user_dong)) {
if (userArea(light, 'REFINE_LOTNO_ADDR', user_target)) {
console.log('light', light);
lights.push(light);
}
......@@ -418,7 +426,7 @@ router.get('/culture', function(req, res) {
for (let i = 0; i < movie_result.MovieTheater[1].row.length; i++) {
movie = movie_result.MovieTheater[1].row[i];
// 폐업인 지점 제외
if (!movie['BSN_STATE_NM'].includes('폐업') && userArea(movie, 'REFINE_LOTNO_ADDR', user_dong)) {
if (!movie['BSN_STATE_NM'].includes('폐업') && userArea(movie, 'REFINE_LOTNO_ADDR', user_target)) {
console.log('movie', movie);
movies.push(movie);
}
......@@ -443,7 +451,7 @@ router.get('/shop', function(req, res) {
for (let i = 0; i < shop_result.MrktStoreM[1].row.length; i++) {
shop = shop_result.MrktStoreM[1].row[i];
// 폐업인 지점 제외
if (userArea(shop, 'REFINE_LOTNO_ADDR', user_dong)) {
if (userArea(shop, 'REFINE_LOTNO_ADDR', user_target)) {
console.log('shop', shop);
shops.push(shop);
}
......@@ -468,7 +476,7 @@ router.get('/gym', function(req, res) {
for (let i = 0; i < gym_result.PhysicaFitnessTrainingPlace[1].row.length; i++) {
gym = gym_result.PhysicaFitnessTrainingPlace[1].row[i];
console.log(gym);
if (userArea(gym, 'REFINE_LOTNO_ADDR', user_dong)) {
if (userArea(gym, 'REFINE_LOTNO_ADDR', user_target)) {
console.log('gym', gym);
gyms.push(gym);
}
......