Skip to content

Commit

Permalink
[UNI-352] refactor : DangerFactors 누락 추가 (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
thdgustjd1 authored Feb 20, 2025
1 parent 08f8dd0 commit 2c36757
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.softeer5.uniro_backend.map.dto.response;

import com.softeer5.uniro_backend.map.enums.CautionFactor;
import com.softeer5.uniro_backend.map.enums.DangerFactor;
import com.softeer5.uniro_backend.map.enums.DirectionType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
Expand All @@ -22,10 +23,13 @@ public class RouteDetailResDTO {
private final Map<String, Double> coordinates;
@Schema(description = "주의 요소 타입 리스트", example = "[\"SLOPE\", \"STAIRS\"]")
private final List<CautionFactor> cautionFactors;
@Schema(description = "위험 요소 타입 리스트", example = "[\"SLOPE\", \"STAIRS\"]")
private final List<DangerFactor> dangerFactors;

public static RouteDetailResDTO of(double dist, DirectionType directionType,
Map<String, Double> coordinates,
List<CautionFactor> cautionFactors) {
return new RouteDetailResDTO(dist, directionType, coordinates, cautionFactors);
List<CautionFactor> cautionFactors,
List<DangerFactor> dangerFactors) {
return new RouteDetailResDTO(dist, directionType, coordinates, cautionFactors, dangerFactors);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.softeer5.uniro_backend.map.entity.*;
import com.softeer5.uniro_backend.map.dto.request.CreateRouteReqDTO;
import com.softeer5.uniro_backend.map.enums.CautionFactor;
import com.softeer5.uniro_backend.map.enums.DangerFactor;
import com.softeer5.uniro_backend.map.enums.DirectionType;
import com.softeer5.uniro_backend.map.entity.Route;
import lombok.AllArgsConstructor;
Expand Down Expand Up @@ -362,6 +363,7 @@ private List<RouteDetailResDTO> getRouteDetail(Node startNode, Node endNode, Lis
Map<String,Double> checkPointNodeCoordinates = startNode.getXY();
DirectionType checkPointType = DirectionType.STRAIGHT;
List<CautionFactor> checkPointCautionFactors = new ArrayList<>();
List<DangerFactor> checkPointDangerFactors = new ArrayList<>();

// 길찾기 결과 상세정보 정리
for(int i=0;i<shortestRoutes.size();i++){
Expand All @@ -372,7 +374,7 @@ private List<RouteDetailResDTO> getRouteDetail(Node startNode, Node endNode, Lis
if(!nowRoute.getCautionFactors().isEmpty()){
double halfOfRouteDistance = calculateRouteDistance(nowRoute)/2;
details.add(RouteDetailResDTO.of(accumulatedDistance - halfOfRouteDistance,
checkPointType, checkPointNodeCoordinates, checkPointCautionFactors));
checkPointType, checkPointNodeCoordinates, checkPointCautionFactors, checkPointDangerFactors));
accumulatedDistance = halfOfRouteDistance;
checkPointNodeCoordinates = getCenter(now, nxt);
checkPointType = DirectionType.CAUTION;
Expand All @@ -382,17 +384,17 @@ private List<RouteDetailResDTO> getRouteDetail(Node startNode, Node endNode, Lis
if(!nowRoute.getDangerFactors().isEmpty()){
double halfOfRouteDistance = calculateRouteDistance(nowRoute)/2;
details.add(RouteDetailResDTO.of(accumulatedDistance - halfOfRouteDistance,
checkPointType, checkPointNodeCoordinates, checkPointCautionFactors));
checkPointType, checkPointNodeCoordinates, checkPointCautionFactors, checkPointDangerFactors));
accumulatedDistance = halfOfRouteDistance;
checkPointNodeCoordinates = getCenter(now, nxt);
checkPointType = DirectionType.DANGER;
checkPointCautionFactors = nowRoute.getCautionFactorsByList();
checkPointDangerFactors = nowRoute.getDangerFactorsByList();
}

if(nxt.equals(endNode)){
details.add(RouteDetailResDTO.of(accumulatedDistance, checkPointType,
checkPointNodeCoordinates, checkPointCautionFactors));
details.add(RouteDetailResDTO.of(0, DirectionType.FINISH, nxt.getXY(), new ArrayList<>()));
checkPointNodeCoordinates, checkPointCautionFactors, checkPointDangerFactors));
details.add(RouteDetailResDTO.of(0, DirectionType.FINISH, nxt.getXY(), new ArrayList<>(), new ArrayList<>()));
break;
}
if(nxt.isCore()){
Expand All @@ -403,11 +405,12 @@ private List<RouteDetailResDTO> getRouteDetail(Node startNode, Node endNode, Lis
continue;
}
details.add(RouteDetailResDTO.of(accumulatedDistance, checkPointType,
checkPointNodeCoordinates, checkPointCautionFactors));
checkPointNodeCoordinates, checkPointCautionFactors, checkPointDangerFactors));
checkPointNodeCoordinates = nxt.getXY();
checkPointType = directionType;
accumulatedDistance = 0.0;
checkPointCautionFactors = Collections.emptyList();
checkPointDangerFactors = Collections.emptyList();
}

now = nxt;
Expand Down

0 comments on commit 2c36757

Please sign in to comment.