use of org.opentripplanner.routing.graphfinder.PlaceAtDistance in project OpenTripPlanner by opentripplanner.
the class LegacyGraphQLQueryTypeImpl method node.
@Override
public DataFetcher<Object> node() {
return environment -> {
var args = new LegacyGraphQLTypes.LegacyGraphQLQueryTypeNodeArgs(environment.getArguments());
String type = args.getLegacyGraphQLId().getType();
String id = args.getLegacyGraphQLId().getId();
RoutingService routingService = environment.<LegacyGraphQLRequestContext>getContext().getRoutingService();
BikeRentalStationService bikerentalStationService = routingService.getBikerentalStationService();
switch(type) {
case "Agency":
return routingService.getAgencyForId(FeedScopedId.parseId(id));
case "Alert":
// TODO
return null;
case "BikePark":
return bikerentalStationService == null ? null : bikerentalStationService.getBikeParks().stream().filter(bikePark -> bikePark.id.equals(id)).findAny().orElse(null);
case "BikeRentalStation":
return bikerentalStationService == null ? null : bikerentalStationService.getBikeRentalStations().stream().filter(bikeRentalStation -> bikeRentalStation.id.equals(id)).findAny().orElse(null);
case "CarPark":
// TODO
return null;
case "Cluster":
// TODO
return null;
case "DepartureRow":
return PatternAtStop.fromId(routingService, id);
case "Pattern":
return routingService.getTripPatternForId(FeedScopedId.parseId(id));
case "placeAtDistance":
{
String[] parts = id.split(";");
Relay.ResolvedGlobalId internalId = new Relay().fromGlobalId(parts[1]);
Object place = node().get(DataFetchingEnvironmentImpl.newDataFetchingEnvironment(environment).source(new Object()).arguments(Map.of("id", internalId)).build());
return new PlaceAtDistance(place, Double.parseDouble(parts[0]));
}
case "Route":
return routingService.getRouteForId(FeedScopedId.parseId(id));
case "Stop":
return routingService.getStopForId(FeedScopedId.parseId(id));
case "Stoptime":
// TODO
return null;
case "stopAtDistance":
{
String[] parts = id.split(";");
Stop stop = routingService.getStopForId(FeedScopedId.parseId(parts[1]));
// TODO: Add geometry
return new StopAtDistance(stop, Integer.parseInt(parts[0]), null, null, null);
}
case "TicketType":
// TODO
return null;
case "Trip":
return routingService.getTripForId().get(FeedScopedId.parseId(id));
default:
return null;
}
};
}
use of org.opentripplanner.routing.graphfinder.PlaceAtDistance in project OpenTripPlanner by opentripplanner.
the class LegacyGraphQLNodeTypeResolver method getType.
@Override
public GraphQLObjectType getType(TypeResolutionEnvironment environment) {
Object o = environment.getObject();
GraphQLSchema schema = environment.getSchema();
if (o instanceof Agency)
return schema.getObjectType("Agency");
if (o instanceof TransitAlert)
return schema.getObjectType("Alert");
if (o instanceof BikePark)
return schema.getObjectType("BikePark");
if (o instanceof BikeRentalStation)
return schema.getObjectType("BikeRentalStation");
// if (o instanceof Cluster) return schema.getObjectType("Cluster");
if (o instanceof PatternAtStop)
return schema.getObjectType("DepartureRow");
if (o instanceof TripPattern)
return schema.getObjectType("Pattern");
if (o instanceof PlaceAtDistance)
return schema.getObjectType("placeAtDistance");
if (o instanceof Route)
return schema.getObjectType("Route");
if (o instanceof Stop)
return schema.getObjectType("Stop");
if (o instanceof Station)
return schema.getObjectType("Stop");
if (o instanceof TripTimeShort)
return schema.getObjectType("Stoptime");
if (o instanceof StopAtDistance)
return schema.getObjectType("stopAtDistance");
if (o instanceof FareRuleSet)
return schema.getObjectType("TicketType");
if (o instanceof Trip)
return schema.getObjectType("Trip");
return null;
}
Aggregations