Skip to content

Commit

Permalink
Use three states for accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Jan 2, 2025
1 parent e473061 commit 713143b
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void buildElevatorEdges(Graph graph) {
}
int travelTime = parseDuration(node).orElse(-1);

var wheelchair = node.getWheelchairAccessibility();
var wheelchair = node.wheelchairAccessibility();

createElevatorHopEdges(
onboardVertices,
Expand Down Expand Up @@ -138,7 +138,7 @@ public void buildElevatorEdges(Graph graph) {

int travelTime = parseDuration(elevatorWay).orElse(-1);
int levels = nodes.size();
var wheelchair = elevatorWay.getWheelchairAccessibility();
var wheelchair = elevatorWay.wheelchairAccessibility();

createElevatorHopEdges(
onboardVertices,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ IntersectionVertex getVertexForOsmNode(OsmNode node, OsmWithTags way) {

if (includeOsmSubwayEntrances && node.isSubwayEntrance()) {
String ref = node.getTag("ref");

boolean accessible = node.isTag("wheelchair", "yes");
iv = vertexFactory.stationEntrance(nid, coordinate, ref, accessible);
iv = vertexFactory.stationEntrance(nid, coordinate, ref, node.wheelchairAccessibility());
}

if (iv == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public boolean isTagFalse(String tag) {
/**
* Returns the level of wheelchair access of the element.
*/
public Accessibility getWheelchairAccessibility() {
public Accessibility wheelchairAccessibility() {
if (isTagTrue("wheelchair")) {
return Accessibility.POSSIBLE;
} else if (isTagFalse("wheelchair")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.opentripplanner.street.model.vertex.Vertex;
import org.opentripplanner.street.search.TraverseMode;
import org.opentripplanner.street.search.state.State;
import org.opentripplanner.transit.model.basic.Accessibility;
import org.opentripplanner.transit.model.site.Entrance;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ public class StationEntranceVertex extends OsmVertex {

private static final String FEED_ID = "osm";
private final String code;
private final boolean wheelchairAccessible;
private final Accessibility wheelchairAccessibility;

public StationEntranceVertex(
double lat,
double lon,
long nodeId,
String code,
boolean wheelchairAccessible
Accessibility wheelchairAccessibility
) {
super(lat, lon, nodeId);
this.code = code;
this.wheelchairAccessible = wheelchairAccessible;
this.wheelchairAccessibility = wheelchairAccessibility;
}

/**
Expand All @@ -44,7 +44,7 @@ public String code() {
}

public Accessibility wheelchairAccessibility() {
return wheelchairAccessible ? Accessibility.POSSIBLE : Accessibility.NOT_POSSIBLE;
return wheelchairAccessibility;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.opentripplanner.service.vehiclerental.model.VehicleRentalPlace;
import org.opentripplanner.service.vehiclerental.street.VehicleRentalPlaceVertex;
import org.opentripplanner.street.model.edge.StreetEdge;
import org.opentripplanner.transit.model.basic.Accessibility;
import org.opentripplanner.transit.model.site.BoardingArea;
import org.opentripplanner.transit.model.site.Entrance;
import org.opentripplanner.transit.model.site.PathwayNode;
Expand Down Expand Up @@ -98,9 +99,11 @@ public StationEntranceVertex stationEntrance(
long nid,
Coordinate coordinate,
String code,
boolean accessible
Accessibility wheelchairAccessibility
) {
return addToGraph(new StationEntranceVertex(coordinate.x, coordinate.y, nid, code, accessible));
return addToGraph(
new StationEntranceVertex(coordinate.x, coordinate.y, nid, code, wheelchairAccessibility)
);
}

public OsmVertex osm(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.opentripplanner.osm.wayproperty.specifier.WayTestData;
import org.opentripplanner.transit.model.basic.Accessibility;

public class OsmWithTagsTest {

Expand Down Expand Up @@ -215,6 +216,20 @@ void isWheelchairAccessible() {
assertTrue(osm3.isWheelchairAccessible());
}

@Test
void wheelchairAccessibility() {
var osm1 = new OsmWithTags();
assertEquals(Accessibility.NO_INFORMATION, osm1.wheelchairAccessibility());

var osm2 = new OsmWithTags();
osm2.addTag("wheelchair", "no");
assertEquals(Accessibility.NOT_POSSIBLE, osm2.wheelchairAccessibility());

var osm3 = new OsmWithTags();
osm3.addTag("wheelchair", "yes");
assertEquals(Accessibility.POSSIBLE, osm3.wheelchairAccessibility());
}

@Test
void isRoutable() {
assertFalse(WayTestData.zooPlatform().isRoutable());
Expand Down

0 comments on commit 713143b

Please sign in to comment.