Skip to content

Commit

Permalink
Remove backwards-compatibility with old versions of flex
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Apr 5, 2024
1 parent fd8e842 commit 1829ba6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,44 +61,12 @@ public final class StopTime extends IdentityBean<Integer> implements
@CsvField(optional = true, mapping = StopTimeFieldMappingFactory.class)
private int departureTime = MISSING_VALUE;

/**
* @deprecated
* GTFS-Flex v2.1 renamed this field. Use {@link #startPickupDropOffWindow} instead.
*/
@Deprecated
@CsvField(optional = true, mapping = StopTimeFieldMappingFactory.class, defaultValue = "-999")
private int minArrivalTime = MISSING_VALUE;

@CsvField(optional = true, name = "start_pickup_drop_off_window", mapping = StopTimeFieldMappingFactory.class, defaultValue = "-999")
private int startPickupDropOffWindow = MISSING_VALUE;

/**
* @deprecated
* GTFS-Flex v2.1 renamed "dropoff" to "drop off": https://github.com/MobilityData/gtfs-flex/commit/547200dfb580771265ae14b07d9bfd7b91c16ed2
*/
@Deprecated
@CsvField(optional = true, name = "start_pickup_dropoff_window", mapping = StopTimeFieldMappingFactory.class, defaultValue = "-999")
public int oldSpellingOfStartPickupDropOffWindow = MISSING_VALUE;

/**
* @deprecated
* GTFS-Flex v2.1 renamed this field. Use {@link #endPickupDropOffWindow} instead.
*/
@Deprecated
@CsvField(optional = true, mapping = StopTimeFieldMappingFactory.class, defaultValue = "-999")
private int maxDepartureTime = MISSING_VALUE;

@CsvField(optional = true, name = "end_pickup_drop_off_window", mapping = StopTimeFieldMappingFactory.class, defaultValue = "-999")
private int endPickupDropOffWindow = MISSING_VALUE;

/**
* @deprecated
* GTFS-Flex v2.1 renamed "dropoff" to "drop off": https://github.com/MobilityData/gtfs-flex/commit/547200dfb580771265ae14b07d9bfd7b91c16ed2
*/
@Deprecated
@CsvField(optional = true, name = "end_pickup_dropoff_window", mapping = StopTimeFieldMappingFactory.class, defaultValue = "-999")
public int oldSpellingOfEndPickupDropOffWindow = MISSING_VALUE;

@CsvField(optional = true, defaultValue = "-999")
private int timepoint = MISSING_VALUE;

Expand Down Expand Up @@ -192,9 +160,7 @@ public StopTime(StopTime st) {
this.dropOffType = st.dropOffType;
this.id = st.id;
this.pickupType = st.pickupType;
this.minArrivalTime = st.minArrivalTime;
this.startPickupDropOffWindow = st.startPickupDropOffWindow;
this.maxDepartureTime = st.maxDepartureTime;
this.endPickupDropOffWindow = st.endPickupDropOffWindow;
this.continuousPickup = st.continuousPickup;
this.continuousDropOff = st.continuousDropOff;
Expand Down Expand Up @@ -411,50 +377,17 @@ public void clearDepartureTime() {
this.departureTime = MISSING_VALUE;
}

@Deprecated
public int getMinArrivalTime() {
return minArrivalTime;
}

@Deprecated
public void setMinArrivalTime(int minArrivalTime) {
this.minArrivalTime = minArrivalTime;
}

public int getStartPickupDropOffWindow() {
if (startPickupDropOffWindow != MISSING_VALUE) {
return startPickupDropOffWindow;
} else if(oldSpellingOfStartPickupDropOffWindow != MISSING_VALUE){
return oldSpellingOfStartPickupDropOffWindow;
} else {
return minArrivalTime;
}
return startPickupDropOffWindow;
}

public void setStartPickupDropOffWindow(int startPickupDropOffWindow) {
this.startPickupDropOffWindow = startPickupDropOffWindow;
}

@Deprecated
public int getMaxDepartureTime() {
return maxDepartureTime;
}

@Deprecated
public void setMaxDepartureTime(int maxDepartureTime) {
this.maxDepartureTime = maxDepartureTime;
}

public int getEndPickupDropOffWindow() {
if (endPickupDropOffWindow != MISSING_VALUE) {
return endPickupDropOffWindow;
}
else if (oldSpellingOfEndPickupDropOffWindow != MISSING_VALUE) {
return oldSpellingOfEndPickupDropOffWindow;
}
else {
return maxDepartureTime;
}
return endPickupDropOffWindow;
}

public void setEndPickupDropOffWindow(int endPickupDropOffWindow) {
Expand Down Expand Up @@ -806,30 +739,11 @@ public void setFreeRunningFlag(String freeRunningFlag) {
}
this.freeRunningFlag = freeRunningFlag;
}
@Deprecated
public void setOldSpellingOfStartPickupDropOffWindow(int time) {
oldDropOffSpellingWarning("start");
this.oldSpellingOfStartPickupDropOffWindow = time;
}

@Deprecated
public void setOldSpellingOfEndPickupDropOffWindow(int time) {
oldDropOffSpellingWarning("end");
this.oldSpellingOfEndPickupDropOffWindow = time;
}

private static void oldDropOffSpellingWarning(String type) {
_log.warn("This feed uses the old spelling of '{}_pickup_drop_off_window' ('dropoff' instead of 'drop_off'). "
+ "Compatibility will be removed in the future, so please update your feed to be in line with the latest Flex V2 spec:"
+ " https://github.com/MobilityData/gtfs-flex/commit/547200dfb", type);
}
@Deprecated
public int getOldSpellingOfStartPickupDropOffWindow() {
return this.oldSpellingOfStartPickupDropOffWindow;
}

@Deprecated
public int getOldSpellingOfEndPickupDropOffWindow() {
return oldSpellingOfEndPickupDropOffWindow;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void testWithoutUnderscore() throws IOException {
_gtfs.putDefaultTrips();
_gtfs.putDefaultStops();
_gtfs.putLines("stop_times.txt",
"trip_id,stop_id,stop_sequence,arrival_time,departure_time,end_pickup_dropoff_window",
"trip_id,stop_id,stop_sequence,arrival_time,departure_time,end_pickup_drop_off_window",
"T10-0,100,0,05:55:55,08:00:00,08:23:23", "T10-0,200,1,05:55:55,09:00:00,08:44:44");

GtfsRelationalDao dao = _gtfs.read();
Expand All @@ -94,7 +94,7 @@ public void testWithoutUnderscore() throws IOException {
boolean foundUnderscoreParam = false;
while(scan.hasNext()){
String line = scan.nextLine();
if(line.contains("end_pickup_dropoff_window")){
if(line.contains("end_pickup_drop_off_window")){
foundUnderscoreParam = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@
*/
public class FlexDropOffSpellingTest {

@Test
public void oldSpelling() throws IOException {
testFlexStopTimeWithSpelling("dropoff");
}

@Test
public void newSpelling() throws IOException {
testFlexStopTimeWithSpelling("drop_off");
Expand Down

0 comments on commit 1829ba6

Please sign in to comment.