Skip to content

Commit

Permalink
[UNI-344] fix : 도보에서는 위험요소도 반영되도록 변경 (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
thdgustjd1 authored Feb 20, 2025
1 parent 6ce7eb4 commit c25a612
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
public class FastestRouteResDTO {
@Schema(description = "길찾기 타입 (PEDES-도보, WHEEL_FAST-휠체어빠른, WHEEL_SAFE-휠체어안전)", example = "PEDES")
private final RoadExclusionPolicy routeType;
@Schema(description = "길 찾기 결과에 위험요소가 포함되어있는지 여부", example = "true")
@Schema(description = "길 찾기 결과에 주의요소가 포함되어있는지 여부", example = "true")
private final boolean hasCaution;
@Schema(description = "길 찾기 결과에 위험요소가 포함되어있는지 여부", example = "true")
private final boolean hasDanger;
@Schema(description = "총 이동거리", example = "150.3421234")
private final double totalDistance;
@Schema(description = "총 걸리는 시간(초) - 도보", example = "1050.32198432")
Expand All @@ -31,6 +33,7 @@ public class FastestRouteResDTO {

public static FastestRouteResDTO of(RoadExclusionPolicy routeType,
boolean hasCaution,
boolean hasDanger,
double totalDistance,
Double pedestrianTotalCost,
Double manualTotalCost,
Expand All @@ -39,6 +42,7 @@ public static FastestRouteResDTO of(RoadExclusionPolicy routeType,
List<RouteDetailResDTO> routeDetails) {
return new FastestRouteResDTO(routeType,
hasCaution,
hasDanger,
totalDistance,
pedestrianTotalCost,
manualTotalCost,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public enum DirectionType {
SHARP_RIGHT, // 큰 우회전
SHARP_LEFT, // 큰 좌회전
FINISH, // 도착점
CAUTION; //위험요소
CAUTION, // 주의요소
DANGER; // 위험요소
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public List<FastestRouteResDTO> calculateFastestRoute(Long startNodeId, Long end
}

boolean hasCaution = false;
boolean hasDanger = false;
double totalDistance = 0.0;

// 결과를 DTO로 정리
Expand All @@ -146,6 +147,9 @@ public List<FastestRouteResDTO> calculateFastestRoute(Long startNodeId, Long end
if (!route.getCautionFactors().isEmpty()) {
hasCaution = true;
}
if(!route.getDangerFactors().isEmpty()){
hasDanger = true;
}

Node firstNode = route.getNode1();
Node secondNode = route.getNode2();
Expand All @@ -164,7 +168,7 @@ public List<FastestRouteResDTO> calculateFastestRoute(Long startNodeId, Long end

List<RouteDetailResDTO> details = getRouteDetail(startNode, endNode, shortestRoutes);

result.add(FastestRouteResDTO.of(policy, hasCaution, totalDistance,
result.add(FastestRouteResDTO.of(policy, hasCaution, hasDanger, totalDistance,
calculateCost(policy, PEDESTRIAN_SECONDS_PER_MITER, totalDistance),
calculateCost(policy, MANUAL_WHEELCHAIR_SECONDS_PER_MITER,totalDistance),
calculateCost(policy, ELECTRIC_WHEELCHAIR_SECONDS_PER_MITER,totalDistance),
Expand Down Expand Up @@ -375,6 +379,16 @@ private List<RouteDetailResDTO> getRouteDetail(Node startNode, Node endNode, Lis
checkPointCautionFactors = nowRoute.getCautionFactorsByList();
}

if(!nowRoute.getDangerFactors().isEmpty()){
double halfOfRouteDistance = calculateRouteDistance(nowRoute)/2;
details.add(RouteDetailResDTO.of(accumulatedDistance - halfOfRouteDistance,
checkPointType, checkPointNodeCoordinates, checkPointCautionFactors));
accumulatedDistance = halfOfRouteDistance;
checkPointNodeCoordinates = getCenter(now, nxt);
checkPointType = DirectionType.DANGER;
checkPointCautionFactors = nowRoute.getCautionFactorsByList();
}

if(nxt.equals(endNode)){
details.add(RouteDetailResDTO.of(accumulatedDistance, checkPointType,
checkPointNodeCoordinates, checkPointCautionFactors));
Expand Down

0 comments on commit c25a612

Please sign in to comment.