Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
habrahamsson-skanetrafiken committed Oct 4, 2024
1 parent b619d61 commit 684a90e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 34 deletions.
16 changes: 8 additions & 8 deletions doc/user/BuildConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1075,17 +1075,17 @@ case where this is not the case.

List stations that should route to centroid.

This field contains a list of station ids for which the centroid will be used instead
of the stop coordinates.
This field contains a list of station ids for which street legs will start/end at the station
centroid instead of the child stops.

When doing street routing from/to a station the default behaviour is to route to any of
the stations child stops. This can cause strange results for stations that have stops
spread over a large area.
When searching from/to a station the default behaviour is to route from/to any of the stations child
stops. This can cause strange results for stations that have stops spread over a large area.

For some stations you might instead wish to use the centroid of the station as the
source/destination for street routing. In this case the centroid will be used both for
direct street search and for access/egress street search where the station is used as
the start/end of the access/egress.
origin/destination. In this case the centroid will be used both for direct street search and for
access/egress street search where the station is used as the start/end of the access/egress. But
transit that starts/ends at the station will work as usual without any additional street leg from/to
the centroid.



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ private void linkTransitEntrances(Graph graph) {
}

private void linkStationCentroids(Graph graph) {
BiFunction<Vertex, StreetVertex, List<Edge>> createLinkEdges = (theStation, streetVertex) ->
BiFunction<Vertex, StreetVertex, List<Edge>> linkStationAndStreetVertex = (
theStation,
streetVertex
) ->
List.of(
StreetStationCentroidLink.createStreetStationLink(
(StationCentroidVertex) theStation,
Expand All @@ -282,7 +285,7 @@ private void linkStationCentroids(Graph graph) {
station,
new TraverseModeSet(TraverseMode.WALK),
LinkingDirection.BOTH_WAYS,
createLinkEdges
linkStationAndStreetVertex
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ public class AccessEgressRouter {
private AccessEgressRouter() {}

/**
* Search for accesses or egresses. This will return both:
* <li> Directly accessible stops if the source/destination is a stop id.
* <li> Stops reachable by street search from the coordinates that correspond to the source/destination.
*
* Find accesses or egresses.
*/
public static Collection<NearbyStop> findAccessEgresses(
RouteRequest request,
Expand All @@ -42,17 +39,18 @@ public static Collection<NearbyStop> findAccessEgresses(
) {
OTPRequestTimeoutException.checkForTimeout();

// Note: We do direct and street search in two parts since some stations will use the centroid
// for street routing, but should still give direct access/egresses to its child-stops.
var directAccessEgress = findDirectAccessEgress(
// Note: We calculate access/egresses in two parts. First we fetch the stops with zero distance.
// Then we do street search. This is because some stations might use the centroid for street
// routing, but should still give zero distance access/egresses to its child-stops.
var zeroDistanceAccessEgress = findAccessEgressWithZeroDistance(
verticesContainer,
request,
streetRequest,
accessOrEgress
);

// When looking for street accesses/egresses we ignore the already found direct accesses/egresses
var ignoreVertices = directAccessEgress
var ignoreVertices = zeroDistanceAccessEgress
.stream()
.map(nearbyStop -> nearbyStop.state.getVertex())
.collect(Collectors.toSet());
Expand All @@ -68,7 +66,7 @@ public static Collection<NearbyStop> findAccessEgresses(
)
.findNearbyStops(originVertices, request, streetRequest, accessOrEgress.isEgress());

var results = ListUtils.combine(directAccessEgress, streetAccessEgress);
var results = ListUtils.combine(zeroDistanceAccessEgress, streetAccessEgress);
LOG.debug("Found {} {} stops", results.size(), accessOrEgress);
return results;
}
Expand All @@ -77,18 +75,18 @@ public static Collection<NearbyStop> findAccessEgresses(
* Return a list of direct accesses/egresses that do not require any street search. This will
* return an empty list if the source/destination is not a stopId.
*/
private static List<NearbyStop> findDirectAccessEgress(
private static List<NearbyStop> findAccessEgressWithZeroDistance(
TemporaryVerticesContainer verticesContainer,
RouteRequest routeRequest,
StreetRequest streetRequest,
AccessEgressType accessOrEgress
) {
var directVertices = accessOrEgress.isAccess()
var transitStopVertices = accessOrEgress.isAccess()
? verticesContainer.getFromStopVertices()
: verticesContainer.getToStopVertices();

return NearbyStop.nearbyStopsForTransitStopVerticesFiltered(
directVertices,
transitStopVertices,
accessOrEgress.isEgress(),
routeRequest,
streetRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,18 +443,18 @@ to check in to a flight (2-3 hours for international flights) than to alight and
.summary("List stations that should route to centroid.")
.description(
"""
This field contains a list of station ids for which the centroid will be used instead
of the stop coordinates.
When doing street routing from/to a station the default behaviour is to route to any of
the stations child stops. This can cause strange results for stations that have stops
spread over a large area.
For some stations you might instead wish to use the centroid of the station as the
source/destination for street routing. In this case the centroid will be used both for
direct street search and for access/egress street search where the station is used as
the start/end of the access/egress.
"""
This field contains a list of station ids for which street legs will start/end at the station
centroid instead of the child stops.
When searching from/to a station the default behaviour is to route from/to any of the stations child
stops. This can cause strange results for stations that have stops spread over a large area.
For some stations you might instead wish to use the centroid of the station as the
origin/destination. In this case the centroid will be used both for direct street search and for
access/egress street search where the station is used as the start/end of the access/egress. But
transit that starts/ends at the station will work as usual without any additional street leg from/to
the centroid.
"""
)
.asFeedScopedIds(List.of());

Expand Down

0 comments on commit 684a90e

Please sign in to comment.