use of org.opentripplanner.graph_builder.issues.StopNotLinkedForTransfers in project OpenTripPlanner by opentripplanner.
the class DirectTransferGenerator method buildGraph.
@Override
public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra, DataImportIssueStore issueStore) {
/* Initialize graph index which is needed by the nearby stop finder. */
if (graph.index == null) {
graph.index = new GraphIndex(graph);
}
/* The linker will use streets if they are available, or straight-line distance otherwise. */
NearbyStopFinder nearbyStopFinder = new NearbyStopFinder(graph, radiusMeters);
if (nearbyStopFinder.useStreets) {
LOG.info("Creating direct transfer edges between stops using the street network from OSM...");
} else {
LOG.info("Creating direct transfer edges between stops using straight line distance (not streets)...");
}
Iterable<TransitStopVertex> stops = Iterables.filter(graph.getVertices(), TransitStopVertex.class);
ProgressTracker progress = ProgressTracker.track("Create transfer edges", 1000, Iterables.size(stops));
int nTransfersTotal = 0;
int nLinkableStops = 0;
// This could be multi-threaded, in which case we'd need to be careful about the lifecycle of NearbyStopFinder instances.
for (TransitStopVertex ts0 : stops) {
Stop stop = ts0.getStop();
LOG.debug("Linking stop '{}' {}", stop, ts0);
/* Make transfers to each nearby stop that is the closest stop on some trip pattern. */
int n = 0;
for (StopAtDistance sd : nearbyStopFinder.findNearbyStopsConsideringPatterns(ts0, false)) {
// Skip the origin stop, loop transfers are not needed.
if (sd.stop == stop) {
continue;
}
graph.transfersByStop.put(stop, new SimpleTransfer(stop, sd.stop, sd.distance, sd.edges));
n += 1;
}
if (OTPFeature.FlexRouting.isOn()) {
// from Stops to FlexStopLocations and between Stops are already covered above.
for (StopAtDistance sd : nearbyStopFinder.findNearbyStopsConsideringPatterns(ts0, true)) {
// Skip the origin stop, loop transfers are not needed.
if (sd.stop == ts0.getStop()) {
continue;
}
if (sd.stop instanceof Stop) {
continue;
}
graph.transfersByStop.put(sd.stop, new SimpleTransfer(sd.stop, ts0.getStop(), sd.distance, sd.edges));
n += 1;
}
}
LOG.debug("Linked stop {} to {} nearby stops on other patterns.", stop, n);
if (n == 0) {
issueStore.add(new StopNotLinkedForTransfers(ts0));
}
// Keep lambda! A method-ref would causes incorrect class and line number to be logged
progress.step(m -> LOG.info(m));
nTransfersTotal += n;
}
LOG.info(progress.completeMessage());
LOG.info("Done connecting stops to one another. Created a total of {} transfers from {} stops.", nTransfersTotal, nLinkableStops);
graph.hasDirectTransfers = true;
}
Aggregations