Skip to content

Commit

Permalink
Fix merge artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Jun 3, 2021
1 parent 2698711 commit d2687d9
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 34 deletions.
Empty file removed .attach_pid128911
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) { return false; }
final NearbyStop that = (NearbyStop) o;
return Double.compare(that.distance, distance) == 0
&& distanceIndependentTime == that.distanceIndependentTime
&& stop.equals(that.stop)
&& Objects.equals(edges, that.edges)
&& Objects.equals(geometry, that.geometry)
Expand All @@ -61,14 +60,13 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(stop, distance, distanceIndependentTime, edges, geometry, state);
return Objects.hash(stop, distance, edges, geometry, state);
}

public String toString() {
return String.format(
"stop %s at %.1f meters%s%s%s%s",
"stop %s at %.1f meters%s%s%s",
stop, distance,
distanceIndependentTime > 0 ? " +" + distanceIndependentTime + " seconds" : "",
edges != null ? " (" + edges.size() + " edges)" : "",
geometry != null ? " w/geometry" : "",
state != null ? " w/state" : ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
package org.opentripplanner.api.parameter;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.opentripplanner.routing.api.request.RequestModes;

import javax.ws.rs.BadRequestException;
import java.util.Set;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.opentripplanner.routing.api.request.StreetMode.BIKE;
import static org.opentripplanner.routing.api.request.StreetMode.BIKE_RENTAL;
import static org.opentripplanner.routing.api.request.StreetMode.BIKE_TO_PARK;
import static org.opentripplanner.routing.api.request.StreetMode.FLEXIBLE;
import static org.opentripplanner.routing.api.request.StreetMode.WALK;

import java.util.Set;
import javax.ws.rs.BadRequestException;
import org.junit.Test;
import org.opentripplanner.routing.api.request.RequestModes;

public class QualifiedModeSetTest {
@Test
public void emptyModeSet() {
Expand All @@ -28,14 +24,14 @@ public void emptyModeSet() {
public void singleWalk() {
QualifiedModeSet modeSet = new QualifiedModeSet("WALK");
assertEquals(Set.of(new QualifiedMode("WALK")), modeSet.qModes);
assertEquals(new RequestModes(WALK, WALK, WALK, Set.of()), modeSet.getRequestModes());
assertEquals(new RequestModes(WALK, WALK, WALK, WALK, Set.of()), modeSet.getRequestModes());
}

@Test
public void multipleWalks() {
QualifiedModeSet modeSet = new QualifiedModeSet("WALK,WALK,WALK");
assertEquals(Set.of(new QualifiedMode("WALK")), modeSet.qModes);
assertEquals(new RequestModes(WALK, WALK, WALK, Set.of()), modeSet.getRequestModes());
assertEquals(new RequestModes(WALK, WALK, WALK, WALK, Set.of()), modeSet.getRequestModes());
}

@Test
Expand All @@ -45,7 +41,7 @@ public void singleWalkAndBicycle() {
new QualifiedMode("WALK"),
new QualifiedMode("BICYCLE")
), modeSet.qModes);
assertEquals(new RequestModes(BIKE, BIKE, BIKE, Set.of()), modeSet.getRequestModes());
assertEquals(new RequestModes(BIKE, BIKE, BIKE, BIKE, Set.of()), modeSet.getRequestModes());
}

@Test
Expand All @@ -65,7 +61,7 @@ public void singleWalkAndBicycleToPark() {
new QualifiedMode("WALK"),
new QualifiedMode("BICYCLE_PARK")
), modeSet.qModes);
assertEquals(new RequestModes(BIKE_TO_PARK, WALK, BIKE_TO_PARK, Set.of()), modeSet.getRequestModes());
assertEquals(new RequestModes(BIKE_TO_PARK, WALK, WALK, BIKE_TO_PARK, Set.of()), modeSet.getRequestModes());
}

@Test
Expand All @@ -75,7 +71,7 @@ public void multipleWalksAndBicycle() {
new QualifiedMode("WALK"),
new QualifiedMode("BICYCLE")
), modeSet.qModes);
assertEquals(new RequestModes(BIKE, BIKE, BIKE, Set.of()), modeSet.getRequestModes());
assertEquals(new RequestModes(BIKE, BIKE, BIKE, BIKE, Set.of()), modeSet.getRequestModes());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public void build() {

@Test
void findClosestStops() {
var ns1 = new NearbyStop(S1, 0, null, linestring(47.500, 19.000, 47.500, 19.000), null);
var ns2 = new NearbyStop(S2, 1112, null, linestring(47.500, 19.000, 47.510, 19.000), null);
var ns1 = new NearbyStop(S1.getStop(), 0, null, null, null);
var ns2 = new NearbyStop(S2.getStop(), 1112, null, null, null);

var testee = new DirectGraphFinder(graph);
assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,15 @@
import org.opentripplanner.routing.algorithm.GraphRoutingTest;
import org.opentripplanner.routing.edgetype.StreetTraversalPermission;
import org.opentripplanner.routing.graph.GraphIndex;
import org.opentripplanner.routing.vertextype.BikeParkVertex;
import org.opentripplanner.routing.vertextype.BikeRentalStationVertex;
import org.opentripplanner.routing.vertextype.IntersectionVertex;
import org.opentripplanner.routing.vertextype.ParkAndRideVertex;
import org.opentripplanner.routing.vertextype.TransitStopVertex;

class StreetGraphFinderTest extends GraphRoutingTest {

private TransitStopVertex S1, S2, S3;
private IntersectionVertex A, B, C, D;
private BikeRentalStationVertex BR1, BR2;
private BikeParkVertex BP1;
private ParkAndRideVertex PR1, PR2;
private RoutingService routingService;
private StreetGraphFinder graphFinder;
private Route R1, R2;
Expand Down Expand Up @@ -59,24 +55,28 @@ public void build() {
BR1 = bikeRentalStation("BR1", 47.500, 18.999);
BR2 = bikeRentalStation("BR2", 47.520, 18.999);

BP1 = bikePark("BP1", 47.520, 18.999);

PR1 = carPark("PR1", 47.510, 18.999);
PR2 = carPark("PR2", 47.530, 18.999);

A = intersection("A", 47.500, 19.00);
B = intersection("B", 47.510, 19.00);
C = intersection("C", 47.520, 19.00);
D = intersection("D", 47.530, 19.00);

vehicleParking("BP1", 47.520, 18.999, true, false, List.of(
vehicleParkingEntrance(A, "All Park Entrance", true, true)
));

vehicleParking("PR1", 47.510, 18.999, false, true, List.of(
vehicleParkingEntrance(A, "All Park Entrance", true, true)
));
vehicleParking("PR2", 47.530, 18.999, false, true, List.of(
vehicleParkingEntrance(A, "All Park Entrance", true, true)
));


biLink(A, S1);
biLink(A, BR1);
biLink(B, S2);
biLink(B, PR1);
biLink(C, S3);
biLink(C, BP1);
biLink(C, BR2);
biLink(D, PR2);

street(A, B, 100, StreetTraversalPermission.ALL);
street(B, C, 100, StreetTraversalPermission.ALL);
Expand All @@ -99,8 +99,8 @@ public void build() {

@Test
void findClosestStops() {
var ns1 = new NearbyStop(S1, 0, null, linestring(47.500, 19.000, 47.500, 19.001), null);
var ns2 = new NearbyStop(S2, 100, null, linestring(47.500, 19.000, 47.510, 19.000, 47.510, 19.001), null);
var ns1 = new NearbyStop(S1.getStop(), 0, null, null, null);
var ns2 = new NearbyStop(S2.getStop(), 100, null, null, null);

assertEquals(
List.of(ns1),
Expand Down Expand Up @@ -294,10 +294,9 @@ void findClosestPlacesWithACarParkFilter() {
private List<NearbyStop> simplify(List<NearbyStop> closestStops) {
return closestStops.stream().map(
ns -> new NearbyStop(
ns.stop, ns.distance, ns.distanceIndependentTime, null, ns.geometry, null
ns.stop, ns.distance, null, ns.geometry, null
)
)
.collect(Collectors.toList());
).collect(Collectors.toList());
}

private StopTime st(TransitStopVertex s1) {
Expand Down

0 comments on commit d2687d9

Please sign in to comment.