Skip to content

Commit

Permalink
NYS-233 fix: MTA values translated to GTFS values
Browse files Browse the repository at this point in the history
  • Loading branch information
sheldonabrown committed Oct 1, 2023
1 parent ef78c67 commit 5bbf4c0
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public class MTAStation {
public static final int ADA_FULLY_ACCESSIBLE = 1;
public static final int ADA_PARTIALLY_ACCESSIBLE = 2;

public static final int GTFS_WHEELCHAIR_UNKNOWN = 0;
public static final int GTFS_WHEELCHAIR_ACCESSIBLE = 1;
public static final int GTFS_WHEELCHAIR_NOT_ACCESSIBLE = 2;
public static final int GTFS_WHEELCHAIR_EXPERIMENTAL_PARTIALLY_ACCESSIBLE = 3;

private static final int MISSING_VALUE = -999;
@CsvField(name = "Station ID")
private int id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,37 @@ public void run(TransformContext context, GtfsMutableRelationalDao dao) {

private void markStopAccessible(GtfsMutableRelationalDao dao, String stopId, String compassDirection,
int accessibilityQualifier) {
String unqualifedStopId = stopId + compassDirection;
Stop stopForId = idToStopMap.get(unqualifedStopId);
int gtfsValue = convertMTAccessibilityToGTFS(accessibilityQualifier);
String unqualifiedStopId = stopId + compassDirection;
Stop stopForId = idToStopMap.get(unqualifiedStopId);
if (stopForId == null) {
_log.error("no such stop for stopId {}", unqualifedStopId);
_log.error("no such stop for stopId {}", unqualifiedStopId);
return;
}
stopForId.setWheelchairBoarding(accessibilityQualifier);
stopForId.setWheelchairBoarding(gtfsValue);
this.accessibleStops.add(stopForId);
}

/**
* MTA 0 -> GTFS 2
* MTA 1 -> GTFS 1
* MTA 2 -> GTFS 3 (experimental)
* @param accessibilityQualifier
* @return
*/
public int convertMTAccessibilityToGTFS(int accessibilityQualifier) {
switch (accessibilityQualifier) {
case ADA_NOT_ACCESSIBLE:
return GTFS_WHEELCHAIR_NOT_ACCESSIBLE;
case ADA_FULLY_ACCESSIBLE:
return GTFS_WHEELCHAIR_ACCESSIBLE;
case ADA_PARTIALLY_ACCESSIBLE:
return GTFS_WHEELCHAIR_EXPERIMENTAL_PARTIALLY_ACCESSIBLE;
default:
return GTFS_WHEELCHAIR_UNKNOWN;
}
}


private List<MTAStation> getStations() {
return readCsv(MTAStation.class, stationsCsv);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.onebusaway.gtfs_transformer.csv.MTAStation.*;

/**
* Document and test partial and fully accessible MTAStations.
Expand Down Expand Up @@ -66,16 +67,36 @@ private void assertStation(GtfsRelationalDao dao, String stopId, int ada, Intege
assertNotNull(sStop);

assertEquals("expecting ada flag to match wheelchairBoarding flag for stop " + parentStop.getId(),
ada, parentStop.getWheelchairBoarding());
ada, converGTFSccessibilityToMTA(parentStop.getWheelchairBoarding()));
if (northBoundFlag == null) {
assertEquals("expecting N/A wheelchairBoarding for northbound stop " + nStop,0, nStop.getWheelchairBoarding()); // default is 0
assertEquals("expecting N/A wheelchairBoarding for northbound stop " + nStop,0, converGTFSccessibilityToMTA(nStop.getWheelchairBoarding())); // default is 0
} else {
assertEquals("expecting northBoundFlag to match wheelchairBoarding flag for stop" + nStop, northBoundFlag.intValue(), nStop.getWheelchairBoarding());
assertEquals("expecting northBoundFlag to match wheelchairBoarding flag for stop" + nStop, northBoundFlag.intValue(), converGTFSccessibilityToMTA(nStop.getWheelchairBoarding()));
}
if (southBoundFlag == null) {
assertEquals("expecting N/A wheelchairBoarding for southbound stop " + sStop,0, sStop.getWheelchairBoarding());
assertEquals("expecting N/A wheelchairBoarding for southbound stop " + sStop,0, converGTFSccessibilityToMTA(sStop.getWheelchairBoarding()));
} else {
assertEquals("expecting southBoundFlag to match wheelchairBoarding flag for stop" + sStop, southBoundFlag.intValue(), sStop.getWheelchairBoarding());
assertEquals("expecting southBoundFlag to match wheelchairBoarding flag for stop" + sStop, southBoundFlag.intValue(), converGTFSccessibilityToMTA(sStop.getWheelchairBoarding()));
}
}

/**
* GTFS 1 -> MTA 1
* GTFS 2 -> MTA 0
* GTFS 3 -> MTA 2
* @param gtfsValue
* @return
*/
private int converGTFSccessibilityToMTA(int gtfsValue) {
switch (gtfsValue) {
case 1:
return ADA_FULLY_ACCESSIBLE;
case 2:
return ADA_NOT_ACCESSIBLE;
case 3:
return ADA_PARTIALLY_ACCESSIBLE;
default:
return 0;// unknown
}
}
}

0 comments on commit 5bbf4c0

Please sign in to comment.