fix logic bug, no exception should be thrown if weather is bad

This commit is contained in:
2026-02-22 17:51:06 +01:00
parent 16bf41beaa
commit 0bc692d64a
@@ -82,14 +82,16 @@ public class AlternativeFilterService {
ArrayList<RouteDTO> filteredAlternatives = new ArrayList<>();
for (RouteDTO route : alternatives) {
if (route.isPhysicalActivity()) {
if (!route.isCyclingRoute() && !route.isWalkingRoute()) {
throw new RuntimeException("Unexpected case of a physical activity route that is not pure cycling or walking");
}
var weatherConditions = forecast.getWeatherConditionsBetween(route.getStartDateTime(), route.getEndDateTime());
if (route.isCyclingRoute() && allConditionsAcceptable(weatherConditions, routingProperties.getAcceptableCyclingConditions())) {
filteredAlternatives.add(route);
} else if (route.isWalkingRoute() && allConditionsAcceptable(weatherConditions, routingProperties.getAcceptableWalkingConditions())) {
filteredAlternatives.add(route);
} else {
throw new RuntimeException("Unexpected case of a physical activity route that is not pure cycling or walking");
}
// else: weather conditions not acceptable, route is silently dropped
} else {
filteredAlternatives.add(route);
}