org.opentripplanner.gtfs.mapping.DirectionMapper 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
package org.opentripplanner.gtfs.mapping;
import org.opentripplanner.graph_builder.DataImportIssueStore;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.timetable.Direction;
public class DirectionMapper {
private final DataImportIssueStore issueStore;
public DirectionMapper(DataImportIssueStore issueStore) {
this.issueStore = issueStore;
}
Direction map(String gtfsCode, FeedScopedId id) {
try {
if (gtfsCode == null || gtfsCode.isBlank()) {
return Direction.UNKNOWN;
}
return map(Integer.parseInt(gtfsCode));
} catch (NumberFormatException e) {
issueStore.add(
"InvalidGTFSDirectionId",
"Trip %s does not have direction id, defaults to -1",
id
);
}
return Direction.UNKNOWN;
}
public Direction map(int gtfsCode) {
return switch (gtfsCode) {
case 0 -> Direction.OUTBOUND;
case 1 -> Direction.INBOUND;
default -> Direction.UNKNOWN;
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy