Search in sources :

Example 6 with TransitStopVertex

use of org.opentripplanner.routing.vertextype.TransitStopVertex in project OpenTripPlanner by opentripplanner.

the class TestGeometryAndBlockProcessor method setUp.

public void setUp() throws Exception {
    graph = new Graph();
    this.issueStore = new DataImportIssueStore(true);
    context = contextBuilder(ConstantsForTests.FAKE_GTFS).withIssueStoreAndDeduplicator(graph).build();
    feedId = context.getFeedId().getId();
    GeometryAndBlockProcessor factory = new GeometryAndBlockProcessor(context);
    factory.run(graph, issueStore);
    graph.putService(CalendarServiceData.class, context.getCalendarServiceData());
    String[] stops = { feedId + ":A", feedId + ":B", feedId + ":C", feedId + ":D", feedId + ":E", feedId + ":entrance_a", feedId + ":entrance_b" };
    for (int i = 0; i < stops.length; ++i) {
        TransitStopVertex stop = (TransitStopVertex) (graph.getVertex(stops[i]));
        IntersectionVertex front = new IntersectionVertex(graph, "near_1_" + stop.getStop().getId(), stop.getX() + 0.0001, stop.getY() + 0.0001);
        IntersectionVertex back = new IntersectionVertex(graph, "near_2_" + stop.getStop().getId(), stop.getX() - 0.0001, stop.getY() - 0.0001);
        StreetEdge street1 = new StreetEdge(front, back, GeometryUtils.makeLineString(stop.getX() + 0.0001, stop.getY() + 0.0001, stop.getX() - 0.0001, stop.getY() - 0.0001), "street", 100, StreetTraversalPermission.ALL, false);
        StreetEdge street2 = new StreetEdge(back, front, GeometryUtils.makeLineString(stop.getX() - 0.0001, stop.getY() - 0.0001, stop.getX() + 0.0001, stop.getY() + 0.0001), "street", 100, StreetTraversalPermission.ALL, true);
    }
    StreetLinkerModule ttsnm = new StreetLinkerModule();
    // Linkers aren't run otherwise
    graph.hasStreets = true;
    graph.hasTransit = true;
    ttsnm.buildGraph(graph, new HashMap<Class<?>, Object>());
}
Also used : GeometryAndBlockProcessor(org.opentripplanner.graph_builder.module.geometry.GeometryAndBlockProcessor) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) Graph(org.opentripplanner.routing.graph.Graph) TransitStopVertex(org.opentripplanner.routing.vertextype.TransitStopVertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) DataImportIssueStore(org.opentripplanner.graph_builder.DataImportIssueStore) StreetLinkerModule(org.opentripplanner.graph_builder.module.StreetLinkerModule)

Example 7 with TransitStopVertex

use of org.opentripplanner.routing.vertextype.TransitStopVertex in project OpenTripPlanner by opentripplanner.

the class GraphPathToItineraryMapper method makePlace.

/**
 * Make a {@link Place} to add to a {@link Leg}.
 *
 * @param vertex The {@link Vertex} at the {@link State}.
 * @param stop The {@link Stop} associated with the {@link Vertex}.
 * @param requestedLocale The locale to use for all text attributes.
 * @return The resulting {@link Place} object.
 */
private static Place makePlace(Vertex vertex, Stop stop, Locale requestedLocale) {
    String name = vertex.getName(requestedLocale);
    // We use name in TemporaryStreetLocation since this name generation already happened when temporary location was generated
    if (vertex instanceof StreetVertex && !(vertex instanceof TemporaryStreetLocation)) {
        name = ((StreetVertex) vertex).getIntersectionName(requestedLocale).toString(requestedLocale);
    }
    Place place = new Place(vertex.getLat(), vertex.getLon(), name);
    if (vertex instanceof TransitStopVertex) {
        place.stopId = stop.getId();
        place.stopCode = stop.getCode();
        place.platformCode = stop.getCode();
        place.zoneId = stop.getFirstZoneAsString();
        place.vertexType = VertexType.TRANSIT;
    } else if (vertex instanceof BikeRentalStationVertex) {
        place.bikeShareId = ((BikeRentalStationVertex) vertex).getId();
        LOG.trace("Added bike share Id {} to place", place.bikeShareId);
        place.vertexType = VertexType.BIKESHARE;
    } else if (vertex instanceof BikeParkVertex) {
        place.vertexType = VertexType.BIKEPARK;
    } else {
        place.vertexType = VertexType.NORMAL;
    }
    return place;
}
Also used : TemporaryStreetLocation(org.opentripplanner.routing.location.TemporaryStreetLocation) BikeParkVertex(org.opentripplanner.routing.vertextype.BikeParkVertex) BikeRentalStationVertex(org.opentripplanner.routing.vertextype.BikeRentalStationVertex) TransitStopVertex(org.opentripplanner.routing.vertextype.TransitStopVertex) LineString(org.locationtech.jts.geom.LineString) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) Place(org.opentripplanner.model.plan.Place)

Example 8 with TransitStopVertex

use of org.opentripplanner.routing.vertextype.TransitStopVertex in project OpenTripPlanner by opentripplanner.

the class StreetVertexIndex method postSetup.

@SuppressWarnings("rawtypes")
private void postSetup() {
    for (Vertex gv : graph.getVertices()) {
        Vertex v = gv;
        /*
             * We add all edges with geometry, skipping transit, filtering them out after. We do not
             * index transit edges as we do not need them and some GTFS do not have shape data, so
             * long straight lines between 2 faraway stations will wreck performance on a hash grid
             * spatial index.
             * 
             * If one need to store transit edges in the index, we could improve the hash grid
             * rasterizing splitting long segments.
             */
        for (Edge e : gv.getOutgoing()) {
            LineString geometry = e.getGeometry();
            if (geometry == null) {
                continue;
            }
            Envelope env = geometry.getEnvelopeInternal();
            if (edgeTree instanceof HashGridSpatialIndex)
                ((HashGridSpatialIndex) edgeTree).insert(geometry, e);
            else
                edgeTree.insert(env, e);
        }
        if (v instanceof TransitStopVertex) {
            Envelope env = new Envelope(v.getCoordinate());
            transitStopTree.insert(env, v);
        }
        Envelope env = new Envelope(v.getCoordinate());
        verticesTree.insert(env, v);
    }
}
Also used : TransitStopVertex(org.opentripplanner.routing.vertextype.TransitStopVertex) Vertex(org.opentripplanner.routing.graph.Vertex) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) HashGridSpatialIndex(org.opentripplanner.common.geometry.HashGridSpatialIndex) LineString(org.locationtech.jts.geom.LineString) TransitStopVertex(org.opentripplanner.routing.vertextype.TransitStopVertex) Envelope(org.locationtech.jts.geom.Envelope) TemporaryFreeEdge(org.opentripplanner.routing.edgetype.TemporaryFreeEdge) TemporaryPartialStreetEdge(org.opentripplanner.routing.edgetype.TemporaryPartialStreetEdge) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) Edge(org.opentripplanner.routing.graph.Edge)

Example 9 with TransitStopVertex

use of org.opentripplanner.routing.vertextype.TransitStopVertex in project OpenTripPlanner by opentripplanner.

the class StreetVertexIndex method getNearbyTransitStops.

/**
 * Get all transit stops within a given distance of a coordinate
 * @return The transit stops within a certain radius of the given location.
 */
public List<TransitStopVertex> getNearbyTransitStops(Coordinate coordinate, double radius) {
    Envelope env = new Envelope(coordinate);
    env.expandBy(SphericalDistanceLibrary.metersToLonDegrees(radius, coordinate.y), SphericalDistanceLibrary.metersToDegrees(radius));
    List<TransitStopVertex> nearby = getTransitStopForEnvelope(env);
    List<TransitStopVertex> results = new ArrayList<TransitStopVertex>();
    for (TransitStopVertex v : nearby) {
        if (SphericalDistanceLibrary.distance(v.getCoordinate(), coordinate) <= radius) {
            results.add(v);
        }
    }
    return results;
}
Also used : TransitStopVertex(org.opentripplanner.routing.vertextype.TransitStopVertex) ArrayList(java.util.ArrayList) Envelope(org.locationtech.jts.geom.Envelope)

Example 10 with TransitStopVertex

use of org.opentripplanner.routing.vertextype.TransitStopVertex in project OpenTripPlanner by opentripplanner.

the class LinkStopToPlatformTest method before.

@Before
public void before() {
    // Set up transit platform
    graph = new Graph();
    ArrayList<IntersectionVertex> vertices = new ArrayList<IntersectionVertex>();
    vertices.add(new IntersectionVertex(graph, "1", 10.22054, 59.13568, "Platform vertex 1"));
    vertices.add(new IntersectionVertex(graph, "2", 10.22432, 59.13519, "Platform vertex 2"));
    vertices.add(new IntersectionVertex(graph, "3", 10.22492, 59.13514, "Platform vertex 3"));
    vertices.add(new IntersectionVertex(graph, "4", 10.22493, 59.13518, "Platform vertex 4"));
    vertices.add(new IntersectionVertex(graph, "5", 10.22056, 59.13575, "Platform vertex 5"));
    AreaEdgeList areaEdgeList = new AreaEdgeList();
    ArrayList<AreaEdge> edges = new ArrayList<AreaEdge>();
    edges.add(createAreaEdge(vertices.get(0), vertices.get(1), areaEdgeList, "edge 1"));
    edges.add(createAreaEdge(vertices.get(1), vertices.get(2), areaEdgeList, "edge 2"));
    edges.add(createAreaEdge(vertices.get(2), vertices.get(3), areaEdgeList, "edge 3"));
    edges.add(createAreaEdge(vertices.get(3), vertices.get(4), areaEdgeList, "edge 4"));
    edges.add(createAreaEdge(vertices.get(4), vertices.get(0), areaEdgeList, "edge 5"));
    edges.add(createAreaEdge(vertices.get(1), vertices.get(0), areaEdgeList, "edge 6"));
    edges.add(createAreaEdge(vertices.get(2), vertices.get(1), areaEdgeList, "edge 7"));
    edges.add(createAreaEdge(vertices.get(3), vertices.get(2), areaEdgeList, "edge 8"));
    edges.add(createAreaEdge(vertices.get(4), vertices.get(3), areaEdgeList, "edge 9"));
    edges.add(createAreaEdge(vertices.get(0), vertices.get(4), areaEdgeList, "edge 10"));
    Stop stop = Stop.stopForTest("TestStop", 59.13545, 10.22213);
    TransitStopVertex stopVertex = new TransitStopVertex(graph, stop, null);
}
Also used : Graph(org.opentripplanner.routing.graph.Graph) Stop(org.opentripplanner.model.Stop) TransitStopVertex(org.opentripplanner.routing.vertextype.TransitStopVertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) ArrayList(java.util.ArrayList) AreaEdgeList(org.opentripplanner.routing.edgetype.AreaEdgeList) AreaEdge(org.opentripplanner.routing.edgetype.AreaEdge) Before(org.junit.Before)

Aggregations

TransitStopVertex (org.opentripplanner.routing.vertextype.TransitStopVertex)28 Stop (org.opentripplanner.model.Stop)12 Vertex (org.opentripplanner.routing.graph.Vertex)12 IntersectionVertex (org.opentripplanner.routing.vertextype.IntersectionVertex)8 StreetVertex (org.opentripplanner.routing.vertextype.StreetVertex)8 ArrayList (java.util.ArrayList)7 Coordinate (org.locationtech.jts.geom.Coordinate)7 Envelope (org.locationtech.jts.geom.Envelope)7 Graph (org.opentripplanner.routing.graph.Graph)7 LineString (org.locationtech.jts.geom.LineString)6 DataImportIssueStore (org.opentripplanner.graph_builder.DataImportIssueStore)5 StreetTransitLink (org.opentripplanner.routing.edgetype.StreetTransitLink)5 Iterables (com.google.common.collect.Iterables)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)4 BikeRentalStationVertex (org.opentripplanner.routing.vertextype.BikeRentalStationVertex)4 SplitterVertex (org.opentripplanner.routing.vertextype.SplitterVertex)4 LinearLocation (org.locationtech.jts.linearref.LinearLocation)3 LocationIndexedLine (org.locationtech.jts.linearref.LocationIndexedLine)3