public StoreResponse.StoreInfoDTO getStoreInfo(int userId, int storeId, double customerLatitude, double customerLongitude) {
Store store = storeRepository.findById(storeId)
.orElseThrow(() -> new Exception404("찾을 수 없는 매장입니다."));
...생략
int distance = DistanceUtil.calculateDistance(customerLatitude, customerLongitude, store.getLatitude(), store.getLongitude());
return new StoreResponse.StoreInfoDTO(store, likeCount, isLiked, reviewCount, distance);
}
⚒️ 수정사항: 가게 목록보기 가까운 거리순으로 정렬, distance를 String으로 반환하던 것 int로 변경
✔️ 손님-가게 거리 계산
🐯 DistanceUtil
거리 계산하는 유틸이 필요함. 두 지점의 위도와 경도를 입력받아, 구면 삼각법(Haversine 공식)을 적용하여 두 지점 사이의 거리를 계산하고, 그 거리를 미터 단위로 반환함.
🐯 StoreService.getStoreInfo()