Skip to content

Commit

Permalink
preventing StopLocations from propogating to one another during merge
Browse files Browse the repository at this point in the history
  • Loading branch information
CaylaSavitzky committed May 1, 2024
1 parent 876c386 commit ab4577a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@
import java.util.Iterator;
import java.util.NoSuchElementException;

import org.onebusaway.gtfs.model.Area;
import org.onebusaway.gtfs.model.BookingRule;
import org.onebusaway.gtfs.model.StopLocation;
import org.onebusaway.gtfs.model.StopTime;
import org.onebusaway.gtfs.model.StopTimeProxy;
import org.onebusaway.gtfs.model.Trip;
import org.onebusaway.gtfs.model.*;

public class StopTimeArray extends AbstractList<StopTime> {

Expand All @@ -36,6 +31,10 @@ public class StopTimeArray extends AbstractList<StopTime> {

private StopLocation[] stops = new StopLocation[0];

private StopLocation[] locations = new StopLocation[0];

private StopLocation[] locationGroups = new StopLocation[0];

private Area[] startServiceAreas = new Area[0];

private Area[] endServiceAreas = new Area[0];
Expand Down Expand Up @@ -89,6 +88,8 @@ public boolean add(StopTime stopTime) {
startServiceAreas[index] = stopTime.getStartServiceArea();
endServiceAreas[index] = stopTime.getEndServiceArea();
stops[index] = stopTime.getStop();
locations[index] = stopTime.getLocation();
locationGroups[index] = stopTime.getLocationGroup();
arrivalTimes[index] = stopTime.getArrivalTime();
departureTimes[index] = stopTime.getDepartureTime();
timepoints[index] = stopTime.getTimepoint();
Expand Down Expand Up @@ -151,6 +152,8 @@ private void setLength(int newLength) {
this.startServiceAreas = Arrays.copyOf(this.startServiceAreas, newLength);
this.endServiceAreas = Arrays.copyOf(this.endServiceAreas, newLength);
this.stops = Arrays.copyOf(this.stops, newLength);
this.locationGroups = Arrays.copyOf(this.locationGroups,newLength);
this.locations = Arrays.copyOf(this.locations,newLength);
this.arrivalTimes = Arrays.copyOf(this.arrivalTimes, newLength);
this.departureTimes = Arrays.copyOf(this.departureTimes, newLength);
this.timepoints = Arrays.copyOf(this.timepoints, newLength);
Expand Down Expand Up @@ -260,12 +263,12 @@ public StopLocation getStop() {

@Override
public StopLocation getLocation() {
return stops[index];
return locations[index];
}

@Override
public StopLocation getLocationGroup() {
return stops[index];
return locationGroups[index];
}

@Override
Expand All @@ -275,12 +278,12 @@ public void setStop(StopLocation stop) {

@Override
public void setLocation(StopLocation location) {
stops[index] = location;
locations[index] = location;
}

@Override
public void setLocationGroup(StopLocation group) {
stops[index] = group;
locationGroups[index] = group;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,23 +280,23 @@ public void setToStopSequence(Integer toStopSequence) {

@Override
public StopLocation getStop() {
if (proxy != null & stop!=null) {
if (proxy != null) {
return proxy.getStop();
}
return stop;
}

@Override
public StopLocation getLocation() {
if (proxy != null & location!=null) {
if (proxy != null) {
return proxy.getLocation();
}
return location;
}

@Override
public StopLocation getLocationGroup() {
if (proxy != null & locationGroup!=null) {
if (proxy != null) {
return proxy.getLocationGroup();
}
return locationGroup;
Expand All @@ -309,14 +309,14 @@ public StopLocation getLocationGroup() {
* - location group
*/
public StopLocation getStopLocation(){
if(stop != null){
return stop;
if(getStop() != null){
return getStop();
}
else if(location != null) {
return location;
else if(getLocation() != null) {
return getLocation();
}
else if(locationGroup != null){
return locationGroup;
else if(getLocationGroup() != null){
return getLocationGroup();
}
return null;
}
Expand Down Expand Up @@ -738,7 +738,7 @@ public String displayArrival() {

@Override
public String toString() {
return "StopTime(seq=" + getStopSequence() + " stop=" + (getStopLocation()==null?"NuLl":getStop().getId())
return "StopTime(seq=" + getStopSequence() + " stop=" + (getStopLocation()==null?"NuLl":getStopLocation().getId())
+ " trip=" + (getTrip()==null?"NuLl":getTrip().getId()) + " times="
+ StopTimeFieldMappingFactory.getSecondsAsString(getArrivalTime())
+ "-"
Expand Down

0 comments on commit ab4577a

Please sign in to comment.