use of com.conveyal.gtfs.model.Transfer in project graphhopper by graphhopper.
the class Transfers method getTransfersFromStop.
List<Transfer> getTransfersFromStop(String fromStopId, String fromRouteId) {
final List<Transfer> allOutboundTransfers = transfersFromStop.getOrDefault(fromStopId, Collections.emptyList());
final Map<String, List<Transfer>> byToStop = allOutboundTransfers.stream().filter(t -> t.transfer_type == 2).filter(t -> t.from_route_id == null || fromRouteId.equals(t.from_route_id)).collect(Collectors.groupingBy(t -> t.to_stop_id));
final List<Transfer> result = new ArrayList<>();
byToStop.forEach((toStop, transfers) -> {
routesByStop.getOrDefault(toStop, Collections.emptySet()).forEach(toRouteId -> {
final Transfer mostSpecificRule = findMostSpecificRule(transfers, fromRouteId, toRouteId);
final Transfer myRule = new Transfer();
myRule.to_route_id = toRouteId;
myRule.from_route_id = fromRouteId;
myRule.to_stop_id = mostSpecificRule.to_stop_id;
myRule.from_stop_id = mostSpecificRule.from_stop_id;
myRule.transfer_type = mostSpecificRule.transfer_type;
myRule.min_transfer_time = mostSpecificRule.min_transfer_time;
myRule.from_trip_id = mostSpecificRule.from_trip_id;
myRule.to_trip_id = mostSpecificRule.to_trip_id;
result.add(myRule);
});
});
return result;
}
use of com.conveyal.gtfs.model.Transfer in project graphhopper by graphhopper.
the class Transfers method getTransfersToStop.
// Starts implementing the proposed GTFS extension for route and trip specific transfer rules.
// So far, only the route is supported.
List<Transfer> getTransfersToStop(String toStopId, String toRouteId) {
final List<Transfer> allInboundTransfers = transfersToStop.getOrDefault(toStopId, Collections.emptyList());
final Map<String, List<Transfer>> byFromStop = allInboundTransfers.stream().filter(t -> t.transfer_type == 2).filter(t -> t.to_route_id == null || toRouteId.equals(t.to_route_id)).collect(Collectors.groupingBy(t -> t.from_stop_id));
final List<Transfer> result = new ArrayList<>();
byFromStop.forEach((fromStop, transfers) -> {
routesByStop.getOrDefault(fromStop, Collections.emptySet()).forEach(fromRoute -> {
final Transfer mostSpecificRule = findMostSpecificRule(transfers, fromRoute, toRouteId);
final Transfer myRule = new Transfer();
myRule.to_route_id = toRouteId;
myRule.from_route_id = fromRoute;
myRule.to_stop_id = mostSpecificRule.to_stop_id;
myRule.from_stop_id = mostSpecificRule.from_stop_id;
myRule.transfer_type = mostSpecificRule.transfer_type;
myRule.min_transfer_time = mostSpecificRule.min_transfer_time;
myRule.from_trip_id = mostSpecificRule.from_trip_id;
myRule.to_trip_id = mostSpecificRule.to_trip_id;
result.add(myRule);
});
});
return result;
}
Aggregations