implement full service chain where scheduled task detects regular trips every day and schedules notifications with better alternatives if available
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
This commit is contained in:
@@ -142,6 +142,38 @@ public class RoutingService {
|
||||
return routes;
|
||||
}
|
||||
|
||||
public RouteDTO determineBestAlternativeRouteForRegularTrip(RoutingAlternativeRequestDTO requestDTO) {
|
||||
assert requestDTO.getRoutingPreferencesDTO() != null;
|
||||
|
||||
// TODO for now we use adHocRoutingProperties here, in the future we might want to have separate properties for regular trip alternatives
|
||||
List<RouteDTO> routes = getPossibleAlternativeRoutes(requestDTO);
|
||||
routes = alternativeFilterService.filterForAdditionalTravelTime(requestDTO, routes, adHocRoutingProperties);
|
||||
if (requestDTO.getRoutingPreferencesDTO().isConsiderWeatherConditions()) {
|
||||
routes = alternativeFilterService.filterForBadWeather(requestDTO, routes, adHocRoutingProperties);
|
||||
}
|
||||
|
||||
RouteDTO bestRoute = null;
|
||||
// if users wants physical activity, we pick the fastest physical activity route, if any
|
||||
if (requestDTO.getRoutingPreferencesDTO().isPreferPhysicalActivity()) {
|
||||
bestRoute = routes.stream()
|
||||
.filter(RouteDTO::isPhysicalActivity)
|
||||
.min((r1, r2) -> Long.compare(
|
||||
r1.getDurationSeconds(),
|
||||
r2.getDurationSeconds()
|
||||
)).orElse(null);
|
||||
if (bestRoute != null) {
|
||||
return bestRoute;
|
||||
}
|
||||
}
|
||||
// else we pick the fastest route overall
|
||||
bestRoute = routes.stream()
|
||||
.min((r1, r2) -> Long.compare(
|
||||
r1.getDurationSeconds(),
|
||||
r2.getDurationSeconds()
|
||||
)).orElse(null);
|
||||
return bestRoute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns possible alternative routes for the request - no sanity filtering regarding travel times etc. is applied.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user