Skip to content

Commit

Permalink
Merge pull request #34 from camsys/MOTP-368-Rail-Stop
Browse files Browse the repository at this point in the history
Motp 368 rail stop
  • Loading branch information
mmaranda-cs authored Oct 1, 2019
2 parents 8e2c9ed + 91f2088 commit a566cbe
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/main/java/org/opentripplanner/model/StopPattern.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ public class StopPattern implements Serializable {
public final Stop[] stops;
public final int[] pickups;
public final int[] dropoffs;
public final String[] notes;

public boolean equals(Object other) {
if (other instanceof StopPattern) {
StopPattern that = (StopPattern) other;
return Arrays.equals(this.stops, that.stops) &&
Arrays.equals(this.pickups, that.pickups) &&
Arrays.equals(this.dropoffs, that.dropoffs);
return Arrays.equals(this.stops, that.stops) &&
Arrays.equals(this.pickups, that.pickups) &&
Arrays.equals(this.dropoffs, that.dropoffs) &&
Arrays.equals(this.notes, that.notes) ;
} else {
return false;
}
Expand All @@ -71,14 +73,16 @@ public int hashCode() {
hash += Arrays.hashCode(this.pickups);
hash *= 31;
hash += Arrays.hashCode(this.dropoffs);
hash *= 31;
hash += Arrays.hashCode(this.notes);
return hash;
}

public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("StopPattern: ");
for (int i = 0, j = stops.length; i < j; ++i) {
sb.append(String.format("%s_%d%d ", stops[i].getCode(), pickups[i], dropoffs[i]));
sb.append(String.format("%s_%d%d ", stops[i].getCode(), pickups[i], dropoffs[i], notes[i]));
}
return sb.toString();
}
Expand All @@ -88,6 +92,7 @@ private StopPattern (int size) {
stops = new Stop[size];
pickups = new int[size];
dropoffs = new int[size];
notes = new String[size];
}

/** Assumes that stopTimes are already sorted by time. */
Expand All @@ -101,6 +106,12 @@ public StopPattern (List<StopTime> stopTimes) {
// pick/drop messages could be stored in individual trips
pickups[i] = stopTime.getPickupType();
dropoffs[i] = stopTime.getDropOffType();
if (stopTime.getNote() != null && stopTime.getNote().getDesc() != null )
{
notes[i] = stopTime.getNote().getDesc();
} else {
notes[i] = new String();
}
}
/*
* TriMet GTFS has many trips that differ only in the pick/drop status of their initial and
Expand Down

0 comments on commit a566cbe

Please sign in to comment.