Skip to content

Commit

Permalink
refactor: 메서드 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
drunkenhw committed Oct 19, 2023
1 parent 14db1b3 commit 32ec49d
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@Getter
public class Grid {

private static final BigDecimal HALF = BigDecimal.valueOf(2);

private final Point top;
private final Point bottom;
private final List<Point> points;
Expand Down Expand Up @@ -43,13 +45,15 @@ public boolean isContain(Point point) {
public BigDecimal calculateCenterLatitude() {
Latitude topLatitude = top.getLatitude();
Latitude bottomLatitude = bottom.getLatitude();
return topLatitude.add(bottomLatitude).divide(BigDecimal.valueOf(2), 4, RoundingMode.CEILING);
BigDecimal latitudeDistance = topLatitude.add(bottomLatitude);
return latitudeDistance.divide(HALF, 4, RoundingMode.CEILING);
}

public BigDecimal calculateCenterLongitude() {
Longitude topLongitude = top.getLongitude();
Longitude bottomLongitude = bottom.getLongitude();
return topLongitude.add(bottomLongitude).divide(BigDecimal.valueOf(2), 4, RoundingMode.CEILING);
BigDecimal longitudeDistance = topLongitude.add(bottomLongitude);
return longitudeDistance.divide(HALF, 4, RoundingMode.CEILING);
}

public Point randomPoint() {
Expand Down

0 comments on commit 32ec49d

Please sign in to comment.