diff --git a/onebusaway-gtfs-merge/src/main/java/org/onebusaway/gtfs_merge/strategies/TripMergeStrategy.java b/onebusaway-gtfs-merge/src/main/java/org/onebusaway/gtfs_merge/strategies/TripMergeStrategy.java index 2ddef889a..25aa6513d 100644 --- a/onebusaway-gtfs-merge/src/main/java/org/onebusaway/gtfs_merge/strategies/TripMergeStrategy.java +++ b/onebusaway-gtfs-merge/src/main/java/org/onebusaway/gtfs_merge/strategies/TripMergeStrategy.java @@ -116,6 +116,7 @@ protected void save(GtfsMergeContext context, IdentityBean entity) { for (StopTime stopTime : stopTimes) { stopTime.setId(0); stopTime.setTrip(trip); + stopTime.setRawTripId(trip.getId().getId()); target.saveEntity(stopTime); } } 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 a2a73f1be..2e0784ba7 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 @@ -71,7 +71,10 @@ public class StopTimeArray extends AbstractList { private double[] safeFactors = new double[0]; private String[] freeRunningFlags = new String[0]; - + + private String[] rawTripIds = new String[0]; + private String[] rawStopIds = new String[0]; + public void trimToSize() { setLength(size); } @@ -105,6 +108,8 @@ public boolean add(StopTime stopTime) { meanOffsets[index] = stopTime.getMeanDurationOffset(); meanFactors[index] = stopTime.getMeanDurationFactor(); freeRunningFlags[index] = stopTime.getFreeRunningFlag(); + rawTripIds[index] = stopTime.getRawTripId(); + rawStopIds[index] = stopTime.getRawStopId(); return true; } @@ -167,6 +172,8 @@ private void setLength(int newLength) { this.meanOffsets = Arrays.copyOf(this.meanOffsets, newLength); this.meanFactors = Arrays.copyOf(this.meanFactors, newLength); this.freeRunningFlags = Arrays.copyOf(this.freeRunningFlags, newLength); + this.rawTripIds = Arrays.copyOf(this.rawTripIds, newLength); + this.rawStopIds = Arrays.copyOf(this.rawStopIds, newLength); } private class StopTimeIterator implements Iterator { @@ -472,5 +479,23 @@ public String getFreeRunningFlag() { public void setFreeRunningFlag(String freeRunningFlag) { freeRunningFlags[index] = freeRunningFlag; } + + @Override + public String getRawTripId() { + return rawTripIds[index]; + } + + @Override + public void setRawTripId(String rawTripId) { + rawTripIds[index] = rawTripId; + } + + @Override + public String getRawStopId() { + return rawStopIds[index]; + } + + @Override + public void setRawStopId(String rawStopId) {rawStopIds[index] = rawStopId;} } } diff --git a/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/FareRule.java b/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/FareRule.java index 797e54701..85705bcaf 100644 --- a/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/FareRule.java +++ b/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/FareRule.java @@ -33,6 +33,9 @@ public final class FareRule extends IdentityBean { @CsvField(name = "route_id", optional = true, mapping = EntityFieldMappingFactory.class) private Route route; + @CsvField(optional = true, name = "route_id") + private String rawRouteId; + @CsvField(optional = true) private String originId; @@ -53,6 +56,7 @@ public FareRule(FareRule fr) { this.originId = fr.originId; this.destinationId = fr.destinationId; this.containsId = fr.containsId; + this.rawRouteId = fr.rawRouteId; } @Override @@ -81,6 +85,14 @@ public void setRoute(Route route) { this.route = route; } + public String getRawRouteId() { + return rawRouteId; + } + + public void setRawRouteId(String rawRouteId) { + this.rawRouteId = rawRouteId; + } + public String getOriginId() { return originId; } diff --git a/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/Route.java b/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/Route.java index b2451d6c9..6a1886075 100644 --- a/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/Route.java +++ b/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/Route.java @@ -33,6 +33,9 @@ public final class Route extends IdentityBean { @CsvField(name = "agency_id", optional = true, mapping = RouteAgencyFieldMappingFactory.class, order = -1) private Agency agency; + @CsvField(optional = true, name = "agency_id") + private String rawAgencyId; + @CsvField(optional = true, alwaysIncludeInOutput = true) private String shortName; @@ -99,6 +102,7 @@ public Route(Route r) { this.brandingUrl = r.brandingUrl; this.eligibilityRestricted = r.eligibilityRestricted; this.regionalFareCardAccepted = r.regionalFareCardAccepted; + this.rawAgencyId = r.rawAgencyId; } public AgencyAndId getId() { @@ -117,6 +121,14 @@ public void setAgency(Agency agency) { this.agency = agency; } + public String getRawAgencyId() { + return rawAgencyId; + } + + public void setRawAgencyId(String rawAgencyId) { + this.rawAgencyId = rawAgencyId; + } + public String getShortName() { return shortName; } 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 7e9bb9a72..24a0e43b7 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 @@ -42,12 +42,19 @@ public final class StopTime extends IdentityBean implements @CsvField(name = "trip_id", mapping = EntityFieldMappingFactory.class) private Trip trip; + @CsvField(optional = true, name = "trip_id") + private String rawTripId; + /** * This is optional because in flex you can also have location_id and location_group_id. */ + @CsvField(name = "stop_id", optional = true, mapping = StopLocationFieldMappingFactory.class) private StopLocation stop; + @CsvField(optional = true, name = "stop_id") + private String rawStopId; + @CsvField(name = "location_id", optional = true, mapping = StopLocationFieldMappingFactory.class) private StopLocation location; @@ -181,6 +188,8 @@ public final class StopTime extends IdentityBean implements @CsvField(optional = true, name = "free_running_flag") private String freeRunningFlag; + + public StopTime() { @@ -223,6 +232,8 @@ public StopTime(StopTime st) { this.meanDurationOffset= st.meanDurationOffset; this.meanDurationFactor= st.meanDurationFactor; this.freeRunningFlag = st.freeRunningFlag; + this.rawTripId = st.rawTripId; + this.rawStopId = st.rawStopId; } public Integer getId() { @@ -806,6 +817,39 @@ public void setFreeRunningFlag(String freeRunningFlag) { } this.freeRunningFlag = freeRunningFlag; } + + public String getRawTripId() { + if (proxy != null) { + return proxy.getRawTripId(); + } + return rawTripId; + } + + + public void setRawTripId(String rawTripId) { + if (proxy != null) { + proxy.setRawTripId(rawTripId); + return; + } + this.rawTripId = rawTripId; + } + + public String getRawStopId() { + if (proxy != null) { + return proxy.getRawStopId(); + } + return rawStopId; + } + + + public void setRawStopId(String rawStopId) { + if (proxy != null) { + proxy.setRawStopId(rawStopId); + return; + } + this.rawStopId = rawStopId; + } + @Deprecated public void setOldSpellingOfStartPickupDropOffWindow(int time) { oldDropOffSpellingWarning("start"); diff --git a/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/StopTimeProxy.java b/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/StopTimeProxy.java index 21f8f5251..a4b0c82c9 100644 --- a/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/StopTimeProxy.java +++ b/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/StopTimeProxy.java @@ -130,4 +130,11 @@ public interface StopTimeProxy { public void setFreeRunningFlag(String freeRunningFlag); + public String getRawTripId(); + + public void setRawTripId(String rawTripId); + + public String getRawStopId(); + + public void setRawStopId(String rawStopId); } diff --git a/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/Trip.java b/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/Trip.java index e6611f8e3..c04573bf3 100644 --- a/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/Trip.java +++ b/onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/model/Trip.java @@ -32,9 +32,14 @@ public final class Trip extends IdentityBean { @CsvField(name = "route_id", mapping = EntityFieldMappingFactory.class, order = -1) private Route route; + @CsvField(optional = true, name = "route_id", order = -2) + private String rawRouteId; + @CsvField(mapping = DefaultAgencyIdFieldMappingFactory.class) private AgencyAndId serviceId; + @CsvField(optional = true, name = "service_id") + private String rawServiceId; @CsvField(optional = true) private String tripShortName; @@ -158,6 +163,8 @@ public Trip(Trip obj) { this.peakOffpeak = obj.peakOffpeak; this.mtaTripId = obj.mtaTripId; this.boardingType = obj.boardingType; + this.rawRouteId = obj.rawRouteId; + this.rawServiceId = obj.rawServiceId; } public AgencyAndId getId() { @@ -176,6 +183,14 @@ public void setRoute(Route route) { this.route = route; } + public String getRawRouteId() { + return rawRouteId; + } + + public void setRawRouteId(String rawRouteId) { + this.rawRouteId = rawRouteId; + } + public AgencyAndId getServiceId() { return serviceId; } @@ -184,6 +199,14 @@ public void setServiceId(AgencyAndId serviceId) { this.serviceId = serviceId; } + public String getRawServiceId() { + return rawServiceId; + } + + public void setRawServiceId(String rawServiceId) { + this.rawServiceId = rawServiceId; + } + public String getTripShortName() { return tripShortName; }