1 package org.matsim.core.population.routes;
26 }
catch (CloneNotSupportedException e) {
63 this.travelTime = Double.NaN;
68 return this.startLinkIndex < 0 ? null :
Id.
get(this.startLinkIndex,
Link.class);
73 this.startLinkIndex = linkId == null ? -1 : linkId.
index();
78 return this.endLinkIndex < 0 ? null :
Id.
get(this.endLinkIndex,
Link.class);
83 this.endLinkIndex = linkId == null ? -1 : linkId.
index();
101 if (fromLinkId.
equals(
this.getStartLinkId())) {
104 for (
int i = 0, n = route.size(); (i < n) && (fromIndex < 0); i++) {
105 if (fromLinkId.
equals(route.get(i))) {
109 if (fromIndex < 0 && fromLinkId.
equals(
this.getEndLinkId())) {
110 fromIndex = route.size();
113 throw new IllegalArgumentException(
"Cannot create subroute because fromLinkId is not part of the route.");
117 if (fromLinkId.
equals(toLinkId)) {
118 toIndex = fromIndex - 1;
120 for (
int i = fromIndex, n = route.size(); (i < n) && (toIndex < 0); i++) {
121 if (fromLinkId.
equals(route.get(i))) {
124 if (toLinkId.
equals(route.get(i))) {
128 if (toIndex < 0 && toLinkId.
equals(
this.getEndLinkId())) {
129 toIndex = route.size();
132 throw new IllegalArgumentException(
"Cannot create subroute because toLinkId is not part of the route.");
136 if (toIndex > fromIndex) {
137 ret.
setLinkIds(fromLinkId, route.subList(fromIndex, toIndex), toLinkId);
156 StringBuilder desc =
new StringBuilder(100);
160 desc.append(linkId.toString());
167 return desc.toString();
175 if (linkIds.size() > 0) {
176 startLinkId = linkIds.remove(0);
179 if (linkIds.size() > 0) {
180 endLinkId = linkIds.remove(linkIds.size() - 1);
183 this.
setLinkIds(startLinkId, linkIds, endLinkId);
static< T > Id< T > get(int index, final Class< T > type)
void setVehicleId(Id< Vehicle > vehicleId)
void setStartLinkId(Id< Link > linkId)
String getRouteDescription()
Id< Link > getEndLinkId()
void setRouteDescription(String routeDescription)
void setTravelTimeUndefined()
List< Id< Link > > getLinkIds()
static NetworkRoute createLinkNetworkRouteImpl(Id< Link > startLinkId, Id< Link > endLinkId)
void setTravelCost(double travelCost)
Id< Link > getStartLinkId()
void setTravelTime(double travelTime)
static OptionalTime defined(double seconds)
static List< Id< Link > > getLinkIds(final String links)
AbstractNetworkRoute clone()
Id< Vehicle > getVehicleId()
void setEndLinkId(Id< Link > linkId)
static OptionalTime undefined()
NetworkRoute getSubRoute(Id< Link > fromLinkId, Id< Link > toLinkId)
boolean equals(Object obj)
void setLinkIds(final Id< Link > startLinkId, final List< Id< Link >> linkIds, final Id< Link > endLinkId)
OptionalTime getTravelTime()
void setDistance(double distance)