Search in sources :

Example 1 with GHLocation

use of com.graphhopper.gtfs.GHLocation in project graphhopper by graphhopper.

the class PtRouteResource method route.

@GET
@Produces(MediaType.APPLICATION_JSON)
public ObjectNode route(@QueryParam("point") @Size(min = 2, max = 2) List<GHLocationParam> requestPoints, @QueryParam("pt.earliest_departure_time") @NotNull OffsetDateTimeParam departureTimeParam, @QueryParam("pt.profile_duration") DurationParam profileDuration, @QueryParam("pt.arrive_by") @DefaultValue("false") boolean arriveBy, @QueryParam("locale") String localeStr, @QueryParam("pt.ignore_transfers") Boolean ignoreTransfers, @QueryParam("pt.profile") Boolean profileQuery, @QueryParam("pt.limit_solutions") Integer limitSolutions, @QueryParam("pt.limit_trip_time") DurationParam limitTripTime, @QueryParam("pt.limit_street_time") DurationParam limitStreetTime, @QueryParam("pt.access_profile") String accessProfile, @QueryParam("pt.egress_profile") String egressProfile) {
    StopWatch stopWatch = new StopWatch().start();
    List<GHLocation> points = requestPoints.stream().map(AbstractParam::get).collect(toList());
    Instant departureTime = departureTimeParam.get().toInstant();
    Request request = new Request(points, departureTime);
    request.setArriveBy(arriveBy);
    Optional.ofNullable(profileQuery).ifPresent(request::setProfileQuery);
    Optional.ofNullable(profileDuration.get()).ifPresent(request::setMaxProfileDuration);
    Optional.ofNullable(ignoreTransfers).ifPresent(request::setIgnoreTransfers);
    Optional.ofNullable(localeStr).ifPresent(s -> request.setLocale(Helper.getLocale(s)));
    Optional.ofNullable(limitSolutions).ifPresent(request::setLimitSolutions);
    Optional.ofNullable(limitTripTime.get()).ifPresent(request::setLimitTripTime);
    Optional.ofNullable(limitStreetTime.get()).ifPresent(request::setLimitStreetTime);
    Optional.ofNullable(accessProfile).ifPresent(request::setAccessProfile);
    Optional.ofNullable(egressProfile).ifPresent(request::setEgressProfile);
    GHResponse route = ptRouter.route(request);
    return ResponsePathSerializer.jsonObject(route, true, true, false, false, stopWatch.stop().getMillis());
}
Also used : GHLocation(com.graphhopper.gtfs.GHLocation) Instant(java.time.Instant) Request(com.graphhopper.gtfs.Request) GHResponse(com.graphhopper.GHResponse) StopWatch(com.graphhopper.util.StopWatch)

Aggregations

GHResponse (com.graphhopper.GHResponse)1 GHLocation (com.graphhopper.gtfs.GHLocation)1 Request (com.graphhopper.gtfs.Request)1 StopWatch (com.graphhopper.util.StopWatch)1 Instant (java.time.Instant)1