Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public DataImportIssueStore(boolean storeIssues) {
this.storeIssues = storeIssues;
}

public static DataImportIssueStore noop() {
return new DataImportIssueStore(false);
}

public void add(DataImportIssue issue) {
ISSUE_LOG.debug("{} - {}", issue.getType(), issue.getMessage());
if (storeIssues) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.opentripplanner.transit.service.TransitModel;
import org.opentripplanner.util.OTPFeature;
import org.opentripplanner.util.OtpAppException;
import org.opentripplanner.util.time.DurationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -123,15 +124,15 @@ public static GraphBuilder create(
}
gtfsBundle.parentStationTransfers = config.stationTransfers;
gtfsBundle.subwayAccessTime = config.getSubwayAccessTimeSeconds();
gtfsBundle.maxInterlineDistance = config.maxInterlineDistance;
gtfsBundle.setMaxStopToShapeSnapDistance(config.maxStopToShapeSnapDistance);
gtfsBundles.add(gtfsBundle);
}
GtfsModule gtfsModule = new GtfsModule(
gtfsBundles,
config.getTransitServicePeriod(),
config.fareServiceFactory,
config.discardMinTransferTimes
config.discardMinTransferTimes,
config.maxInterlineDistance
);
graphBuilder.addModule(gtfsModule);
}
Expand Down Expand Up @@ -279,7 +280,8 @@ public void run() {

long endTime = System.currentTimeMillis();
LOG.info(
String.format("Graph building took %.1f minutes.", (endTime - startTime) / 1000 / 60.0)
"Graph building took {}.",
DurationUtils.durationToStr(Duration.ofMillis(endTime - startTime))
);
LOG.info("Main graph size: |V|={} |E|={}", graph.countVertices(), graph.countEdges());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public class GtfsBundle {

private double maxStopToShapeSnapDistance = 150;

public int maxInterlineDistance;

/** Used by unit tests */
public GtfsBundle(File gtfsFile) {
this(DataStoreFactory.compositeSource(gtfsFile, FileType.GTFS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.awt.Color;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
Expand All @@ -29,7 +28,8 @@
import org.opentripplanner.ext.flex.FlexTripsMapper;
import org.opentripplanner.graph_builder.DataImportIssueStore;
import org.opentripplanner.graph_builder.model.GtfsBundle;
import org.opentripplanner.graph_builder.module.geometry.GeometryAndBlockProcessor;
import org.opentripplanner.graph_builder.module.geometry.GeometryProcessor;
import org.opentripplanner.graph_builder.module.interlining.InterlineProcessor;
import org.opentripplanner.graph_builder.services.GraphBuilderModule;
import org.opentripplanner.gtfs.GenerateTripPatternsOperation;
import org.opentripplanner.gtfs.RepairStopTimesForEachTripOperation;
Expand Down Expand Up @@ -62,29 +62,25 @@ public class GtfsModule implements GraphBuilderModule {
private final List<GtfsBundle> gtfsBundles;
private final FareServiceFactory fareServiceFactory;
private final boolean discardMinTransferTimes;
private DataImportIssueStore issueStore;
private final int maxInterlineDistance;
private int nextAgencyId = 1; // used for generating agency IDs to resolve ID conflicts

public GtfsModule(
List<GtfsBundle> bundles,
ServiceDateInterval transitPeriodLimit,
FareServiceFactory fareServiceFactory,
boolean discardMinTransferTimes
boolean discardMinTransferTimes,
int maxInterlineDistance
) {
this.gtfsBundles = bundles;
this.transitPeriodLimit = transitPeriodLimit;
this.fareServiceFactory = fareServiceFactory;
this.discardMinTransferTimes = discardMinTransferTimes;
this.maxInterlineDistance = maxInterlineDistance;
}

public GtfsModule(List<GtfsBundle> bundles, ServiceDateInterval transitPeriodLimit) {
this(bundles, transitPeriodLimit, new DefaultFareServiceFactory(), false);
}

public List<String> provides() {
List<String> result = new ArrayList<>();
result.add("transit");
return result;
this(bundles, transitPeriodLimit, new DefaultFareServiceFactory(), false, 100);
}

@Override
Expand All @@ -94,8 +90,6 @@ public void buildGraph(
HashMap<Class<?>, Object> extra,
DataImportIssueStore issueStore
) {
this.issueStore = issueStore;

// we're about to add another agency to the graph, so clear the cached timezone
// in case it should change
// OTP doesn't currently support multiple time zones in a single graph;
Expand Down Expand Up @@ -128,10 +122,16 @@ public void buildGraph(
builder.getFlexTripsById().addAll(FlexTripsMapper.createFlexTrips(builder, issueStore));
}

repairStopTimesForEachTrip(builder.getStopTimesSortedByTrip());
repairStopTimesForEachTrip(builder.getStopTimesSortedByTrip(), issueStore);

// NB! The calls below have side effects - the builder state is updated!
createTripPatterns(graph, transitModel, builder, calendarServiceData.getServiceIds());
createTripPatterns(
graph,
transitModel,
builder,
calendarServiceData.getServiceIds(),
issueStore
);

OtpTransitService otpTransitService = builder.build();

Expand All @@ -140,8 +140,20 @@ public void buildGraph(

addTransitModelToGraph(graph, transitModel, gtfsBundle, otpTransitService);

createGeometryAndBlockProcessor(gtfsBundle, otpTransitService)
.run(graph, transitModel, issueStore);
new GeometryProcessor(
otpTransitService,
gtfsBundle.getMaxStopToShapeSnapDistance(),
issueStore
)
.run(transitModel);

new InterlineProcessor(
transitModel.getTransferService(),
builder.getStaySeatedNotAllowed(),
maxInterlineDistance,
issueStore
)
.run(transitModel.getAllTripPatterns());

fareServiceFactory.processGtfs(otpTransitService);
graph.putService(FareService.class, fareServiceFactory.makeFareService());
Expand Down Expand Up @@ -179,24 +191,28 @@ public void checkInputs() {
/* Private Methods */

/**
* This method have side-effects, the {@code stopTimesByTrip} is updated.
* This method has side effects, the {@code stopTimesByTrip} is updated.
*/
private void repairStopTimesForEachTrip(TripStopTimes stopTimesByTrip) {
private void repairStopTimesForEachTrip(
TripStopTimes stopTimesByTrip,
DataImportIssueStore issueStore
) {
new RepairStopTimesForEachTripOperation(stopTimesByTrip, issueStore).run();
}

/**
* This method have side-effects, the {@code builder} is updated with new TripPatterns.
* This method has side effects, the {@code builder} is updated with new TripPatterns.
*/
private void createTripPatterns(
Graph graph,
TransitModel transitModel,
OtpTransitServiceBuilder builder,
Set<FeedScopedId> calServiceIds
Set<FeedScopedId> calServiceIds,
DataImportIssueStore issueStore
) {
GenerateTripPatternsOperation buildTPOp = new GenerateTripPatternsOperation(
builder,
this.issueStore,
issueStore,
graph.deduplicator,
calServiceIds
);
Expand Down Expand Up @@ -224,17 +240,6 @@ private void addTransitModelToGraph(
);
}

private GeometryAndBlockProcessor createGeometryAndBlockProcessor(
GtfsBundle gtfsBundle,
OtpTransitService transitService
) {
return new GeometryAndBlockProcessor(
transitService,
gtfsBundle.getMaxStopToShapeSnapDistance(),
gtfsBundle.maxInterlineDistance
);
}

private GtfsMutableRelationalDao loadBundle(GtfsBundle gtfsBundle) throws IOException {
StoreImpl store = new StoreImpl(new GtfsRelationalDaoImpl());
store.open();
Expand Down Expand Up @@ -319,7 +324,7 @@ private GtfsMutableRelationalDao loadBundle(GtfsBundle gtfsBundle) throws IOExce
/**
* Generates routeText colors for routes with routeColor and without routeTextColor
* <p>
* If route doesn't have color or already has routeColor and routeTextColor nothing is done.
* If a route doesn't have color or already has routeColor and routeTextColor nothing is done.
* <p>
* textColor can be black or white. White for dark colors and black for light colors of
* routeColor. If color is light or dark is calculated based on luminance formula: sqrt(
Expand Down

This file was deleted.

Loading