req.maxCarTime = maxCarTime;
req.minBikeTime = minBikeTime;
req.minCarTime = minCarTime;
req.suboptimalMinutes = suboptimalMinutes;
ProfileRouter router = new ProfileRouter(graph, req);
try {
ProfileResponse response = router.route();
if (req.analyst) {
surfaceCache.add(router.minSurface);
surfaceCache.add(router.maxSurface);
List<TimeSurfaceShort> surfaceShorts = Lists.newArrayList();
surfaceShorts.add(new TimeSurfaceShort(router.minSurface));
surfaceShorts.add(new TimeSurfaceShort(router.maxSurface));
return Response.status(Status.OK).entity(surfaceShorts).build();
} else {
return Response.status(Status.OK).entity(response).build();
}
} finally {
router.cleanup(); // destroy routing contexts even when an exception happens
}
}