From ab4577ab7e088d2096f162079a249368d34bd837 Mon Sep 17 00:00:00 2001 From: caylasavitzky Date: Wed, 1 May 2024 12:58:29 -0400 Subject: [PATCH] preventing StopLocations from propogating to one another during merge --- .../onebusaway/gtfs/impl/StopTimeArray.java | 23 +++++++++++-------- .../org/onebusaway/gtfs/model/StopTime.java | 20 ++++++++-------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/impl/StopTimeArray.java b/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/impl/StopTimeArray.java index a2a73f1b..1561e0ff 100644 --- a/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/impl/StopTimeArray.java +++ b/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/impl/StopTimeArray.java @@ -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 { @@ -36,6 +31,10 @@ public class StopTimeArray extends AbstractList { 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]; @@ -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(); @@ -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); @@ -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 @@ -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 diff --git a/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/StopTime.java b/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/StopTime.java index 837e0259..f9fe7d80 100644 --- a/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/StopTime.java +++ b/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/StopTime.java @@ -280,7 +280,7 @@ public void setToStopSequence(Integer toStopSequence) { @Override public StopLocation getStop() { - if (proxy != null & stop!=null) { + if (proxy != null) { return proxy.getStop(); } return stop; @@ -288,7 +288,7 @@ public StopLocation getStop() { @Override public StopLocation getLocation() { - if (proxy != null & location!=null) { + if (proxy != null) { return proxy.getLocation(); } return location; @@ -296,7 +296,7 @@ public StopLocation getLocation() { @Override public StopLocation getLocationGroup() { - if (proxy != null & locationGroup!=null) { + if (proxy != null) { return proxy.getLocationGroup(); } return locationGroup; @@ -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; } @@ -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()) + "-"