From c4cab6d1f797f01b64827306c2fc7bee6ed23301 Mon Sep 17 00:00:00 2001 From: Henrik Abrahamsson Date: Fri, 13 Sep 2024 14:26:44 +0200 Subject: [PATCH] Remove previously added Station accessibility information --- .../apis/vectortiles/DebugStyleSpec.java | 4 +- .../AddTransitModelEntitiesToGraph.java | 2 +- .../module/StreetLinkerModule.java | 25 +++++------ .../netex/mapping/StationMapper.java | 11 +---- .../routing/graph/index/StreetIndex.java | 14 +++---- .../model/edge/StreetStationCentroidLink.java | 36 ++++++++++++++++ .../StreetTransitStationCentroidLink.java | 42 ------------------- ...Vertex.java => StationCentroidVertex.java} | 4 +- .../street/model/vertex/VertexFactory.java | 4 +- .../search/TemporaryVerticesContainer.java | 1 - .../transit/model/site/Station.java | 13 +----- .../transit/model/site/StationBuilder.java | 12 ------ .../routing/algorithm/GraphRoutingTest.java | 27 ++++-------- .../apis/vectortiles/style.json | 2 +- 14 files changed, 72 insertions(+), 125 deletions(-) create mode 100644 src/main/java/org/opentripplanner/street/model/edge/StreetStationCentroidLink.java delete mode 100644 src/main/java/org/opentripplanner/street/model/edge/StreetTransitStationCentroidLink.java rename src/main/java/org/opentripplanner/street/model/vertex/{TransitStationCentroidVertex.java => StationCentroidVertex.java} (85%) diff --git a/src/main/java/org/opentripplanner/apis/vectortiles/DebugStyleSpec.java b/src/main/java/org/opentripplanner/apis/vectortiles/DebugStyleSpec.java index 5a8e43899d5..cc30726b474 100644 --- a/src/main/java/org/opentripplanner/apis/vectortiles/DebugStyleSpec.java +++ b/src/main/java/org/opentripplanner/apis/vectortiles/DebugStyleSpec.java @@ -18,8 +18,8 @@ import org.opentripplanner.street.model.edge.EscalatorEdge; import org.opentripplanner.street.model.edge.PathwayEdge; import org.opentripplanner.street.model.edge.StreetEdge; +import org.opentripplanner.street.model.edge.StreetStationCentroidLink; import org.opentripplanner.street.model.edge.StreetTransitEntranceLink; -import org.opentripplanner.street.model.edge.StreetTransitStationCentroidLink; import org.opentripplanner.street.model.edge.StreetTransitStopLink; import org.opentripplanner.street.model.edge.StreetVehicleParkingLink; import org.opentripplanner.street.model.edge.TemporaryFreeEdge; @@ -111,7 +111,7 @@ static StyleSpec build( BoardingLocationToStopLink.class, StreetVehicleRentalLink.class, StreetVehicleParkingLink.class, - StreetTransitStationCentroidLink.class + StreetStationCentroidLink.class ) .lineWidth(LINE_WIDTH) .minZoom(13) diff --git a/src/main/java/org/opentripplanner/graph_builder/module/AddTransitModelEntitiesToGraph.java b/src/main/java/org/opentripplanner/graph_builder/module/AddTransitModelEntitiesToGraph.java index cba60179803..a4bbb10da68 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/AddTransitModelEntitiesToGraph.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/AddTransitModelEntitiesToGraph.java @@ -147,7 +147,7 @@ private void addEntrancesToGraph() { private void addStationCentroidsToGraph() { for (Station station : otpTransitService.stopModel().listStations()) { if (station.shouldRouteToCentroid()) { - vertexFactory.transitStationCentroid(station); + vertexFactory.stationCentroid(station); } } } diff --git a/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java b/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java index 39a2a5c288c..1488da08b4b 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java @@ -15,14 +15,14 @@ import org.opentripplanner.routing.vehicle_parking.VehicleParking; import org.opentripplanner.routing.vehicle_parking.VehicleParkingHelper; import org.opentripplanner.street.model.edge.Edge; +import org.opentripplanner.street.model.edge.StreetStationCentroidLink; import org.opentripplanner.street.model.edge.StreetTransitEntranceLink; -import org.opentripplanner.street.model.edge.StreetTransitStationCentroidLink; import org.opentripplanner.street.model.edge.StreetTransitStopLink; import org.opentripplanner.street.model.edge.StreetVehicleParkingLink; import org.opentripplanner.street.model.edge.VehicleParkingEdge; +import org.opentripplanner.street.model.vertex.StationCentroidVertex; import org.opentripplanner.street.model.vertex.StreetVertex; import org.opentripplanner.street.model.vertex.TransitEntranceVertex; -import org.opentripplanner.street.model.vertex.TransitStationCentroidVertex; import org.opentripplanner.street.model.vertex.TransitStopVertex; import org.opentripplanner.street.model.vertex.VehicleParkingEntranceVertex; import org.opentripplanner.street.search.TraverseMode; @@ -72,7 +72,7 @@ public void buildGraph() { if (graph.hasStreets) { linkTransitStops(graph, transitModel); linkTransitEntrances(graph); - linkTransitStationCentroids(graph); + linkStationCentroids(graph); linkVehicleParks(graph, issueStore); } @@ -260,14 +260,9 @@ private void linkTransitEntrances(Graph graph) { } } - private void linkTransitStationCentroids(Graph graph) { - LOG.info( - "Linking instances of {} to graph...", - TransitStationCentroidVertex.class.getSimpleName() - ); - for (TransitStationCentroidVertex tVertex : graph.getVerticesOfType( - TransitStationCentroidVertex.class - )) { + private void linkStationCentroids(Graph graph) { + LOG.info("Linking instances of {} to graph...", StationCentroidVertex.class.getSimpleName()); + for (StationCentroidVertex tVertex : graph.getVerticesOfType(StationCentroidVertex.class)) { graph .getLinker() .linkVertexPermanently( @@ -276,13 +271,13 @@ private void linkTransitStationCentroids(Graph graph) { LinkingDirection.BOTH_WAYS, (vertex, streetVertex) -> List.of( - StreetTransitStationCentroidLink.createStreetTransitStationLink( - (TransitStationCentroidVertex) vertex, + StreetStationCentroidLink.createStreetStationLink( + (StationCentroidVertex) vertex, streetVertex ), - StreetTransitStationCentroidLink.createStreetTransitStationLink( + StreetStationCentroidLink.createStreetStationLink( streetVertex, - (TransitStationCentroidVertex) vertex + (StationCentroidVertex) vertex ) ) ); diff --git a/src/main/java/org/opentripplanner/netex/mapping/StationMapper.java b/src/main/java/org/opentripplanner/netex/mapping/StationMapper.java index 03d4fc2b22c..5a6875294fe 100644 --- a/src/main/java/org/opentripplanner/netex/mapping/StationMapper.java +++ b/src/main/java/org/opentripplanner/netex/mapping/StationMapper.java @@ -15,7 +15,6 @@ import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore; import org.opentripplanner.netex.mapping.support.FeedScopedIdFactory; import org.opentripplanner.netex.support.JAXBUtils; -import org.opentripplanner.transit.model.basic.Accessibility; import org.opentripplanner.transit.model.framework.FeedScopedId; import org.opentripplanner.transit.model.site.Station; import org.opentripplanner.transit.service.StopModelBuilder; @@ -78,8 +77,7 @@ Station mapStopPlaceToStation(FeedScopedId id, StopPlace stopPlace) { .map(LocaleStructure::getTimeZone) .map(zoneId -> ofZoneId(stopPlace.getId(), zoneId)) .orElse(defaultTimeZone) - ) - .withWheelchairAccessibility(wheelchairAccessibility(stopPlace)); + ); if (noTransfersOnIsolatedStops) { builder.withTransfersNotAllowed( @@ -158,11 +156,4 @@ private WgsCoordinate mapCoordinate(StopPlace stopPlace) { return WgsCoordinate.mean(coordinates); } } - - private Accessibility wheelchairAccessibility(StopPlace stopPlace) { - return WheelChairMapper.wheelchairAccessibility( - stopPlace.getAccessibilityAssessment(), - Accessibility.NO_INFORMATION - ); - } } diff --git a/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java b/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java index 0c497c0477f..df5b3d19b9b 100644 --- a/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java +++ b/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java @@ -32,9 +32,9 @@ import org.opentripplanner.street.model.edge.TemporaryFreeEdge; import org.opentripplanner.street.model.edge.TemporaryPartialStreetEdge; import org.opentripplanner.street.model.edge.TemporaryPartialStreetEdgeBuilder; +import org.opentripplanner.street.model.vertex.StationCentroidVertex; import org.opentripplanner.street.model.vertex.StreetVertex; import org.opentripplanner.street.model.vertex.TemporaryStreetLocation; -import org.opentripplanner.street.model.vertex.TransitStationCentroidVertex; import org.opentripplanner.street.model.vertex.TransitStopVertex; import org.opentripplanner.street.model.vertex.Vertex; import org.opentripplanner.street.search.TraverseMode; @@ -66,7 +66,7 @@ public class StreetIndex { /** * This list contains transitStationVertices for the stations that are configured to route to centroid */ - private final Map transitStationCentroidVertices; + private final Map stationCentroidVertices; private final EdgeSpatialIndex edgeSpatialIndex; private final HashGridSpatialIndex verticesTree; @@ -80,7 +80,7 @@ public StreetIndex(Graph graph, StopModel stopModel) { this.verticesTree = new HashGridSpatialIndex<>(); this.vertexLinker = new VertexLinker(graph, stopModel, edgeSpatialIndex); this.transitStopVertices = toImmutableMap(graph.getVerticesOfType(TransitStopVertex.class)); - this.transitStationCentroidVertices = createTransitStationVertexMap(graph); + this.stationCentroidVertices = createTransitStationVertexMap(graph); postSetup(graph.getVertices()); } @@ -278,7 +278,7 @@ public Set getStopOrChildStopsVertices(FeedScopedId id) { * the station centroid if the station is configured to route to centroid. */ public Set getStreetVerticesById(FeedScopedId id) { - var stationVertex = transitStationCentroidVertices.get(id); + var stationVertex = stationCentroidVertices.get(id); if (stationVertex != null) { return Set.of(stationVertex); } @@ -464,12 +464,12 @@ private static Map toImmutableMap( return Map.copyOf(map); } - private static Map createTransitStationVertexMap( + private static Map createTransitStationVertexMap( Graph graph ) { - var vertices = graph.getVerticesOfType(TransitStationCentroidVertex.class); + var vertices = graph.getVerticesOfType(StationCentroidVertex.class); - var map = new HashMap(); + var map = new HashMap(); for (var vertex : vertices) { if (vertex.getStation().shouldRouteToCentroid()) { map.put(vertex.getStation().getId(), vertex); diff --git a/src/main/java/org/opentripplanner/street/model/edge/StreetStationCentroidLink.java b/src/main/java/org/opentripplanner/street/model/edge/StreetStationCentroidLink.java new file mode 100644 index 00000000000..696268d51b7 --- /dev/null +++ b/src/main/java/org/opentripplanner/street/model/edge/StreetStationCentroidLink.java @@ -0,0 +1,36 @@ +package org.opentripplanner.street.model.edge; + +import org.opentripplanner.street.model.vertex.StationCentroidVertex; +import org.opentripplanner.street.model.vertex.StreetVertex; + +/** + * This represents the connection between a street vertex and a transit station centroid vertex + */ +public class StreetStationCentroidLink extends FreeEdge { + + private StreetStationCentroidLink(StreetVertex fromv, StationCentroidVertex tov) { + super(fromv, tov); + } + + private StreetStationCentroidLink(StationCentroidVertex fromv, StreetVertex tov) { + super(fromv, tov); + } + + public static StreetStationCentroidLink createStreetStationLink( + StreetVertex fromv, + StationCentroidVertex tov + ) { + return connectToGraph(new StreetStationCentroidLink(fromv, tov)); + } + + public static StreetStationCentroidLink createStreetStationLink( + StationCentroidVertex fromv, + StreetVertex tov + ) { + return connectToGraph(new StreetStationCentroidLink(fromv, tov)); + } + + public String toString() { + return "StreetStationCentroidLink(" + fromv + " -> " + tov + ")"; + } +} diff --git a/src/main/java/org/opentripplanner/street/model/edge/StreetTransitStationCentroidLink.java b/src/main/java/org/opentripplanner/street/model/edge/StreetTransitStationCentroidLink.java deleted file mode 100644 index 5fb3fde6287..00000000000 --- a/src/main/java/org/opentripplanner/street/model/edge/StreetTransitStationCentroidLink.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.opentripplanner.street.model.edge; - -import org.opentripplanner.street.model.vertex.StreetVertex; -import org.opentripplanner.street.model.vertex.TransitStationCentroidVertex; -import org.opentripplanner.transit.model.basic.Accessibility; - -/** - * This represents the connection between a street vertex and a transit station centroid vertex - */ -public class StreetTransitStationCentroidLink - extends StreetTransitEntityLink { - - private StreetTransitStationCentroidLink(StreetVertex fromv, TransitStationCentroidVertex tov) { - super(fromv, tov, tov.getStation().getWheelchairAccessibility()); - } - - private StreetTransitStationCentroidLink(TransitStationCentroidVertex fromv, StreetVertex tov) { - super(fromv, tov, fromv.getStation().getWheelchairAccessibility()); - } - - public static StreetTransitStationCentroidLink createStreetTransitStationLink( - StreetVertex fromv, - TransitStationCentroidVertex tov - ) { - return connectToGraph(new StreetTransitStationCentroidLink(fromv, tov)); - } - - public static StreetTransitStationCentroidLink createStreetTransitStationLink( - TransitStationCentroidVertex fromv, - StreetVertex tov - ) { - return connectToGraph(new StreetTransitStationCentroidLink(fromv, tov)); - } - - public String toString() { - return "StreetTransitStationCentroidLink(" + fromv + " -> " + tov + ")"; - } - - protected int getStreetToStopTime() { - return 0; - } -} diff --git a/src/main/java/org/opentripplanner/street/model/vertex/TransitStationCentroidVertex.java b/src/main/java/org/opentripplanner/street/model/vertex/StationCentroidVertex.java similarity index 85% rename from src/main/java/org/opentripplanner/street/model/vertex/TransitStationCentroidVertex.java rename to src/main/java/org/opentripplanner/street/model/vertex/StationCentroidVertex.java index 483e5e6d49a..f6f3b00191d 100644 --- a/src/main/java/org/opentripplanner/street/model/vertex/TransitStationCentroidVertex.java +++ b/src/main/java/org/opentripplanner/street/model/vertex/StationCentroidVertex.java @@ -7,11 +7,11 @@ /** * A vertex representing a station centroid. This can be used as a source/destination for routing. */ -public class TransitStationCentroidVertex extends Vertex { +public class StationCentroidVertex extends Vertex { private final Station station; - public TransitStationCentroidVertex(Station station) { + public StationCentroidVertex(Station station) { super(station.getLon(), station.getLat()); this.station = station; } diff --git a/src/main/java/org/opentripplanner/street/model/vertex/VertexFactory.java b/src/main/java/org/opentripplanner/street/model/vertex/VertexFactory.java index cf311acd166..9da8d0ff892 100644 --- a/src/main/java/org/opentripplanner/street/model/vertex/VertexFactory.java +++ b/src/main/java/org/opentripplanner/street/model/vertex/VertexFactory.java @@ -128,8 +128,8 @@ public TransitStopVertex transitStop(TransitStopVertexBuilder transitStopVertexB } @Nonnull - public TransitStationCentroidVertex transitStationCentroid(Station station) { - return addToGraph(new TransitStationCentroidVertex(station)); + public StationCentroidVertex stationCentroid(Station station) { + return addToGraph(new StationCentroidVertex(station)); } @Nonnull diff --git a/src/main/java/org/opentripplanner/street/search/TemporaryVerticesContainer.java b/src/main/java/org/opentripplanner/street/search/TemporaryVerticesContainer.java index a30c2e735a9..1c6394bfd2f 100644 --- a/src/main/java/org/opentripplanner/street/search/TemporaryVerticesContainer.java +++ b/src/main/java/org/opentripplanner/street/search/TemporaryVerticesContainer.java @@ -19,7 +19,6 @@ import org.opentripplanner.routing.graph.index.StreetIndex; import org.opentripplanner.routing.linking.DisposableEdgeCollection; import org.opentripplanner.routing.linking.SameEdgeAdjuster; -import org.opentripplanner.street.model.vertex.TransitStationCentroidVertex; import org.opentripplanner.street.model.vertex.TransitStopVertex; import org.opentripplanner.street.model.vertex.Vertex; diff --git a/src/main/java/org/opentripplanner/transit/model/site/Station.java b/src/main/java/org/opentripplanner/transit/model/site/Station.java index a7fc1a61477..b46525c8d6d 100644 --- a/src/main/java/org/opentripplanner/transit/model/site/Station.java +++ b/src/main/java/org/opentripplanner/transit/model/site/Station.java @@ -17,7 +17,6 @@ import org.locationtech.jts.geom.Point; import org.opentripplanner.framework.geometry.WgsCoordinate; import org.opentripplanner.framework.i18n.I18NString; -import org.opentripplanner.transit.model.basic.Accessibility; import org.opentripplanner.transit.model.framework.AbstractTransitEntity; import org.opentripplanner.transit.model.framework.FeedScopedId; import org.opentripplanner.transit.model.framework.LogInfo; @@ -40,7 +39,6 @@ public class Station private final I18NString url; private final ZoneId timezone; private final boolean transfersNotAllowed; - private final Accessibility wheelchairAccessibility; // We serialize this class to json only for snapshot tests, and this creates cyclical structures @JsonBackReference @@ -63,7 +61,6 @@ public class Station this.description = builder.getDescription(); this.url = builder.getUrl(); this.timezone = builder.getTimezone(); - this.wheelchairAccessibility = builder.getWheelchairAccessibility(); // Initialize the geometry with an empty set of children this.geometry = computeGeometry(coordinate, Set.of()); @@ -155,13 +152,6 @@ public ZoneId getTimezone() { return timezone; } - /** - * Whether this station is accessible by wheelchair or not. - */ - public Accessibility getWheelchairAccessibility() { - return wheelchairAccessibility; - } - /** * If true do not allow any transfers to or from any stop within station */ @@ -201,8 +191,7 @@ public boolean sameAs(@Nonnull Station other) { Objects.equals(shouldRouteToCentroid, other.shouldRouteToCentroid) && Objects.equals(priority, other.priority) && Objects.equals(url, other.url) && - Objects.equals(timezone, other.timezone) && - Objects.equals(wheelchairAccessibility, other.wheelchairAccessibility) + Objects.equals(timezone, other.timezone) ); } diff --git a/src/main/java/org/opentripplanner/transit/model/site/StationBuilder.java b/src/main/java/org/opentripplanner/transit/model/site/StationBuilder.java index dde15829190..79b3b529146 100644 --- a/src/main/java/org/opentripplanner/transit/model/site/StationBuilder.java +++ b/src/main/java/org/opentripplanner/transit/model/site/StationBuilder.java @@ -3,7 +3,6 @@ import java.time.ZoneId; import org.opentripplanner.framework.geometry.WgsCoordinate; import org.opentripplanner.framework.i18n.I18NString; -import org.opentripplanner.transit.model.basic.Accessibility; import org.opentripplanner.transit.model.framework.AbstractEntityBuilder; import org.opentripplanner.transit.model.framework.FeedScopedId; @@ -17,7 +16,6 @@ public class StationBuilder extends AbstractEntityBuilder biLink(StreetVertex from, TransitStopVertex t return List.of(link(from, to), link(to, from)); } - public StreetTransitStationCentroidLink link( - StreetVertex from, - TransitStationCentroidVertex to - ) { - return StreetTransitStationCentroidLink.createStreetTransitStationLink(from, to); + public StreetStationCentroidLink link(StreetVertex from, StationCentroidVertex to) { + return StreetStationCentroidLink.createStreetStationLink(from, to); } - public StreetTransitStationCentroidLink link( - TransitStationCentroidVertex from, - StreetVertex to - ) { - return StreetTransitStationCentroidLink.createStreetTransitStationLink(from, to); + public StreetStationCentroidLink link(StationCentroidVertex from, StreetVertex to) { + return StreetStationCentroidLink.createStreetStationLink(from, to); } - public List biLink( - StreetVertex from, - TransitStationCentroidVertex to - ) { + public List biLink(StreetVertex from, StationCentroidVertex to) { return List.of(link(from, to), link(to, from)); } diff --git a/src/test/resources/org/opentripplanner/apis/vectortiles/style.json b/src/test/resources/org/opentripplanner/apis/vectortiles/style.json index dbc44364e8d..9c7572f4b6e 100644 --- a/src/test/resources/org/opentripplanner/apis/vectortiles/style.json +++ b/src/test/resources/org/opentripplanner/apis/vectortiles/style.json @@ -144,7 +144,7 @@ "BoardingLocationToStopLink", "StreetVehicleRentalLink", "StreetVehicleParkingLink", - "StreetTransitStationCentroidLink" + "StreetStationCentroidLink" ], "layout" : { "line-cap" : "round",