Search in sources :

Example 81 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class SimpleTraversalCostModelTest method before.

@Before
public void before() {
    graph = new Graph();
    costModel = new SimpleIntersectionTraversalCostModel();
    // Initialize the routing request.
    options = new RoutingRequest();
    options.carSpeed = 1.0;
    options.walkSpeed = 1.0;
    options.carDecelerationSpeed = (2.0);
    options.carAccelerationSpeed = (2.0);
    options.setStreetSubRequestModes(TraverseModeSet.allModes());
}
Also used : Graph(org.opentripplanner.routing.graph.Graph) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) Before(org.junit.Before)

Example 82 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class TestTriangle method testTriangle.

public void testTriangle() {
    Coordinate c1 = new Coordinate(-122.575033, 45.456773);
    Coordinate c2 = new Coordinate(-122.576668, 45.451426);
    StreetVertex v1 = new IntersectionVertex(null, "v1", c1.x, c1.y, (NonLocalizedString) null);
    StreetVertex v2 = new IntersectionVertex(null, "v2", c2.x, c2.y, (NonLocalizedString) null);
    GeometryFactory factory = new GeometryFactory();
    LineString geometry = factory.createLineString(new Coordinate[] { c1, c2 });
    double length = 650.0;
    StreetWithElevationEdge testStreet = new StreetWithElevationEdge(v1, v2, geometry, "Test Lane", length, StreetTraversalPermission.ALL, false);
    // a safe street
    testStreet.setBicycleSafetyFactor(0.74f);
    Coordinate[] profile = new Coordinate[] { // slope = 0.1
    new Coordinate(0, 0), new Coordinate(length / 2, length / 20.0), // slope = -0.1
    new Coordinate(length, 0) };
    PackedCoordinateSequence elev = new PackedCoordinateSequence.Double(profile);
    testStreet.setElevationProfile(elev, false);
    SlopeCosts costs = ElevationUtils.getSlopeCosts(elev, true);
    double trueLength = costs.lengthMultiplier * length;
    double slopeWorkLength = testStreet.getEffectiveBikeWorkCost();
    double slopeSpeedLength = testStreet.getEffectiveBikeDistance();
    RoutingRequest options = new RoutingRequest(TraverseMode.BICYCLE);
    options.optimize = BicycleOptimizeType.TRIANGLE;
    options.bikeSpeed = 6.0;
    options.walkReluctance = 1;
    options.setBikeTriangleSafetyFactor(0);
    options.setBikeTriangleSlopeFactor(0);
    options.setBikeTriangleTimeFactor(1);
    State startState = new State(v1, options);
    State result = testStreet.traverse(startState);
    double timeWeight = result.getWeight();
    double expectedTimeWeight = slopeSpeedLength / options.getSpeed(TraverseMode.BICYCLE);
    assertTrue(Math.abs(expectedTimeWeight - timeWeight) < 0.00001);
    options.setBikeTriangleSafetyFactor(0);
    options.setBikeTriangleSlopeFactor(1);
    options.setBikeTriangleTimeFactor(0);
    startState = new State(v1, options);
    result = testStreet.traverse(startState);
    double slopeWeight = result.getWeight();
    double expectedSlopeWeight = slopeWorkLength / options.getSpeed(TraverseMode.BICYCLE);
    assertTrue(Math.abs(expectedSlopeWeight - slopeWeight) < 0.00001);
    assertTrue(length * 1.5 / options.getSpeed(TraverseMode.BICYCLE) < slopeWeight);
    assertTrue(length * 1.5 * 10 / options.getSpeed(TraverseMode.BICYCLE) > slopeWeight);
    options.setBikeTriangleSafetyFactor(1);
    options.setBikeTriangleSlopeFactor(0);
    options.setBikeTriangleTimeFactor(0);
    startState = new State(v1, options);
    result = testStreet.traverse(startState);
    double safetyWeight = result.getWeight();
    double slopeSafety = costs.slopeSafetyCost;
    double expectedSafetyWeight = (trueLength * 0.74 + slopeSafety) / options.getSpeed(TraverseMode.BICYCLE);
    assertTrue(Math.abs(expectedSafetyWeight - safetyWeight) < 0.00001);
    final double ONE_THIRD = 1 / 3.0;
    options.setBikeTriangleSafetyFactor(ONE_THIRD);
    options.setBikeTriangleSlopeFactor(ONE_THIRD);
    options.setBikeTriangleTimeFactor(ONE_THIRD);
    startState = new State(v1, options);
    result = testStreet.traverse(startState);
    double averageWeight = result.getWeight();
    assertTrue(Math.abs(safetyWeight * ONE_THIRD + slopeWeight * ONE_THIRD + timeWeight * ONE_THIRD - averageWeight) < 0.00000001);
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) SlopeCosts(org.opentripplanner.routing.util.SlopeCosts) Coordinate(org.locationtech.jts.geom.Coordinate) LineString(org.locationtech.jts.geom.LineString) State(org.opentripplanner.routing.core.State) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) PackedCoordinateSequence(org.opentripplanner.common.geometry.PackedCoordinateSequence)

Example 83 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class TestFares method testFareComponent.

public void testFareComponent() throws Exception {
    Graph gg = new Graph();
    GtfsContext context = contextBuilder(ConstantsForTests.FARE_COMPONENT_GTFS).build();
    GeometryAndBlockProcessor factory = new GeometryAndBlockProcessor(context);
    factory.run(gg);
    gg.putService(CalendarServiceData.class, context.getCalendarServiceData());
    String feedId = gg.getFeedIds().iterator().next();
    RoutingRequest options = new RoutingRequest();
    options.dateTime = TestUtils.dateInSeconds("America/Los_Angeles", 2009, 8, 7, 12, 0, 0);
    ShortestPathTree spt;
    GraphPath path;
    Fare fare;
    List<FareComponent> fareComponents = null;
    FareService fareService = gg.getService(FareService.class);
    Money tenUSD = new Money(new WrappedCurrency("USD"), 1000);
    // A -> B, base case
    options.setRoutingContext(gg, feedId + ":A", feedId + ":B");
    spt = aStar.getShortestPathTree(options);
    path = spt.getPath(gg.getVertex(feedId + ":B"), true);
    // was: fareService.getCost(path);
    fare = null;
    fareComponents = fare.getDetails(FareType.regular);
    assertEquals(fareComponents.size(), 1);
    assertEquals(fareComponents.get(0).price, tenUSD);
    assertEquals(fareComponents.get(0).fareId, new FeedScopedId(feedId, "AB"));
    assertEquals(fareComponents.get(0).routes.get(0), new FeedScopedId("agency", "1"));
    // D -> E, null case
    options.setRoutingContext(gg, feedId + ":D", feedId + ":E");
    spt = aStar.getShortestPathTree(options);
    path = spt.getPath(gg.getVertex(feedId + ":E"), true);
    // was: fareService.getCost(path);
    fare = null;
    assertNull(fare);
    // A -> C, 2 components in a path
    options.setRoutingContext(gg, feedId + ":A", feedId + ":C");
    spt = aStar.getShortestPathTree(options);
    path = spt.getPath(gg.getVertex(feedId + ":C"), true);
    // was:  fareService.getCost(path);
    fare = null;
    fareComponents = fare.getDetails(FareType.regular);
    assertEquals(fareComponents.size(), 2);
    assertEquals(fareComponents.get(0).price, tenUSD);
    assertEquals(fareComponents.get(0).fareId, new FeedScopedId(feedId, "AB"));
    assertEquals(fareComponents.get(0).routes.get(0), new FeedScopedId("agency", "1"));
    assertEquals(fareComponents.get(1).price, tenUSD);
    assertEquals(fareComponents.get(1).fareId, new FeedScopedId(feedId, "BC"));
    assertEquals(fareComponents.get(1).routes.get(0), new FeedScopedId("agency", "2"));
    // B -> D, 2 fully connected components
    options.setRoutingContext(gg, feedId + ":B", feedId + ":D");
    spt = aStar.getShortestPathTree(options);
    path = spt.getPath(gg.getVertex(feedId + ":D"), true);
    // was: fareService.getCost(path);
    fare = null;
    fareComponents = fare.getDetails(FareType.regular);
    assertEquals(fareComponents.size(), 1);
    assertEquals(fareComponents.get(0).price, tenUSD);
    assertEquals(fareComponents.get(0).fareId, new FeedScopedId(feedId, "BD"));
    assertEquals(fareComponents.get(0).routes.get(0), new FeedScopedId("agency", "2"));
    assertEquals(fareComponents.get(0).routes.get(1), new FeedScopedId("agency", "3"));
    // E -> G, missing in between fare
    options.setRoutingContext(gg, feedId + ":E", feedId + ":G");
    spt = aStar.getShortestPathTree(options);
    path = spt.getPath(gg.getVertex(feedId + ":G"), true);
    // was: fareService.getCost(path);
    fare = null;
    fareComponents = fare.getDetails(FareType.regular);
    assertEquals(fareComponents.size(), 1);
    assertEquals(fareComponents.get(0).price, tenUSD);
    assertEquals(fareComponents.get(0).fareId, new FeedScopedId(feedId, "EG"));
    assertEquals(fareComponents.get(0).routes.get(0), new FeedScopedId("agency", "5"));
    assertEquals(fareComponents.get(0).routes.get(1), new FeedScopedId("agency", "6"));
    // C -> E, missing fare after
    options.setRoutingContext(gg, feedId + ":C", feedId + ":E");
    spt = aStar.getShortestPathTree(options);
    path = spt.getPath(gg.getVertex(feedId + ":E"), true);
    // was: fareService.getCost(path);
    fare = null;
    fareComponents = fare.getDetails(FareType.regular);
    assertEquals(fareComponents.size(), 1);
    assertEquals(fareComponents.get(0).price, tenUSD);
    assertEquals(fareComponents.get(0).fareId, new FeedScopedId(feedId, "CD"));
    assertEquals(fareComponents.get(0).routes.get(0), new FeedScopedId("agency", "3"));
    // D -> G, missing fare before
    options.setRoutingContext(gg, feedId + ":D", feedId + ":G");
    spt = aStar.getShortestPathTree(options);
    path = spt.getPath(gg.getVertex(feedId + ":G"), true);
    // was: fareService.getCost(path);
    fare = null;
    fareComponents = fare.getDetails(FareType.regular);
    assertEquals(fareComponents.size(), 1);
    assertEquals(fareComponents.get(0).price, tenUSD);
    assertEquals(fareComponents.get(0).fareId, new FeedScopedId(feedId, "EG"));
    assertEquals(fareComponents.get(0).routes.get(0), new FeedScopedId("agency", "5"));
    assertEquals(fareComponents.get(0).routes.get(1), new FeedScopedId("agency", "6"));
    // A -> D, use individual component parts
    options.setRoutingContext(gg, feedId + ":A", feedId + ":D");
    spt = aStar.getShortestPathTree(options);
    path = spt.getPath(gg.getVertex(feedId + ":D"), true);
    // was: fareService.getCost(path);
    fare = null;
    fareComponents = fare.getDetails(FareType.regular);
    assertEquals(fareComponents.size(), 2);
    assertEquals(fareComponents.get(0).price, tenUSD);
    assertEquals(fareComponents.get(0).fareId, new FeedScopedId(feedId, "AB"));
    assertEquals(fareComponents.get(0).routes.get(0), new FeedScopedId("agency", "1"));
    assertEquals(fareComponents.get(1).price, tenUSD);
    assertEquals(fareComponents.get(1).fareId, new FeedScopedId(feedId, "BD"));
    assertEquals(fareComponents.get(1).routes.get(0), new FeedScopedId("agency", "2"));
    assertEquals(fareComponents.get(1).routes.get(1), new FeedScopedId("agency", "3"));
}
Also used : GeometryAndBlockProcessor(org.opentripplanner.graph_builder.module.geometry.GeometryAndBlockProcessor) GtfsContext(org.opentripplanner.gtfs.GtfsContext) GraphPath(org.opentripplanner.routing.spt.GraphPath) WrappedCurrency(org.opentripplanner.routing.core.WrappedCurrency) FareService(org.opentripplanner.routing.services.FareService) Fare(org.opentripplanner.routing.core.Fare) Money(org.opentripplanner.routing.core.Money) Graph(org.opentripplanner.routing.graph.Graph) ShortestPathTree(org.opentripplanner.routing.spt.ShortestPathTree) FeedScopedId(org.opentripplanner.model.FeedScopedId) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) FareComponent(org.opentripplanner.routing.core.FareComponent)

Example 84 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class RoutingResource method buildRequest.

/**
 * Range/sanity check the query parameter fields and build a Request object from them.
 *
 * @throws ParameterException when there is a problem interpreting a query parameter
 */
protected RoutingRequest buildRequest() throws ParameterException {
    Router router = otpServer.getRouter();
    RoutingRequest request = router.defaultRoutingRequest.clone();
    // router configuration and cloned. We check whether each parameter was supplied before overwriting the default.
    if (fromPlace != null)
        request.from = LocationStringParser.fromOldStyleString(fromPlace);
    if (toPlace != null)
        request.to = LocationStringParser.fromOldStyleString(toPlace);
    {
        // FIXME: move into setter method on routing request
        TimeZone tz;
        tz = router.graph.getTimeZone();
        if (date == null && time != null) {
            // Time was provided but not date
            LOG.debug("parsing ISO datetime {}", time);
            try {
                // If the time query param doesn't specify a timezone, use the graph's default. See issue #1373.
                DatatypeFactory df = javax.xml.datatype.DatatypeFactory.newInstance();
                XMLGregorianCalendar xmlGregCal = df.newXMLGregorianCalendar(time);
                GregorianCalendar gregCal = xmlGregCal.toGregorianCalendar();
                if (xmlGregCal.getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
                    gregCal.setTimeZone(tz);
                }
                Date d2 = gregCal.getTime();
                request.setDateTime(d2);
            } catch (DatatypeConfigurationException e) {
                request.setDateTime(date, time, tz);
            }
        } else {
            request.setDateTime(date, time, tz);
        }
    }
    if (searchWindow != null) {
        request.searchWindow = Duration.ofSeconds(searchWindow);
    }
    if (wheelchair != null)
        request.setWheelchairAccessible(wheelchair);
    if (numItineraries != null)
        request.setNumItineraries(numItineraries);
    if (maxWalkDistance != null) {
        request.setMaxWalkDistance(maxWalkDistance);
        request.maxTransferWalkDistance = maxWalkDistance;
    }
    if (maxPreTransitTime != null)
        request.setMaxPreTransitTime(maxPreTransitTime);
    if (walkReluctance != null)
        request.setWalkReluctance(walkReluctance);
    if (waitReluctance != null)
        request.setWaitReluctance(waitReluctance);
    if (waitAtBeginningFactor != null)
        request.setWaitAtBeginningFactor(waitAtBeginningFactor);
    if (walkSpeed != null)
        request.walkSpeed = walkSpeed;
    if (bikeSpeed != null)
        request.bikeSpeed = bikeSpeed;
    if (bikeSwitchTime != null)
        request.bikeSwitchTime = bikeSwitchTime;
    if (bikeSwitchCost != null)
        request.bikeSwitchCost = bikeSwitchCost;
    if (optimize != null) {
        // Optimize types are basically combined presets of routing parameters, except for triangle
        request.setOptimize(optimize);
        if (optimize == BicycleOptimizeType.TRIANGLE) {
            RoutingRequest.assertTriangleParameters(triangleSafetyFactor, triangleTimeFactor, triangleSlopeFactor);
            request.setBikeTriangleSafetyFactor(triangleSafetyFactor);
            request.setBikeTriangleSlopeFactor(triangleSlopeFactor);
            request.setBikeTriangleTimeFactor(triangleTimeFactor);
        }
    }
    if (arriveBy != null) {
        request.setArriveBy(arriveBy);
    }
    if (showIntermediateStops != null) {
        request.showIntermediateStops = showIntermediateStops;
    }
    if (intermediatePlaces != null) {
        request.setIntermediatePlacesFromStrings(intermediatePlaces);
    }
    if (preferredRoutes != null) {
        request.setPreferredRoutesFromSting(preferredRoutes);
    }
    if (otherThanPreferredRoutesPenalty != null) {
        request.setOtherThanPreferredRoutesPenalty(otherThanPreferredRoutesPenalty);
    }
    if (preferredAgencies != null) {
        request.setPreferredAgenciesFromString(preferredAgencies);
    }
    if (unpreferredRoutes != null) {
        request.setUnpreferredRoutesFromSting(unpreferredRoutes);
    }
    if (unpreferredAgencies != null) {
        request.setUnpreferredAgenciesFromString(unpreferredAgencies);
    }
    if (walkBoardCost != null) {
        request.setWalkBoardCost(walkBoardCost);
    }
    if (bikeBoardCost != null) {
        request.setBikeBoardCost(bikeBoardCost);
    }
    if (bannedRoutes != null) {
        request.setBannedRoutesFromSting(bannedRoutes);
    }
    if (whiteListedRoutes != null) {
        request.setWhiteListedRoutesFromSting(whiteListedRoutes);
    }
    if (bannedAgencies != null) {
        request.setBannedAgenciesFromSting(bannedAgencies);
    }
    if (whiteListedAgencies != null) {
        request.setWhiteListedAgenciesFromSting(whiteListedAgencies);
    }
    HashMap<FeedScopedId, BannedStopSet> bannedTripMap = makeBannedTripMap(bannedTrips);
    if (bannedTripMap != null) {
        request.bannedTrips = bannedTripMap;
    }
    // See comment on RoutingRequest.transferPentalty.
    if (transferPenalty != null) {
        request.transferCost = transferPenalty;
    }
    if (optimize == BicycleOptimizeType.TRANSFERS) {
        optimize = BicycleOptimizeType.QUICK;
        request.transferCost += 1800;
    }
    if (optimize != null) {
        request.setOptimize(optimize);
    }
    /* Temporary code to get bike/car parking and renting working. */
    if (modes != null && !modes.qModes.isEmpty()) {
        request.modes = modes.getRequestModes();
    }
    if (request.bikeRental && bikeSpeed == null) {
        // slower bike speed for bike sharing, based on empirical evidence from DC.
        request.bikeSpeed = 4.3;
    }
    if (boardSlack != null)
        request.boardSlack = boardSlack;
    if (alightSlack != null)
        request.alightSlack = alightSlack;
    if (minTransferTime != null) {
        int alightAndBoardSlack = request.boardSlack + request.alightSlack;
        if (alightAndBoardSlack > minTransferTime) {
            throw new IllegalArgumentException("Invalid parameters: 'minTransferTime' must be greater than or equal to board slack plus alight slack");
        }
        request.transferSlack = minTransferTime - alightAndBoardSlack;
    }
    if (nonpreferredTransferPenalty != null)
        request.nonpreferredTransferCost = nonpreferredTransferPenalty;
    if (maxTransfers != null)
        request.maxTransfers = maxTransfers;
    final long NOW_THRESHOLD_MILLIS = 15 * 60 * 60 * 1000;
    boolean tripPlannedForNow = Math.abs(request.getDateTime().getTime() - new Date().getTime()) < NOW_THRESHOLD_MILLIS;
    // TODO the same thing for GTFS-RT
    request.useBikeRentalAvailabilityInformation = tripPlannedForNow;
    if (startTransitStopId != null && !startTransitStopId.isEmpty())
        request.startingTransitStopId = FeedScopedId.parseId(startTransitStopId);
    if (startTransitTripId != null && !startTransitTripId.isEmpty())
        request.startingTransitTripId = FeedScopedId.parseId(startTransitTripId);
    if (ignoreRealtimeUpdates != null)
        request.ignoreRealtimeUpdates = ignoreRealtimeUpdates;
    if (disableRemainingWeightHeuristic != null)
        request.disableRemainingWeightHeuristic = disableRemainingWeightHeuristic;
    if (maxHours != null)
        request.maxHours = maxHours;
    if (useRequestedDateTimeInMaxHours != null)
        request.useRequestedDateTimeInMaxHours = useRequestedDateTimeInMaxHours;
    if (disableAlertFiltering != null)
        request.disableAlertFiltering = disableAlertFiltering;
    if (geoidElevation != null)
        request.geoidElevation = geoidElevation;
    if (pathComparator != null)
        request.pathComparator = pathComparator;
    if (debugItineraryFilter != null) {
        request.debugItineraryFilter = debugItineraryFilter;
    }
    // getLocale function returns defaultLocale if locale is null
    request.locale = ResourceBundleSingleton.INSTANCE.getLocale(locale);
    return request;
}
Also used : DatatypeFactory(javax.xml.datatype.DatatypeFactory) BannedStopSet(org.opentripplanner.routing.api.request.BannedStopSet) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Router(org.opentripplanner.standalone.server.Router) Date(java.util.Date) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) TimeZone(java.util.TimeZone) FeedScopedId(org.opentripplanner.model.FeedScopedId) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest)

Example 85 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class StreetUtils method pruneFloatingIslands.

public static void pruneFloatingIslands(Graph graph, int maxIslandSize, int islandWithStopMaxSize, String islandLogName, DataImportIssueStore issueStore) {
    LOG.debug("pruning");
    PrintWriter islandLog = null;
    if (islandLogName != null && !islandLogName.isEmpty()) {
        try {
            islandLog = new PrintWriter(new File(islandLogName));
        } catch (Exception e) {
            LOG.error("Failed to write islands log file", e);
        }
    }
    if (islandLog != null) {
        islandLog.printf("%s\t%s\t%s\t%s\t%s\n", "id", "stopCount", "streetCount", "wkt", "hadRemoved");
    }
    Map<Vertex, Subgraph> subgraphs = new HashMap<Vertex, Subgraph>();
    Map<Vertex, ArrayList<Vertex>> neighborsForVertex = new HashMap<Vertex, ArrayList<Vertex>>();
    // RoutingRequest options = new RoutingRequest(new TraverseModeSet(TraverseMode.WALK, TraverseMode.TRANSIT));
    RoutingRequest options = new RoutingRequest(new TraverseModeSet(TraverseMode.WALK));
    for (Vertex gv : graph.getVertices()) {
        if (!(gv instanceof StreetVertex)) {
            continue;
        }
        State s0 = new State(gv, options);
        for (Edge e : gv.getOutgoing()) {
            Vertex in = gv;
            if (!(e instanceof StreetEdge || e instanceof StreetTransitLink || e instanceof TransitEntranceLink || e instanceof ElevatorEdge || e instanceof FreeEdge)) {
                continue;
            }
            State s1 = e.traverse(s0);
            if (s1 == null) {
                continue;
            }
            Vertex out = s1.getVertex();
            ArrayList<Vertex> vertexList = neighborsForVertex.get(in);
            if (vertexList == null) {
                vertexList = new ArrayList<Vertex>();
                neighborsForVertex.put(in, vertexList);
            }
            vertexList.add(out);
            vertexList = neighborsForVertex.get(out);
            if (vertexList == null) {
                vertexList = new ArrayList<Vertex>();
                neighborsForVertex.put(out, vertexList);
            }
            vertexList.add(in);
        }
    }
    ArrayList<Subgraph> islands = new ArrayList<Subgraph>();
    /* associate each node with a subgraph */
    for (Vertex gv : graph.getVertices()) {
        if (!(gv instanceof StreetVertex)) {
            continue;
        }
        Vertex vertex = gv;
        if (subgraphs.containsKey(vertex)) {
            continue;
        }
        if (!neighborsForVertex.containsKey(vertex)) {
            continue;
        }
        Subgraph subgraph = computeConnectedSubgraph(neighborsForVertex, vertex);
        if (subgraph != null) {
            for (Iterator<Vertex> vIter = subgraph.streetIterator(); vIter.hasNext(); ) {
                Vertex subnode = vIter.next();
                subgraphs.put(subnode, subgraph);
            }
            islands.add(subgraph);
        }
    }
    LOG.info(islands.size() + " sub graphs found");
    /* remove all tiny subgraphs and large subgraphs without stops */
    for (Subgraph island : islands) {
        boolean hadRemoved = false;
        if (island.stopSize() > 0) {
            // for islands with stops
            if (island.streetSize() < islandWithStopMaxSize) {
                depedestrianizeOrRemove(graph, island, issueStore);
                hadRemoved = true;
            }
        } else {
            // for islands without stops
            if (island.streetSize() < maxIslandSize) {
                depedestrianizeOrRemove(graph, island, issueStore);
                hadRemoved = true;
            }
        }
        if (islandLog != null) {
            WriteNodesInSubGraph(island, islandLog, hadRemoved);
        }
    }
    if (graph.removeEdgelessVertices() > 0) {
        LOG.info("Removed edgeless vertices after pruning islands");
    }
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TraverseModeSet(org.opentripplanner.routing.core.TraverseModeSet) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) StreetTransitLink(org.opentripplanner.routing.edgetype.StreetTransitLink) FreeEdge(org.opentripplanner.routing.edgetype.FreeEdge) State(org.opentripplanner.routing.core.State) Subgraph(org.opentripplanner.common.geometry.Subgraph) TransitEntranceLink(org.opentripplanner.routing.edgetype.TransitEntranceLink) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) ElevatorEdge(org.opentripplanner.routing.edgetype.ElevatorEdge) File(java.io.File) ElevatorEdge(org.opentripplanner.routing.edgetype.ElevatorEdge) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) FreeEdge(org.opentripplanner.routing.edgetype.FreeEdge) Edge(org.opentripplanner.routing.graph.Edge) PrintWriter(java.io.PrintWriter)

Aggregations

RoutingRequest (org.opentripplanner.routing.api.request.RoutingRequest)159 GraphPath (org.opentripplanner.routing.spt.GraphPath)52 ShortestPathTree (org.opentripplanner.routing.spt.ShortestPathTree)43 State (org.opentripplanner.routing.core.State)37 Vertex (org.opentripplanner.routing.graph.Vertex)36 Test (org.junit.jupiter.api.Test)32 Test (org.junit.Test)30 Graph (org.opentripplanner.routing.graph.Graph)24 AStar (org.opentripplanner.routing.algorithm.astar.AStar)22 Edge (org.opentripplanner.routing.graph.Edge)21 TraverseModeSet (org.opentripplanner.routing.core.TraverseModeSet)20 IntersectionVertex (org.opentripplanner.routing.vertextype.IntersectionVertex)20 TransitStopVertex (org.opentripplanner.routing.vertextype.TransitStopVertex)20 RequestModes (org.opentripplanner.routing.api.request.RequestModes)18 StateEditor (org.opentripplanner.routing.core.StateEditor)18 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)14 Router (org.opentripplanner.standalone.server.Router)13 StreetVertex (org.opentripplanner.routing.vertextype.StreetVertex)12 TemporaryStreetLocation (org.opentripplanner.routing.location.TemporaryStreetLocation)11 NonLocalizedString (org.opentripplanner.util.NonLocalizedString)11