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 Sep 9, 2024
1 parent 41a9870 commit 4db3bc5
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.opentripplanner.street.model.edge.PathwayEdge;
import org.opentripplanner.street.model.edge.StreetEdge;
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;
Expand Down Expand Up @@ -109,7 +110,8 @@ static StyleSpec build(
StreetTransitEntranceLink.class,
BoardingLocationToStopLink.class,
StreetVehicleRentalLink.class,
StreetVehicleParkingLink.class
StreetVehicleParkingLink.class,
StreetTransitStationCentroidLink.class
)
.lineWidth(LINE_WIDTH)
.minZoom(13)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,10 @@ private void linkTransitEntrances(Graph graph) {
}

private void linkTransitStationCentroids(Graph graph) {
LOG.info("Linking TransitStationCentroidVertices to graph...");
LOG.info(
"Linking instances of {} to graph...",
TransitStationCentroidVertex.class.getSimpleName()
);
for (TransitStationCentroidVertex tVertex : graph.getVerticesOfType(
TransitStationCentroidVertex.class
)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class DirectlyConnectedStopFinder {

/**
* Given a list of vertices, find the ones that corresponds to stops and return them as NearbyStops
* Given a list of vertices, find the ones that correspond to stops and return them as NearbyStops
*/
public static List<NearbyStop> findDirectlyConnectedStops(
Set<Vertex> originVertices,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import javax.annotation.Nullable;
import org.opentripplanner.ext.dataoverlay.routing.DataOverlayContext;
import org.opentripplanner.framework.application.OTPRequestTimeoutException;
import org.opentripplanner.framework.collection.ListUtils;
import org.opentripplanner.graph_builder.module.nearbystops.DirectlyConnectedStopFinder;
import org.opentripplanner.graph_builder.module.nearbystops.StreetNearbyStopFinder;
import org.opentripplanner.routing.api.request.RouteRequest;
Expand Down Expand Up @@ -77,12 +78,8 @@ public static Collection<NearbyStop> findAccessEgresses(
)
.findNearbyStops(originVertices, request, streetRequest, accessOrEgress.isEgress());

List<NearbyStop> results = Stream
.concat(directAccessEgress.stream(), streetAccessEgress.stream())
.toList();

var results = ListUtils.combine(directAccessEgress, streetAccessEgress);
LOG.debug("Found {} {} stops", results.size(), accessOrEgress);

return results;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@
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<TransitStationCentroidVertex> {

private final boolean isEntrance;

private StreetTransitStationCentroidLink(StreetVertex fromv, TransitStationCentroidVertex tov) {
super(fromv, tov, tov.getStation().getWheelchairAccessibility());
isEntrance = true;
}

private StreetTransitStationCentroidLink(TransitStationCentroidVertex fromv, StreetVertex tov) {
super(fromv, tov, fromv.getStation().getWheelchairAccessibility());
isEntrance = false;
}

public static StreetTransitStationCentroidLink createStreetTransitStationLink(
Expand All @@ -33,14 +32,6 @@ public static StreetTransitStationCentroidLink createStreetTransitStationLink(
return connectToGraph(new StreetTransitStationCentroidLink(fromv, tov));
}

public boolean isEntrance() {
return isEntrance;
}

public boolean isExit() {
return !isEntrance;
}

public String toString() {
return "StreetTransitStationCentroidLink(" + fromv + " -> " + tov + ")";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import org.opentripplanner.framework.i18n.I18NString;
import org.opentripplanner.transit.model.site.Station;

/**
* A vertex representing a station centroid. This can be used as a source/destination for routing.
*/
public class TransitStationCentroidVertex extends Vertex {

private final Station station;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ public ZoneId getTimezone() {
return timezone;
}

/**
* Whether this station is accessible by wheelchair or not.
*/
public Accessibility getWheelchairAccessibility() {
return wheelchairAccessibility;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.opentripplanner;
package org.opentripplanner._support.geometry;

import org.opentripplanner.framework.geometry.SphericalDistanceLibrary;
import org.opentripplanner.framework.geometry.WgsCoordinate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class DebugStyleSpecTest {

private final ResourceLoader RESOURCES = ResourceLoader.of(this);

/**
* Remove the style.json file and re-run this test in order to regenerate the file.
*/
@Test
void spec() throws IOException {
var vectorSource = new VectorSource("vectorSource", "https://example.com");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.opentripplanner.CoordinateHelper;
import org.opentripplanner._support.geometry.CoordinateHelper;
import org.opentripplanner.routing.algorithm.GraphRoutingTest;
import org.opentripplanner.routing.api.request.RouteRequest;
import org.opentripplanner.routing.api.request.request.StreetRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.opentripplanner.CoordinateHelper;
import org.opentripplanner._support.geometry.CoordinateHelper;
import org.opentripplanner.framework.geometry.WgsCoordinate;
import org.opentripplanner.model.GenericLocation;
import org.opentripplanner.routing.algorithm.GraphRoutingTest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.opentripplanner.street.model.vertex;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;
import org.opentripplanner.framework.geometry.WgsCoordinate;

class VertexTest {

Expand All @@ -25,4 +27,10 @@ void testDifferentLocation() {
Vertex v2 = new SimpleVertex("", LAT + EPSILON_10_E_MINUS_7, LON);
assertFalse(v1.sameLocation(v2));
}

@Test
void testWgsCoordinate() {
Vertex v1 = new SimpleVertex("", LAT, LON);
assertEquals(new WgsCoordinate(LAT, LON), v1.getWgsCoordinate());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@
"StreetTransitEntranceLink",
"BoardingLocationToStopLink",
"StreetVehicleRentalLink",
"StreetVehicleParkingLink"
"StreetVehicleParkingLink",
"StreetTransitStationCentroidLink"
],
"layout" : {
"line-cap" : "round",
Expand Down

0 comments on commit 4db3bc5

Please sign in to comment.