Search in sources :

Example 31 with TraverseModeSet

use of org.opentripplanner.routing.core.TraverseModeSet in project OpenTripPlanner by opentripplanner.

the class TriangleInequalityTest method testTriangleInequalityWalkingOnly.

@Test
public void testTriangleInequalityWalkingOnly() {
    TraverseModeSet modes = new TraverseModeSet(TraverseMode.WALK);
    checkTriangleInequality(modes);
}
Also used : TraverseModeSet(org.opentripplanner.routing.core.TraverseModeSet) Test(org.junit.Test)

Example 32 with TraverseModeSet

use of org.opentripplanner.routing.core.TraverseModeSet in project OpenTripPlanner by opentripplanner.

the class TriangleInequalityTest method testTriangleInequalityWalkTransit.

@Test
public void testTriangleInequalityWalkTransit() {
    TraverseModeSet modes = new TraverseModeSet(TraverseMode.WALK, TraverseMode.TRANSIT);
    checkTriangleInequality(modes);
}
Also used : TraverseModeSet(org.opentripplanner.routing.core.TraverseModeSet) Test(org.junit.Test)

Example 33 with TraverseModeSet

use of org.opentripplanner.routing.core.TraverseModeSet in project OpenTripPlanner by opentripplanner.

the class TriangleInequalityTest method testTriangleInequalityWalkTransitBasicSPT.

@Test
public void testTriangleInequalityWalkTransitBasicSPT() {
    TraverseModeSet modes = new TraverseModeSet(TraverseMode.WALK, TraverseMode.TRANSIT);
    checkTriangleInequality(modes);
}
Also used : TraverseModeSet(org.opentripplanner.routing.core.TraverseModeSet) Test(org.junit.Test)

Example 34 with TraverseModeSet

use of org.opentripplanner.routing.core.TraverseModeSet in project OpenTripPlanner by opentripplanner.

the class GraphVisualizer method route.

protected void route(String from, String to) {
    Date when;
    // Year + 1900
    try {
        when = dateFormat.parse(searchDate.getText());
    } catch (ParseException e) {
        searchDate.setText("Format: " + dateFormat.toPattern());
        return;
    }
    TraverseModeSet modeSet = new TraverseModeSet();
    modeSet.setWalk(walkCheckBox.isSelected());
    modeSet.setBicycle(bikeCheckBox.isSelected());
    modeSet.setFerry(ferryCheckBox.isSelected());
    modeSet.setRail(trainCheckBox.isSelected());
    modeSet.setTram(trainCheckBox.isSelected());
    modeSet.setSubway(trainCheckBox.isSelected());
    modeSet.setFunicular(trainCheckBox.isSelected());
    modeSet.setGondola(trainCheckBox.isSelected());
    modeSet.setBus(busCheckBox.isSelected());
    modeSet.setCableCar(busCheckBox.isSelected());
    modeSet.setCar(carCheckBox.isSelected());
    // otherwise 'false' will clear trainish and busish
    if (transitCheckBox.isSelected())
        modeSet.setTransit(true);
    RoutingRequest options = new RoutingRequest(modeSet);
    options.setArriveBy(arriveByCheckBox.isSelected());
    // override low 2-4 minute values
    options.setWalkBoardCost(Integer.parseInt(boardingPenaltyField.getText()) * 60);
    // TODO LG Add ui element for bike board cost (for now bike = 2 * walk)
    options.setBikeBoardCost(Integer.parseInt(boardingPenaltyField.getText()) * 60 * 2);
    // there should be a ui element for walk distance and optimize type
    options.setOptimize(getSelectedOptimizeType());
    options.setMaxWalkDistance(Integer.parseInt(maxWalkField.getText()));
    options.setDateTime(when);
    options.setFromString(from);
    options.setToString(to);
    options.walkSpeed = Float.parseFloat(walkSpeed.getText());
    options.bikeSpeed = Float.parseFloat(bikeSpeed.getText());
    options.softWalkLimiting = (softWalkLimiting.isSelected());
    options.softWalkPenalty = (Float.parseFloat(softWalkPenalty.getText()));
    options.softWalkOverageRate = (Float.parseFloat(this.softWalkOverageRate.getText()));
    options.numItineraries = 1;
    System.out.println("--------");
    System.out.println("Path from " + from + " to " + to + " at " + when);
    System.out.println("\tModes: " + modeSet);
    System.out.println("\tOptions: " + options);
    options.numItineraries = (Integer.parseInt(this.nPaths.getText()));
    // apply callback if the options call for it
    // if( dontUseGraphicalCallbackCheckBox.isSelected() ){
    // TODO perhaps avoid using a GraphPathFinder and go one level down the call chain directly to a GenericAStar
    // TODO perhaps instead of giving the pathservice a callback, we can just put the visitor in the routing request
    GraphPathFinder finder = new GraphPathFinder(router);
    long t0 = System.currentTimeMillis();
    // TODO: check options properly intialized (AMB)
    List<GraphPath> paths = finder.graphPathFinderEntryPoint(options);
    long dt = System.currentTimeMillis() - t0;
    searchTimeElapsedLabel.setText("search time elapsed: " + dt + "ms");
    if (paths == null) {
        System.out.println("no path");
        showGraph.highlightGraphPath(null);
        return;
    }
    // now's a convenient time to set graphical SPT weights
    showGraph.simpleSPT.setWeights();
    showPathsInPanel(paths);
    // now's a good time to set showGraph's SPT drawing weights
    showGraph.setSPTFlattening(Float.parseFloat(sptFlattening.getText()));
    showGraph.setSPTThickness(Float.parseFloat(sptThickness.getText()));
    showGraph.redraw();
    options.cleanup();
}
Also used : GraphPath(org.opentripplanner.routing.spt.GraphPath) TraverseModeSet(org.opentripplanner.routing.core.TraverseModeSet) RoutingRequest(org.opentripplanner.routing.core.RoutingRequest) ParseException(java.text.ParseException) GraphPathFinder(org.opentripplanner.routing.impl.GraphPathFinder)

Example 35 with TraverseModeSet

use of org.opentripplanner.routing.core.TraverseModeSet in project OpenTripPlanner by opentripplanner.

the class GtfsTest method plan.

public Leg[] plan(long dateTime, String fromVertex, String toVertex, String onTripId, boolean wheelchairAccessible, boolean preferLeastTransfers, TraverseMode preferredMode, String excludedRoute, String excludedStop, int legCount) {
    final TraverseMode mode = preferredMode != null ? preferredMode : TraverseMode.TRANSIT;
    RoutingRequest routingRequest = new RoutingRequest();
    routingRequest.setNumItineraries(1);
    routingRequest.setArriveBy(dateTime < 0);
    routingRequest.dateTime = Math.abs(dateTime);
    if (fromVertex != null && !fromVertex.isEmpty()) {
        routingRequest.from = (new GenericLocation(null, feedId.getId() + ":" + fromVertex));
    }
    if (toVertex != null && !toVertex.isEmpty()) {
        routingRequest.to = new GenericLocation(null, feedId.getId() + ":" + toVertex);
    }
    if (onTripId != null && !onTripId.isEmpty()) {
        routingRequest.startingTransitTripId = (new AgencyAndId(feedId.getId(), onTripId));
    }
    routingRequest.setRoutingContext(graph);
    routingRequest.setWheelchairAccessible(wheelchairAccessible);
    routingRequest.transferPenalty = (preferLeastTransfers ? 300 : 0);
    routingRequest.setModes(new TraverseModeSet(TraverseMode.WALK, mode));
    // TODO route matcher still using underscores because it's quite nonstandard and should be eliminated from the 1.0 release rather than reworked
    if (excludedRoute != null && !excludedRoute.isEmpty()) {
        routingRequest.setBannedRoutes(feedId.getId() + "__" + excludedRoute);
    }
    if (excludedStop != null && !excludedStop.isEmpty()) {
        routingRequest.setBannedStopsHard(feedId.getId() + ":" + excludedStop);
    }
    routingRequest.setOtherThanPreferredRoutesPenalty(0);
    // The walk board cost is set low because it interferes with test 2c1.
    // As long as boarding has a very low cost, waiting should not be "better" than riding
    // since this makes interlining _worse_ than alighting and re-boarding the same line.
    // TODO rethink whether it makes sense to weight waiting to board _less_ than 1.
    routingRequest.setWaitReluctance(1);
    routingRequest.setWalkBoardCost(30);
    List<GraphPath> paths = new GraphPathFinder(router).getPaths(routingRequest);
    TripPlan tripPlan = GraphPathToTripPlanConverter.generatePlan(paths, routingRequest);
    // Stored in instance field for use in individual tests
    itinerary = tripPlan.itinerary.get(0);
    assertEquals(legCount, itinerary.legs.size());
    return itinerary.legs.toArray(new Leg[legCount]);
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) GraphPath(org.opentripplanner.routing.spt.GraphPath) TripPlan(org.opentripplanner.api.model.TripPlan) GenericLocation(org.opentripplanner.common.model.GenericLocation) TraverseMode(org.opentripplanner.routing.core.TraverseMode) RoutingRequest(org.opentripplanner.routing.core.RoutingRequest) TraverseModeSet(org.opentripplanner.routing.core.TraverseModeSet) GraphPathFinder(org.opentripplanner.routing.impl.GraphPathFinder)

Aggregations

TraverseModeSet (org.opentripplanner.routing.core.TraverseModeSet)44 Test (org.junit.Test)25 RoutingRequest (org.opentripplanner.routing.core.RoutingRequest)17 Graph (org.opentripplanner.routing.graph.Graph)14 Edge (org.opentripplanner.routing.graph.Edge)10 Vertex (org.opentripplanner.routing.graph.Vertex)10 Coordinate (com.vividsolutions.jts.geom.Coordinate)8 QualifiedModeSet (org.opentripplanner.api.parameter.QualifiedModeSet)8 GenericLocation (org.opentripplanner.common.model.GenericLocation)8 ShortestPathTree (org.opentripplanner.routing.spt.ShortestPathTree)8 LocalDate (org.joda.time.LocalDate)7 ProfileRequest (org.opentripplanner.profile.ProfileRequest)7 RepeatedRaptorProfileRouter (org.opentripplanner.profile.RepeatedRaptorProfileRouter)7 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)6 GraphPath (org.opentripplanner.routing.spt.GraphPath)6 FakeGraph (org.opentripplanner.graph_builder.module.FakeGraph)5 DefaultStreetVertexIndexFactory (org.opentripplanner.routing.impl.DefaultStreetVertexIndexFactory)5 NonLocalizedString (org.opentripplanner.util.NonLocalizedString)5 LineString (com.vividsolutions.jts.geom.LineString)4 ArrayList (java.util.ArrayList)4