|
24 | 24 | import org.opentripplanner.service.osminfo.model.Platform;
|
25 | 25 | import org.opentripplanner.street.model.StreetTraversalPermission;
|
26 | 26 | import org.opentripplanner.street.model.edge.AreaEdge;
|
| 27 | +import org.opentripplanner.street.model.edge.AreaEdgeList; |
27 | 28 | import org.opentripplanner.street.model.edge.BoardingLocationToStopLink;
|
28 | 29 | import org.opentripplanner.street.model.edge.Edge;
|
29 | 30 | import org.opentripplanner.street.model.edge.NamedArea;
|
@@ -134,42 +135,56 @@ private Envelope getEnvelope(TransitStopVertex ts) {
|
134 | 135 |
|
135 | 136 | /**
|
136 | 137 | * Connect a transit stop vertex into a boarding location area in the index.
|
137 |
| - * <p> |
138 |
| - * A centroid vertex is generated in the area and connected to the vertices on the platform edge. |
| 138 | + * A centroid vertex is generated in the area or its sub platform |
| 139 | + * and connected to the visibility vertices of the area |
139 | 140 | *
|
140 | 141 | * @return if the vertex has been connected
|
141 | 142 | */
|
142 | 143 | private boolean connectVertexToArea(TransitStopVertex ts, StreetIndex index) {
|
143 | 144 | RegularStop stop = ts.getStop();
|
144 |
| - var nearbyAreaEdgeLists = index |
145 |
| - .getEdgesForEnvelope(getEnvelope(ts)) |
146 |
| - .stream() |
147 |
| - .filter(AreaEdge.class::isInstance) |
148 |
| - .map(AreaEdge.class::cast) |
149 |
| - .map(AreaEdge::getArea) |
150 |
| - .collect(Collectors.toSet()); |
| 145 | + var nearbyAreas = new HashMap<AreaEdgeList, Platform>(); |
151 | 146 |
|
152 |
| - // Iterate over all nearby areas representing transit stops in OSM, linking to them if they have a stop code or id |
| 147 | + // Find nearby areas representing transit stops in OSM, having a stop code or id |
153 | 148 | // in their ref= tag that matches the GTFS stop code of this StopVertex.
|
154 |
| - for (var edgeList : nearbyAreaEdgeLists) { |
155 |
| - if (matchesReference(stop, edgeList.references)) { |
156 |
| - var name = edgeList |
157 |
| - .getAreas() |
158 |
| - .stream() |
159 |
| - .findFirst() |
160 |
| - .map(NamedArea::getName) |
161 |
| - .orElse(LOCALIZED_PLATFORM_NAME); |
162 |
| - var boardingLocation = makeBoardingLocation( |
163 |
| - stop, |
164 |
| - edgeList.getGeometry().getCentroid(), |
165 |
| - edgeList.references, |
166 |
| - name |
167 |
| - ); |
168 |
| - linker.addPermanentAreaVertex(boardingLocation, edgeList); |
169 |
| - linkBoardingLocationToStop(ts, stop.getCode(), boardingLocation); |
170 |
| - return true; |
| 149 | + // Find also an actual included platform which may be a part of a larger area |
| 150 | + for (var edge : index.getEdgesForEnvelope(getEnvelope(ts))) { |
| 151 | + if (edge instanceof AreaEdge aEdge) { |
| 152 | + var areaEdgeList = aEdge.getArea(); |
| 153 | + if (matchesReference(stop, areaEdgeList.references)) { |
| 154 | + var opt = osmInfoGraphBuildService.findPlatform(edge); |
| 155 | + if (opt.isPresent()) { |
| 156 | + var platform = opt.get(); |
| 157 | + if (!matchesReference(stop, platform.references())) { |
| 158 | + nearbyAreas.put(areaEdgeList, platform); |
| 159 | + } |
| 160 | + } |
| 161 | + // collect area also if no platform available |
| 162 | + if (nearbyAreas.get(areaEdgeList) == null) { |
| 163 | + nearbyAreas.put(areaEdgeList, null); |
| 164 | + } |
| 165 | + } |
171 | 166 | }
|
172 | 167 | }
|
| 168 | + |
| 169 | + // Iterate over resulting areas and create proper linking to them |
| 170 | + for (var area : nearbyAreas.entrySet()) { |
| 171 | + var edgeList = area.getKey(); |
| 172 | + var name = edgeList |
| 173 | + .getAreas() |
| 174 | + .stream() |
| 175 | + .findFirst() |
| 176 | + .map(NamedArea::getName) |
| 177 | + .orElse(LOCALIZED_PLATFORM_NAME); |
| 178 | + |
| 179 | + Platform platform = nearbyAreas.get(edgeList); |
| 180 | + var centroid = platform != null |
| 181 | + ? platform.geometry().getCentroid() |
| 182 | + : edgeList.getGeometry().getCentroid(); |
| 183 | + var boardingLocation = makeBoardingLocation(stop, centroid, edgeList.references, name); |
| 184 | + linker.addPermanentAreaVertex(boardingLocation, edgeList); |
| 185 | + linkBoardingLocationToStop(ts, stop.getCode(), boardingLocation); |
| 186 | + return true; |
| 187 | + } |
173 | 188 | return false;
|
174 | 189 | }
|
175 | 190 |
|
|
0 commit comments