Skip to content

Commit

Permalink
[Chore] 위도경도 자료형 수정
Browse files Browse the repository at this point in the history
Float -> Double
  • Loading branch information
choeun7 committed Feb 18, 2024
1 parent c02f23f commit 6940213
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,17 @@ public List<Comment> getAllComments() {
// AR뷰를 위한 댓글 조회
public ResponseEntity<?> getCommentForAR(GetCommentReq getCommentReq) {

Float userLatitude = getCommentReq.getLatitude();
Float userLongitude = getCommentReq.getLongitude();
Double userLatitude = getCommentReq.getLatitude();
Double userLongitude = getCommentReq.getLongitude();

List<Comment> allComments = getAllComments();
Double radius = 20.0; // 반경값 확인 필요
List<GetCommentRes> showComments = new ArrayList<>();

for (Comment comment : allComments) {

Float commentLatitude = comment.getLatitude();
Float commentLongitude = comment.getLongitude();
Double commentLatitude = comment.getLatitude();
Double commentLongitude = comment.getLongitude();

double distance = calculateDistance(userLatitude, userLongitude, commentLatitude, commentLongitude);

Expand All @@ -153,7 +153,7 @@ public ResponseEntity<?> getCommentForAR(GetCommentReq getCommentReq) {
}

// 거리 계산
private double calculateDistance(Float lat1, Float lon1, Float lat2, Float lon2) {
private double calculateDistance(Double lat1, Double lon1, Double lat2, Double lon2) {
double R = 6371; // 지구 반지름

double dLat = Math.toRadians(lat2 - lat1);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/ttubeog/domain/comment/domain/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public class Comment extends BaseEntity {
private String content;

@Column(name = "latitude")
private Float latitude;
private Double latitude;

@Column(name = "longitude")
private Float longitude;
private Double longitude;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
public class GetCommentReq {

@Schema(description = "사용자 위치 위도값")
private Float latitude;
private Double latitude;

@Schema(description = "사용자 위치 경도값")
private Float longitude;
private Double longitude;

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class WriteCommentReq {
@Schema(description = "댓글 내용")
private String content;
@Schema(description = "위도")
private Float latitude;
private Double latitude;
@Schema(description = "경도")
private Float longitude;
private Double longitude;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ public class WriteCommentRes {
private String content;

@Schema(description = "위도")
private Float latitude;
private Double latitude;

@Schema(description = "경도")
private Float longitude;
private Double longitude;

@Builder
public WriteCommentRes(Long commentId, Long memberId, String content, Float latitude, Float longitude) {
public WriteCommentRes(Long commentId, Long memberId, String content, Double latitude, Double longitude) {
this.commentId = commentId;
this.memberId = memberId;
this.content = content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,8 @@ private GetAllPlaceRes mapSpotToDto(HttpServletRequest request, Spot spot) {
.memberId(spot.getMember().getId())
.name(spot.getName())
.info(spot.getInfo())
// 위도, 경도 double로 변경 필요
//.latitude(spot.getLatitude())
//.longitude(spot.getLongitude())
.latitude(spot.getLatitude())
.longitude(spot.getLongitude())
.image(representativeImageUrl)
.stars(spot.getStars())
.guestbookCount(intValue(guestBookRepository.countAllBySpot(spot)))
Expand Down

0 comments on commit 6940213

Please sign in to comment.