Search in sources :

Example 1 with GeometryAndBlockProcessor

use of org.opentripplanner.graph_builder.module.geometry.GeometryAndBlockProcessor in project OpenTripPlanner by opentripplanner.

the class GraphStatisticsResourceTest method setUp.

@Before
public void setUp() throws Exception {
    GtfsContext context = contextBuilder(ConstantsForTests.FAKE_GTFS).build();
    Graph graph = new Graph();
    AddTransitModelEntitiesToGraph.addToGraph(context, graph);
    new GeometryAndBlockProcessor(context).run(graph);
    graph.putService(CalendarServiceData.class, context.getCalendarServiceData());
    graph.index();
    long expStops = graph.index.getAllStops().size();
    expResult = "{data={graphStatistics={stops=" + expStops + "}}}";
    subject = new GraphStatisticsResource(new RoutingService(graph));
}
Also used : GeometryAndBlockProcessor(org.opentripplanner.graph_builder.module.geometry.GeometryAndBlockProcessor) Graph(org.opentripplanner.routing.graph.Graph) AddTransitModelEntitiesToGraph(org.opentripplanner.graph_builder.module.AddTransitModelEntitiesToGraph) GtfsContext(org.opentripplanner.gtfs.GtfsContext) RoutingService(org.opentripplanner.routing.RoutingService) Before(org.junit.Before)

Example 2 with GeometryAndBlockProcessor

use of org.opentripplanner.graph_builder.module.geometry.GeometryAndBlockProcessor in project OpenTripPlanner by opentripplanner.

the class NetexModule method buildGraph.

@Override
public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra, DataImportIssueStore issueStore) {
    graph.clearTimeZone();
    CalendarServiceData calendarServiceData = new CalendarServiceData();
    try {
        for (NetexBundle netexBundle : netexBundles) {
            netexBundle.checkInputs();
            OtpTransitServiceBuilder transitBuilder = netexBundle.loadBundle(graph.deduplicator, issueStore);
            transitBuilder.limitServiceDays(transitPeriodLimit);
            calendarServiceData.add(transitBuilder.buildCalendarServiceData());
            OtpTransitService otpService = transitBuilder.build();
            // TODO OTP2 - Move this into the AddTransitModelEntitiesToGraph
            // - and make sure thay also work with GTFS feeds - GTFS do no
            // - have operators and notice assignments.
            graph.getOperators().addAll(otpService.getAllOperators());
            graph.addNoticeAssignments(otpService.getNoticeAssignments());
            GtfsFeedId feedId = new GtfsFeedId.Builder().id(netexFeedId).build();
            AddTransitModelEntitiesToGraph.addToGraph(feedId, otpService, subwayAccessTime, graph);
            new GeometryAndBlockProcessor(otpService, fareServiceFactory, MAX_STOP_TO_SHAPE_SNAP_DISTANCE, maxInterlineDistance).run(graph, issueStore);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    graph.putService(CalendarServiceData.class, calendarServiceData);
    graph.updateTransitFeedValidity(calendarServiceData, issueStore);
    graph.hasTransit = true;
    graph.calculateTransitCenter();
}
Also used : CalendarServiceData(org.opentripplanner.model.calendar.CalendarServiceData) OtpTransitServiceBuilder(org.opentripplanner.model.impl.OtpTransitServiceBuilder) GeometryAndBlockProcessor(org.opentripplanner.graph_builder.module.geometry.GeometryAndBlockProcessor) NetexBundle(org.opentripplanner.netex.loader.NetexBundle) GtfsFeedId(org.opentripplanner.graph_builder.module.GtfsFeedId) OtpTransitService(org.opentripplanner.model.OtpTransitService) OtpTransitServiceBuilder(org.opentripplanner.model.impl.OtpTransitServiceBuilder)

Example 3 with GeometryAndBlockProcessor

use of org.opentripplanner.graph_builder.module.geometry.GeometryAndBlockProcessor in project OpenTripPlanner by opentripplanner.

the class ConstantsForTests method setupPortland.

private void setupPortland() {
    try {
        portlandGraph = new Graph();
        // Add street data from OSM
        {
            File osmFile = new File(PORTLAND_CENTRAL_OSM);
            BinaryOpenStreetMapProvider osmProvider = new BinaryOpenStreetMapProvider(osmFile, false);
            OpenStreetMapModule osmModule = new OpenStreetMapModule(Lists.newArrayList(osmProvider));
            osmModule.skipVisibility = true;
            osmModule.buildGraph(portlandGraph, new HashMap<>());
        }
        // Add transit data from GTFS
        {
            portlandContext = contextBuilder(ConstantsForTests.PORTLAND_GTFS).withIssueStoreAndDeduplicator(portlandGraph).build();
            AddTransitModelEntitiesToGraph.addToGraph(portlandContext, portlandGraph);
            GeometryAndBlockProcessor factory = new GeometryAndBlockProcessor(portlandContext);
            factory.run(portlandGraph);
        }
        // Link transit stops to streets
        {
            GraphBuilderModule streetTransitLinker = new StreetLinkerModule();
            streetTransitLinker.buildGraph(portlandGraph, new HashMap<>());
        }
        // TODO: eliminate GTFSContext
        // this is now making a duplicate calendarservicedata but it's oh so practical
        portlandGraph.putService(CalendarServiceData.class, portlandContext.getCalendarServiceData());
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}
Also used : GeometryAndBlockProcessor(org.opentripplanner.graph_builder.module.geometry.GeometryAndBlockProcessor) Graph(org.opentripplanner.routing.graph.Graph) AddTransitModelEntitiesToGraph(org.opentripplanner.graph_builder.module.AddTransitModelEntitiesToGraph) OpenStreetMapModule(org.opentripplanner.graph_builder.module.osm.OpenStreetMapModule) HashMap(java.util.HashMap) BinaryOpenStreetMapProvider(org.opentripplanner.openstreetmap.BinaryOpenStreetMapProvider) GraphBuilderModule(org.opentripplanner.graph_builder.services.GraphBuilderModule) File(java.io.File) StreetLinkerModule(org.opentripplanner.graph_builder.module.StreetLinkerModule) IOException(java.io.IOException)

Example 4 with GeometryAndBlockProcessor

use of org.opentripplanner.graph_builder.module.geometry.GeometryAndBlockProcessor in project OpenTripPlanner by opentripplanner.

the class ConstantsForTests method buildGraph.

public static Graph buildGraph(String path) {
    Graph graph = new Graph();
    GtfsContext context;
    try {
        context = contextBuilder(path).build();
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
    AddTransitModelEntitiesToGraph.addToGraph(context, graph);
    GeometryAndBlockProcessor factory = new GeometryAndBlockProcessor(context);
    factory.run(graph);
    graph.putService(CalendarServiceData.class, context.getCalendarServiceData());
    return graph;
}
Also used : GeometryAndBlockProcessor(org.opentripplanner.graph_builder.module.geometry.GeometryAndBlockProcessor) Graph(org.opentripplanner.routing.graph.Graph) AddTransitModelEntitiesToGraph(org.opentripplanner.graph_builder.module.AddTransitModelEntitiesToGraph) GtfsContext(org.opentripplanner.gtfs.GtfsContext) IOException(java.io.IOException)

Example 5 with GeometryAndBlockProcessor

use of org.opentripplanner.graph_builder.module.geometry.GeometryAndBlockProcessor 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)

Aggregations

GeometryAndBlockProcessor (org.opentripplanner.graph_builder.module.geometry.GeometryAndBlockProcessor)14 Graph (org.opentripplanner.routing.graph.Graph)12 GtfsContext (org.opentripplanner.gtfs.GtfsContext)10 RoutingRequest (org.opentripplanner.routing.api.request.RoutingRequest)4 GraphPath (org.opentripplanner.routing.spt.GraphPath)4 ShortestPathTree (org.opentripplanner.routing.spt.ShortestPathTree)4 BeforeClass (org.junit.BeforeClass)3 AddTransitModelEntitiesToGraph (org.opentripplanner.graph_builder.module.AddTransitModelEntitiesToGraph)3 Fare (org.opentripplanner.routing.core.Fare)3 Money (org.opentripplanner.routing.core.Money)3 WrappedCurrency (org.opentripplanner.routing.core.WrappedCurrency)3 FareService (org.opentripplanner.routing.services.FareService)3 IOException (java.io.IOException)2 StreetLinkerModule (org.opentripplanner.graph_builder.module.StreetLinkerModule)2 TripDescriptor (com.google.transit.realtime.GtfsRealtime.TripDescriptor)1 TripUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate)1 File (java.io.File)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 DataImportIssueStore (org.opentripplanner.graph_builder.DataImportIssueStore)1