use of org.opentripplanner.api.model.TimeSurfaceShort in project OpenTripPlanner by opentripplanner.
the class SurfaceResource method createSurface.
@POST
public Response createSurface(@QueryParam("cutoffMinutes") @DefaultValue("90") int cutoffMinutes, @QueryParam("routerId") String routerId) {
// Build the request
try {
// batch must be true
RoutingRequest req = buildRequest();
// routerId is optional -- select default graph if not set
Router router = otpServer.getRouter(routerId);
req.setRoutingContext(router.graph);
EarliestArrivalSearch sptService = new EarliestArrivalSearch();
sptService.maxDuration = (60 * cutoffMinutes);
ShortestPathTree spt = sptService.getShortestPathTree(req);
req.cleanup();
if (spt != null) {
TimeSurface surface = new TimeSurface(spt);
surface.params = Maps.newHashMap();
for (Map.Entry<String, List<String>> e : uriInfo.getQueryParameters().entrySet()) {
// include only the first instance of each query parameter
surface.params.put(e.getKey(), e.getValue().get(0));
}
surface.cutoffMinutes = cutoffMinutes;
otpServer.surfaceCache.add(surface);
// .created(URI)
return Response.ok().entity(new TimeSurfaceShort(surface)).build();
} else {
return Response.noContent().entity("NO SPT").build();
}
} catch (ParameterException pex) {
return Response.status(Response.Status.BAD_REQUEST).entity("BAD USER").build();
}
}
Aggregations