Skip to content

Commit

Permalink
NYS-226 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sheldonabrown committed Sep 19, 2023
1 parent 3e7cb04 commit a678e86
Showing 1 changed file with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class MTAEntrancesStrategy implements GtfsTransformStrategy {
private Set<AgencyAndId> stopIdsWithPathways = new HashSet<AgencyAndId>();

@CsvField(ignore = true)
private Map<AgencyAndId, Stop> complexStopIds = new HashMap<>();
private Map<String, Stop> complexStopIds = new HashMap<>();

@CsvField(ignore = true)
private String agencyId;
Expand Down Expand Up @@ -113,6 +113,10 @@ public class MTAEntrancesStrategy implements GtfsTransformStrategy {

private boolean contextualAccessibility;

@CsvField(optional = true)
private boolean markStopsAccessible = false;


@CsvField(optional = true)
private boolean skipStopsWithExistingPathways = true;

Expand All @@ -131,9 +135,6 @@ public class MTAEntrancesStrategy implements GtfsTransformStrategy {
@CsvField(optional = true)
private int elevatorTraversalTime = 120;

@CsvField(optional = true)
private boolean markStopsAsAccessible = false;

public String getName() {
return this.getClass().getName();
}
Expand Down Expand Up @@ -166,6 +167,7 @@ public void run(TransformContext context, GtfsMutableRelationalDao dao) {
}
}

_log.info("elevatorCsv={}, entrancesCsv={}, accessibleComplexFile={}", elevatorsCsv, entrancesCsv, accessibleComplexFile);
agencyId = dao.getAllAgencies().iterator().next().getId();

newStops = new HashSet<>();
Expand Down Expand Up @@ -233,12 +235,15 @@ public void run(TransformContext context, GtfsMutableRelationalDao dao) {
readElevatorData(stopGroups, getComplexList(dao));
}

_log.info("found {} complex stops to mark as accessible", complexStopIds.size());
for (AgencyAndId aid : complexStopIds.keySet()) {
Stop stop = complexStopIds.get(aid);
stop.setWheelchairBoarding(WHEELCHAIR_ACCESSIBLE);
_log.info("marking stop {} as accessible", stop.getId());
dao.saveEntity(stop);
_log.info("found {} complex stops to mark as accessible and mark={}",
complexStopIds.size(), markStopsAccessible);
if (markStopsAccessible) {
for (String idOnly : complexStopIds.keySet()) {
Stop stop = complexStopIds.get(idOnly);
stop.setWheelchairBoarding(WHEELCHAIR_ACCESSIBLE);
_log.info("marking stop {} as accessible", stop.getId());
dao.updateEntity(stop);
}
}

for (Stop s : newStops) {
Expand Down Expand Up @@ -580,14 +585,13 @@ private Map<String, List<Stop>> getComplexList(GtfsDao dao) {
try (BufferedReader br = new BufferedReader(new FileReader(new File(this.accessibleComplexFile)))) {
String line;
while ((line = br.readLine()) != null) {
_log.info("accessibleComplexFile line: " + line);
List<Stop> complex = new ArrayList<>();
for (String id : line.split(STOP_SEPARATOR)) {
Stop stop = stops.get(id);
if (stop == null)
_log.info("null stop: {}", id);
complex.add(stop);
this.complexStopIds.put(AgencyAndId.convertFromString(id), stop);
this.complexStopIds.put(id, stop);
}
complexes.put("complex-" + UUID.randomUUID(), complex);
}
Expand All @@ -600,7 +604,7 @@ private Map<String, List<Stop>> getComplexList(GtfsDao dao) {
private Map<String, Stop> getStopMap(GtfsDao dao) {
Map<String, Stop> map = new HashMap<>();
for (Stop stop : dao.getAllStops()) {
if (stop.getLocationType() == 0) {
if (stop.getLocationType() == LOCATION_TYPE_STOP) {
map.put(stop.getId().getId(), stop);
}
}
Expand Down Expand Up @@ -759,5 +763,9 @@ public void setContextualAccessibility(boolean contextualAccessibility) {
private String getNamespace(){
return System.getProperty("cloudwatch.namespace");
}

public void setMarkStopsAccessible(boolean flag) {
markStopsAccessible = flag;
}
}

0 comments on commit a678e86

Please sign in to comment.