
org.opentripplanner.apis.transmodel.mapping.TripRequestMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
The newest version!
package org.opentripplanner.apis.transmodel.mapping;
import static org.opentripplanner.apis.transmodel.mapping.TransitIdMapper.mapIDsToDomainNullSafe;
import graphql.schema.DataFetchingEnvironment;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.opentripplanner.apis.transmodel.TransmodelRequestContext;
import org.opentripplanner.apis.transmodel.support.DataFetcherDecorator;
import org.opentripplanner.apis.transmodel.support.GqlUtil;
import org.opentripplanner.routing.api.request.RouteRequest;
import org.opentripplanner.standalone.api.OtpServerRequestContext;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.service.TransitService;
public class TripRequestMapper {
/**
* Create a RouteRequest from the input fields of the trip query arguments.
*/
public static RouteRequest createRequest(DataFetchingEnvironment environment) {
TransmodelRequestContext context = environment.getContext();
OtpServerRequestContext serverContext = context.getServerContext();
RouteRequest request = serverContext.defaultRouteRequest();
DataFetcherDecorator callWith = new DataFetcherDecorator(environment);
callWith.argument("locale", (String v) -> request.setLocale(Locale.forLanguageTag(v)));
callWith.argument(
"from",
(Map v) -> request.setFrom(GenericLocationMapper.toGenericLocation(v))
);
callWith.argument(
"to",
(Map v) -> request.setTo(GenericLocationMapper.toGenericLocation(v))
);
final TransitService transitService = context.getTransitService();
callWith.argument(
"passThroughPoints",
(List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy