org.opentripplanner.routing.algorithm.transferoptimization.model.TripToTripTransfer 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.routing.algorithm.transferoptimization.model;
import javax.annotation.Nullable;
import org.opentripplanner.model.base.ToStringBuilder;
import org.opentripplanner.model.transfer.ConstrainedTransfer;
import org.opentripplanner.transit.raptor.api.transit.RaptorTransfer;
import org.opentripplanner.transit.raptor.api.transit.RaptorTripSchedule;
/**
*
* @param The TripSchedule type defined by the user of the raptor API.
*/
public class TripToTripTransfer {
private final TripStopTime from;
private final TripStopTime to;
private final RaptorTransfer pathTransfer;
private final ConstrainedTransfer constrainedTransfer;
public TripToTripTransfer(
TripStopTime from,
TripStopTime to,
RaptorTransfer pathTransfer,
@Nullable ConstrainedTransfer constrainedTransfer
) {
this.from = from;
this.to = to;
this.pathTransfer = pathTransfer;
this.constrainedTransfer = constrainedTransfer;
}
public TripStopTime from() {
return from;
}
public TripStopTime to() {
return to;
}
/**
* The time it takes to transfer between the given from and to stop.
* For a transfer at the same stop the time is zero.
*/
public int transferDuration() {
return sameStop() ? 0 : pathTransfer.durationInSeconds();
}
public int generalizedCost() {
return sameStop() ? 0 : pathTransfer.generalizedCost();
}
public boolean sameStop() {
return from.stop() == to.stop();
}
@Nullable
public RaptorTransfer getPathTransfer() {
return pathTransfer;
}
@Nullable
public ConstrainedTransfer constrainedTransfer() {
return constrainedTransfer;
}
@Override
public String toString() {
return ToStringBuilder.of(TripToTripTransfer.class)
.addObj("from", from)
.addObj("to", to)
.addObj("transfer", pathTransfer)
.toString();
}
}