Showing
1 changed file
with
21 additions
and
13 deletions
... | @@ -13,6 +13,8 @@ let user_dong; | ... | @@ -13,6 +13,8 @@ let user_dong; |
13 | let userLocation; | 13 | let userLocation; |
14 | let user_latitude; | 14 | let user_latitude; |
15 | let user_longitude; | 15 | let user_longitude; |
16 | +// 결과 중 사용자 근처인지 검사하기 위한 변수 | ||
17 | +let user_target; | ||
16 | let sigun = [{ | 18 | let sigun = [{ |
17 | sigun_name: '가평군', | 19 | sigun_name: '가평군', |
18 | sigun_code: 41820 | 20 | sigun_code: 41820 |
... | @@ -158,9 +160,15 @@ router.post('/', function(req, res) { | ... | @@ -158,9 +160,15 @@ router.post('/', function(req, res) { |
158 | user_gu = req.body.gu; | 160 | user_gu = req.body.gu; |
159 | user_dong = req.body.dong; | 161 | user_dong = req.body.dong; |
160 | userLocation = `${user_sigun} ${user_gu} ${user_dong}`; | 162 | userLocation = `${user_sigun} ${user_gu} ${user_dong}`; |
161 | - console.log(user_sigun); | 163 | + if (user_gu == '') { |
162 | - console.log(user_gu); | 164 | + user_target = user_dong; |
163 | - console.log(user_dong); | 165 | + } else { |
166 | + user_target = user_gu; | ||
167 | + } | ||
168 | + console.log('user_sigun', user_sigun); | ||
169 | + console.log('user_gu', user_gu); | ||
170 | + console.log('user_dong', user_dong); | ||
171 | + | ||
164 | let KAKAO_API_KEY = process.env.KAKAO_APIKEY; | 172 | let KAKAO_API_KEY = process.env.KAKAO_APIKEY; |
165 | let kakaoOptions = { | 173 | let kakaoOptions = { |
166 | url: 'https://dapi.kakao.com/v2/local/search/address.json', | 174 | url: 'https://dapi.kakao.com/v2/local/search/address.json', |
... | @@ -213,7 +221,7 @@ router.get('/food', function(req, res) { | ... | @@ -213,7 +221,7 @@ router.get('/food', function(req, res) { |
213 | for (let i = 0; i < food_result.PlaceThatDoATasteyFoodSt[1].row.length; i++) { | 221 | for (let i = 0; i < food_result.PlaceThatDoATasteyFoodSt[1].row.length; i++) { |
214 | // 상호명, 음식명, 전화번호, 도로명주소(REFINE_ROADNM_ADDR), 지번 주소(REFINE_LOTNO_ADDR) | 222 | // 상호명, 음식명, 전화번호, 도로명주소(REFINE_ROADNM_ADDR), 지번 주소(REFINE_LOTNO_ADDR) |
215 | store = food_result.PlaceThatDoATasteyFoodSt[1].row[i]; | 223 | store = food_result.PlaceThatDoATasteyFoodSt[1].row[i]; |
216 | - if (userArea(store, 'REFINE_LOTNO_ADDR', user_dong)) { | 224 | + if (userArea(store, 'REFINE_LOTNO_ADDR', user_target)) { |
217 | console.log('store', store); | 225 | console.log('store', store); |
218 | stores.push(store); | 226 | stores.push(store); |
219 | } | 227 | } |
... | @@ -230,7 +238,7 @@ router.get('/food', function(req, res) { | ... | @@ -230,7 +238,7 @@ router.get('/food', function(req, res) { |
230 | for (let i = 0; i < fast_food_result.Genrestrtfastfood[1].row.length; i++) { | 238 | for (let i = 0; i < fast_food_result.Genrestrtfastfood[1].row.length; i++) { |
231 | fast_food_store = fast_food_result.Genrestrtfastfood[1].row[i]; | 239 | fast_food_store = fast_food_result.Genrestrtfastfood[1].row[i]; |
232 | // 폐업인 지점 제외 | 240 | // 폐업인 지점 제외 |
233 | - if (fast_food_store['BSN_STATE_NM'] != '폐업' && userArea(fast_food_store, 'REFINE_LOTNO_ADDR', user_dong)) { | 241 | + if (fast_food_store['BSN_STATE_NM'] != '폐업' && userArea(fast_food_store, 'REFINE_LOTNO_ADDR', user_target)) { |
234 | console.log('fast_store_name', fast_food_store); | 242 | console.log('fast_store_name', fast_food_store); |
235 | fast_food_stores.push(fast_food_store); | 243 | fast_food_stores.push(fast_food_store); |
236 | } | 244 | } |
... | @@ -259,7 +267,7 @@ router.get('/school', function(req, res) { | ... | @@ -259,7 +267,7 @@ router.get('/school', function(req, res) { |
259 | let librarys = []; | 267 | let librarys = []; |
260 | for (let i = 0; i < library_result.Tbggibllbrm[1].row.length; i++) { | 268 | for (let i = 0; i < library_result.Tbggibllbrm[1].row.length; i++) { |
261 | library = library_result.Tbggibllbrm[1].row[i]; | 269 | library = library_result.Tbggibllbrm[1].row[i]; |
262 | - if (userArea(library, 'REFINE_LOTNO_ADDR', user_dong)) { | 270 | + if (userArea(library, 'REFINE_LOTNO_ADDR', user_target)) { |
263 | console.log('library', library); | 271 | console.log('library', library); |
264 | librarys.push(library); | 272 | librarys.push(library); |
265 | } | 273 | } |
... | @@ -275,7 +283,7 @@ router.get('/school', function(req, res) { | ... | @@ -275,7 +283,7 @@ router.get('/school', function(req, res) { |
275 | let institutes = []; | 283 | let institutes = []; |
276 | for (let i = 0; i < institute_result.TninsttInstutM[1].row.length; i++) { | 284 | for (let i = 0; i < institute_result.TninsttInstutM[1].row.length; i++) { |
277 | institute = institute_result.TninsttInstutM[1].row[i]; | 285 | institute = institute_result.TninsttInstutM[1].row[i]; |
278 | - if (userArea(institute, 'REFINE_LOTNO_ADDR', user_dong)) { | 286 | + if (userArea(institute, 'REFINE_LOTNO_ADDR', user_target)) { |
279 | console.log('institute', institute); | 287 | console.log('institute', institute); |
280 | institutes.push(institute); | 288 | institutes.push(institute); |
281 | } | 289 | } |
... | @@ -302,7 +310,7 @@ router.get('/park', function(req, res) { | ... | @@ -302,7 +310,7 @@ router.get('/park', function(req, res) { |
302 | let city_parks = []; | 310 | let city_parks = []; |
303 | for (let i = 0; i < city_park_result.CityPark[1].row.length; i++) { | 311 | for (let i = 0; i < city_park_result.CityPark[1].row.length; i++) { |
304 | city_park = city_park_result.CityPark[1].row[i]; | 312 | city_park = city_park_result.CityPark[1].row[i]; |
305 | - if (userArea(city_park, 'REFINE_LOTNO_ADDR', user_dong)) { | 313 | + if (userArea(city_park, 'REFINE_LOTNO_ADDR', user_target)) { |
306 | city_parks.push(city_park); | 314 | city_parks.push(city_park); |
307 | } | 315 | } |
308 | } | 316 | } |
... | @@ -375,7 +383,7 @@ router.get('/safe', function(req, res) { | ... | @@ -375,7 +383,7 @@ router.get('/safe', function(req, res) { |
375 | console.log(cctv_result); | 383 | console.log(cctv_result); |
376 | for (let i = 0; i < cctv_result.CCTV[1].row.length; i++) { | 384 | for (let i = 0; i < cctv_result.CCTV[1].row.length; i++) { |
377 | cctv = cctv_result.CCTV[1].row[i]; | 385 | cctv = cctv_result.CCTV[1].row[i]; |
378 | - if (userArea(cctv, 'REFINE_LOTNO_ADDR', user_dong)) { | 386 | + if (userArea(cctv, 'REFINE_LOTNO_ADDR', user_target)) { |
379 | console.log('cctv', cctv); | 387 | console.log('cctv', cctv); |
380 | cctvs.push(cctv); | 388 | cctvs.push(cctv); |
381 | } | 389 | } |
... | @@ -390,7 +398,7 @@ router.get('/safe', function(req, res) { | ... | @@ -390,7 +398,7 @@ router.get('/safe', function(req, res) { |
390 | console.log(light_result); | 398 | console.log(light_result); |
391 | for (let i = 0; i < light_result.SECRTLGT[1].row.length; i++) { | 399 | for (let i = 0; i < light_result.SECRTLGT[1].row.length; i++) { |
392 | light = light_result.SECRTLGT[1].row[i]; | 400 | light = light_result.SECRTLGT[1].row[i]; |
393 | - if (userArea(light, 'REFINE_LOTNO_ADDR', user_dong)) { | 401 | + if (userArea(light, 'REFINE_LOTNO_ADDR', user_target)) { |
394 | console.log('light', light); | 402 | console.log('light', light); |
395 | lights.push(light); | 403 | lights.push(light); |
396 | } | 404 | } |
... | @@ -418,7 +426,7 @@ router.get('/culture', function(req, res) { | ... | @@ -418,7 +426,7 @@ router.get('/culture', function(req, res) { |
418 | for (let i = 0; i < movie_result.MovieTheater[1].row.length; i++) { | 426 | for (let i = 0; i < movie_result.MovieTheater[1].row.length; i++) { |
419 | movie = movie_result.MovieTheater[1].row[i]; | 427 | movie = movie_result.MovieTheater[1].row[i]; |
420 | // 폐업인 지점 제외 | 428 | // 폐업인 지점 제외 |
421 | - if (!movie['BSN_STATE_NM'].includes('폐업') && userArea(movie, 'REFINE_LOTNO_ADDR', user_dong)) { | 429 | + if (!movie['BSN_STATE_NM'].includes('폐업') && userArea(movie, 'REFINE_LOTNO_ADDR', user_target)) { |
422 | console.log('movie', movie); | 430 | console.log('movie', movie); |
423 | movies.push(movie); | 431 | movies.push(movie); |
424 | } | 432 | } |
... | @@ -443,7 +451,7 @@ router.get('/shop', function(req, res) { | ... | @@ -443,7 +451,7 @@ router.get('/shop', function(req, res) { |
443 | for (let i = 0; i < shop_result.MrktStoreM[1].row.length; i++) { | 451 | for (let i = 0; i < shop_result.MrktStoreM[1].row.length; i++) { |
444 | shop = shop_result.MrktStoreM[1].row[i]; | 452 | shop = shop_result.MrktStoreM[1].row[i]; |
445 | // 폐업인 지점 제외 | 453 | // 폐업인 지점 제외 |
446 | - if (userArea(shop, 'REFINE_LOTNO_ADDR', user_dong)) { | 454 | + if (userArea(shop, 'REFINE_LOTNO_ADDR', user_target)) { |
447 | console.log('shop', shop); | 455 | console.log('shop', shop); |
448 | shops.push(shop); | 456 | shops.push(shop); |
449 | } | 457 | } |
... | @@ -468,7 +476,7 @@ router.get('/gym', function(req, res) { | ... | @@ -468,7 +476,7 @@ router.get('/gym', function(req, res) { |
468 | for (let i = 0; i < gym_result.PhysicaFitnessTrainingPlace[1].row.length; i++) { | 476 | for (let i = 0; i < gym_result.PhysicaFitnessTrainingPlace[1].row.length; i++) { |
469 | gym = gym_result.PhysicaFitnessTrainingPlace[1].row[i]; | 477 | gym = gym_result.PhysicaFitnessTrainingPlace[1].row[i]; |
470 | console.log(gym); | 478 | console.log(gym); |
471 | - if (userArea(gym, 'REFINE_LOTNO_ADDR', user_dong)) { | 479 | + if (userArea(gym, 'REFINE_LOTNO_ADDR', user_target)) { |
472 | console.log('gym', gym); | 480 | console.log('gym', gym); |
473 | gyms.push(gym); | 481 | gyms.push(gym); |
474 | } | 482 | } | ... | ... |
-
Please register or login to post a comment