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));
}
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();
}
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);
}
}
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;
}
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>());
}
Aggregations